Version Notes
Initial Stable release
Download this release
Release Info
Developer | Chris |
Extension | straker-translations-easy-translation-platform |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.2.0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute.php +41 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute/Grid.php +200 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php +12 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category/Grid.php +4 -4
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Grid.php +18 -11
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php +12 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php +4 -4
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute.php +25 -2
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/{Confirm.php → Attribute/Confirm.php} +3 -4
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Confirm/Grid.php +107 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Grid.php +170 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Category/Confirm/Grid.php +4 -3
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Confirm/Grid.php +0 -150
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Confirm/Grid.php +1 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php +40 -15
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/System/Config/Form/Button.php +1 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/System/Config/Form/Store.php +1 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Action.php +1 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeOriginalLabel.php +18 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeOriginalOption.php +19 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeTranslateLabel.php +18 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeTranslateOption.php +19 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateLabel.php +28 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateOptions.php +33 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Selected.php +65 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TranslateOptions.php +17 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Translated.php +14 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Helper/Data.php +11 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Attribute/Translate.php +85 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php +191 -7
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job/Attribute.php +16 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Product/Translate.php +9 -3
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Attribute/Translate.php +16 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Attribute/Translate/Collection.php +16 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job.php +3 -2
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute.php +16 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute/Collection.php +16 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/AttributeController.php +179 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/CategoryController.php +0 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/JobController.php +10 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/NewController.php +5 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/ProductController.php +0 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/adminhtml.xml +5 -1
- app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config.xml +8 -2
- app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system.xml +86 -86
- app/code/community/StrakerTranslations/EasyTranslationPlatform/sql/strakertranslations_easytranslationplatform_setup/mysql4-install-1.0.0.php +17 -23
- app/code/community/StrakerTranslations/EasyTranslationPlatform/sql/strakertranslations_easytranslationplatform_setup/mysql4-upgrade-1.0.0-1.1.0.php +53 -0
- app/code/community/StrakerTranslations/EasyTranslationPlatform/sql/strakertranslations_easytranslationplatform_setup/mysql4-upgrade-1.1.0-1.2.0.php +218 -0
- app/design/adminhtml/default/straker/layout/straker.xml +11 -0
- app/design/adminhtml/default/straker/template/straker/job/attribute.phtml +39 -0
- app/design/adminhtml/default/straker/template/straker/job/attribute/massaction.phtml +87 -0
- app/design/adminhtml/default/straker/template/straker/job/category.phtml +4 -1
- app/design/adminhtml/default/straker/template/straker/job/product.phtml +4 -1
- app/design/adminhtml/default/straker/template/straker/new/attribute.phtml +31 -0
- app/design/adminhtml/default/straker/template/straker/new/attribute/confirm.phtml +42 -0
- app/design/adminhtml/default/straker/template/straker/new/attribute/massaction.phtml +271 -0
- app/design/adminhtml/default/straker/template/straker/new/attributes.phtml +0 -31
- app/design/adminhtml/default/straker/template/straker/new/category/attributes.phtml +8 -5
- app/design/adminhtml/default/straker/template/straker/new/category/confirm.phtml +9 -8
- app/design/adminhtml/default/straker/template/straker/new/category/tree.phtml +18 -6
- app/design/adminhtml/default/straker/template/straker/new/confirm.phtml +6 -5
- app/design/adminhtml/default/straker/template/straker/new/products.phtml +9 -5
- app/design/adminhtml/default/straker/template/straker/new/products/attributes.phtml +7 -5
- app/design/adminhtml/default/straker/template/straker/new/products/confirm.phtml +9 -8
- app/design/adminhtml/default/straker/template/straker/new/register.phtml +2 -2
- app/design/adminhtml/default/straker/template/straker/new/selectstore.phtml +12 -6
- app/design/adminhtml/default/straker/template/straker/new/setupstore.phtml +12 -7
- app/design/adminhtml/default/straker/template/straker/new/type.phtml +11 -2
- js/straker/translations.js +14 -2
- package.xml +4 -4
- skin/adminhtml/default/straker/css/straker.css +14 -1
- skin/adminhtml/default/straker/css/straker.less +19 -1
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute extends Mage_Adminhtml_Block_Widget_Container{
|
3 |
+
|
4 |
+
protected $_job;
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setTemplate('straker/job/attribute.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _prepareLayout()
|
13 |
+
{
|
14 |
+
$jobId = $this->getRequest()->getParam('job_id');
|
15 |
+
$jobStatus = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId)->getStatusId();
|
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 |
+
}
|
23 |
+
|
24 |
+
$this->setChild('grid', $this->getLayout()->createBlock('strakertranslations_easytranslationplatform/adminhtml_job_attribute_grid', 'job_attribute.grid'));
|
25 |
+
$this->getChild('grid')->setStatusId($jobStatus);
|
26 |
+
return parent::_prepareLayout();
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getGridHtml()
|
30 |
+
{
|
31 |
+
return $this->getChildHtml('grid');
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getJob(){
|
35 |
+
if(!$this->_job) {
|
36 |
+
$jobId = $this->getRequest()->getParam('job_id');
|
37 |
+
$this->_job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
|
38 |
+
}
|
39 |
+
return $this->_job;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute/Grid.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('strakerJobAttributeGrid');
|
8 |
+
$this->setSaveParametersInSession(true);
|
9 |
+
}
|
10 |
+
|
11 |
+
protected function _prepareLayout()
|
12 |
+
{
|
13 |
+
$this->setChild('dispute_button',
|
14 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
15 |
+
->setData(array(
|
16 |
+
'label' => Mage::helper('catalog')->__('Feedback'),
|
17 |
+
'onclick' => 'disputeForm.show(\''.$this->getRequest()->getParam('job_id').'\')',
|
18 |
+
'class' => 'feedback'
|
19 |
+
))
|
20 |
+
);
|
21 |
+
|
22 |
+
return parent::_prepareLayout();
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _prepareCollection() {
|
26 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
27 |
+
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
|
28 |
+
|
29 |
+
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_attribute')->getCollection()
|
30 |
+
->addFieldToFilter('main_table.job_id', $job->getId());
|
31 |
+
|
32 |
+
$collection->getSelect()->joinLeft(
|
33 |
+
array('ea' => $prefix.'eav_attribute'),
|
34 |
+
'ea.attribute_id = main_table.attribute_id',
|
35 |
+
array('attribute_code' => 'attribute_code')
|
36 |
+
);
|
37 |
+
$collection->getSelect()->joinLeft(
|
38 |
+
array('translate' => $prefix.'straker_attribute_translate'),
|
39 |
+
'translate.attribute_id = main_table.attribute_id AND translate.job_id = '.$job->getId(),
|
40 |
+
array('original' => 'original', 'translate' => 'translate')
|
41 |
+
);
|
42 |
+
|
43 |
+
|
44 |
+
//echo $collection->getSelect();
|
45 |
+
//die();
|
46 |
+
$this->setCollection($collection);
|
47 |
+
return parent::_prepareCollection();
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _prepareColumns() {
|
51 |
+
$this->addColumn('id', array(
|
52 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
|
53 |
+
'align' => 'right',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'id',
|
56 |
+
));
|
57 |
+
|
58 |
+
$this->addColumn('attribute_id', array(
|
59 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute ID'),
|
60 |
+
'align' => 'left',
|
61 |
+
'index' => 'attribute_id',
|
62 |
+
));
|
63 |
+
|
64 |
+
$this->addColumn('attribute_code', array(
|
65 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
|
66 |
+
'align' => 'left',
|
67 |
+
'index' => 'attribute_code',
|
68 |
+
));
|
69 |
+
|
70 |
+
|
71 |
+
$this->addColumn('label_original', array(
|
72 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Source'),
|
73 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalLabel',
|
74 |
+
'align' => 'center',
|
75 |
+
'index' => false,
|
76 |
+
'sortable'=> false,
|
77 |
+
'filter' => false,
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addColumn('option_original', array(
|
81 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Source'),
|
82 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalOption',
|
83 |
+
'align' => 'center',
|
84 |
+
'index' => false,
|
85 |
+
'sortable'=> false,
|
86 |
+
'filter' => false,
|
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 |
+
));
|
97 |
+
|
98 |
+
$this->addColumn('option_translate', array(
|
99 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Target'),
|
100 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateOption',
|
101 |
+
'align' => 'center',
|
102 |
+
'index' => false,
|
103 |
+
'sortable'=> false,
|
104 |
+
'filter' => false,
|
105 |
+
));
|
106 |
+
|
107 |
+
if ($this->getStatusId() == '4'){
|
108 |
+
$this->addColumn('version', array(
|
109 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
|
110 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
|
111 |
+
'align' => 'center',
|
112 |
+
'index' => false,
|
113 |
+
'filter' => false,
|
114 |
+
));
|
115 |
+
}
|
116 |
+
|
117 |
+
// $this->addColumn('view_backend', array(
|
118 |
+
// 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
|
119 |
+
// 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
|
120 |
+
// 'align' => 'center',
|
121 |
+
// 'index' => false,
|
122 |
+
// 'filter' => false,
|
123 |
+
// ));
|
124 |
+
|
125 |
+
return parent::_prepareColumns();
|
126 |
+
}
|
127 |
+
|
128 |
+
public function getRowUrl($row) {
|
129 |
+
// return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
130 |
+
return '';
|
131 |
+
}
|
132 |
+
|
133 |
+
protected function _prepareMassaction()
|
134 |
+
{
|
135 |
+
if ($this->getStatusId() == '4') {
|
136 |
+
|
137 |
+
$this->setMassactionIdField('attribute_id');
|
138 |
+
$this->getMassactionBlock()->setFormFieldName('attribute');
|
139 |
+
|
140 |
+
$this->getMassactionBlock()->addItem('add', array(
|
141 |
+
'label' => Mage::helper('catalog')->__('Publish Translation'),
|
142 |
+
'url' => $this->getUrl('*/*/applyTranslation'),
|
143 |
+
'selected' => 1
|
144 |
+
));
|
145 |
+
|
146 |
+
$this->getMassactionBlock()->setTemplate('straker/job/attribute/massaction.phtml');
|
147 |
+
|
148 |
+
$hiddenParams = '<input type="hidden" name="job_id" value="' . $this->getRequest()->getParam('job_id') . '" />';
|
149 |
+
$this->getMassactionBlock()->setHiddenParams($hiddenParams);
|
150 |
+
|
151 |
+
|
152 |
+
// Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
|
153 |
+
return $this;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function _prepareMassactionColumn()
|
158 |
+
{
|
159 |
+
if ($this->getStatusId() == '4') {
|
160 |
+
$columnId = 'massaction';
|
161 |
+
$massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
|
162 |
+
->setData(array(
|
163 |
+
'index' => $this->getMassactionIdField(),
|
164 |
+
'use_index' => $this->getMassactionIdField(),
|
165 |
+
'filter_index' => $this->getMassactionIdFilter(),
|
166 |
+
'type' => 'massaction',
|
167 |
+
'name' => $this->getMassactionBlock()->getFormFieldName(),
|
168 |
+
'align' => 'center',
|
169 |
+
'is_system' => true
|
170 |
+
));
|
171 |
+
|
172 |
+
if ($this->getNoFilterMassactionColumn()) {
|
173 |
+
$massactionColumn->setData('filter', false);
|
174 |
+
}
|
175 |
+
|
176 |
+
$massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
|
177 |
+
->setGrid($this)
|
178 |
+
->setId($columnId);
|
179 |
+
|
180 |
+
$oldColumns = $this->_columns;
|
181 |
+
$this->_columns = array();
|
182 |
+
$this->_columns[$columnId] = $massactionColumn;
|
183 |
+
$this->_columns = array_merge($this->_columns, $oldColumns);
|
184 |
+
return $this;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
public function getMainButtonsHtml()
|
189 |
+
{
|
190 |
+
$html = '';
|
191 |
+
if ($this->getStatusId() == '4') {
|
192 |
+
$html .= $this->getChildHtml('dispute_button');
|
193 |
+
}
|
194 |
+
if($this->getFilterVisibility()){
|
195 |
+
$html.= $this->getResetFilterButtonHtml();
|
196 |
+
$html.= $this->getSearchButtonHtml();
|
197 |
+
}
|
198 |
+
return $html;
|
199 |
+
}
|
200 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category extends Mage_Adminhtml_Block_Widget_Container{
|
|
|
|
|
|
|
3 |
public function __construct()
|
4 |
{
|
5 |
parent::__construct();
|
@@ -9,7 +12,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category e
|
|
9 |
protected function _prepareLayout()
|
10 |
{
|
11 |
$jobId = $this->getRequest()->getParam('job_id');
|
12 |
-
$jobStatus =
|
13 |
if ( $jobStatus == '4'){
|
14 |
$this->_addButton('publish', array(
|
15 |
'label' => Mage::helper('catalog')->__('Publish All Translations'),
|
@@ -27,4 +30,12 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category e
|
|
27 |
{
|
28 |
return $this->getChildHtml('grid');
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
1 |
<?php
|
2 |
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category extends Mage_Adminhtml_Block_Widget_Container{
|
3 |
+
|
4 |
+
protected $_job;
|
5 |
+
|
6 |
public function __construct()
|
7 |
{
|
8 |
parent::__construct();
|
12 |
protected function _prepareLayout()
|
13 |
{
|
14 |
$jobId = $this->getRequest()->getParam('job_id');
|
15 |
+
$jobStatus = $this->getJob()->getStatusId();
|
16 |
if ( $jobStatus == '4'){
|
17 |
$this->_addButton('publish', array(
|
18 |
'label' => Mage::helper('catalog')->__('Publish All Translations'),
|
30 |
{
|
31 |
return $this->getChildHtml('grid');
|
32 |
}
|
33 |
+
|
34 |
+
public function getJob(){
|
35 |
+
if(!$this->_job) {
|
36 |
+
$jobId = $this->getRequest()->getParam('job_id');
|
37 |
+
$this->_job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
|
38 |
+
}
|
39 |
+
return $this->_job;
|
40 |
+
}
|
41 |
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category/Grid.php
CHANGED
@@ -24,7 +24,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
|
|
24 |
}
|
25 |
|
26 |
protected function _prepareCollection() {
|
27 |
-
|
28 |
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
|
29 |
$jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/category_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
|
30 |
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_category')->getCollection()->addFieldToFilter('main_table.job_id', $job->getId());
|
@@ -33,7 +33,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
|
|
33 |
foreach($jobAttributes as $jobAttribute){
|
34 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
35 |
$collection->getSelect()->joinLeft(
|
36 |
-
array($attributeCode =>
|
37 |
$attributeCode.'.category_id = main_table.category_id AND '.$attributeCode.'.attribute_id = '.$jobAttribute->getAttributeId(). ' AND '
|
38 |
.$attributeCode.'.job_id = '.$job->getId(),
|
39 |
array($attributeCode.'_original' => 'original', $attributeCode.'_translate' => 'translate')
|
@@ -73,13 +73,13 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
|
|
73 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
74 |
$attrModel = Mage::getModel('eav/entity_attribute')->loadByCode(3, $attributeCode);
|
75 |
$this->addColumn($attributeCode.'_original', array(
|
76 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s
|
77 |
'align' => 'left',
|
78 |
'index' => $attributeCode.'_original',
|
79 |
));
|
80 |
|
81 |
$this->addColumn($attributeCode.'_translate', array(
|
82 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s
|
83 |
'align' => 'left',
|
84 |
'index' => $attributeCode.'_translate',
|
85 |
));
|
24 |
}
|
25 |
|
26 |
protected function _prepareCollection() {
|
27 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
28 |
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
|
29 |
$jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/category_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
|
30 |
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_category')->getCollection()->addFieldToFilter('main_table.job_id', $job->getId());
|
33 |
foreach($jobAttributes as $jobAttribute){
|
34 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
35 |
$collection->getSelect()->joinLeft(
|
36 |
+
array($attributeCode => $prefix.'straker_category_translate'),
|
37 |
$attributeCode.'.category_id = main_table.category_id AND '.$attributeCode.'.attribute_id = '.$jobAttribute->getAttributeId(). ' AND '
|
38 |
.$attributeCode.'.job_id = '.$job->getId(),
|
39 |
array($attributeCode.'_original' => 'original', $attributeCode.'_translate' => 'translate')
|
73 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
74 |
$attrModel = Mage::getModel('eav/entity_attribute')->loadByCode(3, $attributeCode);
|
75 |
$this->addColumn($attributeCode.'_original', array(
|
76 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', $attrModel->getFrontendLabel()),
|
77 |
'align' => 'left',
|
78 |
'index' => $attributeCode.'_original',
|
79 |
));
|
80 |
|
81 |
$this->addColumn($attributeCode.'_translate', array(
|
82 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', $attrModel->getFrontendLabel()),
|
83 |
'align' => 'left',
|
84 |
'index' => $attributeCode.'_translate',
|
85 |
));
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Grid.php
CHANGED
@@ -23,19 +23,19 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Grid exten
|
|
23 |
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job')->getCollection();
|
24 |
|
25 |
$collection->getSelect()->joinLeft(
|
26 |
-
|
27 |
-
|
28 |
'type_name'
|
29 |
);
|
30 |
$collection->getSelect()->joinLeft(
|
31 |
-
|
32 |
-
|
33 |
'status_name'
|
34 |
|
35 |
);
|
36 |
$collection->getSelect()->joinLeft(
|
37 |
-
|
38 |
-
|
39 |
'name'
|
40 |
);
|
41 |
$this->setCollection($collection);
|
@@ -71,26 +71,33 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Grid exten
|
|
71 |
));
|
72 |
|
73 |
$this->addColumn('type_name', array(
|
74 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Type'),
|
75 |
'align' => 'left',
|
76 |
'index' => 'type_name',
|
77 |
));
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
$this->addColumn('name', array(
|
80 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Store'),
|
81 |
'align' => 'left',
|
82 |
'index' => 'name',
|
83 |
-
'filter_index'
|
84 |
));
|
85 |
|
86 |
$this->addColumn('sl', array(
|
87 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Language
|
88 |
'align' => 'left',
|
89 |
'index' => 'sl',
|
90 |
));
|
91 |
|
92 |
$this->addColumn('tl', array(
|
93 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Language
|
94 |
'align' => 'left',
|
95 |
'index' => 'tl',
|
96 |
));
|
23 |
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job')->getCollection();
|
24 |
|
25 |
$collection->getSelect()->joinLeft(
|
26 |
+
Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_type'),
|
27 |
+
Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_type').'.type_id = main_table.type_id',
|
28 |
'type_name'
|
29 |
);
|
30 |
$collection->getSelect()->joinLeft(
|
31 |
+
Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_status'),
|
32 |
+
Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_status').'.status_id = main_table.status_id',
|
33 |
'status_name'
|
34 |
|
35 |
);
|
36 |
$collection->getSelect()->joinLeft(
|
37 |
+
Mage::getSingleton('core/resource')->getTableName('core/store'),
|
38 |
+
Mage::getSingleton('core/resource')->getTableName('core/store').'.store_id = main_table.store_id',
|
39 |
'name'
|
40 |
);
|
41 |
$this->setCollection($collection);
|
71 |
));
|
72 |
|
73 |
$this->addColumn('type_name', array(
|
74 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Content Type'),
|
75 |
'align' => 'left',
|
76 |
'index' => 'type_name',
|
77 |
));
|
78 |
|
79 |
+
$this->addColumn('selected', array(
|
80 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Content Selected'),
|
81 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Selected',
|
82 |
+
'align' => 'center',
|
83 |
+
'filter' => false,
|
84 |
+
));
|
85 |
+
|
86 |
$this->addColumn('name', array(
|
87 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Store View'),
|
88 |
'align' => 'left',
|
89 |
'index' => 'name',
|
90 |
+
'filter_index' => Mage::getSingleton('core/resource')->getTableName('core/store').'.name',
|
91 |
));
|
92 |
|
93 |
$this->addColumn('sl', array(
|
94 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Source Language'),
|
95 |
'align' => 'left',
|
96 |
'index' => 'sl',
|
97 |
));
|
98 |
|
99 |
$this->addColumn('tl', array(
|
100 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Target Language'),
|
101 |
'align' => 'left',
|
102 |
'index' => 'tl',
|
103 |
));
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product extends Mage_Adminhtml_Block_Widget_Container{
|
|
|
|
|
|
|
3 |
public function __construct()
|
4 |
{
|
5 |
parent::__construct();
|
@@ -9,7 +12,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product ex
|
|
9 |
protected function _prepareLayout()
|
10 |
{
|
11 |
$jobId = $this->getRequest()->getParam('job_id');
|
12 |
-
$jobStatus =
|
13 |
if ( $jobStatus == '4'){
|
14 |
$this->_addButton('publish', array(
|
15 |
'label' => Mage::helper('catalog')->__('Publish All Translations'),
|
@@ -27,4 +30,12 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product ex
|
|
27 |
{
|
28 |
return $this->getChildHtml('grid');
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
1 |
<?php
|
2 |
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product extends Mage_Adminhtml_Block_Widget_Container{
|
3 |
+
|
4 |
+
protected $_job;
|
5 |
+
|
6 |
public function __construct()
|
7 |
{
|
8 |
parent::__construct();
|
12 |
protected function _prepareLayout()
|
13 |
{
|
14 |
$jobId = $this->getRequest()->getParam('job_id');
|
15 |
+
$jobStatus = $this->getJob()->getStatusId();
|
16 |
if ( $jobStatus == '4'){
|
17 |
$this->_addButton('publish', array(
|
18 |
'label' => Mage::helper('catalog')->__('Publish All Translations'),
|
30 |
{
|
31 |
return $this->getChildHtml('grid');
|
32 |
}
|
33 |
+
|
34 |
+
public function getJob(){
|
35 |
+
if(!$this->_job) {
|
36 |
+
$jobId = $this->getRequest()->getParam('job_id');
|
37 |
+
$this->_job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
|
38 |
+
}
|
39 |
+
return $this->_job;
|
40 |
+
}
|
41 |
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php
CHANGED
@@ -24,7 +24,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
|
|
24 |
}
|
25 |
|
26 |
protected function _prepareCollection() {
|
27 |
-
|
28 |
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
|
29 |
$jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/product_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
|
30 |
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_product')->getCollection()->addFieldToFilter('main_table.job_id', $job->getId());
|
@@ -33,7 +33,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
|
|
33 |
foreach($jobAttributes as $jobAttribute){
|
34 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
35 |
$collection->getSelect()->joinLeft(
|
36 |
-
array($attributeCode =>
|
37 |
$attributeCode.'.product_id = main_table.product_id AND '.$attributeCode.'.attribute_id = '.$jobAttribute->getAttributeId(). ' AND '
|
38 |
.$attributeCode.'.job_id = '.$job->getId(),
|
39 |
array($attributeCode.'_original' => 'original', $attributeCode.'_translate' => 'translate')
|
@@ -73,13 +73,13 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
|
|
73 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
74 |
$attrModel = Mage::getModel('eav/entity_attribute')->loadByCode(4, $attributeCode);
|
75 |
$this->addColumn($attributeCode.'_original', array(
|
76 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s
|
77 |
'align' => 'left',
|
78 |
'index' => $attributeCode.'_original',
|
79 |
));
|
80 |
|
81 |
$this->addColumn($attributeCode.'_translate', array(
|
82 |
-
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s
|
83 |
'align' => 'left',
|
84 |
'index' => $attributeCode.'_translate',
|
85 |
));
|
24 |
}
|
25 |
|
26 |
protected function _prepareCollection() {
|
27 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
28 |
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
|
29 |
$jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/product_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
|
30 |
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_product')->getCollection()->addFieldToFilter('main_table.job_id', $job->getId());
|
33 |
foreach($jobAttributes as $jobAttribute){
|
34 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
35 |
$collection->getSelect()->joinLeft(
|
36 |
+
array($attributeCode => $prefix.'straker_product_translate'),
|
37 |
$attributeCode.'.product_id = main_table.product_id AND '.$attributeCode.'.attribute_id = '.$jobAttribute->getAttributeId(). ' AND '
|
38 |
.$attributeCode.'.job_id = '.$job->getId(),
|
39 |
array($attributeCode.'_original' => 'original', $attributeCode.'_translate' => 'translate')
|
73 |
$attributeCode = Mage::getModel('eav/entity_attribute')->load($jobAttribute->getAttributeId())->getAttributeCode();
|
74 |
$attrModel = Mage::getModel('eav/entity_attribute')->loadByCode(4, $attributeCode);
|
75 |
$this->addColumn($attributeCode.'_original', array(
|
76 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', $attrModel->getFrontendLabel()),
|
77 |
'align' => 'left',
|
78 |
'index' => $attributeCode.'_original',
|
79 |
));
|
80 |
|
81 |
$this->addColumn($attributeCode.'_translate', array(
|
82 |
+
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', $attrModel->getFrontendLabel()),
|
83 |
'align' => 'left',
|
84 |
'index' => $attributeCode.'_translate',
|
85 |
));
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute.php
CHANGED
@@ -1,6 +1,29 @@
|
|
1 |
<?php
|
2 |
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute extends Mage_Adminhtml_Block_Widget_Container{
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
}
|
6 |
}
|
1 |
<?php
|
2 |
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute extends Mage_Adminhtml_Block_Widget_Container{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Set template
|
6 |
+
*/
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
parent::__construct();
|
10 |
+
$this->setTemplate('straker/new/attribute.phtml');
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _prepareLayout()
|
14 |
+
{
|
15 |
+
$this->setChild('grid', $this->getLayout()->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_attribute_grid', 'attribute.grid', array('setup_store_id' => $this->getSetupStoreId() )));
|
16 |
+
return parent::_prepareLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Render grid
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getGridHtml()
|
26 |
+
{
|
27 |
+
return $this->getChildHtml('grid');
|
28 |
}
|
29 |
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/{Confirm.php → Attribute/Confirm.php}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class
|
3 |
{
|
4 |
/**
|
5 |
* Set template
|
@@ -7,7 +7,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Confirm ex
|
|
7 |
public function __construct()
|
8 |
{
|
9 |
parent::__construct();
|
10 |
-
$this->setTemplate('straker/new/confirm.phtml');
|
11 |
}
|
12 |
|
13 |
/**
|
@@ -20,11 +20,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Confirm ex
|
|
20 |
$this->_addButton('submit', array(
|
21 |
'label' => Mage::helper('catalog')->__('Submit'),
|
22 |
'onclick' => "$('submit-new-job-form').submit();",
|
23 |
-
// 'onclick' => "setLocation('{$this->getUrl('*/*/submit')}')",
|
24 |
'class' => 'task'
|
25 |
));
|
26 |
|
27 |
-
$this->setChild('grid', $this->getLayout()->createBlock('strakertranslations_easytranslationplatform/
|
28 |
return parent::_prepareLayout();
|
29 |
}
|
30 |
|
1 |
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_Confirm extends Mage_Adminhtml_Block_Widget_Container
|
3 |
{
|
4 |
/**
|
5 |
* Set template
|
7 |
public function __construct()
|
8 |
{
|
9 |
parent::__construct();
|
10 |
+
$this->setTemplate('straker/new/attribute/confirm.phtml');
|
11 |
}
|
12 |
|
13 |
/**
|
20 |
$this->_addButton('submit', array(
|
21 |
'label' => Mage::helper('catalog')->__('Submit'),
|
22 |
'onclick' => "$('submit-new-job-form').submit();",
|
|
|
23 |
'class' => 'task'
|
24 |
));
|
25 |
|
26 |
+
$this->setChild('grid', $this->getLayout()->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_attribute_confirm_grid', 'product.grid', array('store' => $this->getStore(), 'attribute' => $this->getAttribute(), 'option' => $this->getOption())));
|
27 |
return parent::_prepareLayout();
|
28 |
}
|
29 |
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Confirm/Grid.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_Confirm_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('strakerAttribute');
|
9 |
+
$this->setDefaultSort('attribute_code');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setUseAjax(false);
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareLayout()
|
16 |
+
{
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareColumns()
|
21 |
+
{
|
22 |
+
parent::_prepareColumns();
|
23 |
+
|
24 |
+
|
25 |
+
$this->addColumn('attribute_code', array(
|
26 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
|
27 |
+
'sortable'=>true,
|
28 |
+
'filter' => false,
|
29 |
+
'index'=>'attribute_code'
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addColumn('frontend_label', array(
|
33 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Label'),
|
34 |
+
'sortable'=>true,
|
35 |
+
'filter' => false,
|
36 |
+
'index'=>'frontend_label'
|
37 |
+
));
|
38 |
+
|
39 |
+
$this->addColumn('translate_label', array(
|
40 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Translate Attribute Label'),
|
41 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_ConfirmTranslateLabel',
|
42 |
+
'align' => 'center',
|
43 |
+
'index' => false,
|
44 |
+
'sortable'=> false,
|
45 |
+
'filter' => false,
|
46 |
+
));
|
47 |
+
|
48 |
+
$this->addColumn('translate_options', array(
|
49 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Translate Attribute Options'),
|
50 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_ConfirmTranslateOptions',
|
51 |
+
'align' => 'center',
|
52 |
+
'index' => false,
|
53 |
+
'sortable'=> false,
|
54 |
+
'filter' => false,
|
55 |
+
));
|
56 |
+
|
57 |
+
$this->addColumn('is_visible', array(
|
58 |
+
'header'=>Mage::helper('catalog')->__('Visible'),
|
59 |
+
'sortable'=>true,
|
60 |
+
'index'=>'is_visible_on_front',
|
61 |
+
'type' => 'options',
|
62 |
+
'filter' => false,
|
63 |
+
'options' => array(
|
64 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
65 |
+
'0' => Mage::helper('catalog')->__('No'),
|
66 |
+
),
|
67 |
+
'align' => 'center',
|
68 |
+
));
|
69 |
+
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
protected function _prepareCollection()
|
74 |
+
{
|
75 |
+
if ($this->getOption()) {
|
76 |
+
$attributeIds = array_unique(
|
77 |
+
array_merge(
|
78 |
+
$this->getAttribute(),
|
79 |
+
explode(',', $this->getOption())
|
80 |
+
)
|
81 |
+
);
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
$attributeIds = $this->getAttribute();
|
85 |
+
}
|
86 |
+
$collection = Mage::getResourceModel('catalog/product_attribute_collection')
|
87 |
+
->addFieldToFilter('main_table.attribute_id', $attributeIds)
|
88 |
+
->addVisibleFilter();
|
89 |
+
$this->setCollection($collection);
|
90 |
+
|
91 |
+
return parent::_prepareCollection();
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getGridUrl()
|
95 |
+
{
|
96 |
+
return $this->getUrl('*/*/addtoconfirm', array('_current'=>true));
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getRowUrl($row)
|
100 |
+
{
|
101 |
+
return '';
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getAttrArray(){
|
105 |
+
return explode(',', $this->getAttr());
|
106 |
+
}
|
107 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Grid.php
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('attributeGrid');
|
8 |
+
$this->setDefaultSort('attribute_code');
|
9 |
+
$this->setDefaultDir('ASC');
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _getStore()
|
13 |
+
{
|
14 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
15 |
+
return Mage::app()->getStore($storeId);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Prepare product attributes grid collection object
|
20 |
+
*
|
21 |
+
* @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid
|
22 |
+
*/
|
23 |
+
protected function _prepareCollection()
|
24 |
+
{
|
25 |
+
$collection = Mage::getResourceModel('catalog/product_attribute_collection')
|
26 |
+
->addVisibleFilter();
|
27 |
+
|
28 |
+
$store = $this->_getStore();
|
29 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
30 |
+
$jobAttributeQuery = 'select a.`version`, a.`attribute_id` from `'.$prefix.'straker_job_attribute` as a
|
31 |
+
left join `'.$prefix.'straker_job` as b on a.`job_id`=b.`id`
|
32 |
+
where b.`store_id` ='.$store->getId().' and a.`version` =1
|
33 |
+
GROUP BY a.`attribute_id`';
|
34 |
+
|
35 |
+
//join straker job product table to get version for each product
|
36 |
+
$collection->getSelect()->joinLeft(
|
37 |
+
|
38 |
+
new Zend_Db_Expr('('.$jobAttributeQuery.')'),
|
39 |
+
'main_table.attribute_id = t.attribute_id',
|
40 |
+
array('version')
|
41 |
+
|
42 |
+
);
|
43 |
+
$this->setCollection($collection);
|
44 |
+
|
45 |
+
return parent::_prepareCollection();
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Prepare product attributes grid columns
|
51 |
+
*
|
52 |
+
* @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid
|
53 |
+
*/
|
54 |
+
protected function _prepareColumns()
|
55 |
+
{
|
56 |
+
parent::_prepareColumns();
|
57 |
+
|
58 |
+
|
59 |
+
$this->addColumn('attribute_code', array(
|
60 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
|
61 |
+
'sortable'=>true,
|
62 |
+
'index'=>'attribute_code',
|
63 |
+
'filter' => false
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('frontend_label', array(
|
67 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Label'),
|
68 |
+
'sortable'=>true,
|
69 |
+
'index'=>'frontend_label'
|
70 |
+
));
|
71 |
+
|
72 |
+
$this->addColumn('translate_options', array(
|
73 |
+
'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Translate Attribute Options'),
|
74 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TranslateOptions',
|
75 |
+
'align' => 'center',
|
76 |
+
'index' => false,
|
77 |
+
'sortable'=> false,
|
78 |
+
'filter' => false,
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('is_visible', array(
|
82 |
+
'header'=>Mage::helper('catalog')->__('Visible'),
|
83 |
+
'sortable'=>true,
|
84 |
+
'index'=>'is_visible_on_front',
|
85 |
+
'type' => 'options',
|
86 |
+
'options' => array(
|
87 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
88 |
+
'0' => Mage::helper('catalog')->__('No'),
|
89 |
+
),
|
90 |
+
'align' => 'center',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('version',
|
94 |
+
array(
|
95 |
+
'header'=> Mage::helper('catalog')->__('Translated'),
|
96 |
+
'width' => '70px',
|
97 |
+
'index' => 'version',
|
98 |
+
'type' => 'options',
|
99 |
+
'options' => array(
|
100 |
+
'Translated' => Mage::helper('catalog')->__('Translated'),
|
101 |
+
'Not Translated' => Mage::helper('catalog')->__('Not Translated')
|
102 |
+
),
|
103 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Translated',
|
104 |
+
'filter_condition_callback' => array($this, '_versionFilter'),
|
105 |
+
));
|
106 |
+
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
|
110 |
+
protected function _versionFilter($collection, $column)
|
111 |
+
{
|
112 |
+
if (!$value = $column->getFilter()->getValue()) {
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
|
116 |
+
if ($value == 'Translated' ){
|
117 |
+
$collection->getSelect()->where('t.version is not null');
|
118 |
+
// print $this->getCollection()->getSelect(); exit;
|
119 |
+
|
120 |
+
} elseif ($value == 'Not Translated'){
|
121 |
+
$collection->getSelect()->where('t.version is null');
|
122 |
+
}
|
123 |
+
|
124 |
+
return $this;
|
125 |
+
}
|
126 |
+
|
127 |
+
protected function _prepareMassaction()
|
128 |
+
{
|
129 |
+
$this->setMassactionIdField('attribute_id');
|
130 |
+
$this->setMassactionIdFilter('main_table.attribute_id');
|
131 |
+
$this->getMassactionBlock()->setFormFieldName('attribute');
|
132 |
+
|
133 |
+
$this->getMassactionBlock()->addItem('add', array(
|
134 |
+
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
|
135 |
+
'url' => $this->getUrl('*/*/addtoconfirm'),
|
136 |
+
'selected' => 1
|
137 |
+
));
|
138 |
+
$this->getMassactionBlock()->setTemplate('straker/new/attribute/massaction.phtml');
|
139 |
+
|
140 |
+
//todo: refine this
|
141 |
+
$hiddenParams = '<input type="hidden" name="store" value="'.$this->getRequest()->getParam('store').'" /><input type="hidden" name="option" value="'.$this->getRequest()->getParam('internal_option').'" />';
|
142 |
+
$this->getMassactionBlock()->setHiddenParams($hiddenParams);
|
143 |
+
|
144 |
+
Mage::dispatchEvent('adminhtml_strakertranslation_new_products_grid_prepare_massaction', array('block' => $this));
|
145 |
+
return $this;
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
public function getAttributesWithOption(){
|
150 |
+
$AttributeIdsWithOption = clone $this->getCollection()->getSelect();
|
151 |
+
$AttributeIdsWithOption->reset(Zend_Db_Select::ORDER);
|
152 |
+
$AttributeIdsWithOption->reset(Zend_Db_Select::LIMIT_COUNT);
|
153 |
+
$AttributeIdsWithOption->reset(Zend_Db_Select::LIMIT_OFFSET);
|
154 |
+
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
|
155 |
+
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
|
156 |
+
$AttributeIdsWithOption->where('frontend_input=?','select');
|
157 |
+
$AttributeIdsWithOption->columns('attribute_id', 'main_table');
|
158 |
+
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($AttributeIdsWithOption);
|
159 |
+
}
|
160 |
+
|
161 |
+
public function getGridUrl()
|
162 |
+
{
|
163 |
+
return $this->getUrl('*/*/new', array('_current'=>true));
|
164 |
+
}
|
165 |
+
|
166 |
+
public function getRowUrl($row)
|
167 |
+
{
|
168 |
+
return '';
|
169 |
+
}
|
170 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Category/Confirm/Grid.php
CHANGED
@@ -34,9 +34,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
|
|
34 |
}
|
35 |
|
36 |
//join straker job product table to get version for each product
|
|
|
37 |
$collection->getSelect()->joinLeft(
|
38 |
-
|
39 |
-
|
40 |
'version'
|
41 |
);
|
42 |
|
@@ -77,7 +78,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
|
|
77 |
if (in_array('name',$this->getAttrArray())) {
|
78 |
$this->addColumn('name',
|
79 |
array(
|
80 |
-
'header' => Mage::helper('catalog')->__('Name to
|
81 |
'index' => 'name',
|
82 |
'filter' => false,
|
83 |
'sortable' => false
|
34 |
}
|
35 |
|
36 |
//join straker job product table to get version for each product
|
37 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
38 |
$collection->getSelect()->joinLeft(
|
39 |
+
$prefix.'straker_job_category',
|
40 |
+
$prefix.'straker_job_category.category_id = e.entity_id',
|
41 |
'version'
|
42 |
);
|
43 |
|
78 |
if (in_array('name',$this->getAttrArray())) {
|
79 |
$this->addColumn('name',
|
80 |
array(
|
81 |
+
'header' => Mage::helper('catalog')->__('Name to Translate'),
|
82 |
'index' => 'name',
|
83 |
'filter' => false,
|
84 |
'sortable' => false
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Confirm/Grid.php
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Confirm_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
|
5 |
-
public function __construct()
|
6 |
-
{
|
7 |
-
parent::__construct();
|
8 |
-
$this->setId('strakerProducts');
|
9 |
-
$this->setDefaultSort('entity_id');
|
10 |
-
$this->setDefaultDir('DESC');
|
11 |
-
$this->setSaveParametersInSession(true);
|
12 |
-
$this->setUseAjax(false);
|
13 |
-
$this->setVarNameFilter('product_filter');
|
14 |
-
}
|
15 |
-
|
16 |
-
protected function _getStore()
|
17 |
-
{
|
18 |
-
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
19 |
-
return Mage::app()->getStore($storeId);
|
20 |
-
}
|
21 |
-
protected function _prepareLayout()
|
22 |
-
{
|
23 |
-
return $this;
|
24 |
-
}
|
25 |
-
protected function _prepareCollection()
|
26 |
-
{
|
27 |
-
$store = $this->_getStore();
|
28 |
-
$collection = Mage::getModel('catalog/product')->getCollection()
|
29 |
-
->addAttributeToSelect('sku')
|
30 |
-
->addAttributeToSelect('name')
|
31 |
-
->addAttributeToSelect('type_id');
|
32 |
-
$collection->addAttributeToFilter('entity_id', array('in' => $this->getProduct()));
|
33 |
-
|
34 |
-
foreach ($this->getAttrArray() as $attr){
|
35 |
-
$collection->addAttributeToSelect($attr);
|
36 |
-
}
|
37 |
-
if ($store->getId()) {
|
38 |
-
//$collection->setStoreId($store->getId());
|
39 |
-
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
40 |
-
$collection->addStoreFilter($store);
|
41 |
-
$collection->joinAttribute(
|
42 |
-
'name',
|
43 |
-
'catalog_product/name',
|
44 |
-
'entity_id',
|
45 |
-
null,
|
46 |
-
'inner',
|
47 |
-
$adminStore
|
48 |
-
);
|
49 |
-
$collection->joinAttribute(
|
50 |
-
'status',
|
51 |
-
'catalog_product/status',
|
52 |
-
'entity_id',
|
53 |
-
null,
|
54 |
-
'inner',
|
55 |
-
$store->getId()
|
56 |
-
);
|
57 |
-
$collection->joinAttribute(
|
58 |
-
'visibility',
|
59 |
-
'catalog_product/visibility',
|
60 |
-
'entity_id',
|
61 |
-
null,
|
62 |
-
'inner',
|
63 |
-
$store->getId()
|
64 |
-
);
|
65 |
-
}
|
66 |
-
else {
|
67 |
-
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
|
68 |
-
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
|
69 |
-
}
|
70 |
-
|
71 |
-
$this->setCollection($collection);
|
72 |
-
|
73 |
-
parent::_prepareCollection();
|
74 |
-
$this->getCollection()->addWebsiteNamesToResult();
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
protected function _addColumnFilterToCollection($column)
|
79 |
-
{
|
80 |
-
if ($this->getCollection()) {
|
81 |
-
if ($column->getId() == 'websites') {
|
82 |
-
$this->getCollection()->joinField('websites',
|
83 |
-
'catalog/product_website',
|
84 |
-
'website_id',
|
85 |
-
'product_id=entity_id',
|
86 |
-
null,
|
87 |
-
'left');
|
88 |
-
}
|
89 |
-
}
|
90 |
-
return parent::_addColumnFilterToCollection($column);
|
91 |
-
}
|
92 |
-
|
93 |
-
protected function _prepareColumns()
|
94 |
-
{
|
95 |
-
|
96 |
-
$this->addColumn('entity_id',
|
97 |
-
array(
|
98 |
-
'header'=> Mage::helper('catalog')->__('ID'),
|
99 |
-
'width' => '50px',
|
100 |
-
'type' => 'number',
|
101 |
-
'index' => 'entity_id',
|
102 |
-
'filter' => false,
|
103 |
-
));
|
104 |
-
|
105 |
-
if (in_array('name',$this->getAttrArray())) {
|
106 |
-
$this->addColumn('name',
|
107 |
-
array(
|
108 |
-
'header' => Mage::helper('catalog')->__('Name to translate'),
|
109 |
-
'index' => 'name',
|
110 |
-
'filter' => false,
|
111 |
-
));
|
112 |
-
}
|
113 |
-
else{
|
114 |
-
$this->addColumn('name',
|
115 |
-
array(
|
116 |
-
'header' => Mage::helper('catalog')->__('Name'),
|
117 |
-
'index' => 'name',
|
118 |
-
'filter' => false,
|
119 |
-
));
|
120 |
-
}
|
121 |
-
|
122 |
-
foreach ($this->getAttrArray() as $attr){
|
123 |
-
if ($attr!='name') {
|
124 |
-
$attrModel = Mage::getModel('eav/entity_attribute')->loadByCode(4, $attr);
|
125 |
-
$this->addColumn($attr,
|
126 |
-
array(
|
127 |
-
'header' => Mage::helper('catalog')->__($attrModel->getFrontendLabel()) .' to Translate',
|
128 |
-
'index' => $attr,
|
129 |
-
'filter' => false,
|
130 |
-
));
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
return parent::_prepareColumns();
|
135 |
-
}
|
136 |
-
|
137 |
-
public function getGridUrl()
|
138 |
-
{
|
139 |
-
return $this->getUrl('*/*/addtoconfirm', array('_current'=>true));
|
140 |
-
}
|
141 |
-
|
142 |
-
public function getRowUrl($row)
|
143 |
-
{
|
144 |
-
return '';
|
145 |
-
}
|
146 |
-
|
147 |
-
public function getAttrArray(){
|
148 |
-
return explode(',', $this->getAttr());
|
149 |
-
}
|
150 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Confirm/Grid.php
CHANGED
@@ -105,7 +105,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_C
|
|
105 |
if (in_array('name',$this->getAttrArray())) {
|
106 |
$this->addColumn('name',
|
107 |
array(
|
108 |
-
'header' => Mage::helper('catalog')->__('Name to
|
109 |
'index' => 'name',
|
110 |
'filter' => false,
|
111 |
));
|
105 |
if (in_array('name',$this->getAttrArray())) {
|
106 |
$this->addColumn('name',
|
107 |
array(
|
108 |
+
'header' => Mage::helper('catalog')->__('Name to Translate'),
|
109 |
'index' => 'name',
|
110 |
'filter' => false,
|
111 |
));
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php
CHANGED
@@ -63,12 +63,19 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
|
|
63 |
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
|
64 |
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
|
65 |
}
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
//join straker job product table to get version for each product
|
68 |
$collection->getSelect()->joinLeft(
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
);
|
73 |
|
74 |
$this->setCollection($collection);
|
@@ -89,15 +96,15 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
|
|
89 |
null,
|
90 |
'left');
|
91 |
}
|
92 |
-
|
93 |
-
if ($column->getId() == 'version') {
|
94 |
-
$this->getCollection()->joinField('version',
|
95 |
-
'straker_job_product',
|
96 |
-
'version',
|
97 |
-
'product_id=entity_id',
|
98 |
-
null,
|
99 |
-
'left');
|
100 |
-
}
|
101 |
|
102 |
}
|
103 |
return parent::_addColumnFilterToCollection($column);
|
@@ -170,9 +177,11 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
|
|
170 |
'index' => 'version',
|
171 |
'type' => 'options',
|
172 |
'options' => array(
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
|
|
176 |
));
|
177 |
|
178 |
if (!Mage::app()->isSingleStoreMode()) {
|
@@ -190,6 +199,22 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
|
|
190 |
return parent::_prepareColumns();
|
191 |
}
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
protected function _prepareMassaction()
|
194 |
{
|
195 |
$this->setMassactionIdField('entity_id');
|
63 |
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
|
64 |
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
|
65 |
}
|
66 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
67 |
+
$jobProductQuery = 'select a.`version`, a.`product_id` from `'.$prefix.'straker_job_product` as a
|
68 |
+
left join `'.$prefix.'straker_job` as b on a.`job_id`=b.`id`
|
69 |
+
where b.`store_id` = '.$store->getId().' and a.`version` =1
|
70 |
+
GROUP BY a.`product_id`';
|
71 |
|
72 |
//join straker job product table to get version for each product
|
73 |
$collection->getSelect()->joinLeft(
|
74 |
+
|
75 |
+
new Zend_Db_Expr('('.$jobProductQuery.')'),
|
76 |
+
'e.entity_id = t.product_id',
|
77 |
+
array('version')
|
78 |
+
|
79 |
);
|
80 |
|
81 |
$this->setCollection($collection);
|
96 |
null,
|
97 |
'left');
|
98 |
}
|
99 |
+
//
|
100 |
+
// if ($column->getId() == 'version') {
|
101 |
+
// $this->getCollection()->joinField('version',
|
102 |
+
// 'straker_job_product',
|
103 |
+
// 'version',
|
104 |
+
// 'product_id=entity_id',
|
105 |
+
// null,
|
106 |
+
// 'left');
|
107 |
+
// }
|
108 |
|
109 |
}
|
110 |
return parent::_addColumnFilterToCollection($column);
|
177 |
'index' => 'version',
|
178 |
'type' => 'options',
|
179 |
'options' => array(
|
180 |
+
'Translated' => Mage::helper('catalog')->__('Translated'),
|
181 |
+
'Not Translated' => Mage::helper('catalog')->__('Not Translated')
|
182 |
+
),
|
183 |
+
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Translated',
|
184 |
+
'filter_condition_callback' => array($this, '_versionFilter'),
|
185 |
));
|
186 |
|
187 |
if (!Mage::app()->isSingleStoreMode()) {
|
199 |
return parent::_prepareColumns();
|
200 |
}
|
201 |
|
202 |
+
protected function _versionFilter($collection, $column)
|
203 |
+
{
|
204 |
+
if (!$value = $column->getFilter()->getValue()) {
|
205 |
+
return $this;
|
206 |
+
}
|
207 |
+
|
208 |
+
if ($value == 'Translated' ){
|
209 |
+
$this->getCollection()->getSelect()->where('t.version is not null');
|
210 |
+
|
211 |
+
} elseif ($value == 'Not Translated'){
|
212 |
+
$this->getCollection()->getSelect()->where('t.version is null');
|
213 |
+
}
|
214 |
+
|
215 |
+
return $this;
|
216 |
+
}
|
217 |
+
|
218 |
protected function _prepareMassaction()
|
219 |
{
|
220 |
$this->setMassactionIdField('entity_id');
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/System/Config/Form/Button.php
CHANGED
@@ -41,7 +41,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_System_Config_
|
|
41 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
42 |
->setData(array(
|
43 |
'id' => 'straker_clear_button',
|
44 |
-
'label' => $this->helper('adminhtml')->__('Clear All Settings'),
|
45 |
'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl('adminhtml/straker_new/clearSettings').'\');'
|
46 |
));
|
47 |
|
41 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
42 |
->setData(array(
|
43 |
'id' => 'straker_clear_button',
|
44 |
+
'label' => $this->helper('adminhtml')->__('Clear All Language Settings'),
|
45 |
'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl('adminhtml/straker_new/clearSettings').'\');'
|
46 |
));
|
47 |
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/System/Config/Form/Store.php
CHANGED
@@ -42,7 +42,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_System_Config_
|
|
42 |
}
|
43 |
else{
|
44 |
|
45 |
-
return '<div class="empty-button">'.$this->__('No settings
|
46 |
}
|
47 |
}
|
48 |
}
|
42 |
}
|
43 |
else{
|
44 |
|
45 |
+
return '<div class="empty-button">'.$this->__('No language settings applied').'</div>';
|
46 |
}
|
47 |
}
|
48 |
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Action.php
CHANGED
@@ -6,7 +6,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
|
|
6 |
{
|
7 |
if (get_class($row) == get_class(Mage::getModel('strakertranslations_easytranslationplatform/job'))) {
|
8 |
|
9 |
-
$buttonText = $row->getStatusId() == 4 ? $this->__('
|
10 |
|
11 |
$out = '<button id="button-update-'.$row->getId().'" style="margin: 5px; display: block;" onclick="event.stopPropagation(); setLocation(\'' . Mage::helper("adminhtml")->getUrl("adminhtml/straker_".strtolower($row->getTypeName()).'/', array('job_id' => $row->getId())) . '\')" title="View" type="button" style="">'.$buttonText.'</button>';
|
12 |
return $out;
|
6 |
{
|
7 |
if (get_class($row) == get_class(Mage::getModel('strakertranslations_easytranslationplatform/job'))) {
|
8 |
|
9 |
+
$buttonText = $row->getStatusId() == 4 ? $this->__('Confirm') : $this->__('View');
|
10 |
|
11 |
$out = '<button id="button-update-'.$row->getId().'" style="margin: 5px; display: block;" onclick="event.stopPropagation(); setLocation(\'' . Mage::helper("adminhtml")->getUrl("adminhtml/straker_".strtolower($row->getTypeName()).'/', array('job_id' => $row->getId())) . '\')" title="View" type="button" style="">'.$buttonText.'</button>';
|
12 |
return $out;
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeOriginalLabel.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalLabel
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
public function render(Varien_Object $row){
|
6 |
+
$original = $this->xml2array(simplexml_load_string($row->getOriginal()));
|
7 |
+
|
8 |
+
return !empty($original['title']) ? $original['title'] : 'N/A';
|
9 |
+
}
|
10 |
+
|
11 |
+
public function xml2array ( $xmlObject, $out = array () )
|
12 |
+
{
|
13 |
+
foreach ( (array) $xmlObject as $index => $node )
|
14 |
+
$out[$index] = ( is_object ( $node ) ) ? $this->xml2array ( $node ) : $node;
|
15 |
+
|
16 |
+
return $out;
|
17 |
+
}
|
18 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeOriginalOption.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalOption
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function render(Varien_Object $row){
|
7 |
+
$original = $this->xml2array(simplexml_load_string($row->getOriginal()));
|
8 |
+
|
9 |
+
return !empty($original['option']) ? implode(', ', $original['option']) : 'N/A';
|
10 |
+
}
|
11 |
+
|
12 |
+
public function xml2array ( $xmlObject, $out = array () )
|
13 |
+
{
|
14 |
+
foreach ( (array) $xmlObject as $index => $node )
|
15 |
+
$out[$index] = ( is_object ( $node ) ) ? $this->xml2array ( $node ) : $node;
|
16 |
+
|
17 |
+
return $out;
|
18 |
+
}
|
19 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeTranslateLabel.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateLabel
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
public function render(Varien_Object $row){
|
6 |
+
$original = $this->xml2array(simplexml_load_string($row->getTranslate()));
|
7 |
+
|
8 |
+
return !empty($original['title']) ? $original['title'] : 'N/A';
|
9 |
+
}
|
10 |
+
|
11 |
+
public function xml2array ( $xmlObject, $out = array () )
|
12 |
+
{
|
13 |
+
foreach ( (array) $xmlObject as $index => $node )
|
14 |
+
$out[$index] = ( is_object ( $node ) ) ? $this->xml2array ( $node ) : $node;
|
15 |
+
|
16 |
+
return $out;
|
17 |
+
}
|
18 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/AttributeTranslateOption.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateOption
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function render(Varien_Object $row){
|
7 |
+
$original = $this->xml2array(simplexml_load_string($row->getTranslate()));
|
8 |
+
|
9 |
+
return !empty($original['option']) ? implode(', ', $original['option']) : 'N/A';
|
10 |
+
}
|
11 |
+
|
12 |
+
public function xml2array ( $xmlObject, $out = array () )
|
13 |
+
{
|
14 |
+
foreach ( (array) $xmlObject as $index => $node )
|
15 |
+
$out[$index] = ( is_object ( $node ) ) ? $this->xml2array ( $node ) : $node;
|
16 |
+
|
17 |
+
return $out;
|
18 |
+
}
|
19 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateLabel.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_ConfirmTranslateLabel
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
protected $_storeId;
|
6 |
+
|
7 |
+
protected $_label;
|
8 |
+
|
9 |
+
public function render(Varien_Object $row){
|
10 |
+
$id = $row->getAttributeId();
|
11 |
+
$html = '<input disabled type="checkbox" name="option" value="' . $id . '" class="checkbox-option"';
|
12 |
+
if (in_array($id, $this->_getLabel())) {
|
13 |
+
$html .= ' checked="checked" >';
|
14 |
+
}
|
15 |
+
else{
|
16 |
+
$html .= ' >';
|
17 |
+
}
|
18 |
+
return $html;
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _getLabel(){
|
22 |
+
if(!$this->_label){
|
23 |
+
$this->_label = $this->getRequest()->getParam('attribute');
|
24 |
+
}
|
25 |
+
return $this->_label;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateOptions.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_ConfirmTranslateOptions
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
protected $_storeId;
|
6 |
+
|
7 |
+
protected $_option;
|
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" >';
|
15 |
+
}
|
16 |
+
else{
|
17 |
+
$html .= ' >';
|
18 |
+
}
|
19 |
+
}
|
20 |
+
else{
|
21 |
+
$html = 'N/A';
|
22 |
+
}
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _getOption(){
|
27 |
+
if(!$this->_option){
|
28 |
+
$this->_option = explode(',' ,$this->getRequest()->getParam('option'));
|
29 |
+
}
|
30 |
+
return $this->_option;
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Selected.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Selected
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
public function render(Varien_Object $row){
|
6 |
+
|
7 |
+
if (get_class($row) == get_class(Mage::getModel('strakertranslations_easytranslationplatform/job') )) {
|
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;
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
|
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/TranslateOptions.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TranslateOptions
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
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{
|
12 |
+
$html = 'N/A';
|
13 |
+
}
|
14 |
+
return $html;
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Translated.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Translated
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
public function render(Varien_Object $row)
|
6 |
+
{
|
7 |
+
if($row->getVersion()){
|
8 |
+
return 'Translated';
|
9 |
+
}
|
10 |
+
else{
|
11 |
+
return 'Not Translated';
|
12 |
+
}
|
13 |
+
}
|
14 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Helper/Data.php
CHANGED
@@ -20,4 +20,15 @@ class StrakerTranslations_EasyTranslationPlatform_Helper_Data extends Mage_Core_
|
|
20 |
$result['to'] = Mage::getStoreConfig('straker/general/to', $storeId);
|
21 |
return ($result['source'] && $result['from'] && $result['to']) ? $result : false;
|
22 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
20 |
$result['to'] = Mage::getStoreConfig('straker/general/to', $storeId);
|
21 |
return ($result['source'] && $result['from'] && $result['to']) ? $result : false;
|
22 |
}
|
23 |
+
|
24 |
+
public function renderNewJobHeading($storeId){
|
25 |
+
$destinationStore = Mage::getModel('core/store')->load($storeId);
|
26 |
+
$destinationText = $destinationStore->getFrontendName().' ('.$destinationStore->getName().')';
|
27 |
+
|
28 |
+
$config = $this->getStoreSetup($storeId);
|
29 |
+
$sourceStore = Mage::getModel('core/store')->load($config['source']);
|
30 |
+
$sourceText = $sourceStore->getFrontendName().' ('.$sourceStore->getName().')';
|
31 |
+
|
32 |
+
return $sourceText . ' > ' . $destinationText;
|
33 |
+
}
|
34 |
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Attribute/Translate.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: WlliamZhao
|
5 |
+
* Date: 18/01/16
|
6 |
+
* Time: 7:41 PM
|
7 |
+
*/
|
8 |
+
class StrakerTranslations_EasyTranslationPlatform_Model_Attribute_Translate extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('strakertranslations_easytranslationplatform/attribute_translate');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function importTranslation(){
|
17 |
+
|
18 |
+
|
19 |
+
if ($this->getTranslate()){
|
20 |
+
|
21 |
+
$dataInJson = json_encode(simplexml_load_string($this->getTranslate()));
|
22 |
+
$data = json_decode($dataInJson,true);
|
23 |
+
|
24 |
+
$writeConnection = $this->_getConnection();
|
25 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
26 |
+
$storeId = (int) $this->getStoreId();
|
27 |
+
|
28 |
+
foreach ($data as $k => $attribute ){
|
29 |
+
if ($k == 'title' && $attribute){
|
30 |
+
|
31 |
+
$attributeId = (int) $this->getAttributeId();
|
32 |
+
|
33 |
+
$writeConnection->query("
|
34 |
+
INSERT INTO `" . $prefix . "eav_attribute_label` ( `attribute_id`, `store_id`, `value`)
|
35 |
+
SELECT {$attributeId}, {$storeId}, '{$attribute}'
|
36 |
+
FROM (select 1) as a
|
37 |
+
WHERE NOT EXISTS(
|
38 |
+
select `attribute_label_id`
|
39 |
+
from `" . $prefix . "eav_attribute_label`
|
40 |
+
where `attribute_id`={$attributeId} and `store_id` ={$storeId});");
|
41 |
+
|
42 |
+
$writeConnection->query("
|
43 |
+
UPDATE `" . $prefix . "eav_attribute_label` SET `value` = '{$attribute}'
|
44 |
+
where `attribute_id`={$attributeId} and `store_id` ={$storeId} limit 1;");
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($k = 'option'){
|
49 |
+
foreach ($attribute as $optionId => $optionValue) {
|
50 |
+
|
51 |
+
$optionId = str_replace('id_', '',$optionId);
|
52 |
+
|
53 |
+
$writeConnection->query("
|
54 |
+
INSERT INTO `" . $prefix . "eav_attribute_option_value` ( `option_id`, `store_id`, `value`)
|
55 |
+
SELECT {$optionId}, {$storeId}, '{$optionValue}'
|
56 |
+
FROM (select 1) as a
|
57 |
+
WHERE NOT EXISTS(
|
58 |
+
select `value_id`
|
59 |
+
from `" . $prefix . "eav_attribute_option_value`
|
60 |
+
where `option_id`={$optionId} and `store_id` ={$storeId});");
|
61 |
+
|
62 |
+
|
63 |
+
$writeConnection->query("
|
64 |
+
UPDATE `" . $prefix . "eav_attribute_option_value` SET `value` = '{$optionValue}'
|
65 |
+
where `option_id`={$optionId} and `store_id` ={$storeId} limit 1;");
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
$this->setIsImported(1)->save();
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
private function _getConnection() {
|
82 |
+
return Mage::getSingleton('core/resource')->getConnection('core_write');
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php
CHANGED
@@ -33,7 +33,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
33 |
|
34 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
35 |
|
36 |
-
$query = 'INSERT INTO
|
37 |
$queryVals = array();
|
38 |
foreach ($productIds as $productId) {
|
39 |
$queryVals[] = '(' . (int) $productId . ', ' . $this->getId() . ')';
|
@@ -50,7 +50,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
50 |
|
51 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
52 |
|
53 |
-
$query = 'INSERT INTO
|
54 |
$queryVals = array();
|
55 |
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($productAttributeId)->getAttributeCode();
|
56 |
foreach ($productCollection as $product) {
|
@@ -79,7 +79,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
79 |
|
80 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
81 |
|
82 |
-
$query = 'INSERT INTO
|
83 |
$queryVals = array();
|
84 |
foreach ($categoryIds as $categoryId) {
|
85 |
$queryVals[] = '(' . (int) $categoryId . ', ' . $this->getId() . ')';
|
@@ -96,7 +96,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
96 |
|
97 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
98 |
|
99 |
-
$query = 'INSERT INTO
|
100 |
$queryVals = array();
|
101 |
$categoryAttributeCode = Mage::getModel('eav/entity_attribute')->load($categoryAttributeId)->getAttributeCode();
|
102 |
foreach ($categoryCollection as $category) {
|
@@ -108,6 +108,87 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
108 |
return $this;
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
public function addProducts($productAttributeIds,$productIds){
|
112 |
|
113 |
if (!$this->getId()){
|
@@ -192,6 +273,23 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
192 |
return $this;
|
193 |
}
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
protected function _createProductTranslateFile() {
|
196 |
|
197 |
$_xml = '<?xml version="1.0" encoding="utf-8"?><root>';
|
@@ -250,10 +348,56 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
250 |
return $this;
|
251 |
}
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
protected function _summitJob(){
|
254 |
|
255 |
$request = array();
|
256 |
|
|
|
|
|
|
|
|
|
|
|
257 |
$request['title'] = $this->getTitle();
|
258 |
$request['sl'] = $this->getSl();
|
259 |
$request['tl'] = $this->getTl();
|
@@ -302,6 +446,16 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
302 |
return $this;
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
public function updateQuote(){
|
306 |
|
307 |
if ($this->getJobKey()){
|
@@ -386,11 +540,40 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
386 |
|
387 |
$data = simplexml_load_string($xml);
|
388 |
|
|
|
|
|
389 |
foreach ($data->children() as $_translation) {
|
390 |
|
391 |
$_entityTranslationId = (string) $_translation->attributes()->content_id;
|
392 |
-
|
393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
$_entityTranslation->save();
|
395 |
$_entityTranslation->clearInstance();
|
396 |
}
|
@@ -437,7 +620,8 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
|
|
437 |
|
438 |
if (!$updatedIds[$entityId]){
|
439 |
$updatedIds[$entityId] = true;
|
440 |
-
$
|
|
|
441 |
}
|
442 |
}
|
443 |
|
33 |
|
34 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
35 |
|
36 |
+
$query = 'INSERT INTO `'.Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_product').'` (`product_id`, `job_id`) VALUES ';
|
37 |
$queryVals = array();
|
38 |
foreach ($productIds as $productId) {
|
39 |
$queryVals[] = '(' . (int) $productId . ', ' . $this->getId() . ')';
|
50 |
|
51 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
52 |
|
53 |
+
$query = 'INSERT INTO `'.Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/product_translate').'` (`job_id`, `product_id`, `attribute_id`, `original`) VALUES ';
|
54 |
$queryVals = array();
|
55 |
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($productAttributeId)->getAttributeCode();
|
56 |
foreach ($productCollection as $product) {
|
79 |
|
80 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
81 |
|
82 |
+
$query = 'INSERT INTO `'.Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_category').'` (`category_id`, `job_id`) VALUES ';
|
83 |
$queryVals = array();
|
84 |
foreach ($categoryIds as $categoryId) {
|
85 |
$queryVals[] = '(' . (int) $categoryId . ', ' . $this->getId() . ')';
|
96 |
|
97 |
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
98 |
|
99 |
+
$query = 'INSERT INTO `'.Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/category_translate').'` (`job_id`, `category_id`, `attribute_id`, `original`) VALUES ';
|
100 |
$queryVals = array();
|
101 |
$categoryAttributeCode = Mage::getModel('eav/entity_attribute')->load($categoryAttributeId)->getAttributeCode();
|
102 |
foreach ($categoryCollection as $category) {
|
108 |
return $this;
|
109 |
}
|
110 |
|
111 |
+
public function array_to_xml( $data, &$xml_data ) {
|
112 |
+
foreach( $data as $key => $value ) {
|
113 |
+
if( is_array($value) ) {
|
114 |
+
if( is_numeric($key) ){
|
115 |
+
$key = 'item'.$key; //dealing with <0/>..<n/> issues
|
116 |
+
}
|
117 |
+
$subnode = $xml_data->addChild($key);
|
118 |
+
$this->array_to_xml($value, $subnode);
|
119 |
+
} else {
|
120 |
+
$xml_data->addChild("$key",htmlspecialchars("$value"));
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
protected function addAttributeTranslateOriginal($attributeData){
|
126 |
+
|
127 |
+
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
128 |
+
|
129 |
+
$query = 'INSERT INTO `'.Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/straker_attribute_translate').'` (`job_id`, `attribute_id`, `original`) VALUES ';
|
130 |
+
$queryVals = array();
|
131 |
+
|
132 |
+
foreach ($attributeData as $attributeId => $translate) {
|
133 |
+
|
134 |
+
$original = array();
|
135 |
+
|
136 |
+
$original['title'] = $translate['label'] ? Mage::getModel('catalog/resource_eav_attribute')->load($attributeId)->getStoreLabel($this->getSourceStore()) : '';
|
137 |
+
|
138 |
+
|
139 |
+
if ($translate['option'] ){
|
140 |
+
$attributeOptioinCollection = Mage::getModel('eav/entity_attribute_option')
|
141 |
+
->getCollection()
|
142 |
+
->setStoreFilter($this->getSourceStore())
|
143 |
+
->setAttributeFilter($attributeId);
|
144 |
+
|
145 |
+
foreach ($attributeOptioinCollection as $attributeOptioin) {
|
146 |
+
$original['option']['id_'.$attributeOptioin->getoptionId()] = $attributeOptioin->getValue();
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
$xml = new SimpleXMLElement('<attribute/>');
|
151 |
+
|
152 |
+
$this->array_to_xml($original, $xml);
|
153 |
+
|
154 |
+
|
155 |
+
$queryVals[] = '(' . $this->getId() . ', ' . $attributeId . ', \'' . addslashes($xml->asXML()). '\')';
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
$writeConnection->query( $query . implode(',', $queryVals));
|
162 |
+
|
163 |
+
return $this;
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
|
171 |
+
|
172 |
+
protected function addAttributeIds($attributeData){
|
173 |
+
|
174 |
+
|
175 |
+
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
176 |
+
|
177 |
+
$query = 'INSERT INTO `'.Mage::getSingleton('core/resource')->getTableName('strakertranslations_easytranslationplatform/job_attribute').'` (`attribute_id`, `translate_lable`, `translate_option`, `job_id` ) VALUES ';
|
178 |
+
$queryVals = array();
|
179 |
+
|
180 |
+
foreach ($attributeData as $attributeId => $translate) {
|
181 |
+
|
182 |
+
$queryVals[] = '(' . (int) $attributeId . ', '. $translate['label'] .', '. $translate['option'] .', '. $this->getId() . ')';
|
183 |
+
}
|
184 |
+
|
185 |
+
$writeConnection->query( $query . implode(',', $queryVals));
|
186 |
+
|
187 |
+
return $this;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
public function addProducts($productAttributeIds,$productIds){
|
193 |
|
194 |
if (!$this->getId()){
|
273 |
return $this;
|
274 |
}
|
275 |
|
276 |
+
public function addAttributes($attributeData){
|
277 |
+
|
278 |
+
if (!$this->getId()){
|
279 |
+
if (!$this->getStoreId()){
|
280 |
+
Mage::throwException('Error: Missing Store Id');
|
281 |
+
}
|
282 |
+
$this->setSourceStore(Mage::getStoreConfig('straker/general/source',$this->getStoreId()));
|
283 |
+
$this->save();
|
284 |
+
}
|
285 |
+
|
286 |
+
$this->addAttributeIds($attributeData);
|
287 |
+
|
288 |
+
$this->addAttributeTranslateOriginal($attributeData);
|
289 |
+
|
290 |
+
return $this;
|
291 |
+
}
|
292 |
+
|
293 |
protected function _createProductTranslateFile() {
|
294 |
|
295 |
$_xml = '<?xml version="1.0" encoding="utf-8"?><root>';
|
348 |
return $this;
|
349 |
}
|
350 |
|
351 |
+
protected function _createAttributeTranslateFile() {
|
352 |
+
|
353 |
+
$_xml = '<?xml version="1.0" encoding="utf-8"?><root>';
|
354 |
+
|
355 |
+
$attributeTranslateCollection = Mage::getModel('strakertranslations_easytranslationplatform/attribute_translate')->getCollection();
|
356 |
+
$attributeTranslateCollection->addFieldToFilter('job_id',$this->getId());
|
357 |
+
|
358 |
+
foreach ($attributeTranslateCollection as $attributeTranslate ){
|
359 |
+
|
360 |
+
$dataInJson = json_encode(simplexml_load_string($attributeTranslate->getOriginal()));
|
361 |
+
$data = json_decode($dataInJson,true);
|
362 |
+
|
363 |
+
foreach ($data as $k => $attribute ){
|
364 |
+
if ($k == 'title' && $attribute){
|
365 |
+
$_xml .= '<data name="' .$this->getTypeId(). '_' . $this->getStoreId().'_'. $attributeTranslate->getAttributeId().'" ' ;
|
366 |
+
$_xml .= 'content_context="product attribute title" ';
|
367 |
+
$_xml .= 'content_id="'. $attributeTranslate->getId() .'">';
|
368 |
+
$_xml .= '<value><![CDATA['.$attribute.']]></value></data>';
|
369 |
+
}
|
370 |
+
|
371 |
+
if ($k = 'option'){
|
372 |
+
foreach ($attribute as $optionId => $optionValue) {
|
373 |
+
$_xml .= '<data name="' .$this->getTypeId(). '_' . $this->getStoreId().'_'. $attributeTranslate->getAttributeId().'" ' ;
|
374 |
+
$_xml .= 'content_context="product attribute option" ';
|
375 |
+
$_xml .= 'option_id="'. $optionId .'" ';
|
376 |
+
$_xml .= 'content_id="'. $attributeTranslate->getId() .'">';
|
377 |
+
$_xml .= '<value><![CDATA['.$optionValue.']]></value></data>';
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
}
|
384 |
+
$_xml .='</root>';
|
385 |
+
|
386 |
+
file_put_contents(Mage::getBaseDir().$this->_translateFilePath.'job'.$this->getId().'.xml',$_xml);
|
387 |
+
$this->setSourceFile('job'.$this->getId().'.xml')->save() ;
|
388 |
+
|
389 |
+
return $this;
|
390 |
+
}
|
391 |
+
|
392 |
protected function _summitJob(){
|
393 |
|
394 |
$request = array();
|
395 |
|
396 |
+
if (!$this->getTitle()){
|
397 |
+
$store = Mage::getModel('core/store')->load($this->getStoreId());
|
398 |
+
$defaultTitle = $store->getFrontendName().'_'.$store->getName().'_'.Mage::getModel('core/date')->timestamp();
|
399 |
+
$this->setTitle($defaultTitle);
|
400 |
+
}
|
401 |
$request['title'] = $this->getTitle();
|
402 |
$request['sl'] = $this->getSl();
|
403 |
$request['tl'] = $this->getTl();
|
446 |
return $this;
|
447 |
}
|
448 |
|
449 |
+
public function submitAttributes($attributeData){
|
450 |
+
|
451 |
+
//category
|
452 |
+
$this->setTypeId(4);
|
453 |
+
$this->addAttributes($attributeData)
|
454 |
+
->_createAttributeTranslateFile()
|
455 |
+
->_summitJob();
|
456 |
+
return $this;
|
457 |
+
}
|
458 |
+
|
459 |
public function updateQuote(){
|
460 |
|
461 |
if ($this->getJobKey()){
|
540 |
|
541 |
$data = simplexml_load_string($xml);
|
542 |
|
543 |
+
$_translationValueGroup = array();
|
544 |
+
|
545 |
foreach ($data->children() as $_translation) {
|
546 |
|
547 |
$_entityTranslationId = (string) $_translation->attributes()->content_id;
|
548 |
+
if ($this->_getType() == 'attribute'){
|
549 |
+
if ($_translation->attributes()->content_context =="product attribute title"){
|
550 |
+
$_translationValueGroup[$_entityTranslationId]['title'] = (string) $_translation->value;
|
551 |
+
}
|
552 |
+
|
553 |
+
if ($_translation->attributes()->content_context =="product attribute option"){
|
554 |
+
$_translationValueGroup[$_entityTranslationId]['option']['id_'. $_translation->attributes()->option_id] = (string) $_translation->value;
|
555 |
+
}
|
556 |
+
|
557 |
+
}
|
558 |
+
else {
|
559 |
+
$_translationValueGroup[$_entityTranslationId] = (string)$_translation->value;
|
560 |
+
}
|
561 |
+
|
562 |
+
}
|
563 |
+
|
564 |
+
foreach ($_translationValueGroup as $content_id => $_translationValue ){
|
565 |
+
|
566 |
+
$value = $_translationValue;
|
567 |
+
|
568 |
+
if (is_array($_translationValue)){
|
569 |
+
$xml = new SimpleXMLElement('<attribute/>');
|
570 |
+
$this->array_to_xml($_translationValue,$xml);
|
571 |
+
$value = (string) $xml->asXML();
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
$_entityTranslation = Mage::getModel('strakertranslations_easytranslationplatform/'.$this->_getType().'_translate')->load($content_id);
|
576 |
+
$_entityTranslation->setTranslate($value);
|
577 |
$_entityTranslation->save();
|
578 |
$_entityTranslation->clearInstance();
|
579 |
}
|
620 |
|
621 |
if (!$updatedIds[$entityId]){
|
622 |
$updatedIds[$entityId] = true;
|
623 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
624 |
+
$writeConnection->update($prefix.'straker_job_'.$this->_getType() ,array('version' => 1), $this->_getType()."_id = {$entityId} and job_id ={$this->getId()}" );
|
625 |
}
|
626 |
}
|
627 |
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job/Attribute.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: WlliamZhao
|
5 |
+
* Date: 18/01/16
|
6 |
+
* Time: 7:39 PM
|
7 |
+
*/
|
8 |
+
class StrakerTranslations_EasyTranslationPlatform_Model_Job_Attribute extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('strakertranslations_easytranslationplatform/job_attribute');
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Product/Translate.php
CHANGED
@@ -15,15 +15,21 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Product_Translate extend
|
|
15 |
|
16 |
public function importTranslation(){
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId())->load($this->getProductId());
|
19 |
|
20 |
$productAttributeCode = $this->_getAttributeCode($this->getAttributeId());
|
21 |
|
22 |
$this->setBackup($product->getData($productAttributeCode));
|
23 |
|
24 |
-
$product->setData($productAttributeCode, $
|
25 |
-
|
26 |
-
|
27 |
$this->setIsImported(1)->save();
|
28 |
|
29 |
$product->clearInstance();
|
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();
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Attribute/Translate.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: WlliamZhao
|
5 |
+
* Date: 18/01/16
|
6 |
+
* Time: 7:41 PM
|
7 |
+
*/
|
8 |
+
class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Attribute_Translate extends Mage_Core_Model_Resource_Db_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('strakertranslations_easytranslationplatform/straker_attribute_translate', 'id');
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Attribute/Translate/Collection.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: WlliamZhao
|
5 |
+
* Date: 18/01/16
|
6 |
+
* Time: 7:41 PM
|
7 |
+
*/
|
8 |
+
class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Attribute_Translate_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('strakertranslations_easytranslationplatform/attribute_translate');
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job.php
CHANGED
@@ -13,13 +13,14 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job extends Mag
|
|
13 |
}
|
14 |
|
15 |
protected function _getLoadSelect($field, $value, $object) {
|
|
|
16 |
$select = parent::_getLoadSelect($field, $value, $object)
|
17 |
->join(array('t' => $this->getTable('strakertranslations_easytranslationplatform/job_type')),
|
18 |
-
|
19 |
array('type_name')
|
20 |
)
|
21 |
->join(array('s' => $this->getTable('strakertranslations_easytranslationplatform/job_status')),
|
22 |
-
|
23 |
array('status_name')
|
24 |
);
|
25 |
|
13 |
}
|
14 |
|
15 |
protected function _getLoadSelect($field, $value, $object) {
|
16 |
+
$prefix = Mage::getConfig()->getTablePrefix()->__toString();
|
17 |
$select = parent::_getLoadSelect($field, $value, $object)
|
18 |
->join(array('t' => $this->getTable('strakertranslations_easytranslationplatform/job_type')),
|
19 |
+
$prefix.'straker_job.type_id=t.type_id',
|
20 |
array('type_name')
|
21 |
)
|
22 |
->join(array('s' => $this->getTable('strakertranslations_easytranslationplatform/job_status')),
|
23 |
+
$prefix.'straker_job.status_id=s.status_id',
|
24 |
array('status_name')
|
25 |
);
|
26 |
|
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: WlliamZhao
|
5 |
+
* Date: 18/01/16
|
6 |
+
* Time: 7:39 PM
|
7 |