straker-translations-easy-translation-platform - Version 1.4.1

Version Notes

Bug fix release

Download this release

Release Info

Developer Chris
Extension straker-translations-easy-translation-platform
Version 1.4.1
Comparing to
See all releases


Code changes from version 1.4.0 to 1.4.1

Files changed (49) hide show
  1. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Block/Grid.php +0 -4
  2. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Page/Grid.php +0 -4
  3. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute.php +1 -1
  4. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute/Grid.php +54 -61
  5. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php +1 -1
  6. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category/Grid.php +8 -1
  7. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block.php +1 -1
  8. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block/Grid.php +7 -88
  9. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page.php +1 -1
  10. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page/Grid.php +36 -124
  11. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php +1 -1
  12. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php +1 -1
  13. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Grid.php +6 -5
  14. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Block/Grid.php +2 -2
  15. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Page/Grid.php +1 -1
  16. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Confirm/Grid.php +1 -1
  17. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php +1 -1
  18. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Backend.php +5 -20
  19. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/CmsVersion.php +19 -19
  20. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateOptions.php +1 -1
  21. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Frontend.php +5 -22
  22. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Selected.php +19 -50
  23. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TextArea.php +0 -13
  24. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TranslateOptions.php +1 -1
  25. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Attribute/Translate.php +48 -52
  26. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Category/Translate.php +14 -20
  27. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Block/Translate.php +25 -25
  28. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Page/Translate.php +30 -38
  29. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php +108 -209
  30. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Product/Translate.php +22 -19
  31. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute/Collection.php +0 -11
  32. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Block/Collection.php +0 -12
  33. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Page/Collection.php +0 -12
  34. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/AttributeController.php +7 -7
  35. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/CategoryController.php +5 -5
  36. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/Cms/BlockController.php +7 -10
  37. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/Cms/PageController.php +7 -8
  38. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/JobController.php +15 -21
  39. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/ProductController.php +7 -11
  40. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/CallbackController.php +1 -1
  41. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config.xml +10 -13
  42. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config_live.xml +0 -156
  43. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system.xml +108 -108
  44. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system_live.xml +0 -167
  45. app/design/adminhtml/default/straker/layout/straker.xml +6 -2
  46. app/design/adminhtml/default/straker/template/straker/feedback_script.phtml +0 -18
  47. app/design/adminhtml/default/straker/template/straker/new/attribute/confirm.phtml +1 -1
  48. package.xml +7 -9
  49. skin/adminhtml/default/straker/css/straker.css +1 -4
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Block/Grid.php CHANGED
@@ -10,10 +10,6 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Cms_Block_Grid
10
'straker.new_entity_id = main_table.block_id',
11
array('straker_translated' => 'straker.version')
12
);
13
-
14
- $collection->addFilterToMap('title', 'main_table.title');
15
- $collection->addFilterToMap('identifier', 'main_table.identifier');
16
-
17
$this->setCollection($collection);
18
19
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
10
'straker.new_entity_id = main_table.block_id',
11
array('straker_translated' => 'straker.version')
12
);
13
$this->setCollection($collection);
14
15
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Page/Grid.php CHANGED
@@ -10,10 +10,6 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Cms_Page_Grid
10
'straker.new_entity_id = main_table.page_id',
11
array('straker_translated' => 'straker.version')
12
);
13
-
14
- $collection->addFilterToMap('title', 'main_table.title');
15
- $collection->addFilterToMap('identifier', 'main_table.identifier');
16
-
17
$collection->setFirstStoreFlag(true);
18
$this->setCollection($collection);
19
10
'straker.new_entity_id = main_table.page_id',
11
array('straker_translated' => 'straker.version')
12
);
13
$collection->setFirstStoreFlag(true);
14
$this->setCollection($collection);
15
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute/Grid.php CHANGED
@@ -51,94 +51,87 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute_
51
52
protected function _prepareColumns() {
53
$this->addColumn('id', array(
54
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
55
- 'type' => 'number',
56
- 'align' => 'right',
57
- 'width' => '50px',
58
- 'index' => 'id',
59
- 'filter_index' => 'main_table.id',
60
));
61
62
$this->addColumn('attribute_id', array(
63
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute ID'),
64
- 'type' => 'number',
65
- 'align' => 'left',
66
- 'index' => 'attribute_id',
67
- 'filter_index' => 'main_table.attribute_id',
68
- 'width' => '50px'
69
));
70
71
$this->addColumn('attribute_code', array(
72
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
73
- 'align' => 'left',
74
- 'index' => 'attribute_code',
75
- 'width' => '50px'
76
));
77
78
79
$this->addColumn('label_original', array(
80
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Source'),
81
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalLabel',
82
- 'align' => 'center',
83
- 'index' => false,
84
- 'sortable' => false,
85
- 'filter' => false,
86
- 'width' => '15%'
87
));
88
89
- $this->addColumn('label_translate', array(
90
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Target'),
91
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateLabel',
92
- 'align' => 'center',
93
- 'index' => false,
94
- 'sortable' => false,
95
- 'filter' => false,
96
- 'width' => '15%'
97
-
98
));
99
100
- $this->addColumn('option_original', array(
101
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Source'),
102
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalOption',
103
- 'align' => 'center',
104
- 'index' => false,
105
- 'sortable' => false,
106
- 'filter' => false,
107
- 'width' => '20%'
108
));
109
110
$this->addColumn('option_translate', array(
111
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Target'),
112
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateOption',
113
- 'align' => 'center',
114
- 'index' => false,
115
- 'sortable' => false,
116
- 'filter' => false,
117
- 'width' => '20%'
118
));
119
120
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
121
$this->addColumn('version', array(
122
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
123
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
124
- 'align' => 'center',
125
- 'index' => 'version',
126
'filter_condition_callback' => [$this, '_filterVersion'],
127
- 'options' => [
128
'0' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
129
'1' => Mage::helper('strakertranslations_easytranslationplatform')->__('Not Published')
130
],
131
- 'width' => '50px'
132
));
133
}
134
135
- $this->addColumn('view_backend', array(
136
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
137
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
138
- 'align' => 'center',
139
- 'index' => false,
140
- 'filter' => false,
141
- ));
142
143
return parent::_prepareColumns();
144
}
@@ -169,7 +162,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute_
169
170
$this->getMassactionBlock()->addItem('add', array(
171
'label' => Mage::helper('catalog')->__('Publish Translation'),
172
- 'url' => $this->getUrl('*/*/publish'),
173
'selected' => 1
174
));
175
51
52
protected function _prepareColumns() {
53
$this->addColumn('id', array(
54
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
55
+ 'type' => 'number',
56
+ 'align' => 'right',
57
+ 'width' => '50px',
58
+ 'index' => 'id',
59
+ 'filter_index' => 'main_table.id'
60
));
61
62
$this->addColumn('attribute_id', array(
63
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute ID'),
64
+ 'type' => 'number',
65
+ 'align' => 'left',
66
+ 'index' => 'attribute_id',
67
+ 'filter_index' => 'main_table.attribute_id'
68
));
69
70
$this->addColumn('attribute_code', array(
71
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
72
+ 'align' => 'left',
73
+ 'index' => 'attribute_code',
74
));
75
76
77
$this->addColumn('label_original', array(
78
+ 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Source'),
79
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalLabel',
80
+ 'align' => 'center',
81
+ 'index' => false,
82
+ 'sortable'=> false,
83
+ 'filter' => false,
84
));
85
86
+ $this->addColumn('option_original', array(
87
+ 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Source'),
88
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalOption',
89
+ 'align' => 'center',
90
+ 'index' => false,
91
+ 'sortable'=> false,
92
+ 'filter' => false,
93
));
94
95
+ $this->addColumn('label_translate', array(
96
+ 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Target'),
97
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateLabel',
98
+ 'align' => 'center',
99
+ 'index' => false,
100
+ 'sortable'=> false,
101
+ 'filter' => false,
102
));
103
104
$this->addColumn('option_translate', array(
105
+ 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Target'),
106
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateOption',
107
+ 'align' => 'center',
108
+ 'index' => false,
109
+ 'sortable'=> false,
110
+ 'filter' => false,
111
));
112
113
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
114
$this->addColumn('version', array(
115
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
116
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
117
+ 'align' => 'center',
118
+ 'index' => 'version',
119
'filter_condition_callback' => [$this, '_filterVersion'],
120
+ 'options' => [
121
'0' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
122
'1' => Mage::helper('strakertranslations_easytranslationplatform')->__('Not Published')
123
],
124
+ 'width' => '20%'
125
));
126
}
127
128
+ // $this->addColumn('view_backend', array(
129
+ // 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
130
+ // 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
131
+ // 'align' => 'center',
132
+ // 'index' => false,
133
+ // 'filter' => false,
134
+ // ));
135
136
return parent::_prepareColumns();
137
}
162
163
$this->getMassactionBlock()->addItem('add', array(
164
'label' => Mage::helper('catalog')->__('Publish Translation'),
165
+ 'url' => $this->getUrl('*/*/applyTranslation'),
166
'selected' => 1
167
));
168
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category e
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category/Grid.php CHANGED
@@ -113,6 +113,13 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
113
));
114
}
115
116
117
$this->addColumn('view_backend', array(
118
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
@@ -153,7 +160,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
153
154
$this->getMassactionBlock()->addItem('add', array(
155
'label' => Mage::helper('catalog')->__('Publish Translation'),
156
- 'url' => $this->getUrl('*/*/publish'),
157
'selected' => 1
158
));
159
$this->getMassactionBlock()->setTemplate('straker/job/category/massaction.phtml');
113
));
114
}
115
116
+ $this->addColumn('view_frontend', array(
117
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Frontend'),
118
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Frontend',
119
+ 'align' => 'center',
120
+ 'index' => false,
121
+ 'filter' => false,
122
+ ));
123
124
$this->addColumn('view_backend', array(
125
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
160
161
$this->getMassactionBlock()->addItem('add', array(
162
'label' => Mage::helper('catalog')->__('Publish Translation'),
163
+ 'url' => $this->getUrl('*/*/applyTranslation'),
164
'selected' => 1
165
));
166
$this->getMassactionBlock()->setTemplate('straker/job/category/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block/Grid.php CHANGED
@@ -28,49 +28,20 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
- $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_block_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
32
- /** @var StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Block_Collection $collection */
33
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->getCollection()
34
->addFieldToFilter('main_table.job_id', $job->getId());
35
36
//echo $collection->getSelect(); die();
37
- $collection->getSelect()
38
- ->joinLeft(
39
- array('translate' => $collection->getTable('strakertranslations_easytranslationplatform/cms_block_translate')),
40
- 'main_table.id = translate.id
41
- AND translate.cms_block_id = main_table.block_id AND translate.job_id = '.$job->getId(),
42
- array()
43
- );
44
-
45
- //loop through this job's attributes and join them to the collection
46
- foreach ($jobAttributes as $jobAttribute) {
47
- $attributeCode = $jobAttribute->getColumnName();
48
- $collection->getSelect()->joinLeft(
49
- array($attributeCode => $collection->getTable('strakertranslations_easytranslationplatform/cms_block_translate')),
50
- $attributeCode . '.cms_block_id = main_table.block_id
51
- AND ' . $attributeCode . '.column_name = \'' . $attributeCode . '\'
52
- AND ' . $attributeCode . '.job_id = ' . $job->getId(),
53
- array($attributeCode . '_original' => 'original', $attributeCode . '_translate' => 'translate')
54
- );
55
- }
56
-
57
$this->setCollection($collection);
58
return parent::_prepareCollection();
59
}
60
61
protected function _prepareColumns() {
62
- $this->addColumn('id', array(
63
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
64
- 'align' => 'center',
65
- 'width' => '50px',
66
- 'index' => 'id'
67
- ));
68
-
69
- $this->addColumn('block_id', array(
70
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Block ID'),
71
'align' => 'center',
72
- 'width' => '50px',
73
- 'index' => 'block_id'
74
));
75
76
$this->addColumn('identifier', array(
@@ -79,54 +50,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
79
'index' => 'identifier'
80
));
81
82
- $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
83
- $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_block_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
84
- //loop through this job's attributes and add columns to the grid
85
- foreach ($jobAttributes as $jobAttribute) {
86
- $attributeCode = $jobAttribute->getColumnName();
87
- if($attributeCode === 'content'){
88
- $this->addColumn($attributeCode . '_original', array(
89
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
90
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
91
- 'align' => 'left',
92
- 'index' => $attributeCode . '_original',
93
- 'filter' => false,
94
- 'sortable' => false
95
- ));
96
-
97
- $this->addColumn($attributeCode . '_translate', array(
98
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
99
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
100
- 'align' => 'left',
101
- 'index' => $attributeCode . '_translate',
102
- 'filter' => false,
103
- 'sortable' => false
104
- ));
105
- }else{
106
- $this->addColumn($attributeCode . '_original', array(
107
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
108
- 'align' => 'left',
109
- 'index' => $attributeCode . '_original',
110
- // 'filter_index' => $attributeCode.'.translate',
111
- 'filter' => false,
112
- 'sortable' => false
113
- ));
114
-
115
- $this->addColumn($attributeCode . '_translate', array(
116
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
117
- 'align' => 'left',
118
- 'index' => $attributeCode . '_translate',
119
- // 'filter_index' => $attributeCode.'.translate',
120
- 'filter' => false,
121
- 'sortable' => false
122
- ));
123
- }
124
- }
125
-
126
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
127
$this->addColumn('version', array(
128
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
129
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
130
'align' => 'center',
131
'type' => 'options',
132
'index' => 'version',
@@ -139,14 +66,6 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
139
));
140
}
141
142
- $this->addColumn('view_backend', array(
143
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
144
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
145
- 'align' => 'center',
146
- 'index' => false,
147
- 'filter' => false,
148
- ));
149
-
150
return parent::_prepareColumns();
151
}
152
@@ -177,7 +96,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
177
178
$this->getMassactionBlock()->addItem('add', array(
179
'label' => Mage::helper('catalog')->__('Publish Translation'),
180
- 'url' => $this->getUrl('*/*/publish'),
181
'selected' => 1
182
));
183
@@ -188,8 +107,8 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
188
189
190
// Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
191
}
192
- return $this;
193
}
194
195
protected function _prepareMassactionColumn()
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
+
32
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->getCollection()
33
->addFieldToFilter('main_table.job_id', $job->getId());
34
35
//echo $collection->getSelect(); die();
36
$this->setCollection($collection);
37
return parent::_prepareCollection();
38
}
39
40
protected function _prepareColumns() {
41
+ $this->addColumn('title', array(
42
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Title'),
43
'align' => 'center',
44
+ 'index' => 'title'
45
));
46
47
$this->addColumn('identifier', array(
50
'index' => 'identifier'
51
));
52
53
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
54
$this->addColumn('version', array(
55
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
56
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion',
57
'align' => 'center',
58
'type' => 'options',
59
'index' => 'version',
66
));
67
}
68
69
return parent::_prepareColumns();
70
}
71
96
97
$this->getMassactionBlock()->addItem('add', array(
98
'label' => Mage::helper('catalog')->__('Publish Translation'),
99
+ 'url' => $this->getUrl('*/*/applyTranslation'),
100
'selected' => 1
101
));
102
107
108
109
// Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
110
+ return $this;
111
}
112
}
113
114
protected function _prepareMassactionColumn()
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page e
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page/Grid.php CHANGED
@@ -28,49 +28,20 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
- $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_page_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
32
- /** @var StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Page_Collection $collection */
33
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->getCollection()
34
->addFieldToFilter('main_table.job_id', $job->getId());
35
36
- //echo $collection->getSelect(); die();
37
- $collection->getSelect()
38
- ->joinLeft(
39
- array('translate' => $collection->getTable('strakertranslations_easytranslationplatform/cms_page_translate')),
40
- 'main_table.id = translate.id
41
- AND translate.cms_page_id = main_table.page_id AND translate.job_id = '.$job->getId(),
42
- array()
43
- );
44
-
45
- //loop through this job's attributes and join them to the collection
46
- foreach ($jobAttributes as $jobAttribute) {
47
- $attributeCode = $jobAttribute->getColumnName();
48
- $collection->getSelect()->joinLeft(
49
- array($attributeCode => $collection->getTable('strakertranslations_easytranslationplatform/cms_page_translate')),
50
- $attributeCode . '.cms_page_id = main_table.page_id
51
- AND ' . $attributeCode . '.column_name = \'' . $attributeCode . '\'
52
- AND ' . $attributeCode . '.job_id = ' . $job->getId(),
53
- array($attributeCode . '_original' => 'original', $attributeCode . '_translate' => 'translate')
54
- );
55
- }
56
-
57
$this->setCollection($collection);
58
return parent::_prepareCollection();
59
}
60
61
protected function _prepareColumns() {
62
- $this->addColumn('id', array(
63
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
64
- 'align' => 'center',
65
- 'width' => '50px',
66
- 'index' => 'id'
67
- ));
68
69
- $this->addColumn('page_id', array(
70
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Page ID'),
71
'align' => 'center',
72
- 'width' => '50px',
73
- 'index' => 'page_id'
74
));
75
76
$this->addColumn('identifier', array(
@@ -79,54 +50,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
79
'index' => 'identifier'
80
));
81
82
- $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
83
- $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_page_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
84
- //loop through this job's attributes and add columns to the grid
85
- foreach ($jobAttributes as $jobAttribute) {
86
- $attributeCode = $jobAttribute->getColumnName();
87
- if($attributeCode === 'content'){
88
- $this->addColumn($attributeCode . '_original', array(
89
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
90
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
91
- 'align' => 'left',
92
- 'index' => $attributeCode . '_original',
93
- 'filter' => false,
94
- 'sortable' => false
95
- ));
96
-
97
- $this->addColumn($attributeCode . '_translate', array(
98
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
99
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
100
- 'align' => 'left',
101
- 'index' => $attributeCode . '_translate',
102
- 'filter' => false,
103
- 'sortable' => false
104
- ));
105
- }else{
106
- $this->addColumn($attributeCode . '_original', array(
107
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
108
- 'align' => 'left',
109
- 'index' => $attributeCode . '_original',
110
- // 'filter_index' => $attributeCode.'.original',
111
- 'filter' => false,
112
- 'sortable' => false
113
- ));
114
-
115
- $this->addColumn($attributeCode . '_translate', array(
116
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
117
- 'align' => 'left',
118
- 'index' => $attributeCode . '_translate',
119
- // 'filter_index' => $attributeCode.'.translate',
120
- 'filter' => false,
121
- 'sortable' => false
122
- ));
123
- }
124
- }
125
-
126
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
127
$this->addColumn('version', array(
128
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
129
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
130
'align' => 'center',
131
'type' => 'options',
132
'index' => 'version',
@@ -139,21 +66,6 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
139
));
140
}
141
142
- $this->addColumn('view_frontend', array(
143
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Frontend'),
144
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Frontend',
145
- 'align' => 'center',
146
- 'index' => false,
147
- 'filter' => false,
148
- ));
149
- $this->addColumn('view_backend', array(
150
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
151
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
152
- 'align' => 'center',
153
- 'index' => false,
154
- 'filter' => false,
155
- ));
156
-
157
return parent::_prepareColumns();
158
}
159
@@ -184,7 +96,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
184
185
$this->getMassactionBlock()->addItem('add', array(
186
'label' => Mage::helper('catalog')->__('Publish Translation'),
187
- 'url' => $this->getUrl('*/*/publish'),
188
'selected' => 1
189
));
190
@@ -199,36 +111,36 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
199
return $this;
200
}
201
202
- protected function _prepareMassactionColumn()
203
- {
204
- if ($this->getStatusId() == '4') {
205
- $columnId = 'massaction';
206
- $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
207
- ->setData(array(
208
- 'index' => $this->getMassactionIdField(),
209
- 'use_index' => $this->getMassactionIdField(),
210
- 'filter_index' => $this->getMassactionIdFilter(),
211
- 'type' => 'massaction',
212
- 'name' => $this->getMassactionBlock()->getFormFieldName(),
213
- 'align' => 'center',
214
- 'is_system' => true
215
- ));
216
-
217
- if ($this->getNoFilterMassactionColumn()) {
218
- $massactionColumn->setData('filter', false);
219
- }
220
-
221
- $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
222
- ->setGrid($this)
223
- ->setId($columnId);
224
-
225
- $oldColumns = $this->_columns;
226
- $this->_columns = array();
227
- $this->_columns[$columnId] = $massactionColumn;
228
- $this->_columns = array_merge($this->_columns, $oldColumns);
229
- return $this;
230
- }
231
- }
232
233
public function getMainButtonsHtml()
234
{
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
+
32
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->getCollection()
33
->addFieldToFilter('main_table.job_id', $job->getId());
34
35
$this->setCollection($collection);
36
return parent::_prepareCollection();
37
}
38
39
protected function _prepareColumns() {
40
41
+ $this->addColumn('title', array(
42
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Title'),
43
'align' => 'center',
44
+ 'index' => 'title'
45
));
46
47
$this->addColumn('identifier', array(
50
'index' => 'identifier'
51
));
52
53
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
54
$this->addColumn('version', array(
55
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
56
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion',
57
'align' => 'center',
58
'type' => 'options',
59
'index' => 'version',
66
));
67
}
68
69
return parent::_prepareColumns();
70
}
71
96
97
$this->getMassactionBlock()->addItem('add', array(
98
'label' => Mage::helper('catalog')->__('Publish Translation'),
99
+ 'url' => $this->getUrl('*/*/applyTranslation'),
100
'selected' => 1
101
));
102
111
return $this;
112
}
113
114
+ // protected function _prepareMassactionColumn()
115
+ // {
116
+ // if ($this->getStatusId() == '4') {
117
+ // $columnId = 'massaction';
118
+ // $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
119
+ // ->setData(array(
120
+ // 'index' => $this->getMassactionIdField(),
121
+ // 'use_index' => $this->getMassactionIdField(),
122
+ // 'filter_index' => $this->getMassactionIdFilter(),
123
+ // 'type' => 'massaction',
124
+ // 'name' => $this->getMassactionBlock()->getFormFieldName(),
125
+ // 'align' => 'center',
126
+ // 'is_system' => true
127
+ // ));
128
+ //
129
+ // if ($this->getNoFilterMassactionColumn()) {
130
+ // $massactionColumn->setData('filter', false);
131
+ // }
132
+ //
133
+ // $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
134
+ // ->setGrid($this)
135
+ // ->setId($columnId);
136
+ //
137
+ // $oldColumns = $this->_columns;
138
+ // $this->_columns = array();
139
+ // $this->_columns[$columnId] = $massactionColumn;
140
+ // $this->_columns = array_merge($this->_columns, $oldColumns);
141
+ // return $this;
142
+ // }
143
+ // }
144
145
public function getMainButtonsHtml()
146
{
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product ex
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php CHANGED
@@ -174,7 +174,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
174
175
$this->getMassactionBlock()->addItem('add', array(
176
'label' => Mage::helper('catalog')->__('Publish Translation'),
177
- 'url' => $this->getUrl('*/*/publish'),
178
'selected' => 1
179
));
180
$this->getMassactionBlock()->setTemplate('straker/job/product/massaction.phtml');
174
175
$this->getMassactionBlock()->addItem('add', array(
176
'label' => Mage::helper('catalog')->__('Publish Translation'),
177
+ 'url' => $this->getUrl('*/*/applyTranslation'),
178
'selected' => 1
179
));
180
$this->getMassactionBlock()->setTemplate('straker/job/product/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Grid.php CHANGED
@@ -167,11 +167,12 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_
167
return $this;
168
}
169
170
- if ( in_array($value, ['select','multiselect'] ) ){
171
- $collection->getSelect()->where('frontend_input in (?)', ['select','multiselect']);
172
} else {
173
- $collection->getSelect()->where('frontend_input not in (?)', ['select','multiselect']);
174
}
175
return $this;
176
}
177
@@ -183,7 +184,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_
183
184
$this->getMassactionBlock()->addItem('add', array(
185
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
186
- 'url' => $this->getUrl('*/*/addToConfirm'),
187
'selected' => 1
188
));
189
$this->getMassactionBlock()->setTemplate('straker/new/attribute/massaction.phtml');
@@ -212,7 +213,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_
212
$AttributeIdsWithOption->reset(Zend_Db_Select::LIMIT_OFFSET);
213
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
214
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
215
- $AttributeIdsWithOption->where('frontend_input in (?)',['select','multiselect']);
216
$AttributeIdsWithOption->columns('attribute_id', 'main_table');
217
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($AttributeIdsWithOption);
218
}
167
return $this;
168
}
169
170
+ if ($value == 'select' ){
171
+ $collection->getSelect()->where('frontend_input=?', 'select');
172
} else {
173
+ $collection->getSelect()->where('frontend_input<>?', 'select');
174
}
175
+
176
return $this;
177
}
178
184
185
$this->getMassactionBlock()->addItem('add', array(
186
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
187
+ 'url' => $this->getUrl('*/*/addtoconfirm'),
188
'selected' => 1
189
));
190
$this->getMassactionBlock()->setTemplate('straker/new/attribute/massaction.phtml');
213
$AttributeIdsWithOption->reset(Zend_Db_Select::LIMIT_OFFSET);
214
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
215
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
216
+ $AttributeIdsWithOption->where('frontend_input=?','select');
217
$AttributeIdsWithOption->columns('attribute_id', 'main_table');
218
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($AttributeIdsWithOption);
219
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Block/Grid.php CHANGED
@@ -14,8 +14,8 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Cms_Block_
14
15
protected function _prepareCollection()
16
{
17
- /* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
18
$collection = Mage::getModel('cms/block')->getCollection();
19
$this->setCollection($collection);
20
return parent::_prepareCollection();
21
}
@@ -94,7 +94,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Cms_Block_
94
95
$this->getMassactionBlock()->addItem('add', array(
96
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
97
- 'url' => $this->getUrl('*/*/addToConfirm'),
98
'selected' => 1
99
));
100
$this->getMassactionBlock()->setTemplate('straker/new/cms/block/massaction.phtml');
14
15
protected function _prepareCollection()
16
{
17
$collection = Mage::getModel('cms/block')->getCollection();
18
+ /* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
19
$this->setCollection($collection);
20
return parent::_prepareCollection();
21
}
94
95
$this->getMassactionBlock()->addItem('add', array(
96
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
97
+ 'url' => $this->getUrl('*/*/addtoconfirm'),
98
'selected' => 1
99
));
100
$this->getMassactionBlock()->setTemplate('straker/new/cms/block/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Page/Grid.php CHANGED
@@ -108,7 +108,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Cms_Page_G
108
109
$this->getMassactionBlock()->addItem('add', array(
110
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
111
- 'url' => $this->getUrl('*/*/addToConfirm'),
112
'selected' => 1
113
));
114
$this->getMassactionBlock()->setTemplate('straker/new/cms/page/massaction.phtml');
108
109
$this->getMassactionBlock()->addItem('add', array(
110
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
111
+ 'url' => $this->getUrl('*/*/addtoconfirm'),
112
'selected' => 1
113
));
114
$this->getMassactionBlock()->setTemplate('straker/new/cms/page/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Confirm/Grid.php CHANGED
@@ -135,7 +135,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Confirm_Gr
135
136
public function getGridUrl()
137
{
138
- return $this->getUrl('*/*/addToConfirm', array('_current'=>true));
139
}
140
141
public function getRowUrl($row)
135
136
public function getGridUrl()
137
{
138
+ return $this->getUrl('*/*/addtoconfirm', array('_current'=>true));
139
}
140
141
public function getRowUrl($row)
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php CHANGED
@@ -269,7 +269,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
269
270
$this->getMassactionBlock()->addItem('add', array(
271
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
272
- 'url' => $this->getUrl('*/*/addToConfirm'),
273
'selected' => 1
274
));
275
269
270
$this->getMassactionBlock()->addItem('add', array(
271
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
272
+ 'url' => $this->getUrl('*/*/addtoconfirm'),
273
'selected' => 1
274
));
275
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Backend.php CHANGED
@@ -7,38 +7,23 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
- $html .= '<p class="inactive">' . $this->__('View in Backend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->load($row->getProductId());
14
$url = $this->getUrl('adminhtml/catalog_product/edit', array(
15
'store' => $this->getStoreId($row),
16
- 'id' => $product->getId()
17
- )
18
);
19
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
20
- }elseif($row->getAttributeId()){
21
- $product = Mage::getModel('catalog/product')->load($row->getAttributeId());
22
- $url = $this->getUrl('adminhtml/catalog_product_attribute/edit', array(
23
- 'attribute_id' => $row->getAttributeId()
24
- )
25
- );
26
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
27
}
28
elseif($row->getCategoryId()) {
29
$category = Mage::getModel('catalog/category')->load($row->getCategoryId());
30
$url = $this->getUrl('adminhtml/catalog_category/edit', array(
31
'store' => $this->getStoreId($row),
32
- 'id' => $category->getId()
33
- )
34
);
35
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
36
- }elseif($row->getPageId()){
37
- $url = Mage::helper("adminhtml")->getUrl("adminhtml/cms_page/edit",array("page_id"=>$row->getNewEntityId()));
38
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
39
- }elseif($row->getBlockId()){
40
- $url = Mage::helper("adminhtml")->getUrl("adminhtml/cms_block/edit",array("block_id"=>$row->getNewEntityId()));
41
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
42
}
43
return $html;
44
}
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
+ $html .= '<p class="inactive">' . $this->__('View Product in Backend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->load($row->getProductId());
14
$url = $this->getUrl('adminhtml/catalog_product/edit', array(
15
'store' => $this->getStoreId($row),
16
+ 'id' => $product->getId())
17
);
18
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View Product in Backend') . '</a>';
19
}
20
elseif($row->getCategoryId()) {
21
$category = Mage::getModel('catalog/category')->load($row->getCategoryId());
22
$url = $this->getUrl('adminhtml/catalog_category/edit', array(
23
'store' => $this->getStoreId($row),
24
+ 'id' => $category->getId())
25
);
26
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View Category in Backend') . '</a>';
27
}
28
return $html;
29
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/CmsVersion.php CHANGED
@@ -1,20 +1,20 @@
1
<?php
2
- //class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion
3
- // extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
- //{
5
- // public function render(Varien_Object $row)
6
- // {
7
- // if($row->getVersion()){
8
- // if($row->getBlockId()){
9
- // $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_block/edit",array("block_id"=>$row->getNewEntityId()));
10
- // }
11
- // else{
12
- // $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_page/edit",array("page_id"=>$row->getNewEntityId()));
13
- // }
14
- // return '<a href="'.$link.'" target="_blank">View Published</a>';
15
- // }
16
- // else{
17
- // return 'Not Published';
18
- // }
19
- // }
20
- //}
1
<?php
2
+ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion
3
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function render(Varien_Object $row)
6
+ {
7
+ if($row->getVersion()){
8
+ if($row->getBlockId()){
9
+ $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_block/edit",array("block_id"=>$row->getNewEntityId()));
10
+ }
11
+ else{
12
+ $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_page/edit",array("page_id"=>$row->getNewEntityId()));
13
+ }
14
+ return '<a href="'.$link.'" target="_blank">View Published</a>';
15
+ }
16
+ else{
17
+ return 'Not Published';
18
+ }
19
+ }
20
+ }
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateOptions.php CHANGED
@@ -8,7 +8,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
8
9
public function render(Varien_Object $row){
10
$id = $row->getAttributeId();
11
- if (in_array($row->getFrontendInput(), ['select', 'multiselect']) ) {
12
$html = '<input disabled type="checkbox" name="option" value="' . $id . '" class="checkbox-option"';
13
if (in_array($id, $this->_getOption())) {
14
$html .= ' checked="checked" >';
8
9
public function render(Varien_Object $row){
10
$id = $row->getAttributeId();
11
+ if ($row->getFrontendInput()=='select') {
12
$html = '<input disabled type="checkbox" name="option" value="' . $id . '" class="checkbox-option"';
13
if (in_array($id, $this->_getOption())) {
14
$html .= ' checked="checked" >';
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Frontend.php CHANGED
@@ -7,32 +7,20 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
- $html .= '<p class="inactive">' . $this->__('View in Frontend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId($row))->load($row->getProductId());
14
if (!$product->isDisabled() && $product->isVisibleInSiteVisibility()) {
15
- $html .= '<a target="_blank" href="' . $product->getProductUrl() . '">' . $this->__('View in Frontend') . '</a>';
16
} else {
17
$html .= 'Product is not visible in frontend';
18
}
19
}
20
- elseif($row->getPageId()){
21
- $url = '';
22
- if ($row->getPreviewUrl()) {
23
- $href = $row->getPreviewUrl();
24
- } else {
25
- $urlModel = Mage::getModel('core/url')->setStore($row->getData('_first_store_id'));
26
- $url = $urlModel->getUrl(
27
- $row->getIdentifier(), array(
28
- '_current' => false,
29
- '_query' => '___store=' . $this->getStoreCode($row),
30
- )
31
- );
32
- }
33
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Frontend') . '</a>';
34
}
35
-
36
return $html;
37
}
38
@@ -44,9 +32,4 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
44
}
45
return $this->_storeId;
46
}
47
-
48
- protected function getStoreCode($row){
49
- $this->getStoreId($row);
50
- return Mage::app()->getStore($this->_storeId)->getCode();
51
- }
52
}
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
+ $html .= '<p class="inactive">' . $this->__('View Product in Frontend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId($row))->load($row->getProductId());
14
if (!$product->isDisabled() && $product->isVisibleInSiteVisibility()) {
15
+ $html .= '<a target="_blank" href="' . $product->getProductUrl() . '">' . $this->__('View Product in Frontend') . '</a>';
16
} else {
17
$html .= 'Product is not visible in frontend';
18
}
19
}
20
+ elseif($row->getCategoryId()){
21
+ $url = $this->getUrl('catalog/category/view', ['id' => $row->getCategoryId(), '_nosid' => true, '_query' => ['___store' => $this->getStoreId($row) ]]);
22
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View Category in Frontend') . '</a>';
23
}
24
return $html;
25
}
26
32
}
33
return $this->_storeId;
34
}
35
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Selected.php CHANGED
@@ -8,63 +8,50 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
8
9
switch ($row->getTypeName()) {
10
case 'Product':
11
- $productAttributeCollection =
12
Mage::getModel('strakertranslations_easytranslationplatform/product_attributes')
13
->getCollection()->addFieldToFilter('job_id', $row->getId());
14
15
$output =array();
16
17
- foreach ($productAttributeCollection as $productAttribute) {
18
- $output[] = $this->_getAttributeLabel($productAttribute->getAttributeId());
19
}
20
$html = implode(', ', $output);
21
break;
22
case 'Category':
23
- $categoryAttributeCollection =
24
Mage::getModel('strakertranslations_easytranslationplatform/category_attributes')
25
->getCollection()->addFieldToFilter('job_id', $row->getId());
26
27
- $output =array();
28
29
- foreach ($categoryAttributeCollection as $categoryAttribute) {
30
- $output[] = $this->_getAttributeLabel($categoryAttribute->getAttributeId());
31
- }
32
- $html = implode(', ', $output);
33
break;
34
case 'Attribute':
35
$AttributeCollection =
36
Mage::getModel('strakertranslations_easytranslationplatform/job_attribute')
37
->getCollection()->addFieldToFilter('job_id', $row->getId());
38
39
- $output = count($AttributeCollection);
40
- $html = $output > 1 ? "$output Attributes" : '1 Attribute';
41
- break;
42
- case 'CMS Block':
43
- $cmsBlockAttributeCollection =
44
- Mage::getModel('strakertranslations_easytranslationplatform/cms_block_attributes')
45
- ->getCollection()->addFieldToFilter('job_id', $row->getId());
46
47
- $output =array();
48
49
- foreach ($cmsBlockAttributeCollection as $cmsAttribute) {
50
- $output[] = $this->_formatColumnName($cmsAttribute->getData('column_name'));
51
- }
52
- $html = implode(', ', $output);
53
break;
54
- case 'CMS Page':
55
- $cmsPageAttributeCollection =
56
- Mage::getModel('strakertranslations_easytranslationplatform/cms_page_attributes')
57
- ->getCollection()->addFieldToFilter('job_id', $row->getId());
58
59
- $output =array();
60
-
61
- foreach ($cmsPageAttributeCollection as $cmsAttribute) {
62
- $output[] = $this->_formatColumnName($cmsAttribute->getData('column_name'));
63
- }
64
- $html = implode(', ', $output);
65
- break;
66
default:
67
$html = '';
68
}
69
70
return $html;
@@ -75,22 +62,4 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
75
private function _getAttributeLabel($attributeId) {
76
return Mage::getModel('eav/entity_attribute')->load($attributeId)->getFrontendLabel();
77
}
78
-
79
- private function _formatColumnName( $columnName ){
80
- $return = '';
81
- switch(strtolower($columnName)){
82
- case 'meta_keywords':
83
- $return = 'Meta Keywords';
84
- break;
85
- case 'meta_description':
86
- $return = 'Meta Description';
87
- break;
88
- case 'content_heading':
89
- $return = 'Content Heading';
90
- break;
91
- default:
92
- $return = ucfirst($columnName);
93
- }
94
- return $return;
95
- }
96
}
8
9
switch ($row->getTypeName()) {
10
case 'Product':
11
+
12
+ $productAttrubuteCollection =
13
Mage::getModel('strakertranslations_easytranslationplatform/product_attributes')
14
->getCollection()->addFieldToFilter('job_id', $row->getId());
15
16
$output =array();
17
18
+ foreach ($productAttrubuteCollection as $productAttrubute) {
19
+ $output[] = $this->_getAttributeLabel($productAttrubute->getAttributeId());
20
}
21
$html = implode(', ', $output);
22
+
23
break;
24
+
25
case 'Category':
26
+
27
+ $categoryAttrubuteCollection =
28
Mage::getModel('strakertranslations_easytranslationplatform/category_attributes')
29
->getCollection()->addFieldToFilter('job_id', $row->getId());
30
31
+ $output =array();
32
+
33
+ foreach ($categoryAttrubuteCollection as $categoryAttrubute) {
34
+ $output[] = $this->_getAttributeLabel($categoryAttrubute->getAttributeId());
35
+ }
36
+ $html = implode(', ', $output);
37
38
break;
39
+
40
case 'Attribute':
41
+
42
$AttributeCollection =
43
Mage::getModel('strakertranslations_easytranslationplatform/job_attribute')
44
->getCollection()->addFieldToFilter('job_id', $row->getId());
45
46
+ $output = count($AttributeCollection);
47
48
+ $html = $output > 1 ? "$output Attributes" : '1 Attribute';
49
50
break;
51
52
default:
53
$html = '';
54
+
55
}
56
57
return $html;
62
private function _getAttributeLabel($attributeId) {
63
return Mage::getModel('eav/entity_attribute')->load($attributeId)->getFrontendLabel();
64
}
65
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TextArea.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea
3
- extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
- {
5
- public function render(Varien_Object $row)
6
- {
7
- $index = $this->getColumn()->getIndex();
8
- if($index && $row->getData($index)){
9
- $value = $row->getData($index);
10
- return '<textarea cols="100" rows="10">' . htmlspecialchars($value) . '</textarea>';
11
- }
12
- }
13
- }
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TranslateOptions.php CHANGED
@@ -5,7 +5,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
5
protected $_storeId;
6
7
public function render(Varien_Object $row){
8
- if ( in_array($row->getFrontendInput(), ['select', 'multiselect'] ) ) {
9
$html = '<input type="checkbox" name="option" value="' . $row->getAttributeId() . '" class="checkbox-option">';
10
}
11
else{
5
protected $_storeId;
6
7
public function render(Varien_Object $row){
8
+ if ($row->getFrontendInput()=='select') {
9
$html = '<input type="checkbox" name="option" value="' . $row->getAttributeId() . '" class="checkbox-option">';
10
}
11
else{
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Attribute/Translate.php CHANGED
@@ -71,75 +71,71 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Attribute_Translate exte
71
//
72
// }
73
74
- $success = true;
75
- try{
76
- if ($this->getTranslate()){
77
- $dataInJson = json_encode(simplexml_load_string($this->getTranslate()));
78
- $data = json_decode($dataInJson,true);
79
- $storeId = (int) $this->getStoreId();
80
- /** @var Mage_Eav_Model_Attribute $eavAttributeModel */
81
- $eavAttributeModel = Mage::getModel('eav/entity_attribute');
82
- foreach ($data as $k => $attribute ){
83
- if ($k == 'title' && $attribute){
84
- $attributeId = (int) $this->getAttributeId();
85
- $eavAttributeModel->load($attributeId);
86
- $eavAttributeModelId = $eavAttributeModel->getId();
87
- if(!empty($eavAttributeModelId)){
88
- $storeLabels = $eavAttributeModel->getStoreLabels();
89
- if(is_array($storeLabels)){
90
- //get all current stores
91
- $stores = array_keys($storeLabels);
92
- if(!in_array($storeId, $stores)){
93
- $storeLabels[$storeId] = trim($attribute);
94
- $eavAttributeModel->setData('store_labels', $storeLabels)->save();
95
- }
96
}
97
}
98
}
99
100
- if ($k == 'option' && $attribute){
101
- $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
102
103
- /* @var $model Mage_Catalog_Model_Entity_Attribute */
104
- $attrModel = Mage::getModel('catalog/resource_eav_attribute');
105
- $attrModel->load($this->getAttributeId());
106
107
- /** @var $valuesCollection Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection */
108
- $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
109
- ->setStoreFilter($storeId, false)
110
- ->setAttributeFilter($attrModel->getId());
111
112
- //0 => ['option_id' => '20', 'attribute_id' => '92', 'sort_order' => '0', 'value' => 'Black' ]
113
- $optionData = $valuesCollection->getData();
114
- $optionIds = array_column($optionData, 'option_id');
115
116
- $optionValueTable = $setup->getTable('eav/attribute_option_value');
117
118
- $newOptionData = [];
119
- foreach ($attribute as $optionId => $optionValue) {
120
- $optionId = str_replace('id_', '',$optionId);
121
- // /** @var Mage_Eav_Model_Entity_Attribute_Option $optionModel */
122
- // $optionModel = Mage::getModel('eav/entity_attribute_option');
123
- // $optionModel->load($optionId);
124
- if( !in_array($optionId, $optionIds)){
125
- $newOptionData[] = [
126
'option_id' => $optionId,
127
'store_id' => $storeId,
128
'value' => trim($optionValue)
129
- ];
130
- }
131
- }
132
- if($newOptionData){
133
- $setup->getConnection()->insertMultiple($optionValueTable, $newOptionData);
134
}
135
}
136
}
137
}
138
- $this->setIsImported(1)->save();
139
- }catch(Exception $e){
140
- $success = false;
141
}
142
- return $success;
143
}
144
145
// private function _getConnection() {
71
//
72
// }
73
74
+ if ($this->getTranslate()){
75
+ $dataInJson = json_encode(simplexml_load_string($this->getTranslate()));
76
+ $data = json_decode($dataInJson,true);
77
+ $storeId = (int) $this->getStoreId();
78
+ /** @var Mage_Eav_Model_Attribute $eavAttributeModel */
79
+ $eavAttributeModel = Mage::getModel('eav/entity_attribute');
80
+ foreach ($data as $k => $attribute ){
81
+ if ($k == 'title' && $attribute){
82
+ $attributeId = (int) $this->getAttributeId();
83
+ $eavAttributeModel->load($attributeId);
84
+ if(!empty($eavAttributeModel->getId())){
85
+ $storeLabels = $eavAttributeModel->getStoreLabels();
86
+ if(is_array($storeLabels)){
87
+ //get all current stores
88
+ $stores = array_keys($storeLabels);
89
+ if(!in_array($storeId, $stores)){
90
+ $storeLabels[$storeId] = trim($attribute);
91
+ $eavAttributeModel->setData('store_labels', $storeLabels)->save();
92
}
93
}
94
}
95
+ }
96
97
+ if ($k == 'option' && $attribute){
98
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
99
100
+ /* @var $model Mage_Catalog_Model_Entity_Attribute */
101
+ $attrModel = Mage::getModel('catalog/resource_eav_attribute');
102
+ $attrModel->load($this->getAttributeId());
103
104
+ /** @var $valuesCollection Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection */
105
+ $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
106
+ ->setStoreFilter($storeId, false)
107
+ ->setAttributeFilter($attrModel->getId());
108
109
+ //0 => ['option_id' => '20', 'attribute_id' => '92', 'sort_order' => '0', 'value' => 'Black' ]
110
+ $optionData = $valuesCollection->getData();
111
+ $optionIds = array_column($optionData, 'option_id');
112
113
+ $optionValueTable = $setup->getTable('eav/attribute_option_value');
114
115
+ $newOptionData = [];
116
+ foreach ($attribute as $optionId => $optionValue) {
117
+ $optionId = str_replace('id_', '',$optionId);
118
+ // /** @var Mage_Eav_Model_Entity_Attribute_Option $optionModel */
119
+ // $optionModel = Mage::getModel('eav/entity_attribute_option');
120
+ // $optionModel->load($optionId);
121
+ if( !in_array($optionId, $optionIds)){
122
+ array_push(
123
+ $newOptionData,
124
+ [
125
'option_id' => $optionId,
126
'store_id' => $storeId,
127
'value' => trim($optionValue)
128
+ ]
129
+ );
130
}
131
}
132
+ if($newOptionData){
133
+ $setup->getConnection()->insertMultiple($optionValueTable, $newOptionData);
134
+ }
135
}
136
}
137
}
138
+ $this->setIsImported(1)->save();
139
}
140
141
// private function _getConnection() {
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Category/Translate.php CHANGED
@@ -14,26 +14,20 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Category_Translate exten
14
}
15
16
public function importTranslation(){
17
- $success = true;
18
- try{
19
- $translatedValue = $this->getTranslate();
20
- //if translated value is null, skip
21
- if(!is_null($translatedValue)){
22
- $category = Mage::getModel('catalog/category')
23
- ->setStoreId($this->getStoreId())
24
- ->load($this->getCategoryId());
25
- $categoryAttributeCode = $this->_getAttributeCode($this->getAttributeId());
26
- $this->setBackup($category->getData($categoryAttributeCode));
27
- $category->setData($categoryAttributeCode, $translatedValue)
28
- ->getResource()
29
- ->saveAttribute($category, $categoryAttributeCode);
30
- $this->setIsImported(1)->save();
31
- $category->clearInstance();
32
- }
33
- }catch(Exception $e){
34
- $success = false;
35
- }
36
- return $success;
37
}
38
39
protected function _getAttributeCode($attributeId){
14
}
15
16
public function importTranslation(){
17
+
18
+ $category = Mage::getModel('catalog/category')->setStoreId($this->getStoreId())->load($this->getCategoryId());
19
+
20
+ $categoryAttributeCode = $this->_getAttributeCode($this->getAttributeId());
21
+
22
+ $this->setBackup($category->getData($categoryAttributeCode));
23
+
24
+ $category->setData($categoryAttributeCode, $this->getTranslate())
25
+ ->getResource()
26
+ ->saveAttribute($category, $categoryAttributeCode);
27
+ $this->setIsImported(1)->save();
28
+
29
+ $category->clearInstance();
30
+
31
}
32
33
protected function _getAttributeCode($attributeId){
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Block/Translate.php CHANGED
@@ -12,37 +12,37 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Cms_Block_Translate exte
12
{
13
$this->_init('strakertranslations_easytranslationplatform/cms_block_translate');
14
}
15
//
16
- // public function importTranslation(){
17
- //
18
- // $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->load($this->getJobCmsId())
19
- // ->getNewEntityId();
20
//
21
//
22
- //// if ($this->getTranslate()){
23
- ////
24
- //// $writeConnection = $this->_getConnection();
25
- ////
26
- //// $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/block')
27
- //// . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE block_id = '.$newEntityId;
28
- ////
29
- ////
30
- //// $writeConnection->query($query);
31
- ////
32
- ////
33
- //// }
34
//
35
- // if ($this->getTranslate()){
36
- // $model = Mage::getModel('cms/block')->load($newEntityId);
37
- // if($model->getId()){
38
- // $model->setData($this->getColumnName(), $this->getTranslate());
39
- // $model->save();
40
- // }
41
- // }
42
//
43
- // $this->setIsImported(1)->save();
44
//
45
- // }
46
//
47
// private function _getConnection() {
48
// return Mage::getSingleton('core/resource')->getConnection('core_write');
12
{
13
$this->_init('strakertranslations_easytranslationplatform/cms_block_translate');
14
}
15
+
16
+ public function importTranslation(){
17
+
18
+ $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->load($this->getJobCmsId())
19
+ ->getNewEntityId();
20
+
21
+
22
+ // if ($this->getTranslate()){
23
//
24
+ // $writeConnection = $this->_getConnection();
25
//
26
+ // $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/block')
27
+ // . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE block_id = '.$newEntityId;
28
//
29
//
30
+ // $writeConnection->query($query);
31
//
32
//
33
+ // }
34
+
35
+ if ($this->getTranslate()){
36
+ $model = Mage::getModel('cms/block')->load($newEntityId);
37
+ if($model->getId()){
38
+ $model->setData($this->getColumnName(), $this->getTranslate());
39
+ $model->save();
40
+ }
41
+ }
42
+
43
+ $this->setIsImported(1)->save();
44
+
45
+ }
46
//
47
// private function _getConnection() {
48
// return Mage::getSingleton('core/resource')->getConnection('core_write');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Page/Translate.php CHANGED
@@ -13,48 +13,40 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Cms_Page_Translate exten
13
$this->_init('strakertranslations_easytranslationplatform/cms_page_translate');
14
}
15
16
- // public function importTranslation(){
17
- // $success = true;
18
- // $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->load($this->getJobCmsId())
19
- // ->getNewEntityId();
20
- //
21
- //// if ($this->getTranslate()){
22
- //// $writeConnection = $this->_getConnection();
23
- //// $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/page')
24
- //// . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE page_id = '.$newEntityId;
25
- //// $writeConnection->query($query);
26
- //// }
27
- //// $this->setIsImported(1)->save();
28
- //
29
- // $translation = $this->getTranslate();
30
- // if( !empty($translation) ){
31
- // $model = Mage::getModel('cms/page')->load($newEntityId);
32
- // if($model->getId()){
33
- // $model->setData($this->getColumnName(), $translation );
34
- // $model->setData('stores', $this->getStoreId());
35
- // // try to save it
36
- // try {
37
- // // save the data
38
- // $model->save();
39
- //
40
- // // display success message
41
- // Mage::getSingleton('adminhtml/session')->addSuccess(
42
- // Mage::helper('cms')->__('The page has been saved.'));
43
- // $this->setIsImported(1)->save();
44
- // }catch (Exception $e) {
45
- // $success = false;
46
- // Mage::getSingleton('adminhtml/session')->addError($e->getMessage()
47
- // . ' Page ID: ' . $this->getJobCmsId()
48
- // . ' Attribute: ' . $this->getColumnName());
49
- // }
50
- // }
51
// }
52
- // return $success;
53
- // }
54
//
55
// private function _getConnection() {
56
// return Mage::getSingleton('core/resource')->getConnection('core_write');
57
// }
58
59
-
60
}
13
$this->_init('strakertranslations_easytranslationplatform/cms_page_translate');
14
}
15
16
+ public function importTranslation(){
17
+
18
+ $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->load($this->getJobCmsId())
19
+ ->getNewEntityId();
20
+
21
+
22
+ // if ($this->getTranslate()){
23
+ //
24
+ // $writeConnection = $this->_getConnection();
25
+ //
26
+ // $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/page')
27
+ // . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE page_id = '.$newEntityId;
28
+ //
29
+ //
30
+ // $writeConnection->query($query);
31
+ //
32
+ //
33
// }
34
+ //
35
+ // $this->setIsImported(1)->save();
36
+ $translation = $this->getTranslate();
37
+ if( !empty($translation) ){
38
+ $model = Mage::getModel('cms/page')->load($newEntityId);
39
+ if($model->getId()){
40
+ $model->setData($this->getColumnName(), $translation );
41
+ $model->save();
42
+ $model->unsetData();
43
+ }
44
+ }
45
+ $this->setIsImported(1)->save();
46
+ }
47
//
48
// private function _getConnection() {
49
// return Mage::getSingleton('core/resource')->getConnection('core_write');
50
// }
51
52
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php CHANGED
@@ -9,15 +9,12 @@
9
class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Model_Abstract
10
{
11
protected $_attributes = array();
12
protected $_translateFilePath = '/var/straker/';
13
- /** @var $conn Varien_Db_Adapter_Interface */
14
- protected $conn;
15
16
protected function _construct()
17
{
18
$this->_init('strakertranslations_easytranslationplatform/job');
19
- /** @var $conn Varien_Db_Adapter_Interface */
20
- $this->conn = $this->getWriteAdapter();
21
}
22
23
protected function addProductAttributes($productAttributeIds)
@@ -34,51 +31,27 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
34
35
protected function addProductIds($productIds)
36
{
37
- $data = array();
38
- $jobProductTableName = $this->getResource()->getTable('strakertranslations_easytranslationplatform/job_product');
39
-
40
foreach ($productIds as $productId) {
41
- $data[] = [
42
- 'product_id' => $productId,
43
- 'job_id' => $this->getId()
44
- ];
45
}
46
-
47
- $this->conn->insertMultiple($jobProductTableName, $data);
48
- // $model = Mage::getModel('strakertranslations_easytranslationplatform/job_product');
49
- // foreach ($productIds as $productId) {
50
- // $model->setProductId($productId);
51
- // $model->setJobId($this->getId());
52
- // $model->save();
53
- // $model->unsetData();
54
- // }
55
return $this;
56
}
57
58
protected function addProductTranslateOriginal($productAttributeId, $productCollection)
59
{
60
- $data = array();
61
- $productTranslateTableName = $this->getResource()->getTable('strakertranslations_easytranslationplatform/product_translate');
62
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($productAttributeId)->getAttributeCode();
63
- // $model = Mage::getModel('strakertranslations_easytranslationplatform/product_translate');
64
foreach ($productCollection as $product) {
65
- if($product->getData($productAttributeCode)){
66
- $data[] = [
67
- 'job_id' => $this->getId(),
68
- 'product_id' => $product->getId(),
69
- 'attribute_id' => $productAttributeId,
70
- 'original' => $product->getData($productAttributeCode)
71
- ];
72
- }
73
- // $model->setJobId($this->getId());
74
- // $model->setProductId($product->getId());
75
- // $model->setAttributeId($productAttributeId);
76
- // $model->setOriginal($product->getData($productAttributeCode));
77
- // $model->save();
78
- // $model->unsetData();
79
- }
80
- if($data){
81
- $this->conn->insertMultiple($productTranslateTableName, $data);
82
}
83
return $this;
84
}
@@ -114,14 +87,12 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
114
$model = Mage::getModel('strakertranslations_easytranslationplatform/category_translate');
115
$categoryAttributeCode = Mage::getModel('eav/entity_attribute')->load($categoryAttributeId)->getAttributeCode();
116
foreach ($categoryCollection as $category) {
117
- if($category->getData($categoryAttributeCode)){
118
- $model->setJobId($this->getId());
119
- $model->setCategoryId($category->getId());
120
- $model->setAttributeId($categoryAttributeId);
121
- $model->setOriginal($category->getData($categoryAttributeCode));
122
- $model->save();
123
- $model->unsetData();
124
- }
125
}
126
return $this;
127
}
@@ -157,15 +128,13 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
157
break;
158
}
159
}
160
- if($cmsData[$Column]){
161
- $model->setJobId($this->getId());
162
- $model->setData('cms_'.$type.'_id', $cmsData[$type . '_id']);
163
- $model->setcolumnName($Column);
164
- $model->setOriginal($cmsData[$Column]);
165
- $model->setJobCmsId($jobCmsId);
166
- $model->save();
167
- $model->unsetData();
168
- }
169
}
170
171
return $this;
@@ -552,27 +521,23 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
552
$attributeFrontLabel = array();
553
554
foreach ($productTranslateCollection as $productTranslate) {
555
- $sCData = $productTranslate->getOriginal();
556
- if( isset( $sCData ) ){
557
- if (!isset($attributeFrontLabel[$productTranslate->getAttributeId()])) {
558
- $attributeFrontLabel[$productTranslate->getAttributeId()] =
559
- Mage::getModel('eav/entity_attribute')->load($productTranslate->getAttributeId())->getFrontendLabel();
560
- }
561
-
562
- $dataElement = $_xml->createElement('data');
563
- $dataElement->setAttribute('name', $this->getTypeId() . '_' . $this->getStoreId() . '_' . $productTranslate->getAttributeId() . '_' . $productTranslate->getProductId());
564
- $dataElement->setAttribute('content_context', $attributeFrontLabel[$productTranslate->getAttributeId()]);
565
- $dataElement->setAttribute('content_context_url',Mage::getStoreConfig('web/unsecure/base_link_url', $this->getStoreId()) . 'catalog/category/view/id/' . $productTranslate->getProductId());
566
- $dataElement->setAttribute('content_id', $productTranslate->getId());
567
568
- $valueElement = $_xml->createElement('value');
569
- $CDATAValueNode = $_xml->createCDATASection($sCData);
570
- $valueElement->appendChild($CDATAValueNode);
571
572
- $dataElement->appendChild($valueElement);
573
- $rootElement->appendChild($dataElement);
574
- }
575
576
}
577
578
$_xml->appendChild($rootElement);
@@ -725,6 +690,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
725
726
public function submitProducts($productAttributeIds, $productIds)
727
{
728
//product
729
$this->setTypeId(1);
730
$this->addProducts($productAttributeIds, $productIds)
@@ -764,7 +730,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
764
return $this;
765
}
766
767
- public function submitCmsBlock($cmsIds, $columns = array('title', 'content'))
768
{
769
770
$this->setTypeId(6);
@@ -804,7 +770,6 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
804
if ($this->getJobKey()) {
805
$request = array();
806
$request['job_key'] = $this->getJobKey();
807
- /** @var StrakerTranslations_EasyTranslationPlatform_Model_Api $api */
808
$api = $this->_getApi();
809
$response = $api->getTranslation($request);
810
if ($response->job) {
@@ -813,11 +778,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
813
$updateFlag = $this->updateJob($job);
814
}
815
}
816
- if($updateFlag){
817
- $this->setLastStatus(1);
818
- }else{
819
- $this->setLastStatus(0);
820
- }
821
}
822
else{
823
$this->setLastStatus(0);
@@ -830,7 +791,6 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
830
}
831
832
public function bulkUpdateTranslation(){
833
- /** @var StrakerTranslations_EasyTranslationPlatform_Model_Api $api */
834
$api = $this->_getApi();
835
$response = $api->getTranslation(array());
836
return $response->job ? $response->job : false;
@@ -862,8 +822,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
862
foreach ($job->translated_file as $file) {
863
if ($file->download_url && !$this->getDownloadUrl()) {
864
$this->setDownloadUrl($file->download_url)->save();
865
- $result = $this->_importTranslation();
866
- $updateFlag = $result === false ? false : true;
867
}
868
}
869
return $updateFlag;
@@ -882,46 +841,52 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
882
883
protected function _importTranslation()
884
{
885
- /** @var StrakerTranslations_EasyTranslationPlatform_Model_Api $api */
886
- $api = $this->_getApi();
887
- $xml = $api->getTranslatedFile($this->getDownloadUrl());
888
file_put_contents(Mage::getBaseDir() . $this->_translateFilePath . 'translated_job' . $this->getId() . '.xml', $xml, LOCK_EX);
889
$data = simplexml_load_string($xml);
890
891
- if($data === false){
892
- return false;
893
- }else{
894
- $_translationValueGroup = array();
895
-
896
- foreach ($data->children() as $_translation) {
897
- $_entityTranslationId = (string)$_translation->attributes()->content_id;
898
- if ($this->_getType() == 'attribute') {
899
- if ($_translation->attributes()->content_context == "product attribute title") {
900
- $_translationValueGroup[$_entityTranslationId]['title'] = (string)$_translation->value;
901
- }
902
- if ($_translation->attributes()->content_context == "product attribute option") {
903
- $_translationValueGroup[$_entityTranslationId]['option']['id_' . $_translation->attributes()->option_id] = (string)$_translation->value;
904
- }
905
- } else {
906
- $_translationValueGroup[$_entityTranslationId] = (string)$_translation->value;
907
}
908
- }
909
910
- foreach ($_translationValueGroup as $content_id => $_translationValue) {
911
- $value = $_translationValue;
912
- if (is_array($_translationValue)) {
913
- $xml = new SimpleXMLElement('<attribute/>');
914
- $this->array_to_xml($_translationValue, $xml);
915
- $value = (string)$xml->asXML();
916
}
917
918
- $_entityTranslation = Mage::getModel('strakertranslations_easytranslationplatform/' . $this->_getType() . '_translate')->load($content_id);
919
- $_entityTranslation->setTranslate($value);
920
- $_entityTranslation->save();
921
- $_entityTranslation->clearInstance();
922
}
923
- return $this->setDownloadedVersion(1)->save();
924
}
925
}
926
927
protected function _getType()
@@ -948,99 +913,44 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
948
949
public function applyTranslation($entityIds = array())
950
{
951
- $success = true;
952
- $jobType = $this->_getType(); //product, category, cms_page ...
953
- // collection for straker_<TYPE>_translate tables
954
- $collection = Mage::getModel('strakertranslations_easytranslationplatform/' . $jobType . '_translate')->getCollection()->addFieldToFilter('job_id', $this->getId());
955
956
if ($entityIds) {
957
- $collection->addFieldToFilter($jobType . '_id', array('in' => $entityIds));
958
}
959
960
$updatedIds = array();
961
$writeConnection = $this->getWriteAdapter();
962
- $prefix = Mage::getConfig()->getTablePrefix()->__toString();
963
-
964
- try{
965
- if (in_array($jobType, array('cms_block', 'cms_page'))) {
966
- $result = $this->createNewCms($entityIds);
967
- $cmsTableName = str_replace('_', '', $jobType); //cmsxxx
968
- $cmsColumnName = str_replace('cms_', '', $jobType); //xxx
969
- $cmsModelName = 'cms/'.$cmsColumnName;
970
-
971
- if($result['success']){
972
- //translated content array
973
- $newCmsData = [];
974
- foreach($collection as $translation){
975
- if(!$translation->getIsImported()){
976
- if(empty($newCmsData[$translation->getData($jobType . '_id')])){
977
- $newCmsData[$translation->getData($jobType . '_id')] = [
978
- $translation->getColumnName() => $translation->getTranslate(),
979
- ];
980
- }else{
981
- $newCmsData[$translation->getData($jobType . '_id')][$translation->getColumnName()] = $translation->getTranslate();
982
- }
983
- }
984
- }
985
986
- //cms old id and new id pairs
987
- $newCmsIds = $result['new_entity_ids'];
988
- foreach($newCmsIds as $oldId => $newId){
989
- $model = Mage::getModel($cmsModelName)->load($newId);
990
- foreach($newCmsData[$oldId] as $k => $v){
991
- $model->setData($k, $v);
992
- }
993
- $model->setStores($this->getStoreId());
994
- $model->save();
995
- $model->unsetData();
996
- }
997
- foreach($collection as $translation){
998
- $entityId = $translation->getData($jobType . '_id');
999
- if(!$translation->getIsImported()){
1000
- $translation->setIsImported(1)->save();
1001
- }
1002
- if( empty($updatedIds[$entityId]) ){
1003
- $updatedIds[$entityId] = true;
1004
- $writeConnection->update($prefix . 'straker_job_' . $cmsTableName, array('version' => 1), $cmsColumnName . "_id = {$entityId} and job_id ={$this->getId()}");
1005
- }
1006
- }
1007
- }else{
1008
- $success = false;
1009
- }
1010
- }else{
1011
- foreach ($collection as $translation) {
1012
- if(!$translation->getVersion()){
1013
- $return = $translation->setStoreId($this->getStoreId())->importTranslation();
1014
- if($return){
1015
- $entityId = call_user_func(array($translation, 'getData'), strtolower(str_replace(' ', '_', $this->getTypeName() . '_id')));
1016
- if (empty($updatedIds[$entityId])) {
1017
- $updatedIds[$entityId] = true;
1018
- $writeConnection->update($prefix . 'straker_job_' . $jobType, array('version' => 1), $jobType . "_id = {$entityId} and job_id ={$this->getId()}");
1019
- }
1020
- }else{
1021
- $success = false;
1022
- }
1023
- }
1024
}
1025
}
1026
- }catch(Exception $e){
1027
- $success = false;
1028
}
1029
-
1030
- return $success;
1031
}
1032
1033
protected function createNewCms($entityIds)
1034
{
1035
- $return = [
1036
- 'success' => true,
1037
- 'new_entity_ids' => []
1038
- ];
1039
- $jobType = $this->_getType();
1040
- $cmsType = str_replace('cms_', '', $jobType);
1041
- $cmsModelName = str_replace('_', '/', $jobType);
1042
-
1043
- $collection = Mage::getModel('strakertranslations_easytranslationplatform/job_' . $jobType)->getCollection();
1044
$collection->addFieldToFilter('job_id', $this->getId());
1045
1046
if ($entityIds) {
@@ -1056,18 +966,10 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
1056
}
1057
//add target store id
1058
// $cmsModel->setStores(array())->save();
1059
- $cmsModel->setStores([$this->getStoreId()]);
1060
- try{
1061
- $cmsModel->save();
1062
- $jobCms->setNewEntityId($cmsModel->getId())->save();
1063
- $return['new_entity_ids'][$jobCms->getData($cmsType . '_id')] = $cmsModel->getId();
1064
- }catch(Exception $e){
1065
- $return['success'] = false;
1066
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage() . 'URL Key: ' . $jobCms->getIdentifier());
1067
- }
1068
}
1069
}
1070
- return $return;
1071
}
1072
1073
public function isPublished()
@@ -1119,9 +1021,6 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
1119
1120
}
1121
1122
- /**
1123
- * @return Varien_Db_Adapter_Interface
1124
- */
1125
protected function getWriteAdapter()
1126
{
1127
return Mage::getSingleton('core/resource')->getConnection('core_write');
@@ -1143,7 +1042,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
1143
$collection->distinct(true)->addFieldToSelect($filter);
1144
$languages = [];
1145
foreach ($collection->getData() as $lang) {
1146
- $languages[] = $lang[$filter];
1147
}
1148
/** @var $helper StrakerTranslations_EasyTranslationPlatform_Model_Api */
1149
$helper = Mage::getModel('strakertranslations_easytranslationplatform/api');
9
class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Model_Abstract
10
{
11
protected $_attributes = array();
12
+
13
protected $_translateFilePath = '/var/straker/';
14
15
protected function _construct()
16
{
17
$this->_init('strakertranslations_easytranslationplatform/job');
18
}
19
20
protected function addProductAttributes($productAttributeIds)
31
32
protected function addProductIds($productIds)
33
{
34
+ $model = Mage::getModel('strakertranslations_easytranslationplatform/job_product');
35
foreach ($productIds as $productId) {
36
+ $model->setProductId($productId);
37
+ $model->setJobId($this->getId());
38
+ $model->save();
39
+ $model->unsetData();
40
}
41
return $this;
42
}
43
44
protected function addProductTranslateOriginal($productAttributeId, $productCollection)
45
{
46
+ $model = Mage::getModel('strakertranslations_easytranslationplatform/product_translate');
47
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($productAttributeId)->getAttributeCode();
48
foreach ($productCollection as $product) {
49
+ $model->setJobId($this->getId());
50
+ $model->setProductId($product->getId());
51
+ $model->setAttributeId($productAttributeId);
52
+ $model->setOriginal($product->getData($productAttributeCode));
53
+ $model->save();
54
+ $model->unsetData();
55
}
56
return $this;
57
}
87
$model = Mage::getModel('strakertranslations_easytranslationplatform/category_translate');
88
$categoryAttributeCode = Mage::getModel('eav/entity_attribute')->load($categoryAttributeId)->getAttributeCode();
89
foreach ($categoryCollection as $category) {
90
+ $model->setJobId($this->getId());
91
+ $model->setCategoryId($category->getId());
92
+ $model->setAttributeId($categoryAttributeId);
93
+ $model->setOriginal($category->getData($categoryAttributeCode));
94
+ $model->save();
95
+ $model->unsetData();
96
}
97
return $this;
98
}
128
break;
129
}
130
}
131
+ $model->setJobId($this->getId());
132
+ $model->setData('cms_'.$type.'_id', $cmsData[$type . '_id']);
133
+ $model->setcolumnName($Column);
134
+ $model->setOriginal($cmsData[$Column]);
135
+ $model->setJobCmsId($jobCmsId);
136
+ $model->save();
137
+ $model->unsetData();
138
}
139
140
return $this;
521
$attributeFrontLabel = array();
522
523
foreach ($productTranslateCollection as $productTranslate) {
524
+ if (!isset($attributeFrontLabel[$productTranslate->getAttributeId()])) {
525
+ $attributeFrontLabel[$productTranslate->getAttributeId()] =
526
+ Mage::getModel('eav/entity_attribute')->load($productTranslate->getAttributeId())->getFrontendLabel();
527
+ }
528
529
+ $dataElement = $_xml->createElement('data');
530
+ $dataElement->setAttribute('name', $this->getTypeId() . '_' . $this->getStoreId() . '_' . $productTranslate->getAttributeId() . '_' . $productTranslate->getProductId());
531
+ $dataElement->setAttribute('content_context', $attributeFrontLabel[$productTranslate->getAttributeId()]);
532
+ $dataElement->setAttribute('content_context_url',Mage::getStoreConfig('web/unsecure/base_link_url', $this->getStoreId()) . 'catalog/category/view/id/' . $productTranslate->getProductId());
533
+ $dataElement->setAttribute('content_id', $productTranslate->getId());
534
535
+ $valueElement = $_xml->createElement('value');
536
+ $CDATAValueNode = $_xml->createCDATASection($productTranslate->getOriginal());
537
+ $valueElement->appendChild($CDATAValueNode);
538
539
+ $dataElement->appendChild($valueElement);
540
+ $rootElement->appendChild($dataElement);
541
}
542
543
$_xml->appendChild($rootElement);
690
691
public function submitProducts($productAttributeIds, $productIds)
692
{
693
+
694
//product
695
$this->setTypeId(1);
696
$this->addProducts($productAttributeIds, $productIds)
730
return $this;
731
}
732
733
+ public function submitCmsblock($cmsIds, $columns = array('title', 'content'))
734
{
735
736
$this->setTypeId(6);
770
if ($this->getJobKey()) {
771
$request = array();
772
$request['job_key'] = $this->getJobKey();
773
$api = $this->_getApi();
774
$response = $api->getTranslation($request);
775
if ($response->job) {
778
$updateFlag = $this->updateJob($job);
779
}
780
}
781
+ $this->setLastStatus(1);
782
}
783
else{
784
$this->setLastStatus(0);
791
}
792
793
public function bulkUpdateTranslation(){
794
$api = $this->_getApi();
795
$response = $api->getTranslation(array());
796
return $response->job ? $response->job : false;
822
foreach ($job->translated_file as $file) {
823
if ($file->download_url && !$this->getDownloadUrl()) {
824
$this->setDownloadUrl($file->download_url)->save();
825
+ $this->_importTranslation();
826
}
827
}
828
return $updateFlag;
841
842
protected function _importTranslation()
843
{
844
+
845
+ $xml = $this->_getApi()->getTranslatedFile($this->getDownloadUrl());
846
+
847
file_put_contents(Mage::getBaseDir() . $this->_translateFilePath . 'translated_job' . $this->getId() . '.xml', $xml, LOCK_EX);
848
+
849
$data = simplexml_load_string($xml);
850
851
+ $_translationValueGroup = array();
852
+
853
+ foreach ($data->children() as $_translation) {
854
+
855
+ $_entityTranslationId = (string)$_translation->attributes()->content_id;
856
+ if ($this->_getType() == 'attribute') {
857
+ if ($_translation->attributes()->content_context == "product attribute title") {
858
+ $_translationValueGroup[$_entityTranslationId]['title'] = (string)$_translation->value;
859
}
860
861
+ if ($_translation->attributes()->content_context == "product attribute option") {
862
+ $_translationValueGroup[$_entityTranslationId]['option']['id_' . $_translation->attributes()->option_id] = (string)$_translation->value;
863
}
864
865
+ } else {
866
+ $_translationValueGroup[$_entityTranslationId] = (string)$_translation->value;
867
+ }
868
+
869
+ }
870
+
871
+ foreach ($_translationValueGroup as $content_id => $_translationValue) {
872
+
873
+ $value = $_translationValue;
874
+
875
+ if (is_array($_translationValue)) {
876
+ $xml = new SimpleXMLElement('<attribute/>');
877
+ $this->array_to_xml($_translationValue, $xml);
878
+ $value = (string)$xml->asXML();
879
}
880
+
881
+
882
+ $_entityTranslation = Mage::getModel('strakertranslations_easytranslationplatform/' . $this->_getType() . '_translate')->load($content_id);
883
+ $_entityTranslation->setTranslate($value);
884
+ $_entityTranslation->save();
885
+ $_entityTranslation->clearInstance();
886
}
887
+
888
+ return $this->setDownloadedVersion(1)->save();
889
+
890
}
891
892
protected function _getType()
913
914
public function applyTranslation($entityIds = array())
915
{
916
+ $collection = Mage::getModel('strakertranslations_easytranslationplatform/' . $this->_getType() . '_translate')->getCollection()->addFieldToFilter('job_id', $this->getId());
917
918
if ($entityIds) {
919
+ $collection->addFieldToFilter($this->_getType() . '_id', array('in' => $entityIds));
920
}
921
922
$updatedIds = array();
923
$writeConnection = $this->getWriteAdapter();
924
925
+ if (in_array($this->_getType(), array('cms_block', 'cms_page'))) {
926
+ $this->createNewCms($entityIds);
927
+ }
928
+
929
+ foreach ($collection as $translation) {
930
+ $translation->setStoreId($this->getStoreId())->importTranslation();
931
+ $entityId = call_user_func(array($translation, 'getData'), strtolower(str_replace(' ', '_', $this->getTypeName() . '_id')));
932
+ if (empty($updatedIds[$entityId])) {
933
+ $updatedIds[$entityId] = true;
934
+ $prefix = Mage::getConfig()->getTablePrefix()->__toString();
935
+ if (in_array($this->_getType(), array('cms_block', 'cms_page'))) {
936
+ $cmstableName = str_replace('_', '', $this->_getType());
937
+ $cmsColumnName = str_replace('cms_', '', $this->_getType());
938
+ $entityId = $translation->getData($this->_getType() . '_id');
939
+ $writeConnection->update($prefix . 'straker_job_' . $cmstableName, array('version' => 1), $cmsColumnName . "_id = {$entityId} and job_id ={$this->getId()}");
940
+ } else {
941
+ $writeConnection->update($prefix . 'straker_job_' . $this->_getType(), array('version' => 1), $this->_getType() . "_id = {$entityId} and job_id ={$this->getId()}");
942
}
943
}
944
}
945
+ return true;
946
}
947
948
protected function createNewCms($entityIds)
949
{
950
+ $cmsType = str_replace('cms_', '', $this->_getType());
951
+ $cmsModelName = str_replace('_', '/', $this->_getType());
952
+
953
+ $collection = Mage::getModel('strakertranslations_easytranslationplatform/job_' . $this->_getType())->getCollection();
954
$collection->addFieldToFilter('job_id', $this->getId());
955
956
if ($entityIds) {
966
}
967
//add target store id
968
// $cmsModel->setStores(array())->save();
969
+ $cmsModel->setStores([$this->getStoreId()])->save();
970
+ $jobCms->setNewEntityId($cmsModel->getId())->save();
971
}
972
}
973
}
974
975
public function isPublished()
1021
1022
}
1023
1024
protected function getWriteAdapter()
1025
{
1026
return Mage::getSingleton('core/resource')->getConnection('core_write');
1042
$collection->distinct(true)->addFieldToSelect($filter);
1043
$languages = [];
1044
foreach ($collection->getData() as $lang) {
1045
+ array_push($languages, $lang[$filter]);
1046
}
1047
/** @var $helper StrakerTranslations_EasyTranslationPlatform_Model_Api */
1048
$helper = Mage::getModel('strakertranslations_easytranslationplatform/api');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Product/Translate.php CHANGED
@@ -14,29 +14,30 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Product_Translate extend
14
}
15
16
public function importTranslation(){
17
- $success = true;
18
- try{
19
- //if translated value is null, skip
20
- $translatedValue = $this->getTranslate();
21
- if (!is_null($translatedValue)){
22
- $product = Mage::getModel('catalog/product')
23
- ->setStoreId($this->getStoreId())
24
- ->load($this->getProductId());
25
- $productAttributeCode = $this->_getAttributeCode($this->getAttributeId());
26
- $this->setBackup($product->getData($productAttributeCode));
27
- $product->setData($productAttributeCode, $translatedValue)
28
- ->getResource()
29
- ->saveAttribute($product, $productAttributeCode);
30
- $this->setIsImported(1)->save();
31
- $product->clearInstance();
32
- }
33
- }catch(Exception $e){
34
- $success = false;
35
}
36
- return $success;
37
}
38
39
protected function _getAttributeCode($attributeId){
40
if (!Mage::registry('attributeCodeCache_'.$attributeId)){
41
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($attributeId)->getAttributeCode();
42
Mage::register('attributeCodeCache_'.$attributeId,$productAttributeCode);
@@ -44,5 +45,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Product_Translate extend
44
$productAttributeCode = Mage::registry('attributeCodeCache_'.$attributeId);
45
}
46
return $productAttributeCode;
47
}
48
}
14
}
15
16
public function importTranslation(){
17
+
18
+ //if translated value is null, skip
19
+ $translatedValue = $this->getTranslate();
20
+ if (is_null($translatedValue)){
21
+ return;
22
}
23
+
24
+ $product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId())->load($this->getProductId());
25
+
26
+ $productAttributeCode = $this->_getAttributeCode($this->getAttributeId());
27
+
28
+ $this->setBackup($product->getData($productAttributeCode));
29
+
30
+ $product->setData($productAttributeCode, $translatedValue)
31
+ ->getResource()
32
+ ->saveAttribute($product, $productAttributeCode);
33
+ $this->setIsImported(1)->save();
34
+
35
+ $product->clearInstance();
36
+
37
}
38
39
protected function _getAttributeCode($attributeId){
40
+
41
if (!Mage::registry('attributeCodeCache_'.$attributeId)){
42
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($attributeId)->getAttributeCode();
43
Mage::register('attributeCodeCache_'.$attributeId,$productAttributeCode);
45
$productAttributeCode = Mage::registry('attributeCodeCache_'.$attributeId);
46
}
47
return $productAttributeCode;
48
+
49
}
50
+
51
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute/Collection.php CHANGED
@@ -13,15 +13,4 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Attribute_C
13
$this->_init('strakertranslations_easytranslationplatform/job_attribute');
14
}
15
16
- public function getAllIds()
17
- {
18
- $idsSelect = clone $this->getSelect();
19
- $idsSelect->reset(Zend_Db_Select::ORDER);
20
- $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
- $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
- $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
-
24
- $idsSelect->columns('attribute_id', 'main_table');
25
- return $this->getConnection()->fetchCol($idsSelect);
26
- }
27
}
13
$this->_init('strakertranslations_easytranslationplatform/job_attribute');
14
}
15
16
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Block/Collection.php CHANGED
@@ -13,16 +13,4 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Block_C
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_block');
14
}
15
16
- public function getAllIds()
17
- {
18
- $idsSelect = clone $this->getSelect();
19
- $idsSelect->reset(Zend_Db_Select::ORDER);
20
- $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
- $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
- $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
-
24
- $idsSelect->columns('block_id', 'main_table');
25
- return $this->getConnection()->fetchCol($idsSelect);
26
- }
27
-
28
}
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_block');
14
}
15
16
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Page/Collection.php CHANGED
@@ -13,16 +13,4 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Page_Co
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_page');
14
}
15
16
- public function getAllIds()
17
- {
18
- $idsSelect = clone $this->getSelect();
19
- $idsSelect->reset(Zend_Db_Select::ORDER);
20
- $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
- $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
- $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
-
24
- $idsSelect->columns('page_id', 'main_table');
25
- return $this->getConnection()->fetchCol($idsSelect);
26
- }
27
-
28
}
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_page');
14
}
15
16
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/AttributeController.php CHANGED
@@ -61,7 +61,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
61
}
62
}
63
64
- public function addToConfirmAction(){
65
$data = $this->getRequest()->getParams();
66
if(empty($data['attribute']) && empty($data['option'])){
67
$data['attribute'] = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
@@ -87,7 +87,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
87
}
88
}
89
90
- public function submitJobAction(){
91
$data = $this->getRequest()->getParams();
92
if( $data['store'] && isset($data['attribute']) && isset($data['option']) ){
93
$attribute = !empty($data['attribute'])?explode(',', $data['attribute']):array();
@@ -147,7 +147,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
147
}
148
}
149
150
- public function publishAllAction(){
151
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
152
153
if (!$job->getId()){
@@ -168,7 +168,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
168
169
}
170
171
- public function publishAction(){
172
$jobId = $this->getRequest()->getParam('job_id');
173
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
174
@@ -204,8 +204,8 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
204
}
205
206
public function removeFromCartAction(){
207
- $attributeId = $this->getRequest()->getParam('attribute_id');
208
- if(!empty($attributeId)){
209
$attributeId = $this->getRequest()->getParam('attribute_id');
210
}
211
$attributeIds = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
@@ -227,7 +227,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
227
// var_dump($optionIds);
228
// exit;
229
Mage::getSingleton('adminhtml/session')->setData('straker_new_option', implode(',', $optionIds));
230
- $this->_redirect('*/*/addToConfirm');
231
}
232
233
public function gridAction()
61
}
62
}
63
64
+ public function addtoconfirmAction(){
65
$data = $this->getRequest()->getParams();
66
if(empty($data['attribute']) && empty($data['option'])){
67
$data['attribute'] = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
87
}
88
}
89
90
+ public function submitjobAction(){
91
$data = $this->getRequest()->getParams();
92
if( $data['store'] && isset($data['attribute']) && isset($data['option']) ){
93
$attribute = !empty($data['attribute'])?explode(',', $data['attribute']):array();
147
}
148
}
149
150
+ public function copyAllAction(){
151
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
152
153
if (!$job->getId()){
168
169
}
170
171
+ public function applyTranslationAction(){
172
$jobId = $this->getRequest()->getParam('job_id');
173
$job = Mage::getModel('strakertranslations_easytranslationp