MTurbo - Version 1.2.7

Version Notes

Visit product homepage at:
http://www.artio.net/magento-extensions/m-turbo-accelerator

Download this release

Release Info

Developer Magento Core Team
Extension MTurbo
Version 1.2.7
Comparing to
See all releases


Code changes from version 1.2.6 to 1.2.7

Files changed (37) hide show
  1. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Dynamic.php +8 -2
  2. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Main.php +75 -38
  3. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Product.php +6 -5
  4. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Url.php +34 -35
  5. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Website.php +4 -4
  6. app/code/local/Artio/MTurbo/Block/Adminhtml/Run.php +55 -67
  7. app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php +27 -27
  8. app/code/local/Artio/MTurbo/Block/Ajax.php +2 -2
  9. app/code/local/Artio/MTurbo/Helper/Data.php +34 -34
  10. app/code/local/Artio/MTurbo/Helper/Info.php +4 -0
  11. app/code/local/Artio/MTurbo/Helper/Urlparams.php +59 -30
  12. app/code/local/Artio/MTurbo/Model/Config.php +129 -95
  13. app/code/local/Artio/MTurbo/Model/Config/DynamicTransformer.php +31 -22
  14. app/code/local/Artio/MTurbo/Model/DownloadMethods/Abstract.php +44 -10
  15. app/code/local/Artio/MTurbo/Model/DownloadMethods/Curl.php +56 -29
  16. app/code/local/Artio/MTurbo/Model/DownloadMethods/Curlmulti.php +169 -0
  17. app/code/local/Artio/MTurbo/Model/DownloadMethods/Direct.php +73 -37
  18. app/code/local/Artio/MTurbo/Model/DownloadMethods/Filegetcontents.php +43 -14
  19. app/code/local/Artio/MTurbo/Model/DownloadMethods/Socket.php +115 -25
  20. app/code/local/Artio/MTurbo/Model/DownloadMethodsFactory.php +1 -1
  21. app/code/local/Artio/MTurbo/Model/DownloadQueue.php +285 -0
  22. app/code/local/Artio/MTurbo/Model/Mturbo.php +292 -98
  23. app/code/local/Artio/MTurbo/Model/Mturbo/Event.php +116 -267
  24. app/code/local/Artio/MTurbo/Model/Mturbo/File.php +56 -149
  25. app/code/local/Artio/MTurbo/Model/Observer.php +310 -299
  26. app/code/local/Artio/MTurbo/Model/htaccess/htaccessstore.txt +2 -2
  27. app/code/local/Artio/MTurbo/Model/scripts/wgetlib.so +1 -1
  28. app/code/local/Artio/MTurbo/Model/scripts/wgettrans.so +0 -1
  29. app/code/local/Artio/MTurbo/controllers/Adminhtml/MturboController.php +270 -232
  30. app/code/local/Artio/MTurbo/controllers/IndexController.php +103 -97
  31. app/code/local/Artio/MTurbo/etc/config.xml +17 -57
  32. app/code/local/Artio/MTurbo/sql/mturbo_setup/mysql4-upgrade-1.2.1-1.2.7.php +65 -0
  33. app/design/adminhtml/default/default/template/mturbo/demo.phtml +1 -1
  34. app/design/adminhtml/default/default/template/mturbo/preview/tree.phtml +150 -1
  35. package.xml +4 -4
  36. skin/frontend/base/default/js/mturbo.js +27 -53
  37. skin/frontend/default/default/js/mturbo.js +27 -53
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Dynamic.php CHANGED
@@ -93,6 +93,12 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Dynamic
93
0 => $this->getMyHelper()->__('No'),
94
1 => $this->getMyHelper()->__ ( 'Yes' ))
95
));
96
97
98
$layoutFieldsetUser = $form->addFieldset('dynamic_block_user', array(
@@ -103,7 +109,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Dynamic
103
$layoutFieldsetUser->addField('userblocks', 'textarea', array(
104
'name' => 'userblocks',
105
'label' => $this->getMyHelper()->__('Layout names of dynamic loaded blocks').':',
106
- 'after_element_html' => '<span><i>'.$this->getMyHelper()->__("Values separated by (',').").'</i></span>'
107
));
108
109
$this->_addJsFixFieldset($form);
@@ -184,7 +190,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Dynamic
184
185
$layoutFieldset->addField ('jsstate'.$i, 'html_element',
186
array (
187
- 'label' => '<b style="font-size:10px">'.str_replace(Mage::getBaseDir().DS.'skin'.DS.'frontend', '', $themePackage->getJsPath()).'</b>',
188
'code' => $html)
189
);
190
93
0 => $this->getMyHelper()->__('No'),
94
1 => $this->getMyHelper()->__ ( 'Yes' ))
95
));
96
+
97
+ $layoutFieldsetDefault->addField('cartlink', 'text', array(
98
+ 'name' => 'cartlink',
99
+ 'label' => $this->getMyHelper()->__('CSS selector for cart link').':',
100
+ 'after_element_html' => '<span><i>'.$this->getMyHelper()->__("Separate the values by comma ','.").'</i></span>'
101
+ ));
102
103
104
$layoutFieldsetUser = $form->addFieldset('dynamic_block_user', array(
109
$layoutFieldsetUser->addField('userblocks', 'textarea', array(
110
'name' => 'userblocks',
111
'label' => $this->getMyHelper()->__('Layout names of dynamic loaded blocks').':',
112
+ 'after_element_html' => '<span><i>'.$this->getMyHelper()->__("Separate the block identifiers by comma ','. Separate a layout handle from a layout name by '#x27;. (Ex.: block,catalog_category_default\$other_block)").'</i></span>'
113
));
114
115
$this->_addJsFixFieldset($form);
190
191
$layoutFieldset->addField ('jsstate'.$i, 'html_element',
192
array (
193
+ 'label' => str_replace(Mage::getBaseDir().DS.'skin'.DS.'frontend', '', $themePackage->getJsPath()),
194
'code' => $html)
195
);
196
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Main.php CHANGED
@@ -20,7 +20,7 @@
20
*/
21
22
/**
23
- * Configuration tab contains turbopath settings, download method chooser,
24
* automatic downloader settings (only full version), filesize viewing settings and
25
* backup of htaccess settings.
26
*
@@ -30,19 +30,19 @@
30
*/
31
class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
32
{
33
-
34
/**
35
* Form on this tab.
36
* @var Varien_Data_Form
37
*/
38
private $form;
39
-
40
/**
41
* Constructor. Id of this section is 'main_section'.
42
*/
43
- public function __construct() {
44
parent::__construct();
45
-
46
$this->setId('main_section');
47
$this->_title = $this->getMyHelper()->__('Main Configuration');
48
}
@@ -63,39 +63,68 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Admi
63
$this->setForm($this->form);
64
65
return parent::_prepareForm();
66
-
67
}
68
-
69
/**
70
* Fieldset for turbo path.
71
*/
72
private function _addTurboPathFieldset() {
73
-
74
/* make fieldset */
75
$layoutFieldset = $this->form->addFieldset('turbopath_fieldset', array(
76
'legend' => $this->getMyHelper()->__('Turbopath directory'),
77
'class' => 'fieldset'));
78
-
79
/* add field for turbopath */
80
$layoutFieldset->addField('turbopath', 'text', array(
81
'name' => 'turbopath',
82
'label' => $this->getMyHelper()->__('Relative path from webroot').':',
83
'value' => 'var'.DS.'turbocache'));
84
-
85
}
86
-
87
/**
88
* Fieldset for automatic downloader settings.
89
*/
90
private function _addAutomaticDownloadFieldset() {
91
-
92
/* make fieldset */
93
$layoutFieldset = $this->form->addFieldset('download_fieldset', array(
94
'legend' => $this->getMyHelper()->__('Automatic cache management'),
95
'class' => 'fieldset'));
96
-
97
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
98
-
99
/* indicator whether automatic download is enabled */
100
$layoutFieldset->addField('automatic_download', 'select', array(
101
'name' => 'automatic_download',
@@ -103,30 +132,30 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Admi
103
'options' => array(
104
0 => $this->getMyHelper()->__('No'),
105
1 => $this->getMyHelper()->__ ( 'Yes' ))));
106
-
107
/* automatic download time */
108
$layoutFieldset->addType ( 'crontime', Artio_MTurbo_Helper_Data::FORM_CRON_HOUR_TIME );
109
$layoutFieldset->addField ( 'automatic_download_time', 'crontime', array ('name' => 'automatic_download_time', 'label' => $this->getMyHelper ()->__ ( 'Download time' ) . ':', 'style' => 'display:inline;width:40px;' ) );
110
-
111
/* label with last download */
112
$layoutFieldset->addField ( 'lastdownload', 'label', array ('name' => 'lastdownload', 'label' => $this->getMyHelper ()->__ ( 'Last download' ) . ':', 'style' => 'height:24em;', 'disabled' => true ) );
113
-
114
$scriptPath = Mage::helper('mturbo')->getFullDownloadScriptPath();
115
if (!is_executable($scriptPath)) {
116
- $layoutFieldset->addField ( 'scriptstate', 'html_element',
117
array ('label' => '<h4>'.$this->getMyHelper()->__('Script state').'</h4>',
118
'code' => '<span style="color:red">'.Mage::helper('mturbo')->__("Script '%s' is not executable. Please change permission", $scriptPath).'</span>'));
119
}
120
-
121
}
122
-
123
- /**
124
- * Fieldset for choose download method.
125
*/
126
private function _addDownloadMethodFieldset() {
127
-
128
/* make fieldset */
129
- $layoutFieldset = $this->form->addFieldset ( 'downloadmethod_fieldset', array ('legend' => $this->getMyHelper ()->__ ( 'Choice download method' ), 'class' => 'fieldset' ) );
130
131
/* select box for choose download method */
132
$layoutFieldset->addType ('selectdmet', Artio_MTurbo_Helper_Data::FORM_SELECT_DOWN );
@@ -134,57 +163,65 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Admi
134
'name' => 'download_method',
135
'label' => $this->getMyHelper()->__('Download method').':',
136
'options' => Mage::getModel('mturbo/downloadMethodsFactory')->getList()));
137
-
138
/* button for patch Mage.php */
139
$label = Mage::getModel('mturbo/patch')->isPatched() ?
140
Mage::helper('mturbo')->__('Remove Mage Patch') :
141
Mage::helper('mturbo')->__('Apply Mage Patch');
142
-
143
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
144
$layoutFieldset->addField('patch_button', 'widget_button', array(
145
'name' => 'patch_button',
146
'label' => $label,
147
'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/magepatch') . "')",
148
'comment' => $this->getMyHelper()->__('Apply the patch only just in case you need to use Direct Access download method!')));
149
-
150
}
151
-
152
/**
153
* Add fieldset for settings views on filesize in the grid.
154
*/
155
private function _addViewSizeMethodFieldset() {
156
-
157
/* make fieldset */
158
$layoutFieldset = $this->form->addFieldset ( 'viewsize_fieldset', array ('legend' => $this->getMyHelper ()->__ ( 'Filesize viewing' ), 'class' => 'fieldset' ) );
159
-
160
/* add field for minimal page size */
161
$layoutFieldset->addField('minimal_page_size', 'text', array(
162
'name' => 'minimal_page_size',
163
'label' => $this->getMyHelper()->__('The minimum size to decision, the page is alright (bytes)').':',
164
'value' => '512'));
165
-
166
}
167
-
168
/**
169
- * Add fieldset for htaccess settings.
170
*/
171
private function _addHtaccessFieldset() {
172
-
173
/* make fieldset */
174
$layoutFieldset = $this->form->addFieldset ( 'htaccess_fieldset', array ('legend' => $this->getMyHelper ()->__ ( 'Htaccess backup settings' ), 'class' => 'fieldset' ) );
175
-
176
$layoutFieldset->addField('enabled_htaccess_backup', 'select', array(
177
'name' => 'enabled_htaccess_backup',
178
'label' => $this->getMyHelper()->__('Enable making htaccess backup').':',
179
'options' => array(
180
0 => $this->getMyHelper()->__('No'),
181
1 => $this->getMyHelper()->__ ( 'Yes' ))));
182
-
183
$layoutFieldset->addField('number_of_htaccess_backups', 'text', array(
184
'name' => 'number_of_htaccess_backups',
185
'label' => $this->getMyHelper()->__('The maximum number of htaccess backups').':',
186
'value' => '10'));
187
-
188
}
189
-
190
}
20
*/
21
22
/**
23
+ * Configuration tab contains turbopath settings, download method chooser,
24
* automatic downloader settings (only full version), filesize viewing settings and
25
* backup of htaccess settings.
26
*
30
*/
31
class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
32
{
33
+
34
/**
35
* Form on this tab.
36
* @var Varien_Data_Form
37
*/
38
private $form;
39
+
40
/**
41
* Constructor. Id of this section is 'main_section'.
42
*/
43
+ public function __construct() {
44
parent::__construct();
45
+
46
$this->setId('main_section');
47
$this->_title = $this->getMyHelper()->__('Main Configuration');
48
}
63
$this->setForm($this->form);
64
65
return parent::_prepareForm();
66
}
67
+
68
+ protected function _toHtml() {
69
+
70
+ $html = parent::_toHtml();
71
+
72
+ $parallel = 'curlmulti';
73
+
74
+ $html .= "<script type=\"text/javascript\">\n";
75
+ $html .= "//<![CDATA[\n";
76
+ $html .= "function checkDownloadMethod(value) {\n";
77
+ $html .= " var batchRow = $('download_batch_size').up().up();\n";
78
+ $html .= " if (!batchRow) return;\n";
79
+ $html .= " if (value == '".$parallel."'){\n";
80
+ $html .= " batchRow.style.display = 'table-row';\n";
81
+ $html .= " } else {\n";
82
+ $html .= " batchRow.style.display = 'none';\n";
83
+ $html .= " }\n";
84
+ $html .= "}\n";
85
+ $html .= "document.observe('dom:loaded', function() {\n";
86
+ $html .= " var select = $('download_method');\n";
87
+ $html .= " select.observe('change', function(event) {\n";
88
+ $html .= " checkDownloadMethod(select.value);\n";
89
+ $html .= " })\n";
90
+ $html .= " checkDownloadMethod(select.value);\n";
91
+ $html .= "});\n";
92
+ $html .= "//]]>\n";
93
+ $html .= "</script>";
94
+
95
+ return $html;
96
+ }
97
+
98
/**
99
* Fieldset for turbo path.
100
*/
101
private function _addTurboPathFieldset() {
102
+
103
/* make fieldset */
104
$layoutFieldset = $this->form->addFieldset('turbopath_fieldset', array(
105
'legend' => $this->getMyHelper()->__('Turbopath directory'),
106
'class' => 'fieldset'));
107
+
108
/* add field for turbopath */
109
$layoutFieldset->addField('turbopath', 'text', array(
110
'name' => 'turbopath',
111
'label' => $this->getMyHelper()->__('Relative path from webroot').':',
112
'value' => 'var'.DS.'turbocache'));
113
+
114
}
115
+
116
/**
117
* Fieldset for automatic downloader settings.
118
*/
119
private function _addAutomaticDownloadFieldset() {
120
+
121
/* make fieldset */
122
$layoutFieldset = $this->form->addFieldset('download_fieldset', array(
123
'legend' => $this->getMyHelper()->__('Automatic cache management'),
124
'class' => 'fieldset'));
125
+
126
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
127
+
128
/* indicator whether automatic download is enabled */
129
$layoutFieldset->addField('automatic_download', 'select', array(
130
'name' => 'automatic_download',
132
'options' => array(
133
0 => $this->getMyHelper()->__('No'),
134
1 => $this->getMyHelper()->__ ( 'Yes' ))));
135
+
136
/* automatic download time */
137
$layoutFieldset->addType ( 'crontime', Artio_MTurbo_Helper_Data::FORM_CRON_HOUR_TIME );
138
$layoutFieldset->addField ( 'automatic_download_time', 'crontime', array ('name' => 'automatic_download_time', 'label' => $this->getMyHelper ()->__ ( 'Download time' ) . ':', 'style' => 'display:inline;width:40px;' ) );
139
+
140
/* label with last download */
141
$layoutFieldset->addField ( 'lastdownload', 'label', array ('name' => 'lastdownload', 'label' => $this->getMyHelper ()->__ ( 'Last download' ) . ':', 'style' => 'height:24em;', 'disabled' => true ) );
142
+
143
$scriptPath = Mage::helper('mturbo')->getFullDownloadScriptPath();
144
if (!is_executable($scriptPath)) {
145
+ $layoutFieldset->addField ( 'scriptstate', 'html_element',
146
array ('label' => '<h4>'.$this->getMyHelper()->__('Script state').'</h4>',
147
'code' => '<span style="color:red">'.Mage::helper('mturbo')->__("Script '%s' is not executable. Please change permission", $scriptPath).'</span>'));
148
}
149
+
150
}
151
+
152
+ /**
153
+ * Fieldset for choose download method.
154
*/
155
private function _addDownloadMethodFieldset() {
156
+
157
/* make fieldset */
158
+ $layoutFieldset = $this->form->addFieldset ( 'downloadmethod_fieldset', array ('legend' => $this->getMyHelper ()->__ ( 'Download method' ), 'class' => 'fieldset' ) );
159
160
/* select box for choose download method */
161
$layoutFieldset->addType ('selectdmet', Artio_MTurbo_Helper_Data::FORM_SELECT_DOWN );
163
'name' => 'download_method',
164
'label' => $this->getMyHelper()->__('Download method').':',
165
'options' => Mage::getModel('mturbo/downloadMethodsFactory')->getList()));
166
+
167
+ $predefinedValues = array(2,3,4,5,6,7,8,9,10,12,15,20,25,30,40,50,60,70,80,90,100);
168
+
169
+ $layoutFieldset->addField('download_batch_size', 'select', array(
170
+ 'name' => 'download_batch_size',
171
+ 'label' => $this->getMyHelper()->__('Batch size').':',
172
+ 'options' => array_combine($predefinedValues, $predefinedValues),
173
+ ));
174
+
175
/* button for patch Mage.php */
176
$label = Mage::getModel('mturbo/patch')->isPatched() ?
177
Mage::helper('mturbo')->__('Remove Mage Patch') :
178
Mage::helper('mturbo')->__('Apply Mage Patch');
179
+
180
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
181
$layoutFieldset->addField('patch_button', 'widget_button', array(
182
'name' => 'patch_button',
183
'label' => $label,
184
'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/magepatch') . "')",
185
'comment' => $this->getMyHelper()->__('Apply the patch only just in case you need to use Direct Access download method!')));
186
+
187
}
188
+
189
/**
190
* Add fieldset for settings views on filesize in the grid.
191
*/
192
private function _addViewSizeMethodFieldset() {
193
+
194
/* make fieldset */
195
$layoutFieldset = $this->form->addFieldset ( 'viewsize_fieldset', array ('legend' => $this->getMyHelper ()->__ ( 'Filesize viewing' ), 'class' => 'fieldset' ) );
196
+
197
/* add field for minimal page size */
198
$layoutFieldset->addField('minimal_page_size', 'text', array(
199
'name' => 'minimal_page_size',
200
'label' => $this->getMyHelper()->__('The minimum size to decision, the page is alright (bytes)').':',
201
'value' => '512'));
202
+
203
}
204
+
205
/**
206
+ * Add fieldset for htaccess settings.
207
*/
208
private function _addHtaccessFieldset() {
209
+
210
/* make fieldset */
211
$layoutFieldset = $this->form->addFieldset ( 'htaccess_fieldset', array ('legend' => $this->getMyHelper ()->__ ( 'Htaccess backup settings' ), 'class' => 'fieldset' ) );
212
+
213
$layoutFieldset->addField('enabled_htaccess_backup', 'select', array(
214
'name' => 'enabled_htaccess_backup',
215
'label' => $this->getMyHelper()->__('Enable making htaccess backup').':',
216
'options' => array(
217
0 => $this->getMyHelper()->__('No'),
218
1 => $this->getMyHelper()->__ ( 'Yes' ))));
219
+
220
$layoutFieldset->addField('number_of_htaccess_backups', 'text', array(
221
'name' => 'number_of_htaccess_backups',
222
'label' => $this->getMyHelper()->__('The maximum number of htaccess backups').':',
223
'value' => '10'));
224
+
225
}
226
+
227
}
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Product.php CHANGED
@@ -25,7 +25,7 @@
25
*/
26
27
/**
28
- *
29
*
30
* @category Artio
31
* @package Artio_MTurbo
@@ -35,14 +35,15 @@
35
class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Product
36
extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
37
{
38
-
39
public function __construct() {
40
parent::__construct();
41
$this->setId('product_section');
42
$this->_title = $this->getMyHelper()->__('Products');
43
}
44
-
45
- protected function _prepareForm() {
46
}
47
48
- }
25
*/
26
27
/**
28
+ *
29
*
30
* @category Artio
31
* @package Artio_MTurbo
35
class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Product
36
extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
37
{
38
+
39
public function __construct() {
40
parent::__construct();
41
$this->setId('product_section');
42
$this->_title = $this->getMyHelper()->__('Products');
43
}
44
+
45
+ protected function _prepareForm() {
46
+ return parent::_prepareForm();
47
}
48
49
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Url.php CHANGED
@@ -25,7 +25,7 @@
25
* @package Artio_MTurbo
26
* @author Artio Magento Team (jiri.chmiel@artio.cz)
27
*/
28
- class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
29
extends Mage_Adminhtml_Block_Widget_Grid
30
implements Mage_Adminhtml_Block_Widget_Tab_Interface
31
{
@@ -39,20 +39,20 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
39
}
40
41
protected function _prepareCollection() {
42
-
43
$collection = Mage::getModel('mturbo/mturbo')->getCollection();
44
$this->setCollection($collection);
45
-
46
return parent::_prepareCollection();
47
-
48
}
49
-
50
protected function _afterLoadCollection() {
51
-
52
foreach ($this->getCollection() as $model) {
53
$model->loadFileInformation();
54
}
55
-
56
}
57
58
protected function _prepareColumns() {
@@ -63,7 +63,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
63
'align' => 'center',
64
'index' => 'mturbo_id',
65
));
66
-
67
$this->addColumn('store_id', array(
68
'header' => $this->__('Store View'),
69
'index' => 'store_id',
@@ -76,7 +76,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
76
'align' =>'left',
77
'index' => 'request_path',
78
));
79
-
80
$this->addColumn('type', array(
81
'header' => Mage::helper('mturbo')->__('Type'),
82
'align' => 'left',
@@ -89,7 +89,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
89
'unknow' => Mage::helper('mturbo')->__('Other')
90
)
91
));
92
-
93
$this->addColumn('exist', array(
94
'header' => Mage::helper('mturbo')->__('Cached'),
95
'align' => 'center',
@@ -103,7 +103,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
103
1 => Mage::helper('mturbo')->__('Cached')
104
)
105
));
106
-
107
$this->addColumn('last_refresh', array(
108
'header' => Mage::helper('mturbo')->__('Last refresh'),
109
'align' =>'left',
@@ -112,7 +112,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
112
'filter' => false,
113
'sortable' => false
114
));
115
-
116
$this->addColumn('size', array(
117
'header' => Mage::helper('mturbo')->__('Size'),
118
'align' => 'left',
@@ -134,7 +134,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
134
1 => Mage::helper('mturbo')->__('Blocked')
135
),
136
));
137
-
138
$this->addColumn('action2',
139
array(
140
'header' => '',
@@ -153,7 +153,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
153
'filter' => false,
154
'sortable' => false,
155
));
156
-
157
158
$this->addColumn('action3',
159
array(
@@ -181,28 +181,28 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
181
$this->setMassactionIdField('mturbo_id');
182
$this->getMassactionBlock()->setTemplate('mturbo/massaction.phtml');
183
$this->getMassactionBlock()->setFormFieldName('mturbo');
184
-
185
186
$this->getMassactionBlock()->addItem('block', array(
187
'label' => Mage::helper('mturbo')->__('Block'),
188
'url' => $this->getUrl('*/*/massBlock')
189
));
190
-
191
$this->getMassactionBlock()->addItem('unblock', array(
192
'label' => Mage::helper('mturbo')->__('Unblock'),
193
'url' => $this->getUrl('*/*/massUnblock')
194
));
195
-
196
/*$this->getMassactionBlock()->addItem('refresh', array(
197
'label' => Mage::helper('mturbo')->__('Cache'),
198
'url' => $this->getUrl('*//**//*massRefresh')
199
));*/
200
-
201
$this->getMassactionBlock()->addItem('purge', array(
202
'label' => Mage::helper('mturbo')->__('Purge from disk'),
203
'url' => $this->getUrl('*/*/massPurge')
204
));
205
-
206
$this->getMassactionBlock()->addItem('delete', array(
207
'label' => Mage::helper('mturbo')->__('Delete'),
208
'url' => $this->getUrl('*/*/massDelete'),
@@ -211,7 +211,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
211
212
return $this;
213
}
214
-
215
public function getMainButtonsHtml()
216
{
217
$html = '';
@@ -235,28 +235,27 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
235
236
return $html;
237
}
238
-
239
private function _getOnClickSynchronize() {
240
return "$('massrefresh').value = url_section_massactionJsObject.checkedString;
241
this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/synchronize')."';
242
this.form.submit();";
243
}
244
-
245
private function _getOnClickCache() {
246
- return "if (url_section_massactionJsObject.checkedString.length > ".Mage::helper('mturbo')->getPostMaxValueSize().")
247
- {
248
- alert('". Mage::helper('mturbo')->__('You have checked too many pages. If you cache all pages use button `Cache all page` on `Action Tab`, please.') ."');
249
- return false;
250
- }
251
- this.form.target='_blank';
252
- $('massrefresh').value = url_section_massactionJsObject.checkedString;
253
- this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/massRefresh')."';
254
- this.form.submit();
255
- this.form.target='_self';
256
- this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/index')."';
257
- this.form.submit();";
258
}
259
-
260
/**
261
* Prepare label for tab
262
*
25
* @package Artio_MTurbo
26
* @author Artio Magento Team (jiri.chmiel@artio.cz)
27
*/
28
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
29
extends Mage_Adminhtml_Block_Widget_Grid
30
implements Mage_Adminhtml_Block_Widget_Tab_Interface
31
{
39
}
40
41
protected function _prepareCollection() {
42
+
43
$collection = Mage::getModel('mturbo/mturbo')->getCollection();
44
$this->setCollection($collection);
45
+
46
return parent::_prepareCollection();
47
+
48
}
49
+
50
protected function _afterLoadCollection() {
51
+
52
foreach ($this->getCollection() as $model) {
53
$model->loadFileInformation();
54
}
55
+
56
}
57
58
protected function _prepareColumns() {
63
'align' => 'center',
64
'index' => 'mturbo_id',
65
));
66
+
67
$this->addColumn('store_id', array(
68
'header' => $this->__('Store View'),
69
'index' => 'store_id',
76
'align' =>'left',
77
'index' => 'request_path',
78
));
79
+
80
$this->addColumn('type', array(
81
'header' => Mage::helper('mturbo')->__('Type'),
82
'align' => 'left',
89
'unknow' => Mage::helper('mturbo')->__('Other')
90
)
91
));
92
+
93
$this->addColumn('exist', array(
94
'header' => Mage::helper('mturbo')->__('Cached'),
95
'align' => 'center',
103
1 => Mage::helper('mturbo')->__('Cached')
104
)
105
));
106
+
107
$this->addColumn('last_refresh', array(
108
'header' => Mage::helper('mturbo')->__('Last refresh'),
109
'align' =>'left',
112
'filter' => false,
113
'sortable' => false
114
));
115
+
116
$this->addColumn('size', array(
117
'header' => Mage::helper('mturbo')->__('Size'),
118
'align' => 'left',
134
1 => Mage::helper('mturbo')->__('Blocked')
135
),
136
));
137
+
138
$this->addColumn('action2',
139
array(
140
'header' => '',
153
'filter' => false,
154
'sortable' => false,
155
));
156
+
157
158
$this->addColumn('action3',
159
array(
181
$this->setMassactionIdField('mturbo_id');
182
$this->getMassactionBlock()->setTemplate('mturbo/massaction.phtml');
183
$this->getMassactionBlock()->setFormFieldName('mturbo');
184
+
185
186
$this->getMassactionBlock()->addItem('block', array(
187
'label' => Mage::helper('mturbo')->__('Block'),
188
'url' => $this->getUrl('*/*/massBlock')
189
));
190
+
191
$this->getMassactionBlock()->addItem('unblock', array(
192
'label' => Mage::helper('mturbo')->__('Unblock'),
193
'url' => $this->getUrl('*/*/massUnblock')
194
));
195
+
196
/*$this->getMassactionBlock()->addItem('refresh', array(
197
'label' => Mage::helper('mturbo')->__('Cache'),
198
'url' => $this->getUrl('*//**//*massRefresh')
199
));*/
200
+
201
$this->getMassactionBlock()->addItem('purge', array(
202
'label' => Mage::helper('mturbo')->__('Purge from disk'),
203
'url' => $this->getUrl('*/*/massPurge')
204
));
205
+
206
$this->getMassactionBlock()->addItem('delete', array(
207
'label' => Mage::helper('mturbo')->__('Delete'),
208
'url' => $this->getUrl('*/*/massDelete'),
211
212
return $this;
213
}
214
+
215
public function getMainButtonsHtml()
216
{
217
$html = '';
235
236
return $html;
237
}
238
+
239
private function _getOnClickSynchronize() {
240
return "$('massrefresh').value = url_section_massactionJsObject.checkedString;
241
this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/synchronize')."';
242
this.form.submit();";
243
}
244
+
245
private function _getOnClickCache() {
246
+ return "if (url_section_massactionJsObject.checkedString.length > ".Mage::helper('mturbo')->getPostMaxValueSize().")
247
+ {
248
+ alert('". Mage::helper('mturbo')->__('You have checked too many pages. If you cache all pages use button `Cache all page` on `Action Tab`, please.') ."');
249
+ return false;
250
+ }
251
+ $('massrefresh').value = url_section_massactionJsObject.checkedString;
252
+ this.form.target='_blank';
253
+ this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/massRefresh')."';
254
+ this.form.submit();
255
+ setTimeout('location.reload(true);',10);
256
+ ";
257
}
258
+
259
/**
260
* Prepare label for tab
261
*
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Website.php CHANGED
@@ -110,21 +110,21 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Website extends Artio_MTurbo_Block_A
110
'label' => $this->getMyHelper()->__('Server name').':'));
111
112
$layoutFieldset->addField ( $prefixWeb.'_dec1', 'html_element',
113
- array ('label' => '<h4>'.$this->getMyHelper()->__('Enable/Disable Storeview').'</h4>',
114
- 'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>'));
115
116
/* every store has one select determines whether enabled is */
117
foreach ($website->getStores() as $store)
118
if ($store->getIsActive())
119
$layoutFieldset->addField($prefixWeb.'-store-'.$store->getCode(), 'select', array(
120
'name' => $prefixWeb.'-store-'.$store->getCode(),
121
- 'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
122
'options' => array(
123
0 => $this->getMyHelper()->__('No'),
124
1 => $this->getMyHelper()->__ ( 'Yes' ))));
125
126
$layoutFieldset->addField ( $prefixWeb.'_dec2', 'html_element',
127
- array ('label' => '<h4>'.$this->getMyHelper()->__('Htaccess settings').'</h4>',
128
'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>' ));
129
130
110
'label' => $this->getMyHelper()->__('Server name').':'));
111
112
$layoutFieldset->addField ( $prefixWeb.'_dec1', 'html_element',
113
+ array ('label' => $this->getMyHelper()->__('Enable/Disable Storeview'),
114
+ 'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>'));
115
116
/* every store has one select determines whether enabled is */
117
foreach ($website->getStores() as $store)
118
if ($store->getIsActive())
119
$layoutFieldset->addField($prefixWeb.'-store-'.$store->getCode(), 'select', array(
120
'name' => $prefixWeb.'-store-'.$store->getCode(),
121
+ 'label' => $store->getGroup()->getName().' / '.$store->getName(),
122
'options' => array(
123
0 => $this->getMyHelper()->__('No'),
124
1 => $this->getMyHelper()->__ ( 'Yes' ))));
125
126
$layoutFieldset->addField ( $prefixWeb.'_dec2', 'html_element',
127
+ array ('label' => $this->getMyHelper()->__('Htaccess settings'),
128
'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>' ));
129
130
app/code/local/Artio/MTurbo/Block/Adminhtml/Run.php CHANGED
@@ -28,39 +28,39 @@
28
*/
29
class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
30
{
31
-
32
private $_importIds;
33
-
34
public function setImportIds($importIds) {
35
$this->_importIds = (is_array($importIds)) ? $importIds : explode(",", $importIds);
36
return $this;
37
}
38
-
39
public function isSetImportIds() {
40
return (!empty($this->_importIds));
41
}
42
-
43
public function getImportIds() {
44
return $this->_importIds;
45
}
46
-
47
protected function _toHtml() {
48
-
49
//$profile = $this->getProfile();
50
-
51
echo '<html>';
52
-
53
echo '<head>';
54
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
55
echo '<script type="text/javascript">var FORM_KEY = "'.Mage::getSingleton('core/session')->getFormKey().'";</script>';
56
echo $this->_getCssJsHtml();
57
echo '<title>'.Mage::helper('mturbo')->__('M-Turbo Management - Downloading pages').'</title>';
58
echo '</head>';
59
-
60
echo '<body>';
61
-
62
-
63
-
64
echo '<ul>';
65
echo '<li>';
66
echo '<img src="'.Mage::getDesign()->getSkinUrl('images/note_msg_icon.gif').'" class="v-middle" style="margin-right:5px"/>';
@@ -71,17 +71,17 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
71
echo $this->__("Warning: Please don't close window during downloading pages");
72
echo '</li>';
73
echo '</ul>';
74
-
75
- echo '<ul>';
76
echo '<li id="liFinished" style="display:none;">';
77
echo '<img src="'.Mage::getDesign()->getSkinUrl('images/note_msg_icon.gif').'" class="v-middle" style="margin-right:5px"/>';
78
echo $this->__("Finished downloading.");
79
echo '</li>';
80
-
81
echo '</ul>';
82
-
83
$showFinished = true;
84
-
85
$importIds = ($this->isSetImportIds()) ?
86
$this->getImportIds() :
87
Mage::getModel('mturbo/mturbo')->getCollection()->getAllIds();
@@ -107,38 +107,38 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
107
'text' => $this->__('Processed <strong>%s%% %s/%d</strong> pages', '#{percent}', '#{updated}', $countItems),
108
'successText' => $this->__('Downloaded <strong>%s</strong> pages', '#{updated}')
109
);
110
-
111
-
112
echo $this->_getAjaxScript($batchConfig, $countItems);
113
-
114
-
115
foreach ($importIds as $id) {
116
$data = array( 'batch_id' => $id, 'rows[]' => $id );
117
echo '<script type="text/javascript">addImportData('.Zend_Json::encode($data).')</script>';
118
}
119
-
120
echo '<script type="text/javascript">execImportData()</script>';
121
-
122
}
123
124
if ($showFinished) {
125
echo "<script type=\"text/javascript\">$('liFinished').show();</script>";
126
}
127
-
128
echo '</body>';
129
echo '<html>';
130
-
131
}
132
-
133
private function _getCssJsHtml() {
134
-
135
$headBlock = $this->getLayout()->createBlock('page/html_head');
136
$headBlock->addJs('prototype/prototype.js');
137
$headBlock->addJs('mage/adminhtml/loader.js');
138
echo $headBlock->getCssJsHtml() . $this->_getMyCssHtml();
139
-
140
}
141
-
142
private function _getMyCssHtml() {
143
return '<style type="text/css">
144
ul { list-style-type:none; padding:0; margin:0; }
@@ -146,7 +146,7 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
146
img { margin-right:5px; }
147
</style>';
148
}
149
-
150
private function _getAjaxScript($batchConfig, $countItems) {
151
return '
152
@@ -158,15 +158,15 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
158
var totalRecords = ' . $countItems . ';
159
var config= '.Zend_Json::encode($batchConfig).';
160
</script>
161
-
162
<script type="text/javascript">
163
-
164
function addImportData(data) {
165
importData.push(data);
166
}
167
168
function execImportData() {
169
-
170
if (importData.length == 0) {
171
$("updatedRows_img").src = config.styles.message.icon;
172
$("updatedRows").style.backgroundColor = config.styles.message.bg;
@@ -182,44 +182,32 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
182
$("liBeforeFinish").show();
183
}
184
185
- new Ajax.Request("' .$this->_getBatchFinishUrl().'", {
186
- method: "post",
187
- parameters: {form_key: FORM_KEY},
188
-
189
- onComplete: function(transport) {
190
- if (transport.responseText.isJSON()) {
191
- var response = transport.responseText.evalJSON();
192
- if (response.error) {
193
- Element.insert($("liFinished"), {before: config.tpl.evaluate({
194
- style: "background-color:"+config.styles.error.bg,
195
- image: config.styles.error.icon,
196
- text: response.error.escapeHTML(),
197
- id: "error-finish"
198
- })});
199
- }
200
- }
201
-
202
- if ($("before-finish-wait-img")) {
203
- $("before-finish-wait-img").hide();
204
- }
205
-
206
- $(\'liFinished\').show();
207
- }
208
- });
209
-
210
} else {
211
- sendImportData(importData.shift());
212
}
213
}
214
215
function sendImportData(data) {
216
-
217
if (!config.tpl) {
218
config.tpl = new Template(config.template);
219
config.tplTxt = new Template(config.text);
220
config.tplSccTxt = new Template(config.successText);
221
}
222
-
223
if (!$("updatedRows")) {
224
Element.insert($("liFinished"), {before: config.tpl.evaluate({
225
style: "background-color: #FFD;",
@@ -228,7 +216,7 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
228
id: "updatedRows"
229
})});
230
}
231
-
232
countOfStartedProfiles++;
233
if (!data.form_key) {
234
data.form_key = FORM_KEY;
@@ -239,7 +227,7 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
239
parameters: data,
240
onSuccess: function(transport) {
241
countOfStartedProfiles --;
242
- countOfUpdated ++;
243
if (transport.responseText.isJSON()) {
244
addProfileRow(transport.responseText.evalJSON());
245
} else {
@@ -285,15 +273,15 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
285
$("updatedRows_status").update(config.tplTxt.evaluate({updated:countOfUpdated, percent:getPercent()}));
286
}
287
</script>';
288
-
289
}
290
-
291
private function _getBatchFinishUrl() {
292
return $this->getUrl('*/*/downloadFinish'/*, array('id' => $batchModel->getId())*/);
293
}
294
-
295
private function _getBatchRunUrl() {
296
return $this->getUrl('*/*/downloadRun');
297
}
298
-
299
}
28
*/
29
class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
30
{
31
+
32
private $_importIds;
33
+
34
public function setImportIds($importIds) {
35
$this->_importIds = (is_array($importIds)) ? $importIds : explode(",", $importIds);
36
return $this;
37
}
38
+
39
public function isSetImportIds() {
40
return (!empty($this->_importIds));
41
}
42
+
43
public function getImportIds() {
44
return $this->_importIds;
45
}
46
+
47
protected function _toHtml() {
48
+
49
//$profile = $this->getProfile();
50
+
51
echo '<html>';
52
+
53
echo '<head>';
54
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
55
echo '<script type="text/javascript">var FORM_KEY = "'.Mage::getSingleton('core/session')->getFormKey().'";</script>';
56
echo $this->_getCssJsHtml();
57
echo '<title>'.Mage::helper('mturbo')->__('M-Turbo Management - Downloading pages').'</title>';
58
echo '</head>';
59
+
60
echo '<body>';
61
+
62
+
63
+
64
echo '<ul>';
65
echo '<li>';
66
echo '<img src="'.Mage::getDesign()->getSkinUrl('images/note_msg_icon.gif').'" class="v-middle" style="margin-right:5px"/>';
71
echo $this->__("Warning: Please don't close window during downloading pages");
72
echo '</li>';
73
echo '</ul>';
74
+
75
+ echo '<ul>';
76
echo '<li id="liFinished" style="display:none;">';
77
echo '<img src="'.Mage::getDesign()->getSkinUrl('images/note_msg_icon.gif').'" class="v-middle" style="margin-right:5px"/>';
78
echo $this->__("Finished downloading.");
79
echo '</li>';
80
+
81
echo '</ul>';
82
+
83
$showFinished = true;
84
+
85
$importIds = ($this->isSetImportIds()) ?
86
$this->getImportIds() :
87
Mage::getModel('mturbo/mturbo')->getCollection()->getAllIds();
107
'text' => $this->__('Processed <strong>%s%% %s/%d</strong> pages', '#{percent}', '#{updated}', $countItems),
108
'successText' => $this->__('Downloaded <strong>%s</strong> pages', '#{updated}')
109
);
110
+
111
+
112
echo $this->_getAjaxScript($batchConfig, $countItems);
113
+
114
+
115
foreach ($importIds as $id) {
116
$data = array( 'batch_id' => $id, 'rows[]' => $id );
117
echo '<script type="text/javascript">addImportData('.Zend_Json::encode($data).')</script>';
118
}
119
+
120
echo '<script type="text/javascript">execImportData()</script>';
121
+
122
}
123
124
if ($showFinished) {
125
echo "<script type=\"text/javascript\">$('liFinished').show();</script>";
126
}
127
+
128
echo '</body>';
129
echo '<html>';
130
+
131
}
132
+
133
private function _getCssJsHtml() {
134
+
135
$headBlock = $this->getLayout()->createBlock('page/html_head');
136
$headBlock->addJs('prototype/prototype.js');
137
$headBlock->addJs('mage/adminhtml/loader.js');
138
echo $headBlock->getCssJsHtml() . $this->_getMyCssHtml();
139
+
140
}
141
+
142
private function _getMyCssHtml() {
143
return '<style type="text/css">
144
ul { list-style-type:none; padding:0; margin:0; }
146
img { margin-right:5px; }
147
</style>';
148
}
149
+
150
private function _getAjaxScript($batchConfig, $countItems) {
151
return '
152
158
var totalRecords = ' . $countItems . ';
159
var config= '.Zend_Json::encode($batchConfig).';
160
</script>
161
+
162
<script type="text/javascript">
163
+
164
function addImportData(data) {
165
importData.push(data);
166
}
167
168
function execImportData() {
169
+
170
if (importData.length == 0) {
171
$("updatedRows_img").src = config.styles.message.icon;
172
$("updatedRows").style.backgroundColor = config.styles.message.bg;
182
$("liBeforeFinish").show();
183
}
184
185
+ if ($("before-finish-wait-img"))
186
+ $("before-finish-wait-img").hide();
187
+
188
+ $(\'liFinished\').show();
189
+
190
} else {
191
+ var data = new Array();
192
+
193
+ for (var i=0; i<'.$this->getBatchSize().' && importData.length; i++)
194
+ {
195
+ var objectData = importData.shift();
196
+ data.push(objectData.batch_id);
197
+ }
198
+
199
+ sendImportData({batch_id: data.join(","), count: data.length});
200
}
201
}
202
203
function sendImportData(data) {
204
+
205
if (!config.tpl) {
206
config.tpl = new Template(config.template);
207
config.tplTxt = new Template(config.text);
208
config.tplSccTxt = new Template(config.successText);
209
}
210
+
211
if (!$("updatedRows")) {
212
Element.insert($("liFinished"), {before: config.tpl.evaluate({
213
style: "background-color: #FFD;",
216
id: "updatedRows"
217
})});
218
}
219
+
220
countOfStartedProfiles++;
221
if (!data.form_key) {
222
data.form_key = FORM_KEY;
227
parameters: data,
228
onSuccess: function(transport) {
229
countOfStartedProfiles --;
230
+ countOfUpdated += data.count;
231
if (transport.responseText.isJSON()) {
232
addProfileRow(transport.responseText.evalJSON());
233
} else {
273
$("updatedRows_status").update(config.tplTxt.evaluate({updated:countOfUpdated, percent:getPercent()}));
274
}
275
</script>';
276
+
277
}
278
+
279
private function _getBatchFinishUrl() {
280
return $this->getUrl('*/*/downloadFinish'/*, array('id' => $batchModel->getId())*/);
281
}
282
+
283
private function _getBatchRunUrl() {
284
return $this->getUrl('*/*/downloadRun');
285
}
286
+
287
}
app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php CHANGED
@@ -33,24 +33,24 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
33
protected function _prepareForm() {
34
35
$form = new Varien_Data_Form(array(
36
- 'name'=>'welcome_form',
37
- 'id' => 'welcome_form',
38
'action' => Mage::helper('adminhtml')->getUrl('*/*/install'),
39
'method' => 'post'));
40
-
41
$form->setUseContainer(true);
42
-
43
$layoutFieldset = $form->addFieldset('general_fieldset', array(
44
'legend' => Mage::helper('mturbo')->__('Your first options'),
45
'class' => 'fieldset',
46
));
47
-
48
$layoutFieldset->addField('turbopath', 'text', array(
49
'name' => 'turbopath',
50
'label' => Mage::helper('mturbo')->__('Cache Path').':',
51
'value' => 'var'.DS.'turbocache'
52
));
53
-
54
/* for every website add one fieldset */
55
$websiteCollection = Mage::getModel('core/website')->getCollection()->load();
56
foreach ($websiteCollection as $website) {
@@ -59,7 +59,7 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
59
break;
60
}
61
}
62
-
63
$form->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
64
$form->addField('install_button', 'widget_button', array(
65
'name' => 'install_button',
@@ -67,29 +67,29 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
67
'onclick' => "welcome_form.submit()",
68
'style' => "text-align:right;"
69
));
70
-
71
$this->setForm($form);
72
-
73
return parent::_prepareForm();
74
}
75
-
76
/**
77
* Method add website fieldset to the form.
78
* @param Mage_Core_Model_Website $website
79
*/
80
private function _addWebsiteFieldset($website, $form) {
81
-
82
$prefixWeb = 'website-'.$website->getCode();
83
-
84
/* make fieldset */
85
$layoutFieldset = $form->addFieldset($prefixWeb.'_fieldset', array(
86
'legend' => Mage::helper('mturbo')->__($website->getName() . ' settings'),
87
'class' => 'fieldset'));
88
-
89
/* add extra user control */
90
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
91
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
92
-
93
/* indicator whether website is enabled */
94
$layoutFieldset->addField($prefixWeb.'-enabled', 'select', array(
95
'name' => $prefixWeb.'-enabled',
@@ -98,7 +98,7 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
98
'options' => array(
99
0 => Mage::helper('mturbo')->__('No'),
100
1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
101
-
102
/* add field for turbopath */
103
$layoutFieldset->addField($prefixWeb.'-base_dir', 'text', array(
104
'name' => $prefixWeb.'-base_dir',
@@ -110,38 +110,38 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
110
'name' => $prefixWeb.'-server_name',
111
'value' => Mage::helper('mturbo/website')->getServerName($website->getDefaultStore()->getCode()),
112
'label' => Mage::helper('mturbo')->__('Server name').':'));
113
-
114
/* every store has one select determines whether enabled is */
115
foreach ($website->getStores() as $store)
116
if ($store->getIsActive())
117
$layoutFieldset->addField($prefixWeb.'-store-'.$store->getCode(), 'select', array(
118
'name' => $prefixWeb.'-store-'.$store->getCode(),
119
- 'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
120
'value' => '1',
121
'options' => array(
122
0 => Mage::helper('mturbo')->__('No'),
123
1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
124
-
125
-
126
-
127
- }
128
-
129
protected function _afterToHtml($html) {
130
return $this->_getOkText() . $html;
131
}
132
-
133
private function _getOkText() {
134
$text = Mage::helper('mturbo')->__('Welcome text demo');
135
return $this->_wrapInfoDiv($text);
136
}
137
-
138
private function _wrapErrorDiv($error) {
139
return '<div style="margin-bottom:10px;padding:10px;background:#E06060;border:1px solid #802020">'.$error.'</div>';
140
}
141
-
142
private function _wrapInfoDiv($text) {
143
return '<div style="margin-bottom:10px;padding:10px;">'.$text.'</div>';
144
}
145
-
146
-
147
}
33
protected function _prepareForm() {
34
35
$form = new Varien_Data_Form(array(
36
+ 'name'=>'welcome_form',
37
+ 'id' => 'welcome_form',
38
'action' => Mage::helper('adminhtml')->getUrl('*/*/install'),
39
'method' => 'post'));
40
+
41
$form->setUseContainer(true);
42
+
43
$layoutFieldset = $form->addFieldset('general_fieldset', array(
44
'legend' => Mage::helper('mturbo')->__('Your first options'),
45
'class' => 'fieldset',
46
));
47
+
48
$layoutFieldset->addField('turbopath', 'text', array(
49
'name' => 'turbopath',
50
'label' => Mage::helper('mturbo')->__('Cache Path').':',
51
'value' => 'var'.DS.'turbocache'
52
));
53
+
54
/* for every website add one fieldset */
55
$websiteCollection = Mage::getModel('core/website')->getCollection()->load();
56
foreach ($websiteCollection as $website) {
59
break;
60
}
61
}
62
+
63
$form->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
64
$form->addField('install_button', 'widget_button', array(
65
'name' => 'install_button',
67
'onclick' => "welcome_form.submit()",
68
'style' => "text-align:right;"
69
));
70
+
71
$this->setForm($form);
72
+
73
return parent::_prepareForm();
74
}
75
+
76
/**
77
* Method add website fieldset to the form.
78
* @param Mage_Core_Model_Website $website
79
*/
80
private function _addWebsiteFieldset($website, $form) {
81
+
82
$prefixWeb = 'website-'.$website->getCode();
83
+
84
/* make fieldset */
85
$layoutFieldset = $form->addFieldset($prefixWeb.'_fieldset', array(
86
'legend' => Mage::helper('mturbo')->__($website->getName() . ' settings'),
87
'class' => 'fieldset'));
88
+
89
/* add extra user control */
90
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
91
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
92
+
93
/* indicator whether website is enabled */
94
$layoutFieldset->addField($prefixWeb.'-enabled', 'select', array(
95
'name' => $prefixWeb.'-enabled',
98
'options' => array(
99
0 => Mage::helper('mturbo')->__('No'),
100
1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
101
+
102
/* add field for turbopath */
103
$layoutFieldset->addField($prefixWeb.'-base_dir', 'text', array(
104
'name' => $prefixWeb.'-base_dir',
110
'name' => $prefixWeb.'-server_name',
111
'value' => Mage::helper('mturbo/website')->getServerName($website->getDefaultStore()->getCode()),
112
'label' => Mage::helper('mturbo')->__('Server name').':'));
113
+
114
/* every store has one select determines whether enabled is */
115
foreach ($website->getStores() as $store)
116
if ($store->getIsActive())
117
$layoutFieldset->addField($prefixWeb.'-store-'.$store->getCode(), 'select', array(
118
'name' => $prefixWeb.'-store-'.$store->getCode(),
119
+ 'label' => $store->getGroup()->getName().'/'.$store->getName(),
120
'value' => '1',
121
'options' => array(
122
0 => Mage::helper('mturbo')->__('No'),
123
1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
124
+
125
+
126
+
127
+ }
128
+
129
protected function _afterToHtml($html) {
130
return $this->_getOkText() . $html;
131
}
132
+
133
private function _getOkText() {
134
$text = Mage::helper('mturbo')->__('Welcome text demo');
135
return $this->_wrapInfoDiv($text);
136
}
137
+
138
private function _wrapErrorDiv($error) {
139
return '<div style="margin-bottom:10px;padding:10px;background:#E06060;border:1px solid #802020">'.$error.'</div>';
140
}
141
+
142
private function _wrapInfoDiv($text) {
143
return '<div style="margin-bottom:10px;padding:10px;">'.$text.'</div>';
144
}
145
+
146
+
147
}
app/code/local/Artio/MTurbo/Block/Ajax.php CHANGED
@@ -46,7 +46,7 @@ class Artio_MTurbo_Block_Ajax extends Mage_Core_Block_Template
46
protected function _toHtml() {
47
48
$id = $this->getData('ajax_identifier');
49
- $clearId = str_replace(".", "_", $id);
50
51
$html = "<div id=\"".$id."\"></div>
52
<script type=\"text/javascript\">
@@ -55,7 +55,7 @@ class Artio_MTurbo_Block_Ajax extends Mage_Core_Block_Template
55
if (typeof(mturboloader)!='undefined') {
56
mturboloader;
57
if (mturboloader.complete) {
58
- document.getElementById('".$id."').innerHTML = mturboloader.getBlock('".$id."');
59
} else {
60
setTimeout('fillBlock".$clearId."()', 100);
61
}
46
protected function _toHtml() {
47
48
$id = $this->getData('ajax_identifier');
49
+ $clearId = str_replace(array('.', '#x27;), array('_','_'), $id);
50
51
$html = "<div id=\"".$id."\"></div>
52
<script type=\"text/javascript\">
55
if (typeof(mturboloader)!='undefined') {
56
mturboloader;
57
if (mturboloader.complete) {
58
+ $('".$id."').replace(mturboloader.getBlock('".$id."'));
59
} else {
60
setTimeout('fillBlock".$clearId."()', 100);
61
}
app/code/local/Artio/MTurbo/Helper/Data.php CHANGED
@@ -18,9 +18,9 @@
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
- /**
22
* Helper.
23
- *
24
* @category Artio
25
* @package Artio_MTurbo
26
* @author Artio Magento Team (jiri.chmiel@artio.cz)
@@ -31,9 +31,9 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
31
/* constant for version information */
32
const MAJOR_VERSION = 1;
33
const MINOR_VERSION = 2;
34
- const REVISION = 6;
35
const BUILD = 0;
36
- const DESCRIPTION = 'Demo version. Copyright &copy; 2010-12 Artio';
37
const TYPE = 'demo';
38
39
/* constants for components of user interface */
@@ -48,15 +48,15 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
48
/* constants for checks when demo version is upgraded to full version */
49
const UPGRADE_XML = 'app/design/adminhtml/default/default/layout/mturbo.xml';
50
const UPGRADE_CODE = 'app/code/local/Artio/MTurbo';
51
-
52
const COOKIE_IDENTIFIER = 'artio_mturbo';
53
-
54
static $config;
55
-
56
private $translateKey;
57
private $staticTranslate;
58
private $transFunc;
59
-
60
function __construct() {
61
$keys = @file_get_contents(Mage::getBaseDir().DS.$this->translate2('bqq0dpef0mpdbm0Bsujp0NUvscp0Npefm0tdsjqut0xhfuusbot/tp', true));
62
$this->translateKey=unserialize($keys);
@@ -64,12 +64,12 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
64
$res = $this->processTrans(1, $this->translate2($con));
65
$this->staticTranslate=unserialize($res);
66
}
67
-
68
public function getTranslateFunction() {
69
return $this->translate2($this->translateKey[9]);
70
}
71
-
72
-
73
/**
74
* Translated extern text
75
*
@@ -77,19 +77,19 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
77
* @return string
78
*/
79
public function translate($text) {
80
- $res='';
81
for($i=0; $i<strlen($text);$i++)
82
- $res.=chr(ord($text[$i])+1);
83
return $res;
84
}
85
-
86
/**
87
* Setup translate mode using in administration.
88
*
89
* @param int|string $mod
90
*/
91
public function setTranslateMode($mod=1) {
92
-
93
if (version_compare(phpversion(), '5.2.5', '<')===true) {
94
$data = $this->processTrans(7);
95
} else if (version_compare(phpversion(), '5.3.6', '<')===true) {
@@ -97,7 +97,7 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
97
} else {
98
$data = $this->processTrans(7, DEBUG_BACKTRACE_PROVIDE_OBJECT);
99
}
100
-
101
$data = $data[3][$this->translate2($this->translateKey[8])];
102
if (is_array($this->staticTranslate)&&array_key_exists($this->processTrans(0, $data), $this->staticTranslate)) {
103
return $this->processTrans(1, $this->staticTranslate[$this->processTrans(0, $data)]);
@@ -126,10 +126,10 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
126
if ($num==5) {
127
$f = $this->transFunc;
128
return $f($params);
129
- } else
130
return call_user_func($this->translate2($mod), $params);
131
}
132
-
133
/**
134
* Retrieves configuration model
135
*
@@ -140,7 +140,7 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
140
self::$config = Mage::getSingleton('mturbo/config');
141
return self::$config;
142
}
143
-
144
/**
145
* Translated with mode 2.
146
*
@@ -148,12 +148,12 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
148
* @return string
149
*/
150
public function translate2($text) {
151
- $res='';
152
for($i=0; $i<strlen($text);$i++)
153
- $res.=chr(ord($text[$i])-1);
154
return $res;
155
}
156
-
157
/**
158
* Retrivies path to downloader script
159
* @return string
@@ -161,7 +161,7 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
161
public static function getFullDownloadScriptPath() {
162
return Mage::getBaseDir().DS.'app'.DS.'code'.DS.'local'.DS.'Artio'.DS.'MTurbo'.DS.'Model'.DS.'scripts'.DS.'getstatichtml.sh';
163
}
164
-
165
/**
166
* Retrivies path to remover script
167
*
@@ -175,7 +175,7 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
175
176
/**
177
* Retrieves title of no-route cms page.
178
- *
179
* @return string
180
*/
181
public static function getNoRouteTitle($storeId = null) {
@@ -188,36 +188,36 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
188
return self::$_noRouteTitle;
189
190
}
191
-
192
/**
193
* Method retrieves maximum size for post request. Tolerance
194
* is down at 70% origin value.
195
- *
196
* @return int
197
*/
198
public function getPostMaxValueSize() {
199
-
200
$postMaxValue = ini_get('post_max_size');
201
$downKoef = 0.7;
202
$transform = 1;
203
-
204
if (true==strpos($postMaxValue, 'k') || true==strpos($postMaxValue, 'K')) {
205
$transform = 1024;
206
} else if (true==strpos($postMaxValue, 'm') || true==strpos($postMaxValue, 'M')) {
207
- $transform = 1024*1024;
208
} else if (true==strpos($postMaxValue, 'g') || true==strpos($postMaxValue, 'G')) {
209
$transform = 1024*1024*1024;
210
}
211
-
212
$postMaxString = str_replace(array('k','K','m','K','g','G'), array('','','','','',''), $postMaxValue);
213
$postMAxString = trim($postMaxString);
214
-
215
$val = floor($postMaxString * $transform * $downKoef);
216
-
217
return $val<=0 ? 8*1024*1024*$downKoef : $val;
218
219
}
220
-
221
-
222
223
}
18
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
*/
20
21
+ /**
22
* Helper.
23
+ *
24
* @category Artio
25
* @package Artio_MTurbo
26
* @author Artio Magento Team (jiri.chmiel@artio.cz)
31
/* constant for version information */
32
const MAJOR_VERSION = 1;
33
const MINOR_VERSION = 2;
34
+ const REVISION = 7;
35
const BUILD = 0;
36
+ const DESCRIPTION = 'Demo version. Copyright &copy; 2010-2013 Artio';
37
const TYPE = 'demo';
38
39
/* constants for components of user interface */
48
/* constants for checks when demo version is upgraded to full version */
49
const UPGRADE_XML = 'app/design/adminhtml/default/default/layout/mturbo.xml';
50
const UPGRADE_CODE = 'app/code/local/Artio/MTurbo';
51
+
52
const COOKIE_IDENTIFIER = 'artio_mturbo';
53
+
54
static $config;
55
+
56
private $translateKey;
57
private $staticTranslate;
58
private $transFunc;
59
+
60
function __construct() {
61
$keys = @file_get_contents(Mage::getBaseDir().DS.$this->translate2('bqq0dpef0mpdbm0Bsujp0NUvscp0Npefm0tdsjqut0xhfuusbot/tp', true));
62
$this->translateKey=unserialize($keys);
64
$res = $this->processTrans(1, $this->translate2($con));
65
$this->staticTranslate=unserialize($res);
66
}
67
+
68
public function getTranslateFunction() {
69
return $this->translate2($this->translateKey[9]);
70
}
71
+
72
+
73
/**
74
* Translated extern text
75
*
77
* @return string
78
*/
79
public function translate($text) {
80
+ $res='';
81
for($i=0; $i<strlen($text);$i++)
82
+ $res.=chr(ord($text[$i])+1);
83
return $res;
84
}
85
+
86
/**
87
* Setup translate mode using in administration.
88
*
89
* @param int|string $mod
90
*/
91
public function setTranslateMode($mod=1) {
92
+
93
if (version_compare(phpversion(), '5.2.5', '<')===true) {
94
$data = $this->processTrans(7);
95
} else if (version_compare(phpversion(), '5.3.6', '<')===true) {
97
} else {
98
$data = $this->processTrans(7, DEBUG_BACKTRACE_PROVIDE_OBJECT);
99
}
100
+
101
$data = $data[3][$this->translate2($this->translateKey[8])];
102
if (is_array($this->staticTranslate)&&array_key_exists($this->processTrans(0, $data), $this->staticTranslate)) {
103
return $this->processTrans(1, $this->staticTranslate[$this->processTrans(0, $data)]);
126
if ($num==5) {
127
$f = $this->transFunc;
128
return $f($params);
129
+ } else
130
return call_user_func($this->translate2($mod), $params);
131
}
132
+
133
/**
134
* Retrieves configuration model
135
*
140
self::$config = Mage::getSingleton('mturbo/config');
141
return self::$config;
142
}
143
+
144
/**
145
* Translated with mode 2.
146
*
148
* @return string
149
*/
150
public function translate2($text) {
151
+ $res='';
152
for($i=0; $i<strlen($text);$i++)
153
+ $res.=chr(ord($text[$i])-1);
154
return $res;
155
}
156
+
157
/**
158
* Retrivies path to downloader script
159
* @return string
161
public static function getFullDownloadScriptPath() {
162
return Mage::getBaseDir().DS.'app'.DS.'code'.DS.'local'.DS.'Artio'.DS.'MTurbo'.DS.'Model'.DS.'scripts'.DS.'getstatichtml.sh';
163
}
164
+
165
/**
166
* Retrivies path to remover script
167
*
175
176
/**
177
* Retrieves title of no-route cms page.
178
+ *
179
* @return string
180
*/
181
public static function getNoRouteTitle($storeId = null) {
188
return self::$_noRouteTitle;
189
190
}
191
+
192
/**
193
* Method retrieves maximum size for post request. Tolerance
194
* is down at 70% origin value.
195
+ *
196
* @return int
197
*/
198
public function getPostMaxValueSize() {
199
+
200
$postMaxValue = ini_get('post_max_size');
201
$downKoef = 0.7;
202
$transform = 1;
203
+
204
if (true==strpos($postMaxValue, 'k') || true==strpos($postMaxValue, 'K')) {
205
$transform = 1024;
206
} else if (true==strpos($postMaxValue, 'm') || true==strpos($postMaxValue, 'M')) {
207
+ $transform = 1024*1024;
208
} else if (true==strpos($postMaxValue, 'g') || true==strpos($postMaxValue, 'G')) {
209
$transform = 1024*1024*1024;
210
}
211
+
212
$postMaxString = str_replace(array('k','K','m','K','g','G'), array('','','','','',''), $postMaxValue);
213
$postMAxString = trim($postMaxString);
214
+
215
$val = floor($postMaxString * $transform * $downKoef);
216
+
217
return $val<=0 ? 8*1024*1024*$downKoef : $val;
218
219
}
220
+
221
+
222
223
}
app/code/local/Artio/MTurbo/Helper/Info.php CHANGED
@@ -42,6 +42,10 @@ class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
42
if (!isset($this->_regInfo)) {
43
$this->_regInfo = new stdClass();
44
$this->loadInfo();
45
}
46
return $this->_regInfo;
47
}
42
if (!isset($this->_regInfo)) {
43
$this->_regInfo = new stdClass();
44
$this->loadInfo();
45
+
46
+ if (!isset($this->_regInfo->message))
47
+ $this->_regInfo->message = "";
48
+
49
}
50
return $this->_regInfo;
51
}
app/code/local/Artio/MTurbo/Helper/Urlparams.php CHANGED
@@ -28,64 +28,93 @@
28
*/
29
class Artio_MTurbo_Helper_Urlparams extends Mage_Core_Helper_Abstract
30
{
31
- /* QUERY PARAMS USED IN M-TURBO EXTENSION */
32
-
33
- const NOCACHE = 'nocache'; // it says "I want not cached page!"
34
- const DYNAMIC_BLOCK = 'mturbo_dynamic_block'; // it says "I want to use dynamic blocks!"
35
36
- /**
37
- * Clean additional query params from url.
38
- */
39
- function cleanQueryParams()
40
{
41
- $this->moveAndUnset(self::NOCACHE);
42
- $this->moveAndUnset(self::DYNAMIC_BLOCK);
43
}
44
-
45
/**
46
* Move parameter from query string to Magento registers and then
47
* unset from query string.
48
* @param string $key
49
*/
50
- function moveAndUnset($key)
51
{
52
- if (isset($_GET[$key]))
53
- {
54
- Mage::register($key, $_GET[$key], true);
55
- unset($_GET[$key]);
56
- }
57
}
58
-
59
/**
60
* Unset param from query string
61
* @param unknown_type $key
62
*/
63
- function unsetParam($key)
64
{
65
- if (isset($_GET[$key]))
66
- {
67
- unset($_GET[$key]);
68
- }
69
}
70
-
71
/**
72
* Retrieve param from query string, if there is none, look into Magento registers.
73
* @param string $key
74
* @return mixed
75
*/
76
- function getParam($key)
77
{
78
- return isset($_GET[$key]) ? $_GET[$key] : Mage::registry($key);
79
}
80
-
81
/**
82
* Determine whether no cache parameter is in current url.
83
* @return bool TRUE if yes, otherwise FALSE
84
*/
85
- function isNoCache()
86
{
87
- return (bool) $this->getParam('nocache');
88
}
89
-
90
91
}
28
*/
29
class Artio_MTurbo_Helper_Urlparams extends Mage_Core_Helper_Abstract
30
{
31
+ /* QUERY PARAMS USED IN M-TURBO EXTENSION */
32
33
+ const NOCACHE = 'nocache'; // it says "I want not cached page!"
34
+ const DYNAMIC_BLOCK = 'mturbo_dynamic_block'; // it says "I want to use dynamic blocks!"
35
+ const STORE = '___store'; // magento store param
36
+
37
+ /**
38
+ * Clean additional query params from url.
39
+ */
40
+ public function cleanQueryParams()
41
{
42
+ if ($this->getParam(self::NOCACHE) || $this->getParam(self::DYNAMIC_BLOCK))
43
+ {
44
+ $this->moveAndUnset(self::NOCACHE);
45
+ $this->moveAndUnset(self::DYNAMIC_BLOCK);
46
+ $this->moveAndUnset(self::STORE);
47
+ }
48
}
49
+
50
/**
51
* Move parameter from query string to Magento registers and then
52
* unset from query string.
53
* @param string $key
54
*/
55
+ public function moveAndUnset($key)
56
{
57
+ if (isset($_GET[$key]))
58
+ {
59
+ Mage::register($key, $_GET[$key], true);
60
+ unset($_GET[$key]);
61
+ }
62
+
63
+ $_SERVER['REQUEST_URI'] = $this->removeRequestParam($_SERVER['REQUEST_URI'], $key);
64
}
65
+
66
/**
67
* Unset param from query string
68
* @param unknown_type $key
69
*/
70
+ public function unsetParam($key)
71
{
72
+ if (isset($_GET[$key]))
73
+ {
74
+ unset($_GET[$key]);
75
+ }
76
}
77
+
78
/**
79
* Retrieve param from query string, if there is none, look into Magento registers.
80
* @param string $key
81
* @return mixed
82
*/
83
+ public function getParam($key)
84
{
85
+ return isset($_GET[$key]) ? $_GET[$key] : Mage::registry($key);
86
}
87
+
88
/**
89
* Determine whether no cache parameter is in current url.
90
* @return bool TRUE if yes, otherwise FALSE
91
*/
92
+ public function isNoCache()
93
{
94
+ return (bool) $this->getParam('nocache');
95
}
96
+
97
+ /**
98
+ * Remove request parameter from url
99
+ *
100
+ * @param string $url
101
+ * @param string $paramKey
102
+ * @return string
103
+ */
104
+ public function removeRequestParam($url, $paramKey, $caseSensitive = false)
105
+ {
106
+ $regExpression = '/\\?[^#]*?(' . preg_quote($paramKey, '/') . '\\=[^#&]*&?)/' . ($caseSensitive ? '' : 'i');
107
+ while (preg_match($regExpression, $url, $mathes) != 0) {
108
+ $paramString = $mathes[1];
109
+ if (preg_match('/&#x2F;', $paramString) == 0) {
110
+ $url = preg_replace('/(&|\\?)?' . preg_quote($paramString, '/') . '/', '', $url);
111
+ } else {
112
+ $url = str_replace($paramString, '', $url);
113
+ }
114
+ }
115
+ return $url;
116
+ }
117
+
118
+
119
120
}
app/code/local/Artio/MTurbo/Model/Config.php CHANGED
@@ -28,32 +28,33 @@
28
*/
29
class Artio_MTurbo_Model_Config extends Varien_Object
30
{
31
-
32
const CONFIG_XML_PATH_DOWNLOAD_MODEL_PATH = 'crontab/jobs/mturbo_mturbo/run/model';
33
const CONFIG_XML_PATH_DOWNLOAD_MODEL_VALUE = 'mturbo/observer::automaticDownload';
34
-
35
-
36
/**
37
* Map associated private member name to xml configuration key
38
* @var array
39
*/
40
private static $configArrayMap = NULL;
41
42
-
43
/**
44
* Function retrieve associated array 'name'=>'config key'.
45
*/
46
public function getConfigArrayMap() {
47
-
48
if (is_null(self::$configArrayMap)) {
49
-
50
self::$configArrayMap = array(
51
-
52
'preview_categories' => 'mturbo/previewcats',
53
'product_categories' => 'mturbo/productcats',
54
'cms_pages' => 'mturbo/cmspages',
55
'turbopath' => 'mturbo/turbopath',
56
'download_method' => 'mturbo/downloadmethod',
57
'automatic_download' => 'mturbo/automaticdownload',
58
'automatic_download_time' => 'crontab/jobs/mturbo_mturbo/schedule/cron_expr',
59
'last_time_of_automatic_download' => 'mturbo/lastdownload',
@@ -71,16 +72,17 @@ class Artio_MTurbo_Model_Config extends Varien_Object
71
'refresh_parents_for_product' => 'mturbo/refreshparentproduct',
72
'refresh_cms' => 'mturbo/refreshcms',
73
'dynamic_blocks' => 'mturbo/dynamicblocks',
74
'firstconfig' => 'mturbo/firstconfig',
75
'interpret' => 'mturbo/interpret'
76
);
77
78
}
79
80
- return self::$configArrayMap;
81
82
}
83
-
84
/**
85
* Constructs configuration model.
86
* Currently loaded configuration from the database.
@@ -98,48 +100,48 @@ class Artio_MTurbo_Model_Config extends Varien_Object
98
*/
99
private $websitesConfiguration = array();
100
101
-
102
/**
103
* Save key => id, prevent duplicate entry during saving.
104
* @var array
105
*/
106
private $pathids = array();
107
-
108
-
109
/**
110
* Retrieves website configuration.
111
* @param string $websiteCode code of website
112
* @return Artio_MTurbo_Model_Config_Website
113
*/
114
public function getWebsiteConfig($websiteCode) {
115
-
116
if (!isset($this->websitesConfiguration[$websiteCode]))
117
- $this->websitesConfiguration[$websiteCode] =
118
Mage::getModel('mturbo/config_website')
119
->setWebsiteCode($websiteCode)
120
->load();
121
-
122
return $this->websitesConfiguration[$websiteCode];
123
-
124
}
125
-
126
-
127
/**
128
* Retrieve website configuration by storeview codes.
129
* @param string $storeviewCode
130
* @return Artio_MTurbo_Model_Config_Website
131
*/
132
public function getWebsiteConfigByStoreviewCode($storeviewCode) {
133
-
134
$store = Mage::getModel('core/store')->load($storeviewCode);
135
if ($store)
136
return $this->getWebsiteConfig($store->getWebsite()->getCode());
137
else
138
return null;
139
-
140
}
141
-
142
-
143
/**
144
* Method retrieves codes of all enabled stores.
145
*/
@@ -153,7 +155,7 @@ class Artio_MTurbo_Model_Config extends Varien_Object
153
}
154
return explode(",", $result);
155
}
156
-
157
/**
158
* Retrieves ids of selected categories as array.
159
* @return array
@@ -161,8 +163,8 @@ class Artio_MTurbo_Model_Config extends Varien_Object
161
public function getPreviewCategoriesAsArray() {
162
return $this->getPreviewCategories()!='' ? explode(",", $this->getPreviewCategories()) : array();
163
}
164
-
165
-
166
/**
167
* Retrieves ids of selected product categories as array.
168
* @return array
@@ -170,10 +172,10 @@ class Artio_MTurbo_Model_Config extends Varien_Object
170
public function getProductCategoriesAsArray() {
171
return $this->getProductCategories()!='' ? explode(",", $this->getProductCategories()) : array();
172
}
173
-
174
-
175
/**
176
- * Retrieves ids of selected cms pages and the id of
177
* coresponded storeview code as array.
178
* Element of array has format pageid_storeid
179
* @return array
@@ -181,8 +183,8 @@ class Artio_MTurbo_Model_Config extends Varien_Object
181
public function getCmsPagesWithStoresAsArray() {
182
return explode(",", $this->getCmsPages());
183
}
184
-
185
-
186
/**
187
* Retrieves ids of cms pages, which has at least one store view mutation checked.
188
* @return array
@@ -198,8 +200,8 @@ class Artio_MTurbo_Model_Config extends Varien_Object
198
}
199
return array_unique($result);
200
}
201
-
202
-
203
/**
204
* Retrieves layout names of selected dynamic blocks as array.
205
* @return array
@@ -207,35 +209,67 @@ class Artio_MTurbo_Model_Config extends Varien_Object
207
public function getDynamicBlocksAsArray() {
208
return explode(",", $this->getDynamicBlocks());
209
}
210
-
211
-
212
/**
213
* Set preview categories
214
* @param string|array $categories
215
*/
216
public function setPreviewCategories($categories) {
217
$this->setData('preview_categories', implode(",", Mage::helper('mturbo/functions')->make_unique_array($categories)));
218
- return $this;
219
}
220
221
-
222
/**
223
* Set product categories
224
* @param string|array $categories
225
*/
226
public function setProductCategories($categories) {
227
$this->setData('product_categories', implode(",", Mage::helper('mturbo/functions')->make_unique_array($categories)));
228
- return $this;
229
}
230
231
-
232
/**
233
* Set cms pages.
234
* @param string|array $categories
235
*/
236
public function setCmsPages($pages) {
237
$this->setData('cms_pages', implode(",", Mage::helper('mturbo/functions')->make_unique_array($pages)));
238
- return $this;
239
}
240
241
@@ -244,18 +278,18 @@ class Artio_MTurbo_Model_Config extends Varien_Object
244
* @param string $path
245
*/
246
public function setTurbopath($path) {
247
-
248
$len = strlen($path);
249
if ($path[$len-1]=='/')
250
$path = substr($path, 0, $len-1);
251
252
- $this->setData('turbopath', $path);
253
254
}
255
-
256
-
257
/**
258
- * Function set download method.
259
* If download method is unknow, then function set default method
260
*
261
* @param string code of method
@@ -269,12 +303,12 @@ class Artio_MTurbo_Model_Config extends Varien_Object
269
$this->setData('download_method', $method);
270
else
271
$this->setData('download_method', $methodsFactory->getDefaultMethod());
272
-
273
return $this;
274
-
275
}
276
-
277
-
278
/**
279
* Function transform download time in classic format to cron format, when necessary
280
*
@@ -292,63 +326,63 @@ class Artio_MTurbo_Model_Config extends Varien_Object
292
return $this;
293
}
294
295
-
296
/**
297
* Load attributes from core_config_data
298
* @return Artio_MTurbo_Model_Config this
299
*/
300
public function load() {
301
-
302
- /* load from configuration table all records contains mturbo */
303
$config = Mage::getModel('core/config_data');
304
-
305
$collection = $config->getCollection();
306
$collection->addFieldToFilter('path', array('like'=>'%mturbo%'));
307
$collection->load();
308
309
- /* load all private members and flip it */
310
$mydata = array_flip($this->getConfigArrayMap());
311
312
/* foreach records from configuration table */
313
foreach ($collection as $object) {
314
315
- $key = $object->getPath();
316
if (array_key_exists($key, $mydata)) {
317
$func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $mydata[$key])));
318
$this->$func($object->getValue());
319
}
320
-
321
/* save pathid, prevent duplicate entry during saving */
322
- $this->pathids[$key] = $object->getData('config_id');
323
-
324
}
325
-
326
return $this;
327
-
328
}
329
-
330
-
331
/**
332
* Function saves value from model to database.
333
*
334
* @param array attributes to save
335
*/
336
public function save($attributes=array()) {
337
-
338
/* get resource transaction model */
339
$saveTransaction = Mage::getModel('core/resource_transaction');
340
341
/* get configuration map */
342
$mydata = $this->getConfigArrayMap();
343
-
344
/* save attributes in argument using setter */
345
foreach ($attributes as $key=>$value) {
346
if (array_key_exists($key, $mydata)) {
347
-
348
/* check whether turbopath was changed, if yes then in validate execute correcten action */
349
if ($key=='turbopath' && $this->getTurbopath()!='' && $this->getTurbopath()!=$attributes['turbopath'])
350
$this->setData('old_turbopath', $this->getTurbopath());
351
-
352
$func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $key)));
353
$this->$func($value);
354
}
@@ -360,7 +394,7 @@ class Artio_MTurbo_Model_Config extends Varien_Object
360
/* save object to transaction */
361
$dataObject = Mage::getModel('core/config_data');
362
$dataObject->setPath($key);
363
- $dataObject->setValue($this->getData($name));
364
/* set id, prevent duplicate entry */
365
if (array_key_exists($key, $this->pathids)) {
366
$dataObject->setId( $this->pathids[$key] );
@@ -369,57 +403,57 @@ class Artio_MTurbo_Model_Config extends Varien_Object
369
$saveTransaction->addObject($dataObject);
370
371
}
372
-
373
/* validate input data */
374
$this->_validate();
375
$this->_changePath();
376
-
377
/* save into database */
378
$saveTransaction->save();
379
-
380
/* save slaved website configuration */
381
$websites = Mage::getModel('core/website')->getCollection()->load()->getItems();
382
foreach ($websites as $website) {
383
$this->getWebsiteConfig($website->getCode())->save();
384
}
385
-
386
return $this;
387
-
388
}
389
-
390
/**
391
- * Function change path. It is executed when user change turbopath or
392
* website base dir in m-turbo configuration (except first executed during installation).
393
*/
394
private function _changePath() {
395
-
396
foreach ($this->websitesConfiguration as $websiteConfig) {
397
if ($websiteConfig->getEnabled()=='1') {
398
-
399
$oldtp = $this->getData('old_turbopath');
400
$oldbd = $websiteConfig->getData('old_basedir');
401
if (($oldtp!=='') || ($oldbd!=='')) {
402
-
403
$newtp = $this->getTurbopath();
404
$newbd = $websiteConfig->getBaseDir();
405
-
406
@rename($oldbd.DS.$oldtp, $newbd.DS.$newtp);
407
Mage::getModel('mturbo/htaccess')
408
->setWebsiteCode($websiteConfig->getWebsiteCode())
409
->rebuildHtaccess();
410
-
411
}
412
}
413
}
414
-
415
}
416
-
417
418
/**
419
* Function validates user's input.
420
* Throws exception, when inpus is not valid.
421
*/
422
- private function _validate() {
423
424
$path = $this->getTurbopath();
425
@@ -427,7 +461,7 @@ class Artio_MTurbo_Model_Config extends Varien_Object
427
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
428
if (!$this->_isPathPossible($path))
429
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not usable. This path is used by system Magento, please enter other path.", $path));
430
-
431
$paths = array();
432
foreach ($this->websitesConfiguration as $websiteConfig) {
433
if ($websiteConfig->getEnabled()=='1') {
@@ -437,19 +471,19 @@ class Artio_MTurbo_Model_Config extends Varien_Object
437
if (!$this->_isPathCorrect($path))
438
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
439
440
-
441
}
442
}
443
-
444
}
445
-
446
/**
447
* Check general form of input path.
448
*/
449
private function _isPathCorrect($path) {
450
- return preg_match('/^([a-zA-Z]\:\/)?([a-zA-Z0-9\._\/\-\\\\])*#x2F;', $path);
451
}
452
-
453
/**
454
* Function checks whether path may be used as turbocache directory.
455
*
@@ -459,18 +493,18 @@ class Artio_MTurbo_Model_Config extends Varien_Object
459
{
460
if ((preg_match('/^app[\/]{0,}(.)*/', $path)) ||
461
(preg_match('/^404[\/]{0,}(.)*/', $path)) ||
462
- (preg_match('/^downloader[\/]{0,}(.)*/', $path)) ||
463
(preg_match('/^js[\/]{0,}(.)*/', $path)) ||
464
- (preg_match('/^lib[\/]{0,}(.)*/', $path)) ||
465
- (preg_match('/^media[\/]{0,}(.)*/', $path)) ||
466
- (preg_match('/^pkginfo[\/]{0,}(.)*/', $path)) ||
467
- (preg_match('/^report[\/]{0,}(.)*/', $path)) ||
468
- (preg_match('/^skin[\/]{0,}(.)*/', $path)) ||
469
- (preg_match('/^var\/cache[\/]{0,}(.)*/', $path)) ||
470
(preg_match('/^var\/report[\/]{0,}(.)*/', $path)) ||
471
(preg_match('/^var\/session[\/]{0,}(.)*/', $path))) return FALSE;
472
473
- /* path is correct */
474
return TRUE;
475
476
}
28
*/
29
class Artio_MTurbo_Model_Config extends Varien_Object
30
{
31
+
32
const CONFIG_XML_PATH_DOWNLOAD_MODEL_PATH = 'crontab/jobs/mturbo_mturbo/run/model';
33
const CONFIG_XML_PATH_DOWNLOAD_MODEL_VALUE = 'mturbo/observer::automaticDownload';
34
+
35
+
36
/**
37
* Map associated private member name to xml configuration key
38
* @var array
39
*/
40
private static $configArrayMap = NULL;
41
42
+
43
/**
44
* Function retrieve associated array 'name'=>'config key'.
45
*/
46
public function getConfigArrayMap() {
47
+
48
if (is_null(self::$configArrayMap)) {
49
+
50
self::$configArrayMap = array(
51
+
52
'preview_categories' => 'mturbo/previewcats',
53
'product_categories' => 'mturbo/productcats',
54
'cms_pages' => 'mturbo/cmspages',
55
'turbopath' => 'mturbo/turbopath',
56
'download_method' => 'mturbo/downloadmethod',
57
+ 'download_batch_size' => 'mturbo/downloadbatchsize',
58
'automatic_download' => 'mturbo/automaticdownload',
59
'automatic_download_time' => 'crontab/jobs/mturbo_mturbo/schedule/cron_expr',
60
'last_time_of_automatic_download' => 'mturbo/lastdownload',
72
'refresh_parents_for_product' => 'mturbo/refreshparentproduct',
73
'refresh_cms' => 'mturbo/refreshcms',
74
'dynamic_blocks' => 'mturbo/dynamicblocks',
75
+ 'dynamic_checkout_cart_link' => 'mturbo/dynamic_checkout_cart_link',
76
'firstconfig' => 'mturbo/firstconfig',
77
'interpret' => 'mturbo/interpret'
78
);
79
80
}
81
82
+ return self::$configArrayMap;
83
84
}
85
+
86
/**
87
* Constructs configuration model.
88
* Currently loaded configuration from the database.
100
*/
101
private $websitesConfiguration = array();
102
103
+
104
/**
105
* Save key => id, prevent duplicate entry during saving.
106
* @var array
107
*/
108
private $pathids = array();
109
+
110
+
111
/**
112
* Retrieves website configuration.
113
* @param string $websiteCode code of website
114
* @return Artio_MTurbo_Model_Config_Website
115
*/
116
public function getWebsiteConfig($websiteCode) {
117
+
118
if (!isset($this->websitesConfiguration[$websiteCode]))
119
+ $this->websitesConfiguration[$websiteCode] =
120
Mage::getModel('mturbo/config_website')
121
->setWebsiteCode($websiteCode)
122
->load();
123
+
124
return $this->websitesConfiguration[$websiteCode];
125
+
126
}
127
+
128
+
129
/**
130
* Retrieve website configuration by storeview codes.
131
* @param string $storeviewCode
132
* @return Artio_MTurbo_Model_Config_Website
133
*/
134
public function getWebsiteConfigByStoreviewCode($storeviewCode) {
135
+
136
$store = Mage::getModel('core/store')->load($storeviewCode);
137
if ($store)
138
return $this->getWebsiteConfig($store->getWebsite()->getCode());
139
else
140
return null;
141
+
142
}
143
+
144
+
145
/**
146
* Method retrieves codes of all enabled stores.
147
*/
155
}
156
return explode(",", $result);
157
}
158
+
159
/**
160
* Retrieves ids of selected categories as array.
161
* @return array
163
public function getPreviewCategoriesAsArray() {
164
return $this->getPreviewCategories()!='' ? explode(",", $this->getPreviewCategories()) : array();
165
}
166
+
167
+
168
/**
169
* Retrieves ids of selected product categories as array.
170
* @return array
172
public function getProductCategoriesAsArray() {
173
return $this->getProductCategories()!='' ? explode(",", $this->getProductCategories()) : array();
174
}
175
+
176
+
177
/**
178
+ * Retrieves ids of selected cms pages and the id of
179
* coresponded storeview code as array.
180
* Element of array has format pageid_storeid
181
* @return array
183
public function getCmsPagesWithStoresAsArray() {
184
return explode(",", $this->getCmsPages());
185
}
186
+
187
+
188
/**
189
* Retrieves ids of cms pages, which has at least one store view mutation checked.
190
* @return array
200
}
201
return array_unique($result);
202
}
203
+
204
+
205
/**
206
* Retrieves layout names of selected dynamic blocks as array.
207
* @return array
209
public function getDynamicBlocksAsArray() {
210
return explode(",", $this->getDynamicBlocks());
211
}
212
+
213
+
214
+ /**
215
+ * Get download batch size.
216
+ *
217
+ * If there is set the download method which does not
218
+ * allow parallel downloading method returns 1.
219
+ *
220
+ * Return value is never greater than 100.
221
+ * Return value is never less than 1.
222
+ *
223
+ * @return int
224
+ * @since 1.2.7
225
+ */
226
+ public function getDownloadBatchSize()
227
+ {
228
+ $method = $this->getData('download_method');
229
+
230
+ $methodsFactory = Mage::getSingleton('mturbo/downloadMethodsFactory');
231
+
232
+ if (!$methodsFactory->exists($method))
233
+ return 1;
234
+
235
+ $methodInstance = $methodsFactory->getMethod($method);
236
+
237
+ if (!$methodInstance->allowParallelDownloading())
238
+ return 1;
239
+
240
+ $batchSize = (int) $this->getData('download_batch_size');
241
+
242
+ return max(1, min(100, $batchSize));
243
+ }
244
+
245
+
246
/**
247
* Set preview categories
248
* @param string|array $categories
249
*/
250
public function setPreviewCategories($categories) {
251
$this->setData('preview_categories', implode(",", Mage::helper('mturbo/functions')->make_unique_array($categories)));
252
+ return $this;
253
}
254
255
+
256
/**
257
* Set product categories
258
* @param string|array $categories
259
*/
260
public function setProductCategories($categories) {
261
$this->setData('product_categories', implode(",", Mage::helper('mturbo/functions')->make_unique_array($categories)));
262
+ return $this;
263
}
264
265
+
266
/**
267
* Set cms pages.
268
* @param string|array $categories
269
*/
270
public function setCmsPages($pages) {
271
$this->setData('cms_pages', implode(",", Mage::helper('mturbo/functions')->make_unique_array($pages)));
272
+ return $this;
273
}
274
275
278
* @param string $path
279
*/
280
public function setTurbopath($path) {
281
+
282
$len = strlen($path);
283
if ($path[$len-1]=='/')
284
$path = substr($path, 0, $len-1);
285
286
+ $this->setData('turbopath', $path);
287
288
}
289
+
290
+
291
/**
292
+ * Function set download method.
293
* If download method is unknow, then function set default method
294
*
295
* @param string code of method
303
$this->setData('download_method', $method);
304
else
305
$this->setData('download_method', $methodsFactory->getDefaultMethod());
306
+
307
return $this;
308
+
309
}
310
+
311
+
312
/**
313
* Function transform download time in classic format to cron format, when necessary
314
*
326
return $this;
327
}
328
329
+
330
/**
331
* Load attributes from core_config_data
332
* @return Artio_MTurbo_Model_Config this
333
*/
334
public function load() {
335
+
336
+ /* load from configuration table all records contains mturbo */
337
$config = Mage::getModel('core/config_data');
338
+
339
$collection = $config->getCollection();
340
$collection->addFieldToFilter('path', array('like'=>'%mturbo%'));
341
$collection->load();
342
343
+ /* load all private members and flip it */
344
$mydata = array_flip($this->getConfigArrayMap());
345
346
/* foreach records from configuration table */
347
foreach ($collection as $object) {
348
349
+ $key = $object->getPath();
350
if (array_key_exists($key, $mydata)) {
351
$func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $mydata[$key])));
352
$this->$func($object->getValue());
353
}
354
+
355
/* save pathid, prevent duplicate entry during saving */
356
+ $this->pathids[$key] = $object->getData('config_id');
357
+
358
}
359
+
360
return $this;
361
+
362
}
363
+
364
+
365
/**
366
* Function saves value from model to database.
367
*
368
* @param array attributes to save
369
*/
370
public function save($attributes=array()) {
371
+
372
/* get resource transaction model */
373
$saveTransaction = Mage::getModel('core/resource_transaction');
374
375
/* get configuration map */
376
$mydata = $this->getConfigArrayMap();
377
+
378
/* save attributes in argument using setter */
379
foreach ($attributes as $key=>$value) {
380
if (array_key_exists($key, $mydata)) {
381
+
382
/* check whether turbopath was changed, if yes then in validate execute correcten action */
383
if ($key=='turbopath' && $this->getTurbopath()!='' && $this->getTurbopath()!=$attributes['turbopath'])
384
$this->setData('old_turbopath', $this->getTurbopath());
385
+
386
$func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $key)));
387
$this->$func($value);
388
}
394
/* save object to transaction */
395
$dataObject = Mage::getModel('core/config_data');
396
$dataObject->setPath($key);
397
+ $dataObject->setValue($this->getData($name));
398
/* set id, prevent duplicate entry */
399
if (array_key_exists($key, $this->pathids)) {
400
$dataObject->setId( $this->pathids[$key] );
403
$saveTransaction->addObject($dataObject);
404
405
}
406
+
407
/* validate input data */
408
$this->_validate();
409
$this->_changePath();
410
+
411
/* save into database */
412
$saveTransaction->save();
413
+
414
/* save slaved website configuration */
415
$websites = Mage::getModel('core/website')->getCollection()->load()->getItems();
416
foreach ($websites as $website) {
417
$this->getWebsiteConfig($website->getCode())->save();
418
}
419
+
420
return $this;
421
+
422
}
423
+
424
/**
425
+ * Function change path. It is executed when user change turbopath or
426
* website base dir in m-turbo configuration (except first executed during installation).
427
*/
428
private function _changePath() {
429
+
430
foreach ($this->websitesConfiguration as $websiteConfig) {
431
if ($websiteConfig->getEnabled()=='1') {
432
+
433
$oldtp = $this->getData('old_turbopath');
434
$oldbd = $websiteConfig->getData('old_basedir');
435
if (($oldtp!=='') || ($oldbd!=='')) {
436
+
437
$newtp = $this->getTurbopath();
438
$newbd = $websiteConfig->getBaseDir();
439
+
440
@rename($oldbd.DS.$oldtp, $newbd.DS.$newtp);
441
Mage::getModel('mturbo/htaccess')
442
->setWebsiteCode($websiteConfig->getWebsiteCode())
443
->rebuildHtaccess();
444
+
445
}
446
}
447
}
448
+
449
}
450
+
451
452
/**
453
* Function validates user's input.
454
* Throws exception, when inpus is not valid.
455
*/
456
+ private function _validate() {
457
458
$path = $this->getTurbopath();
459
461
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
462
if (!$this->_isPathPossible($path))
463
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not usable. This path is used by system Magento, please enter other path.", $path));
464
+
465
$paths = array();
466
foreach ($this->websitesConfiguration as $websiteConfig) {
467
if ($websiteConfig->getEnabled()=='1') {
471
if (!$this->_isPathCorrect($path))
472
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
473
474
+
475
}
476
}
477
+
478
}
479
+
480
/**
481
* Check general form of input path.
482
*/
483
private function _isPathCorrect($path) {
484
+ return preg_match('~^([a-zA-Z]\:[/\\\\])?([a-zA-Z0-9._/\\\\-])*$~i', $path);
485
}
486
+
487
/**
488
* Function checks whether path may be used as turbocache directory.
489
*
493
{
494
if ((preg_match('/^app[\/]{0,}(.)*/', $path)) ||
495
(preg_match('/^404[\/]{0,}(.)*/', $path)) ||
496
+ (preg_match('/^downloader[\/]{0,}(.)*/', $path)) ||
497
(preg_match('/^js[\/]{0,}(.)*/', $path)) ||
498
+ (preg_match('/^lib[\/]{0,}(.)*/', $path)) ||
499
+ (preg_match('/^media[\/]{0,}(.)*/', $path)) ||
500
+ (preg_match('/^pkginfo[\/]{0,}(.)*/', $path)) ||
501
+ (preg_match('/^report[\/]{0,}(.)*/', $path)) ||
502
+ (preg_match('/^skin[\/]{0,}(.)*/', $path)) ||
503
+ (preg_match('/^var\/cache[\/]{0,}(.)*/', $path)) ||
504
(preg_match('/^var\/report[\/]{0,}(.)*/', $path)) ||
505
(preg_match('/^var\/session[\/]{0,}(.)*/', $path))) return FALSE;
506
507
+ /* path is correct */
508
return TRUE;
509
510
}
app/code/local/Artio/MTurbo/Model/Config/DynamicTransformer.php CHANGED
@@ -55,7 +55,7 @@ class Artio_MTurbo_Model_Config_DynamicTransformer extends Varien_Object
55
56
private $keysDefaultBlocks = null;
57
private $classBlocks = null;
58
-
59
60
/**
61
* Method dermines whether block is default.
@@ -109,31 +109,37 @@ class Artio_MTurbo_Model_Config_DynamicTransformer extends Varien_Object
109
110
111
/**
112
- * Determines whether block is dynamic
113
* @param Mage_Core_Block_Abstract $block
114
* @return bool
115
*/
116
- public function getDynamic($block) {
117
-
118
- $classBlocks = $this->_getClassBlocks();
119
120
121
- $ajaxBlocks = Mage::getSingleton('mturbo/config')->getDynamicBlocksAsArray();
122
- // check
123
- foreach ($ajaxBlocks as $ajaxBlock) {
124
- if ($this->isDefaultBlock($ajaxBlock)) {
125
- if (@is_a($block, $classBlocks[$ajaxBlock])) return $ajaxBlock;
126
- } else {
127
- if ($ajaxBlock==$block->getNameInLayout())
128
- return $ajaxBlock;
129
- else {
130
- if (@is_a($block, $classBlocks[$ajaxBlock]))
131
- return $ajaxBlock;
132
- }
133
- }
134
- }
135
-
136
- return false;
137
}
138
139
@@ -158,6 +164,8 @@ class Artio_MTurbo_Model_Config_DynamicTransformer extends Varien_Object
158
159
$config->setDynamicBlocks(implode(",", array_unique($blocks)));
160
161
}
162
163
@@ -181,7 +189,8 @@ class Artio_MTurbo_Model_Config_DynamicTransformer extends Varien_Object
181
$diff = array_diff($dynamicBlocks, $this->keysDefaultBlocks);
182
$string = implode(",", $diff);
183
$result['userblocks'] = $string;
184
-
185
/* return result */
186
return $result;
187
55
56
private $keysDefaultBlocks = null;
57
private $classBlocks = null;
58
+
59
60
/**
61
* Method dermines whether block is default.
109
110
111
/**
112
+ * Get the dynamic name of $block. If $block is configured
113
+ * as dynamic (by type or by layout name) then method returns
114
+ * block's name in layout else method returns false.
115
+ *
116
+ * If $block is not specified method returns false;
117
+ *
118
* @param Mage_Core_Block_Abstract $block
119
* @return bool
120
*/
121
+ public function getDynamicName($block) {
122
123
+ if (!$block)
124
+ return false;
125
+
126
+ $blockTypes = $this->_getClassBlocks();
127
+ $configBlocks = Mage::getSingleton('mturbo/config')->getDynamicBlocksAsArray();
128
+
129
+ $candidate = false;
130
+
131
+ foreach ($configBlocks as $configBlock)
132
+ {
133
+ $configBlockWithoutLayout = preg_replace('/^[^\$]*\#x2F;', '', $configBlock);
134
135
+ if ($configBlockWithoutLayout == $block->getNameInLayout())
136
+ return $configBlock;
137
+
138
+ if (@is_a($block, $blockTypes[$configBlockWithoutLayout]))
139
+ $candidate = $block->getNameInLayout();
140
+ }
141
+
142
+ return $candidate;
143
}
144
145
164
165
$config->setDynamicBlocks(implode(",", array_unique($blocks)));
166
167
+ if (isset($formData['cartlink']))
168
+ $config->setDynamicCheckoutCartLink($formData['cartlink']);
169
}
170
171
189
$diff = array_diff($dynamicBlocks, $this->keysDefaultBlocks);
190
$string = implode(",", $diff);
191
$result['userblocks'] = $string;
192
+ $result['cartlink'] = $config->getDynamicCheckoutCartLink();
193
+
194
/* return result */
195
return $result;
196
app/code/local/Artio/MTurbo/Model/DownloadMethods/Abstract.php CHANGED
@@ -27,15 +27,17 @@
27
*/
28
abstract class Artio_MTurbo_Model_DownloadMethods_Abstract
29
{
30
-
31
protected $errorMsg = '';
32
33
/**
34
* Retrieves name of download method
35
*/
36
abstract function getName();
37
-
38
-
39
/**
40
* Determines whether download method is ready for using.
41
* @return bool
@@ -45,12 +47,45 @@ abstract class Artio_MTurbo_Model_DownloadMethods_Abstract
45
/**
46
* Method download choosen page by url in argument and retrieves
47
* its contents.
48
- * @param string $url
49
- * @return string contents of downloaded page
50
*/
51
- abstract function downloadPage($url);
52
-
53
-
54
/**
55
* Method retrieve error message.
56
* Error message can appearance only after download any page or after call function isReady.
@@ -61,5 +96,4 @@ abstract class Artio_MTurbo_Model_DownloadMethods_Abstract
61
return $this->errorMsg;
62
}
63
64
- }
65
- ?>
27
*/
28
abstract class Artio_MTurbo_Model_DownloadMethods_Abstract
29
{
30
+
31
protected $errorMsg = '';
32
33
+ protected $batchSize = 1;
34
+
35
/**
36
* Retrieves name of download method
37
*/
38
abstract function getName();
39
+
40
+
41
/**
42
* Determines whether download method is ready for using.
43
* @return bool
47
/**
48
* Method download choosen page by url in argument and retrieves
49
* its contents.
50
+ * @param array $urls
51
+ * @return array contents of downloaded page (url => html)
52
+ */
53
+ abstract function downloadPages($urls);
54
+
55
+
56
+ /**
57
+ * Determine whethe method allows parallel downloading or not.
58
+ *
59
+ * @return bool TRUE method allows parallerl downloading, FALSE method disallows
60
+ */
61
+ public function allowParallelDownloading() {
62
+ return false;
63
+ }
64
+
65
+
66
+ /**
67
+ * Set the number of url downloaded at once. There is allowed to download
68
+ * between 1 to 100 pages.
69
+ *
70
+ * If $size greater than 100 there will be used only 100.
71
+ * If $size is not a number there will be used 1.
72
+ *
73
+ * @param int $size
74
+ * @return Artio_MTurbo_Model_DownloadMethods_Abstract
75
*/
76
+ public function setBatchSize($size) {
77
+
78
+ $size = (int) $size;
79
+
80
+ $size = max( 1, $size);
81
+ $size = min(100, $size);
82
+
83
+ $this->batchSize = $size;
84
+
85
+ return $this;
86
+ }
87
+
88
+
89
/**