MTurbo - Version 1.2.0

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.0
Comparing to
See all releases


Code changes from version 1.1.1 to 1.2.0

Files changed (77) hide show
  1. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Form.php +1 -1
  2. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Actions.php +3 -3
  3. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Category.php +36 -6
  4. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Cms.php +94 -0
  5. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Dynamic.php +144 -0
  6. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/License.php +2 -2
  7. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Main.php +118 -99
  8. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Product.php +10 -2
  9. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Uninstall.php +73 -0
  10. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Url.php +98 -54
  11. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Website.php +160 -0
  12. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tabs.php +0 -5
  13. app/code/local/Artio/MTurbo/Block/Adminhtml/Mturbo.php +10 -8
  14. app/code/local/Artio/MTurbo/Block/Adminhtml/Run.php +9 -6
  15. app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome.php +9 -6
  16. app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php +55 -21
  17. app/code/local/Artio/MTurbo/Block/Ajax.php +69 -0
  18. app/code/local/Artio/MTurbo/Block/Data/Form/Element/Button.php +6 -8
  19. app/code/local/Artio/MTurbo/Block/Data/Form/Element/CategoryTree.php +3 -9
  20. app/code/local/Artio/MTurbo/Block/Data/Form/Element/CmsTree.php +179 -0
  21. app/code/local/Artio/MTurbo/Block/Data/Form/Element/Html.php +40 -0
  22. app/code/local/Artio/MTurbo/Block/Data/Form/Element/NoEscLabel.php +1 -6
  23. app/code/local/Artio/MTurbo/Block/Data/Form/Element/SelectDownloadMethod.php +6 -11
  24. app/code/local/Artio/MTurbo/Block/Data/Form/Element/Time.php +3 -7
  25. app/code/local/Artio/MTurbo/Block/Data/Grid/Column/Blocked.php +1 -6
  26. app/code/local/Artio/MTurbo/Block/Data/Grid/Column/ColorOption.php +54 -0
  27. app/code/local/Artio/MTurbo/Block/Data/Grid/Column/FileSize.php +65 -0
  28. app/code/local/Artio/MTurbo/Block/Data/Grid/Column/SwitchAction.php +172 -0
  29. app/code/local/Artio/MTurbo/Helper/Checker.php +0 -90
  30. app/code/local/Artio/MTurbo/Helper/Data.php +31 -46
  31. app/code/local/Artio/MTurbo/Helper/Downloader.php +110 -113
  32. app/code/local/Artio/MTurbo/Helper/Functions.php +245 -0
  33. app/code/local/Artio/MTurbo/Helper/Info.php +25 -26
  34. app/code/local/Artio/MTurbo/Helper/Website.php +116 -0
  35. app/code/local/Artio/MTurbo/Model/Config.php +318 -628
  36. app/code/local/Artio/MTurbo/Model/Config/CmsTransformer.php +77 -0
  37. app/code/local/Artio/MTurbo/Model/Config/DynamicTransformer.php +190 -0
  38. app/code/local/Artio/MTurbo/Model/Config/Website.php +268 -0
  39. app/code/local/Artio/MTurbo/Model/Config/WebsiteTransformer.php +104 -0
  40. app/code/local/Artio/MTurbo/Model/DownloadMethods/Abstract.php +65 -0
  41. app/code/local/Artio/MTurbo/Model/DownloadMethods/Curl.php +80 -0
  42. app/code/local/Artio/MTurbo/Model/DownloadMethods/Direct.php +100 -0
  43. app/code/local/Artio/MTurbo/Model/DownloadMethods/Filegetcontents.php +69 -0
  44. app/code/local/Artio/MTurbo/Model/DownloadMethods/Socket.php +108 -0
  45. app/code/local/Artio/MTurbo/Model/DownloadMethodsFactory.php +92 -0
  46. app/code/local/Artio/MTurbo/Model/File.php +0 -256
  47. app/code/local/Artio/MTurbo/Model/File.php~ +0 -404
  48. app/code/local/Artio/MTurbo/Model/Htaccess.php +468 -0
  49. app/code/local/Artio/MTurbo/Model/LayoutPatch.php +164 -0
  50. app/code/local/Artio/MTurbo/Model/Mturbo.php +294 -274
  51. app/code/local/Artio/MTurbo/Model/Mturbo.php~ +0 -418
  52. app/code/local/Artio/MTurbo/Model/Mturbo/Event.php +283 -0
  53. app/code/local/Artio/MTurbo/Model/Mturbo/File.php +281 -0
  54. app/code/local/Artio/MTurbo/Model/Mysql4/Mturbo.php +1 -6
  55. app/code/local/Artio/MTurbo/Model/Mysql4/Mturbo/Collection.php +1 -6
  56. app/code/local/Artio/MTurbo/Model/Observer.php +320 -77
  57. app/code/local/Artio/MTurbo/Model/Observer2.php +0 -225
  58. app/code/local/Artio/MTurbo/Model/Patch.php +114 -0
  59. app/code/local/Artio/MTurbo/Model/htaccess/htaccess.txt +13 -19
  60. app/code/local/Artio/MTurbo/Model/htaccess/{htaccessroot.txt → htaccessside.txt} +0 -0
  61. app/code/local/Artio/MTurbo/Model/htaccess/htaccessstore.txt +38 -0
  62. app/code/local/Artio/MTurbo/Model/patches/layout.txt +3 -0
  63. app/code/local/Artio/MTurbo/Model/scripts/wgetlib.so +1 -1
  64. app/code/local/Artio/MTurbo/controllers/Adminhtml/CheckController.php +11 -18
  65. app/code/local/Artio/MTurbo/controllers/Adminhtml/MturboController.php +670 -347
  66. app/code/local/Artio/MTurbo/controllers/AdminhtmlController.php +28 -32
  67. app/code/local/Artio/MTurbo/controllers/IndexController.php +149 -0
  68. app/code/local/Artio/MTurbo/etc/config.xml +51 -3
  69. app/code/local/Artio/MTurbo/sql/mturbo_setup/{mysql4-install-1.0.0.php → mysql4-install-1.2.0.php} +30 -14
  70. app/design/adminhtml/default/default/layout/mturbo.xml +9 -0
  71. app/design/adminhtml/default/default/template/mturbo/demo.phtml +10 -1
  72. app/design/adminhtml/default/default/template/mturbo/grid.phtml +230 -0
  73. app/design/adminhtml/default/default/template/mturbo/version.phtml +33 -0
  74. app/design/frontend/default/default/layout/mturbo.xml +37 -0
  75. app/locale/en_US/Artio_MTurbo.csv +161 -61
  76. package.xml +9 -5
  77. skin/frontend/default/default/js/mturbo.js +81 -0
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Form.php CHANGED
@@ -30,7 +30,7 @@
30
  *
31
  * @category Artio
32
  * @package Artio_MTurbo
33
- * @author Artio <info@artio.net>
34
  */
35
  class Artio_MTurbo_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
  {
30
  *
31
  * @category Artio
32
  * @package Artio_MTurbo
33
+ * @author Artio Magento Team <info@artio.net>
34
  */
35
  class Artio_MTurbo_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
  {
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Actions.php CHANGED
@@ -75,7 +75,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Actions extends Artio_MTurbo_Block_A
75
 
76
  $layoutFieldset->addField('generate_button', 'widget_button', array(
77
  'name' => 'generate_button',
78
- 'label' => $this->getMyHelper()->__('Generate list of rewrite URLs to the file'),
79
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/generateurllist') . "')",
80
  'comment' => $this->getMyHelper()->__(' Generate a list of the URLs and store it on the disk. This action will be executed if Automatic cache management is enabled.')
81
  ));
@@ -90,9 +90,9 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Actions extends Artio_MTurbo_Block_A
90
 
91
  $layoutFieldset->addField('htaccess_button', 'widget_button', array(
92
  'name' => 'htaccess_button',
93
- 'label' => $this->getMyHelper()->__('Rebuild .htaccess'),
94
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/htaccessbuild') . "')",
95
- 'comment' => $this->getMyHelper()->__('Rebuild .htaccess file. First remove MTurbo section and then insert it. At the same time check .htaccess file in turbocache folder'),
96
 
97
  ));
98
 
75
 
76
  $layoutFieldset->addField('generate_button', 'widget_button', array(
77
  'name' => 'generate_button',
78
+ 'label' => $this->getMyHelper()->__('Generate URL list for all websites'),
79
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/generateurllist') . "')",
80
  'comment' => $this->getMyHelper()->__(' Generate a list of the URLs and store it on the disk. This action will be executed if Automatic cache management is enabled.')
81
  ));
90
 
91
  $layoutFieldset->addField('htaccess_button', 'widget_button', array(
92
  'name' => 'htaccess_button',
93
+ 'label' => $this->getMyHelper()->__('Rebuild .htaccess for all websites'),
94
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/htaccessbuild') . "')",
95
+ 'comment' => $this->getMyHelper()->__('Rebuild .htaccess for all websites.'),
96
 
97
  ));
98
 
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Category.php CHANGED
@@ -44,25 +44,55 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Category extends Artio_MTurbo_Block_
44
  protected function _prepareForm() {
45
 
46
  $config = Mage::getSingleton('mturbo/config');
47
- $config->loadAttributes();
48
 
49
  $form = new Varien_Data_Form();
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  $layoutFieldset = $form->addFieldset('categories_fieldset', array(
52
  'legend' => $this->getMyHelper()->__( 'Select categories, where to cache list pages' ),
53
  'class' => 'fieldset'
54
  ));
55
 
 
56
  $layoutFieldset->addType('categories_tree', Artio_MTurbo_Helper_Data::FORM_CATEGORY_TREE);
57
  $layoutFieldset->addField('categories', 'categories_tree', array(
58
- 'name' => 'category_chooser',
59
- 'treeId' => 'category_chooser',
60
- 'categoryIds' => $config->getPreviewCategoryIds(),
61
  'updateElementId' => 'preview_categories',
62
- 'formName' => 'edit_form'
63
  ));
64
 
65
-
 
66
  $this->setForm($form);
67
 
68
  return parent::_prepareForm();
44
  protected function _prepareForm() {
45
 
46
  $config = Mage::getSingleton('mturbo/config');
 
47
 
48
  $form = new Varien_Data_Form();
49
 
50
+ /* fieldset for automatic refresh */
51
+ $layoutFieldsetRefresh = $form->addFieldset('categories_refresh_fieldset', array(
52
+ 'legend' => $this->getMyHelper()->__( 'Automatic refresh settings' ),
53
+ 'class' => 'fieldset'
54
+ ));
55
+
56
+ $layoutFieldsetRefresh->addField('add_newly_category_to_select', 'select', array(
57
+ 'name' => 'add_newly_category_to_select',
58
+ 'label' => $this->getMyHelper()->__('Add newly created categories to select').':',
59
+ 'options' => array(
60
+ 0 => $this->getMyHelper()->__('No'),
61
+ 1 => $this->getMyHelper()->__ ( 'Yes' ) ) ) );
62
+
63
+ $layoutFieldsetRefresh->addField('refresh_category', 'select', array(
64
+ 'name' => 'refresh_category',
65
+ 'label' => $this->getMyHelper()->__('Enable automatic refresh for preview of saved category').':',
66
+ 'options' => array(
67
+ 0 => $this->getMyHelper()->__('No'),
68
+ 1 => $this->getMyHelper()->__ ( 'Yes' ) ) ) );
69
+
70
+ $layoutFieldsetRefresh->addField('refresh_parents_for_category', 'select', array(
71
+ 'name' => 'refresh_parents_for_category',
72
+ 'label' => $this->getMyHelper()->__('Enable automatic refresh for previews of parents of saved category').':',
73
+ 'options' => array(
74
+ 0 => $this->getMyHelper()->__('No'),
75
+ 1 => $this->getMyHelper()->__ ( 'Yes' ) ) ) );
76
+
77
+
78
+ /* fieldset for tree */
79
  $layoutFieldset = $form->addFieldset('categories_fieldset', array(
80
  'legend' => $this->getMyHelper()->__( 'Select categories, where to cache list pages' ),
81
  'class' => 'fieldset'
82
  ));
83
 
84
+ /* tree */
85
  $layoutFieldset->addType('categories_tree', Artio_MTurbo_Helper_Data::FORM_CATEGORY_TREE);
86
  $layoutFieldset->addField('categories', 'categories_tree', array(
87
+ 'name' => 'category_chooser',
88
+ 'treeId' => 'category_chooser',
89
+ 'categoryIds' => $config->getPreviewCategoriesAsArray(),
90
  'updateElementId' => 'preview_categories',
91
+ 'formName' => 'edit_form'
92
  ));
93
 
94
+ /* bind data */
95
+ $form->setValues($config->getData());
96
  $this->setForm($form);
97
 
98
  return parent::_prepareForm();
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Cms.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Artio
22
+ * @package Artio_MTurbo
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ *
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Cms
36
+ extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
37
+ {
38
+
39
+ public function __construct() {
40
+ parent::__construct();
41
+ $this->setId('cms_section');
42
+ $this->_title = $this->getMyHelper()->__('CMS');
43
+ }
44
+
45
+ protected function _prepareForm() {
46
+
47
+ $config = Mage::getSingleton('mturbo/config');
48
+
49
+ $form = new Varien_Data_Form();
50
+
51
+ /* fieldset for automatic refresh */
52
+ $layoutFieldsetRefresh = $form->addFieldset('products_refresh_fieldset', array(
53
+ 'legend' => $this->getMyHelper()->__( 'Automatic refresh settings' ),
54
+ 'class' => 'fieldset'
55
+ ));
56
+
57
+ $layoutFieldsetRefresh->addField('add_newly_cms_to_select', 'select', array(
58
+ 'name' => 'add_newly_cms_to_select',
59
+ 'label' => $this->getMyHelper()->__('Added newly cms to select').':',
60
+ 'options' => array(
61
+ 0 => $this->getMyHelper()->__('No'),
62
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
63
+
64
+ $layoutFieldsetRefresh->addField('refresh_cms', 'select', array(
65
+ 'name' => 'refresh_cms',
66
+ 'label' => $this->getMyHelper()->__('Enable automatic refresh after save CMS pages').':',
67
+ 'options' => array(
68
+ 0 => $this->getMyHelper()->__('No'),
69
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
70
+
71
+
72
+ /* fieldset for tree */
73
+ $layoutFieldset = $form->addFieldset('products_fieldset', array(
74
+ 'legend' => $this->getMyHelper()->__( 'Select CMS pages to cache' ),
75
+ 'class' => 'fieldset'
76
+ ));
77
+
78
+ /* tree */
79
+ $layoutFieldset->addType('cms_tree', Artio_MTurbo_Helper_Data::FORM_CMS_TREE);
80
+ $layoutFieldset->addField('cms_tree', 'cms_tree', array(
81
+ 'name' => 'cms_tree',
82
+ 'with' => $config->getCmsPagesWithStoresAsArray(),
83
+ 'without' => $config->getCmsPagesWithoutStoresAsArray()
84
+ ));
85
+
86
+
87
+ /* bind data */
88
+ $form->setValues($config->getData());
89
+ $this->setForm($form);
90
+
91
+ return parent::_prepareForm();
92
+ }
93
+
94
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Dynamic.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Artio
22
+ * @package Artio_MTurbo
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ *
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Artio Magento Team <jiri.chmiel@artio.cz>
33
+ */
34
+
35
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Dynamic
36
+ extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
37
+ {
38
+
39
+ public function __construct() {
40
+ parent::__construct();
41
+ $this->setId('dynamic_section');
42
+ $this->_title = $this->getMyHelper()->__('Dynamic loaded blocks');
43
+ }
44
+
45
+ protected function _prepareForm() {
46
+
47
+ $config = Mage::getSingleton('mturbo/config');
48
+
49
+ $form = new Varien_Data_Form();
50
+
51
+ $layoutPatch = Mage::getSingleton('mturbo/layoutPatch');
52
+ if ($layoutPatch->needToPatch()) {
53
+ $this->_addLayoutPatchFieldset($form);
54
+ }
55
+
56
+ if (!$layoutPatch->needToPatch() || $layoutPatch->isPatched()) {
57
+
58
+ /* fieldset for automatic refresh */
59
+ $layoutFieldsetDefault = $form->addFieldset('dynamic_block_default', array(
60
+ 'legend' => $this->getMyHelper()->__( 'Default dynamic loaded blocks' ),
61
+ 'class' => 'fieldset'
62
+ ));
63
+
64
+ $layoutFieldsetDefault->addField('cartsidebar', 'select', array(
65
+ 'name' => 'cartsidebar',
66
+ 'label' => $this->getMyHelper()->__('Cart Block (sidebar)').':',
67
+ 'options' => array(
68
+ 0 => $this->getMyHelper()->__('No'),
69
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
70
+
71
+ $layoutFieldsetDefault->addField('pollsidebar', 'select', array(
72
+ 'name' => 'pollsidebar',
73
+ 'label' => $this->getMyHelper()->__('Poll Block (sidebar)').':',
74
+ 'options' => array(
75
+ 0 => $this->getMyHelper()->__('No'),
76
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
77
+
78
+ $layoutFieldsetDefault->addField('comparesidebar', 'select', array(
79
+ 'name' => 'comparesidebar',
80
+ 'label' => $this->getMyHelper()->__('Compare Block (sidebar)').':',
81
+ 'options' => array(
82
+ 0 => $this->getMyHelper()->__('No'),
83
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
84
+
85
+
86
+
87
+ $layoutFieldsetUser = $form->addFieldset('dynamic_block_user', array(
88
+ 'legend' => $this->getMyHelper()->__( 'User dynamic loaded blocks (only for advanced developers).' ),
89
+ 'class' => 'fieldset'
90
+ ));
91
+
92
+ $layoutFieldsetUser->addField('userblocks', 'textarea', array(
93
+ 'name' => 'userblocks',
94
+ 'label' => $this->getMyHelper()->__('Layout names of dynamic loaded blocks').':',
95
+ 'after_element_html' => '<span><i>'.$this->getMyHelper()->__("Values separated by (',').").'</i></span>'));
96
+
97
+ }
98
+
99
+ /* bind data */
100
+ $form->setValues(Mage::getSingleton('mturbo/config_dynamicTransformer')->configToForm($config));
101
+ $this->setForm($form);
102
+
103
+ return parent::_prepareForm();
104
+ }
105
+
106
+ /**
107
+ * Fieldset for layout.
108
+ */
109
+ private function _addLayoutPatchFieldset($form) {
110
+
111
+ $patchModel = Mage::getSingleton('mturbo/layoutPatch');
112
+
113
+ /* make fieldset */
114
+ $layoutFieldset = $form->addFieldset('layout_fieldset', array(
115
+ 'legend' => $this->getMyHelper()->__('Layout patch'),
116
+ 'class' => 'fieldset'));
117
+
118
+ /* button for patch Mage.php */
119
+ $label = $patchModel->isPatched() ?
120
+ Mage::helper('mturbo')->__('Remove Layout Patch') :
121
+ Mage::helper('mturbo')->__('Apply Layout Patch');
122
+
123
+ if ($patchModel->isWriteable()) {
124
+
125
+ $layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
126
+ $layoutFieldset->addField('laypatch_button', 'widget_button', array(
127
+ 'name' => 'laypatch_button',
128
+ 'label' => $label,
129
+ 'style' => 'width:800px',
130
+ 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/layoutpatch') . "')",
131
+ 'comment' => $this->getMyHelper()->__('This patch is required for dynamic loaded blocks. (Patched file: app/code/core/Mage/Core/Model/Layout.php)')));
132
+
133
+ } else {
134
+
135
+ $scriptPath = $patchModel->getLayoutPath();
136
+ $layoutFieldset->addField ( 'layoutstate', 'html_element',
137
+ array ('label' => '<h4>'.$this->getMyHelper()->__('Layout state').'</h4>',
138
+ 'code' => '<span style="color:red">'.Mage::helper('mturbo')->__("Model '%s' is not writeable. Please change permission to write for patch.", $scriptPath).'</span>'));
139
+ }
140
+
141
+
142
+ }
143
+
144
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/License.php CHANGED
@@ -64,8 +64,8 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_License extends Artio_MTurbo_Block_A
64
  ));
65
  $layoutFieldset->addType('noesclabel', Artio_MTurbo_Helper_Data::FORM_NO_ESC_LABEL);
66
 
67
- $layoutFieldset->addField('licenseid', 'text', array(
68
- 'name' => 'licenseid',
69
  'label' => $this->getMyHelper()->__('Your Download ID').':',
70
  'value' => ''
71
  ));
64
  ));
65
  $layoutFieldset->addType('noesclabel', Artio_MTurbo_Helper_Data::FORM_NO_ESC_LABEL);
66
 
67
+ $layoutFieldset->addField('download_id', 'text', array(
68
+ 'name' => 'download_id',
69
  'label' => $this->getMyHelper()->__('Your Download ID').':',
70
  'value' => ''
71
  ));
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Main.php CHANGED
@@ -12,41 +12,53 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
27
  {
28
 
29
  /**
 
30
  * @var Varien_Data_Form
31
  */
32
  private $form;
33
-
34
- public function __construct() {
 
 
 
35
  parent::__construct();
 
36
  $this->setId('main_section');
37
- $this->_title = $this->getMyHelper()->__('Options');
38
  }
39
 
40
  protected function _prepareForm() {
41
 
42
  $config = Mage::getSingleton('mturbo/config');
43
 
 
44
  $this->form = new Varien_Data_Form();
45
- $this->_addGeneralFieldset();
46
- $this->_addHomepageFieldset();
47
- //$this->_addAutomaticDownloadFieldset(); DEMO VERSION
48
  $this->_addDownloadMethodFieldset();
 
 
49
 
 
50
  $this->form->setValues($config->getData());
51
  $this->setForm($this->form);
52
 
@@ -54,107 +66,77 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Admi
54
 
55
  }
56
 
57
- private function _addGeneralFieldset() {
58
-
59
- $layoutFieldset = $this->form->addFieldset('general_fieldset', array(
60
- 'legend' => $this->getMyHelper()->__('General Options'),
61
- 'class' => 'fieldset'
62
- ));
 
 
 
63
 
 
64
  $layoutFieldset->addField('turbopath', 'text', array(
65
  'name' => 'turbopath',
66
- 'label' => $this->getMyHelper()->__('Cache Path').':',
67
- 'value' => 'var/turbocache'
68
- ));
69
-
70
- $layoutFieldset->addField('multistoreview', 'select', array(
71
- 'name' => 'multistoreview',
72
- 'label' => $this->getMyHelper()->__('Enable multi-storeview').':',
73
- 'options' => array(
74
- 0 => $this->getMyHelper()->__('No'),
75
- 1 => $this->getMyHelper()->__('Yes'))
76
- ));
77
-
78
- $layoutFieldset->addField('refreshsave', 'select', array(
79
- 'name' => 'refreshsave',
80
- 'label' => $this->getMyHelper()->__('Refresh cache after product or category save').':',
81
- 'options' => array(
82
- 0 => $this->getMyHelper()->__('No'),
83
- 1 => $this->getMyHelper()->__('Yes'))
84
- ));
85
-
86
  }
87
 
 
 
 
88
  private function _addAutomaticDownloadFieldset() {
89
 
 
90
  $layoutFieldset = $this->form->addFieldset('download_fieldset', array(
91
  'legend' => $this->getMyHelper()->__('Automatic cache management'),
92
- 'class' => 'fieldset'
93
- ));
94
-
95
- $layoutFieldset->addField('automaticdownload', 'select', array(
96
- 'name' => 'automaticdownload',
97
- 'label' => $this->getMyHelper()->__('Enable automatic cache refresh').':',
98
- 'options' => array(
99
- 0 => $this->getMyHelper()->__('No'),
100
- 1 => $this->getMyHelper()->__('Yes'))
101
- ));
102
-
103
- $layoutFieldset->addType('crontime', Artio_MTurbo_Helper_Data::FORM_CRON_HOUR_TIME);
104
- $layoutFieldset->addField('downloadtime', 'crontime', array(
105
- 'name' => 'downloadtime',
106
- 'label' => $this->getMyHelper()->__('Download time').':',
107
- 'style' => 'display:inline;width:40px;'
108
- ));
109
-
110
- $layoutFieldset->addField('lastdownload', 'label', array(
111
- 'name' => 'lastdownload',
112
- 'label' => $this->getMyHelper()->__('Last download').':',
113
- 'style' => 'height:24em;',
114
- 'disabled' => true
115
- ));
116
-
117
-
118
 
119
- }
120
-
121
-
122
- private function _addHomepageFieldset() {
123
-
124
- $layoutFieldset = $this->form->addFieldset('homepage_fieldset', array(
125
- 'legend' => $this->getMyHelper()->__('Homepage Cache Options'),
126
- 'class' => 'fieldset'
127
- ));
128
 
129
- $layoutFieldset->addField('homepage', 'select', array(
130
- 'name' => 'homepage',
131
- 'label' => $this->getMyHelper()->__('Cache homepage').':',
 
132
  'options' => array(
133
  0 => $this->getMyHelper()->__('No'),
134
- 1 => $this->getMyHelper()->__('Yes'))
135
- ));
136
-
137
- }
138
-
139
- private function _addDownloadMethodFieldset() {
140
-
141
- $layoutFieldset = $this->form->addFieldset('downloadmethod_fieldset', array(
142
- 'legend' => $this->getMyHelper()->__('Choice download method'),
143
- 'class' => 'fieldset'
144
- ));
145
-
146
- $layoutFieldset->addType('selectdmet', Artio_MTurbo_Helper_Data::FORM_SELECT_DOW);
147
- $layoutFieldset->addField('downloadmethod', 'selectdmet', array(
148
- 'name' => 'downloadmethod',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  'label' => $this->getMyHelper()->__('Download method').':',
150
- 'options' => array(
151
- DownloadMethods::FILE_GET_CONTENTS => $this->getMyHelper()->__('Use function "file_get_contents"'),
152
- DownloadMethods::SOCKET => $this->getMyHelper()->__('Create connection over sockets'),
153
- DownloadMethods::CURL => $this->getMyHelper()->__('Use CURL PHP extension'),
154
- DownloadMethods::DIRECT_ACCESS => $this->getMyHelper()->__('Direct access (created new instance Magento)'))
155
- ));
156
 
157
- $label = Artio_MTurbo_Helper_Data::getConfig()->isPatched() ?
 
158
  Mage::helper('mturbo')->__('Remove Mage Patch') :
159
  Mage::helper('mturbo')->__('Apply Mage Patch');
160
 
@@ -163,9 +145,46 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Main extends Artio_MTurbo_Block_Admi
163
  'name' => 'patch_button',
164
  'label' => $label,
165
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/magepatch') . "')",
166
- 'comment' => $this->getMyHelper()->__('Apply the patch only just in case you need to use Direct Access download method!')
167
- ));
168
 
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
18
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
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
+ *
27
+ * @category Artio
28
+ * @package Artio_MTurbo
29
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
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
  }
49
 
50
  protected function _prepareForm() {
51
 
52
  $config = Mage::getSingleton('mturbo/config');
53
 
54
+ /* make form */
55
  $this->form = new Varien_Data_Form();
56
+ $this->_addTurboPathFieldset();
 
 
57
  $this->_addDownloadMethodFieldset();
58
+ $this->_addViewSizeMethodFieldset();
59
+ $this->_addHtaccessFieldset();
60
 
61
+ /* bind data */
62
  $this->form->setValues($config->getData());
63
  $this->setForm($this->form);
64
 
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/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',
102
+ 'label' => $this->getMyHelper()->__('Enable automatic cache refresh').':',
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 );
133
+ $layoutFieldset->addField('download_method', 'selectdmet', array(
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
 
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
  }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Product.php CHANGED
@@ -29,12 +29,20 @@
29
  *
30
  * @category Artio
31
  * @package Artio_MTurbo
32
- * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
 
35
  class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Product
36
  extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
37
  {
38
 
 
 
 
 
 
39
 
40
- }
 
 
 
29
  *
30
  * @category Artio
31
  * @package Artio_MTurbo
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
 
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
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Uninstall.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Artio
22
+ * @package Artio_MTurbo
23
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Uninstall extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
27
+ {
28
+
29
+ /**
30
+ * @var Varien_Data_Form
31
+ */
32
+ private $form;
33
+
34
+ public function __construct() {
35
+ parent::__construct();
36
+ $this->setId('action_section');
37
+ $this->_title = $this->getMyHelper()->__('Uninstall');
38
+ }
39
+
40
+ protected function _prepareForm() {
41
+
42
+ $config = Mage::getSingleton('mturbo/config');
43
+
44
+ $this->form = new Varien_Data_Form();
45
+ $this->_addActionFieldset();
46
+
47
+ $this->form->setValues($config->getData());
48
+ $this->setForm($this->form);
49
+
50
+ return parent::_prepareForm();
51
+
52
+ }
53
+
54
+ private function _addActionFieldset() {
55
+
56
+ $layoutFieldset = $this->form->addFieldset('uninstall_fieldset', array(
57
+ 'legend' => $this->getMyHelper()->__('Uninstall M-Turbo'),
58
+ 'class' => 'fieldset'
59
+ ));
60
+
61
+ $layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
62
+ $layoutFieldset->addField('clear_button', 'widget_button', array(
63
+ 'name' => 'clear_button',
64
+ 'label' => $this->getMyHelper()->__('Uninstall M-Turbo'),
65
+ 'style' => 'width:850px',
66
+ 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/uninstall') . "')",
67
+ 'comment' => $this->getMyHelper()->__('This action completely removes M-Turbo from your Magento')
68
+ ));
69
+
70
+
71
+ }
72
+
73
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Url.php CHANGED
@@ -12,26 +12,19 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
  /**
28
- *
29
  *
30
- * @category Artio
31
- * @package Artio_MTurbo
32
- * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
-
35
  class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
36
  extends Mage_Adminhtml_Block_Widget_Grid
37
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
@@ -57,7 +50,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
57
  protected function _afterLoadCollection() {
58
 
59
  foreach ($this->getCollection() as $model) {
60
- $model->checkExist();
61
  }
62
 
63
  }
@@ -66,20 +59,17 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
66
 
67
  $this->addColumn('mturbo_id', array(
68
  'header' => Mage::helper('mturbo')->__('ID'),
69
- 'align' =>'right',
70
- 'width' => '50px',
71
  'index' => 'mturbo_id',
72
  ));
73
 
74
- if (!Mage::app()->isSingleStoreMode()) {
75
  $this->addColumn('store_id', array(
76
  'header' => $this->__('Store View'),
77
- 'width' => '200px',
78
  'index' => 'store_id',
79
  'type' => 'store',
80
  'store_view' => true,
81
  ));
82
- }
83
 
84
  $this->addColumn('url', array(
85
  'header' => Mage::helper('mturbo')->__('Request path'),
@@ -87,17 +77,30 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
87
  'index' => 'request_path',
88
  ));
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  $this->addColumn('exist', array(
91
  'header' => Mage::helper('mturbo')->__('Cached'),
92
- 'align' =>'left',
93
  'type' => 'select',
94
  'index' => 'exist',
95
  'filter' => false,
96
  'sortable' => false,
97
- 'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_Blocked(),
98
  'options' => array(
99
- 1 => Mage::helper('mturbo')->__('Not cached'),
100
- 0 => Mage::helper('mturbo')->__('Cached')
101
  )
102
  ));
103
 
@@ -107,13 +110,22 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
107
  'type' => 'datetime',
108
  'index' => 'last_refresh',
109
  'filter' => false,
110
- 'sortable' => false
 
 
 
 
 
 
 
 
 
 
111
  ));
112
 
113
  $this->addColumn('blocked', array(
114
  'header' => Mage::helper('mturbo')->__('Status'),
115
  'align' => 'center',
116
- 'width' => '80px',
117
  'index' => 'blocked',
118
  'type' => 'options',
119
  'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_Blocked(),
@@ -125,16 +137,16 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
125
 
126
  $this->addColumn('action2',
127
  array(
128
- 'header' => Mage::helper('mturbo')->__('Cache'),
129
  'width' => '50px',
130
- 'type' => 'action',
131
- 'getter' => 'getId',
132
  'actions' => array(
133
  array(
134
- 'caption' => Mage::helper('mturbo')->__('Cache'),
135
- 'url' => array(
136
- 'base'=>'*/*/refresh',
137
- ),
138
  'field' => 'id'
139
  )
140
  ),
@@ -142,6 +154,25 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
142
  'sortable' => false,
143
  ));
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  return parent::_prepareColumns();
146
  }
147
 
@@ -151,10 +182,6 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
151
  $this->getMassactionBlock()->setTemplate('mturbo/massaction.phtml');
152
  $this->getMassactionBlock()->setFormFieldName('mturbo');
153
 
154
- /* $this->getMassactionBlock()->addItem('refresh', array(
155
- 'label' => Mage::helper('mturbo')->__('Refresh'),
156
- 'url' => $this->getUrl('*//**//*massRefresh')
157
- ));*/
158
 
159
  $this->getMassactionBlock()->addItem('block', array(
160
  'label' => Mage::helper('mturbo')->__('Block'),
@@ -166,6 +193,16 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
166
  'url' => $this->getUrl('*/*/massUnblock')
167
  ));
168
 
 
 
 
 
 
 
 
 
 
 
169
  $this->getMassactionBlock()->addItem('delete', array(
170
  'label' => Mage::helper('mturbo')->__('Delete'),
171
  'url' => $this->getUrl('*/*/massDelete'),
@@ -178,22 +215,34 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
178
  public function getMainButtonsHtml()
179
  {
180
  $html = '';
181
- if($this->getFilterVisibility()){
182
- //$html.= '<span>'.Mage::helper('mturbo')->__('Before synchronization must be configuration saved').'</span>';
183
- $html.= Mage::getSingleton('core/layout')
184
- ->createBlock('adminhtml/widget_button', '', array(
185
- 'label' => Mage::helper('mturbo')->__('Cache selected pages'),
186
- 'type' => 'button',
187
- 'onclick' => $this->_getOnClickScript()
188
- ))->toHtml();
189
- $html.= '<input type="hidden" name="massrefresh" id="massrefresh" value="" />';
190
- $html.= $this->getResetFilterButtonHtml();
191
- $html.= $this->getSearchButtonHtml();
192
- }
 
 
 
 
 
 
193
  return $html;
194
  }
195
 
196
- private function _getOnClickScript() {
 
 
 
 
 
 
197
  return "this.form.target='_blank';
198
  $('massrefresh').value = url_section_massactionJsObject.checkedString;
199
  this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/massRefresh')."';
@@ -202,11 +251,6 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
202
  this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/index')."';
203
  this.form.submit();";
204
  }
205
-
206
- public function getRowUrl($row)
207
- {
208
- //return $this->getUrl('*/*/edit', array('id' => $row->getId()));
209
- }
210
 
211
  /**
212
  * Prepare label for tab
@@ -248,4 +292,4 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Url
248
  return false;
249
  }
250
 
251
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
21
  /**
22
+ * Grid tab.
23
  *
24
+ * @category Artio
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
50
  protected function _afterLoadCollection() {
51
 
52
  foreach ($this->getCollection() as $model) {
53
+ $model->loadFileInformation();
54
  }
55
 
56
  }
59
 
60
  $this->addColumn('mturbo_id', array(
61
  'header' => Mage::helper('mturbo')->__('ID'),
62
+ 'width' => '15px',
63
+ 'align' => 'center',
64
  'index' => 'mturbo_id',
65
  ));
66
 
 
67
  $this->addColumn('store_id', array(
68
  'header' => $this->__('Store View'),
 
69
  'index' => 'store_id',
70
  'type' => 'store',
71
  'store_view' => true,
72
  ));
 
73
 
74
  $this->addColumn('url', array(
75
  'header' => Mage::helper('mturbo')->__('Request path'),
77
  'index' => 'request_path',
78
  ));
79
 
80
+ $this->addColumn('type', array(
81
+ 'header' => Mage::helper('mturbo')->__('Type'),
82
+ 'align' => 'left',
83
+ 'type' => 'options',
84
+ 'index' => 'type',
85
+ 'options' => array(
86
+ 'category' => Mage::helper('mturbo')->__('Category view'),
87
+ 'product' => Mage::helper('mturbo')->__('Product detail'),
88
+ 'cms' => Mage::helper('mturbo')->__('CMS page'),
89
+ 'unknow' => Mage::helper('mturbo')->__('Other')
90
+ )
91
+ ));
92
+
93
  $this->addColumn('exist', array(
94
  'header' => Mage::helper('mturbo')->__('Cached'),
95
+ 'align' => 'center',
96
  'type' => 'select',
97
  'index' => 'exist',
98
  'filter' => false,
99
  'sortable' => false,
100
+ 'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_ColorOption(array(0=>'red',1=>'green')),
101
  'options' => array(
102
+ 0 => Mage::helper('mturbo')->__('Not cached'),
103
+ 1 => Mage::helper('mturbo')->__('Cached')
104
  )
105
  ));
106
 
110
  'type' => 'datetime',
111
  'index' => 'last_refresh',
112
  'filter' => false,
113
+ 'sortable' => false
114
+ ));
115
+
116
+ $this->addColumn('size', array(
117
+ 'header' => Mage::helper('mturbo')->__('Size'),
118
+ 'align' => 'left',
119
+ 'type' => 'text',
120
+ 'index' => 'page_size',
121
+ 'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_FileSize(),
122
+ 'filter' => false,
123
+ 'sortable' => false,
124
  ));
125
 
126
  $this->addColumn('blocked', array(
127
  'header' => Mage::helper('mturbo')->__('Status'),
128
  'align' => 'center',
 
129
  'index' => 'blocked',
130
  'type' => 'options',
131
  'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_Blocked(),
137
 
138
  $this->addColumn('action2',
139
  array(
140
+ 'header' => '',
141
  'width' => '50px',
142
+ 'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_SwitchAction(),
143
+ 'getter' => 'getId',
144
  'actions' => array(
145
  array(
146
+ 'captions' => array(Mage::helper('mturbo')->__('Purge')=>array('exist'=>true),
147
+ Mage::helper('mturbo')->__('Cache')=>array('exist'=>false),
148
+ '_'=>array('blocked'=>true)),
149
+ 'url' => array('base' => '*/*/refresh',),
150
  'field' => 'id'
151
  )
152
  ),
154
  'sortable' => false,
155
  ));
156
 
157
+
158
+ $this->addColumn('action3',
159
+ array(
160
+ 'header' => '',
161
+ 'width' => '50px',
162
+ 'renderer' => new Artio_MTurbo_Block_Data_Grid_Column_SwitchAction(),
163
+ 'getter' => 'getId',
164
+ 'actions' => array(
165
+ array(
166
+ 'captions' => array(Mage::helper('mturbo')->__('Preview')=>array('exist'=>true),'_'=>array('exist'=>false)),
167
+ 'url' => array('base'=>'*/*/preview'),
168
+ 'field' => 'id',
169
+ 'popup' => true
170
+ )
171
+ ),
172
+ 'filter' => false,
173
+ 'sortable' => false,
174
+ ));
175
+
176
  return parent::_prepareColumns();
177
  }
178
 
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'),
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'),
215
  public function getMainButtonsHtml()
216
  {
217
  $html = '';
218
+
219
+ $html.= Mage::getSingleton('core/layout')
220
+ ->createBlock('adminhtml/widget_button', '', array(
221
+ 'label' => Mage::helper('mturbo')->__('Cache selected pages'),
222
+ 'type' => 'button',
223
+ 'onclick' => $this->_getOnClickCache()
224
+ ))->toHtml();
225
+ //$html.= '<input type="hidden" name="massrefresh" id="massrefresh" value="" />';
226
+ $html.= Mage::getSingleton('core/layout')
227
+ ->createBlock('adminhtml/widget_button', '', array(
228
+ 'label' => Mage::helper('mturbo')->__('Synchronize'),
229
+ 'type' => 'button',
230
+ 'onclick' => $this->_getOnClickSynchronize()
231
+ ))->toHtml();
232
+ $html.= '<input type="hidden" name="massrefresh" id="massrefresh" value="" />';
233
+ $html.= $this->getResetFilterButtonHtml();
234
+ $html.= $this->getSearchButtonHtml();
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 "this.form.target='_blank';
247
  $('massrefresh').value = url_section_massactionJsObject.checkedString;
248
  this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/massRefresh')."';
251
  this.form.action = '".Mage::helper('adminhtml')->getUrl('*/*/index')."';
252
  this.form.submit();";
253
  }
 
 
 
 
 
254
 
255
  /**
256
  * Prepare label for tab
292
  return false;
293
  }
294
 
295
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Website.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Configuration tab for websites.
24
+ * Number of fieldsets equals to number of enabled website.
25
+ * Demo version has only one website.
26
+ *
27
+ * @category Artio
28
+ * @package Artio_MTurbo
29
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
30
+ */
31
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Website extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
32
+ {
33
+
34
+ /**
35
+ * @var Varien_Data_Form
36
+ */
37
+ private $form;
38
+
39
+ /**
40
+ * Constructor.
41
+ */
42
+ public function __construct() {
43
+ parent::__construct();
44
+ $this->setId('website_section');
45
+ $this->_title = $this->getMyHelper()->__('Websites Configuration');
46
+ }
47
+
48
+ /**
49
+ * (non-PHPdoc)
50
+ * @see Mage_Adminhtml_Block_Widget_Form::_prepareForm()
51
+ */
52
+ protected function _prepareForm() {
53
+
54
+ $config = Mage::getSingleton('mturbo/config');
55
+
56
+ /* make form */
57
+ $this->form = new Varien_Data_Form();
58
+
59
+ /* for every website add one fieldset */
60
+ $websiteCollection = Mage::getModel('core/website')->getCollection()->load();
61
+ foreach ($websiteCollection as $website) {
62
+ $this->_addWebsiteFieldset($website);
63
+ break;
64
+ }
65
+
66
+ /* bind data */
67
+ $this->form->setValues(Mage::getSingleton('mturbo/config_websiteTransformer')->configToForm($config));
68
+ $this->setForm($this->form);
69
+
70
+ return parent::_prepareForm();
71
+
72
+ }
73
+
74
+
75
+ /**
76
+ * Method add website fieldset to the form.
77
+ * @param Mage_Core_Model_Website $website
78
+ */
79
+ private function _addWebsiteFieldset($website) {
80
+
81
+ $prefixWeb = 'website_'.$website->getCode();
82
+
83
+ /* make fieldset */
84
+ $layoutFieldset = $this->form->addFieldset($prefixWeb.'_fieldset', array(
85
+ 'legend' => $this->getMyHelper()->__($website->getName() . ' settings'),
86
+ 'class' => 'fieldset'));
87
+
88
+ /* add extra user control */
89
+ $layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
90
+ $layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
91
+
92
+ /* indicator whether website is enabled */
93
+ $layoutFieldset->addField($prefixWeb.'_enabled', 'select', array(
94
+ 'name' => $prefixWeb.'_enabled',
95
+ 'label' => $this->getMyHelper()->__('Enable website').':',
96
+ 'options' => array(
97
+ 0 => $this->getMyHelper()->__('No'),
98
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
99
+
100
+ /* add field for turbopath */
101
+ $layoutFieldset->addField($prefixWeb.'_base_dir', 'text', array(
102
+ 'name' => $prefixWeb.'_base_dir',
103
+ 'label' => $this->getMyHelper()->__('Base directory').':'));
104
+
105
+ $layoutFieldset->addField ( $prefixWeb.'_dec1', 'html_element',
106
+ array ('label' => '<h4>'.$this->getMyHelper()->__('Enable/Disable Storeview').'</h4>',
107
+ 'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>'));
108
+
109
+ /* every store has one select determines whether enabled is */
110
+ foreach ($website->getStores() as $store)
111
+ if ($store->getIsActive())
112
+ $layoutFieldset->addField($prefixWeb.'_store_'.$store->getCode(), 'select', array(
113
+ 'name' => $prefixWeb.'_store_'.$store->getCode(),
114
+ 'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
115
+ 'options' => array(
116
+ 0 => $this->getMyHelper()->__('No'),
117
+ 1 => $this->getMyHelper()->__ ( 'Yes' ))));
118
+
119
+ $layoutFieldset->addField ( $prefixWeb.'_dec2', 'html_element',
120
+ array ('label' => '<h4>'.$this->getMyHelper()->__('Htaccess settings').'</h4>',
121
+ 'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>' ));
122
+
123
+
124
+ /* get htaccess state and set color by it */
125
+ $htaccess = Mage::getModel('mturbo/htaccess')->setWebsiteCode($website->getCode());
126
+ $state = '';
127
+ $pathToHtaccess = $htaccess->getPathToBaseHtaccess();
128
+ $color = (Mage::helper('mturbo/functions')->get_file_state($pathToHtaccess, $state, 'ew')) ? 'green' : 'red';
129
+
130
+ $layoutFieldset->addField ( $prefixWeb.'_dec3', 'html_element',
131
+ array ('label' => $this->getMyHelper()->__('File .htaccess path'),
132
+ 'code' => '<span>'.$pathToHtaccess.'</span>' ));
133
+
134
+ $edit = $htaccess->isEditedByMTurbo() ? 'yes' : 'no';
135
+
136
+ $layoutFieldset->addField ( $prefixWeb.'_dec5', 'html_element',
137
+ array ('label' => $this->getMyHelper()->__('Edited by MTurbo'),
138
+ 'code' => '<span><b>'.$this->getMyHelper()->__($edit).'</b></span>' ));
139
+
140
+ $layoutFieldset->addField ( $prefixWeb.'_dec4', 'html_element',
141
+ array ('label' => $this->getMyHelper()->__('File .htaccess state'),
142
+ 'code' => '<span style="color:'.$color.'">'.$this->getMyHelper()->__($state).'</span>' ));
143
+
144
+ /* button 'rebuild' show only if htaccess is ready */
145
+ if ($color=='green')
146
+ $layoutFieldset->addField($prefixWeb.'_htaccess_button', 'widget_button', array(
147
+ 'name' => $prefixWeb.'_htaccess_button',
148
+ 'label' => $this->getMyHelper()->__('Rebuild .htaccess for this website'),
149
+ 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/htaccessbuild', array('websitecode'=>$website->getCode())) . "')"
150
+ ));
151
+
152
+ $layoutFieldset->addField($prefixWeb.'_urllist_button', 'widget_button', array(
153
+ 'name' => $prefixWeb.'_urllist_button',
154
+ 'label' => $this->getMyHelper()->__('Generate URL list for this website'),
155
+ 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/generateurllist', array('websitecode'=>$website->getCode())) . "')"
156
+ ));
157
+
158
+ }
159
+
160
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tabs.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
app/code/local/Artio/MTurbo/Block/Adminhtml/Mturbo.php CHANGED
@@ -12,17 +12,20 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_Block_Adminhtml_MTurbo extends Mage_Adminhtml_Block_Widget_Form_Container
27
  {
28
 
@@ -37,10 +40,9 @@ class Artio_MTurbo_Block_Adminhtml_MTurbo extends Mage_Adminhtml_Block_Widget_Fo
37
  $this->_removeButton('reset');
38
  $this->_removeButton('back');
39
  $this->_updateButton('save', 'label', Mage::helper('mturbo')->__('Save configuration'));
40
- $this->_addButton('upgrade', array(
41
  'label' => Mage::helper('mturbo')->__('Upgrade to Full Version'),
42
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/upgrade') . "')"), -1);
43
-
44
  }
45
 
46
  /**
@@ -61,4 +63,4 @@ class Artio_MTurbo_Block_Adminhtml_MTurbo extends Mage_Adminhtml_Block_Widget_Fo
61
  protected function _isAllowedAction($action) {
62
  return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
63
  }
64
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
18
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
+
22
+ /**
23
+ * Main container
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team <info@artio.net>
28
+ */
29
  class Artio_MTurbo_Block_Adminhtml_MTurbo extends Mage_Adminhtml_Block_Widget_Form_Container
30
  {
31
 
40
  $this->_removeButton('reset');
41
  $this->_removeButton('back');
42
  $this->_updateButton('save', 'label', Mage::helper('mturbo')->__('Save configuration'));
43
+ $this->_addButton('upgrade', array(
44
  'label' => Mage::helper('mturbo')->__('Upgrade to Full Version'),
45
  'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/upgrade') . "')"), -1);
 
46
  }
47
 
48
  /**
63
  protected function _isAllowedAction($action) {
64
  return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
65
  }
66
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Run.php CHANGED
@@ -12,17 +12,20 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
27
  {
28
 
@@ -293,4 +296,4 @@ class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
293
  return $this->getUrl('*/*/downloadRun');
294
  }
295
 
296
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
18
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
+
22
+ /**
23
+ * Indicator downloading pages.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team <info@artio.net>
28
+ */
29
  class Artio_MTurbo_Block_Adminhtml_Run extends Mage_Adminhtml_Block_Abstract
30
  {
31
 
296
  return $this->getUrl('*/*/downloadRun');
297
  }
298
 
299
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome.php CHANGED
@@ -12,17 +12,20 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_Block_Adminhtml_Welcome extends Mage_Adminhtml_Block_Widget_Form_Container
27
  {
28
 
@@ -54,4 +57,4 @@ class Artio_MTurbo_Block_Adminhtml_Welcome extends Mage_Adminhtml_Block_Widget_F
54
  return '<div style="width:50%;margin:0 auto;font-weight:bold;">'.$html.'</div>';
55
  }
56
 
57
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
18
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
+
22
+ /**
23
+ * Welcome page. Showed at first executed MTurbo Management.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team <info@artio.net>
28
+ */
29
  class Artio_MTurbo_Block_Adminhtml_Welcome extends Mage_Adminhtml_Block_Widget_Form_Container
30
  {
31
 
57
  return '<div style="width:50%;margin:0 auto;font-weight:bold;">'.$html.'</div>';
58
  }
59
 
60
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
@@ -26,7 +21,7 @@
26
 
27
 
28
  /**
29
- * Adminhtml cms block edit form
30
  *
31
  * @category Artio
32
  * @package Artio_MTurbo
@@ -56,6 +51,13 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
56
  'value' => 'var/turbocache'
57
  ));
58
 
 
 
 
 
 
 
 
59
  $form->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
60
  $form->addField('install_button', 'widget_button', array(
61
  'name' => 'install_button',
@@ -69,27 +71,59 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
69
  return parent::_prepareForm();
70
  }
71
 
72
- protected function _afterToHtml($html) {
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- if (true) {
 
 
75
 
76
- if (Artio_MTurbo_Helper_Checker::checkPermission()) {
77
- $html = $this->_getOkText() . $html;
78
- } else {
79
- $html = $this->_wrapErrorDiv(Mage::helper('mturbo')->__("I can't write to .htaccess, please change permission."));
80
- }
81
-
82
- } else {
83
- $html = $this->_wrapErrorDiv( Mage::helper('mturbo')->__('No file is decoded. Probably, your licence is not loaded on server.') );
84
- }
85
 
86
- return $html;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
  private function _getOkText() {
90
- $text = Mage::helper('mturbo')->__('Welcome to M-Turbo Cache developed by Artio.
91
- To complete installation, we need to have entered the path to your directory where you want to store cached pages.
92
- This path is then entered into a .htaccess file, which is a function of the components necessary.');
93
  return $this->_wrapInfoDiv($text);
94
  }
95
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
21
 
22
 
23
  /**
24
+ * Installation form. Showed at first execute MTurbo Management.
25
  *
26
  * @category Artio
27
  * @package Artio_MTurbo
51
  'value' => 'var/turbocache'
52
  ));
53
 
54
+ /* for every website add one fieldset */
55
+ $websiteCollection = Mage::getModel('core/website')->getCollection()->load();
56
+ foreach ($websiteCollection as $website) {
57
+ $this->_addWebsiteFieldset($website, $form);
58
+ break;
59
+ }
60
+
61
  $form->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
62
  $form->addField('install_button', 'widget_button', array(
63
  'name' => 'install_button',
71
  return parent::_prepareForm();
72
  }
73
 
74
+ /**
75
+ * Method add website fieldset to the form.
76
+ * @param Mage_Core_Model_Website $website
77
+ */
78
+ private function _addWebsiteFieldset($website, $form) {
79
+
80
+ $prefixWeb = 'website_'.$website->getCode();
81
+
82
+ /* make fieldset */
83
+ $layoutFieldset = $form->addFieldset($prefixWeb.'_fieldset', array(
84
+ 'legend' => Mage::helper('mturbo')->__($website->getName() . ' settings'),
85
+ 'class' => 'fieldset'));
86
 
87
+ /* add extra user control */
88
+ $layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
89
+ $layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
90
 
91
+ /* indicator whether website is enabled */
92
+ $layoutFieldset->addField($prefixWeb.'_enabled', 'select', array(
93
+ 'name' => $prefixWeb.'_enabled',
94
+ 'label' => Mage::helper('mturbo')->__('Enable website').':',
95
+ 'value' => '1',
96
+ 'options' => array(
97
+ 0 => Mage::helper('mturbo')->__('No'),
98
+ 1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
 
99
 
100
+ /* add field for turbopath */
101
+ $layoutFieldset->addField($prefixWeb.'_base_dir', 'text', array(
102
+ 'name' => $prefixWeb.'_base_dir',
103
+ 'value' => Mage::getBaseDir(),
104
+ 'label' => Mage::helper('mturbo')->__('Base directory').':'));
105
+
106
+ /* every store has one select determines whether enabled is */
107
+ foreach ($website->getStores() as $store)
108
+ if ($store->getIsActive())
109
+ $layoutFieldset->addField($prefixWeb.'_store_'.$store->getCode(), 'select', array(
110
+ 'name' => $prefixWeb.'_store_'.$store->getCode(),
111
+ 'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
112
+ 'value' => '1',
113
+ 'options' => array(
114
+ 0 => Mage::helper('mturbo')->__('No'),
115
+ 1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
116
+
117
+
118
+
119
+ }
120
+
121
+ protected function _afterToHtml($html) {
122
+ return $this->_getOkText() . $html;
123
  }
124
 
125
  private function _getOkText() {
126
+ $text = Mage::helper('mturbo')->__('Welcome text demo');
 
 
127
  return $this->_wrapInfoDiv($text);
128
  }
129
 
app/code/local/Artio/MTurbo/Block/Ajax.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Main container
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (info@artio.net)
28
+ */
29
+ class Artio_MTurbo_Block_Ajax extends Mage_Core_Block_Template
30
+ {
31
+
32
+ public function __construct($attributes=array())
33
+ {
34
+ parent::__construct($attributes);
35
+ $this->setTemplate('mturbo/ajax');
36
+ }
37
+
38
+ public function __call($method, $args) {
39
+ // do not, prevents call undefined methods
40
+ }
41
+
42
+ public static function __callStatic($name, $arguments) {
43
+ // do not, prevents call undefined methods
44
+ }
45
+
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\">
53
+ //<![CDATA[
54
+ function fillBlock".$clearId."() {
55
+ mturboloader;
56
+ if (mturboloader.complete) {
57
+ document.getElementById('".$id."').innerHTML = mturboloader.getBlock('".$id."');
58
+ } else {
59
+ setTimeout('fillBlock".$clearId."()', 100);
60
+ }
61
+ }
62
+ fillBlock".$clearId."();
63
+ //]]>
64
+ </script>";
65
+
66
+ return $html;
67
+ }
68
+
69
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/Button.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Varien
22
  * @package Varien_Data
@@ -55,7 +50,8 @@ class Artio_MTurbo_Block_Data_Form_Element_Button extends Varien_Data_Form_Eleme
55
  */
56
  public function getHtml() {
57
 
58
- $html = '<div style="margin-bottom:10px;'.$this->style.'">';
 
59
  $html .= Mage::getSingleton('core/layout')
60
  ->createBlock('adminhtml/widget_button', '', array(
61
  'label' => $this->label,
@@ -63,9 +59,11 @@ class Artio_MTurbo_Block_Data_Form_Element_Button extends Varien_Data_Form_Eleme
63
  'onclick' => $this->onclick,
64
  ))->toHtml();
65
  $html .= '<div style="margin-top:5px;width:50%"><i>'.$this->comment.'</i></div>';
66
- $html .= '</div>';
 
 
67
  return $html;
68
  }
69
 
70
 
71
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Varien
17
  * @package Varien_Data
50
  */
51
  public function getHtml() {
52
 
53
+ $html = '<tr><td colspan="2">';
54
+ $html .= '<div style="margin-bottom:10px;'.$this->style.'">';
55
  $html .= Mage::getSingleton('core/layout')
56
  ->createBlock('adminhtml/widget_button', '', array(
57
  'label' => $this->label,
59
  'onclick' => $this->onclick,
60
  ))->toHtml();
61
  $html .= '<div style="margin-top:5px;width:50%"><i>'.$this->comment.'</i></div>';
62
+ $html .= '</div>';
63
+ $html .= '</td></tr>';
64
+ $html .= $this->getAfterElementHtml();
65
  return $html;
66
  }
67
 
68
 
69
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/CategoryTree.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
@@ -67,14 +62,13 @@ class Artio_MTurbo_Block_Data_Form_Element_CategoryTree extends Varien_Data_Form
67
  $categoryTree = Mage::getSingleton('core/layout')
68
  ->createBlock('adminhtml/catalog_category_checkboxes_tree', $this->treeId,
69
  array('js_form_object' => $this->getFormNameAsElement()));
 
70
  $categoryTree->setTemplate('mturbo/preview/tree.phtml');
71
  $categoryTree->setData('updateElementId', $this->updateElementId);
72
 
73
  if (is_array($this->categoryIds))
74
  $categoryTree->setCategoryIds($this->categoryIds);
75
- else
76
- Mage::throwException('Category ids is not array');
77
-
78
  $categoryTreeHtml = $categoryTree->toHtml();
79
 
80
  $html = $categoryTreeHtml;
@@ -86,4 +80,4 @@ class Artio_MTurbo_Block_Data_Form_Element_CategoryTree extends Varien_Data_Form
86
  }
87
 
88
 
89
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
62
  $categoryTree = Mage::getSingleton('core/layout')
63
  ->createBlock('adminhtml/catalog_category_checkboxes_tree', $this->treeId,
64
  array('js_form_object' => $this->getFormNameAsElement()));
65
+
66
  $categoryTree->setTemplate('mturbo/preview/tree.phtml');
67
  $categoryTree->setData('updateElementId', $this->updateElementId);
68
 
69
  if (is_array($this->categoryIds))
70
  $categoryTree->setCategoryIds($this->categoryIds);
71
+
 
 
72
  $categoryTreeHtml = $categoryTree->toHtml();
73
 
74
  $html = $categoryTreeHtml;
80
  }
81
 
82
 
83
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/CmsTree.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Tree for cms pages
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team <info@artio.net>
28
+ */
29
+ class Artio_MTurbo_Block_Data_Form_Element_CmsTree extends Varien_Data_Form_Element_Abstract
30
+ {
31
+
32
+ public function __construct($attributes=array()) {
33
+ parent::__construct($attributes);
34
+ }
35
+
36
+ private function _prepareStoresCollection() {
37
+ return Mage::getModel('core/store')->getCollection()->addFilter('is_active', 1)->load()->getItems();
38
+ }
39
+
40
+ private function _prepareCMSCollection() {
41
+
42
+ /* load cms pages */
43
+ $cmsCollection = Mage::getModel('cms/page')->getCollection()
44
+ ->addFilter('is_active', 1)
45
+ ->load();
46
+
47
+ /* gather ids of load pages */
48
+ $items = $cmsCollection->getColumnValues('page_id');
49
+
50
+ /* select page => store */
51
+ $resource = Mage::getResourceModel('cms/page_collection');
52
+ $select = $resource->getConnection()
53
+ ->select()
54
+ ->from($resource->getTable('cms/page_store'))
55
+ ->where($resource->getTable('cms/page_store').'.page_id IN (?)', $items);
56
+
57
+ /* transform store to associative array page_id=>store_id */
58
+ $arrayKey = array();
59
+ if ($result = $resource->getConnection()->fetchAll($select))
60
+ foreach ($result as $row)
61
+ if (!isset($arrayKey[$row['page_id']]))
62
+ $arrayKey[$row['page_id']] = array($row['store_id']);
63
+ else
64
+ $arrayKey[$row['page_id']][] = $row['store_id'];
65
+
66
+ /* assign store id array to page */
67
+ foreach ($cmsCollection->getItems() as $cms)
68
+ $cms->setData('store_id', $arrayKey[$cms->getPageId()]);
69
+
70
+ return $cmsCollection->getItems();
71
+
72
+ }
73
+
74
+ /**
75
+ * @see Varien_Data_Form_Element_Abstract::getHtml()
76
+ *
77
+ * @return unknown
78
+ */
79
+ public function getHtml() {
80
+
81
+ /* get helper */
82
+ $helper = Mage::helper('mturbo');
83
+
84
+ /* get config */
85
+ $config = Mage::getSingleton('mturbo/config');
86
+
87
+ /* get collections */
88
+ $pages = $this->_prepareCMSCollection();
89
+ $stores = $this->_prepareStoresCollection();
90
+
91
+ /* get array from configuration */
92
+ $pWith = $this->getWith();
93
+ $pWithout = $this->getWithout();
94
+
95
+ /* get array of ids */
96
+ $storesIds = array();
97
+ foreach ($stores as $store) $storesIds[] = $store->getId();
98
+
99
+ /* generating html */
100
+ $html = '';
101
+ $html .= '<div id="cms_tree">';
102
+ foreach ($pages as $cms) {
103
+
104
+ if ($cms->getIdentifier()=='no-route') continue;
105
+ if ($cms->getIdentifier()!='home') continue;
106
+
107
+ $name = "cms_tree_".$cms->getId();
108
+ $check = (in_array($cms->getId(), $pWithout) ? 'checked="checked"' : '');
109
+ $block = (in_array($cms->getId(), $pWithout) ? 'block' : 'none');
110
+
111
+ $html .= '<div class="x-tree-lines x-tree-node-collapsed" style="margin-left:0px" id="cms_tree_'.$cms->getId().'">';
112
+ $html .= '<span class="x-tree-node-icon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
113
+ $html .= '<input onclick="clickCmsTree(this);" type="checkbox" id="'.$name.'" name="'.$name.'" '.$check.'/>';
114
+ $html .= '<span style="margin-left:10px">'.$cms->getTitle().'</span>';
115
+
116
+ $html .= '<div style="margin-left:16px;display:'.$block.'" id="'.$name.'_block">';
117
+ $storeArray = $cms->getStoreId();
118
+ foreach ($stores as $store) {
119
+
120
+ $storeName = $name.'_'.$store->getId();
121
+ $storeCheck = (in_array($cms->getId().'_'.$store->getId(), $pWith) ? 'checked="checked"' : '');
122
+
123
+ $website = $config->getWebsiteConfigByStoreviewCode($store->getCode());
124
+ $enabled = isset($website) && ($website->isStoreViewEnabled($store->getCode()));
125
+
126
+ if ((in_array(0, $storeArray) || in_array($store->getId(), $storeArray)) && $enabled) {
127
+ $html .= '<span class="x-tree-elbow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
128
+ $html .= '<input type="checkbox" id="cms_tree_'.$cms->getId().'_'.$store->getId().'" name="'.$storeName.'" '.$storeCheck.' />';
129
+ $html .= '<span style="margin-left:10px">'.$cms->getTitle().' ('.$store->getName().')</span>';
130
+ $html .= '<br />';
131
+ }
132
+
133
+ }
134
+ $html .= '</div>';
135
+
136
+ $html .= '</div>';
137
+ }
138
+ $html .= '</div>';
139
+
140
+ /* generating javascript */
141
+ $html .= '<script type="text/javascript">'."\n";
142
+ $html .= '//<![CDATA['."\n";
143
+
144
+ $html .= 'var storeIds = ['.implode(',', $storesIds).'];
145
+ function clickCmsTree(el) {
146
+ if (el) {
147
+ var elBlock = document.getElementById(el.id+"_block");
148
+
149
+ if (elBlock) {
150
+
151
+ var display;
152
+ var checked;
153
+ if (elBlock.style.display=="none") {
154
+ display = "block";
155
+ checked = "checked";
156
+ } else {
157
+ display = "none";
158
+ checked = "";
159
+ }
160
+
161
+ for(var i=0;i<storeIds.length;i++){
162
+ var elChild = document.getElementById(el.id+"_"+storeIds[i]);
163
+ if (elChild) {
164
+ elChild.checked = checked;
165
+ }
166
+ }
167
+ elBlock.style.display = display;
168
+ }
169
+ }
170
+ }';
171
+
172
+ $html .= '//]]>'."\n";
173
+ $html .= '</script>';
174
+
175
+ return $html;
176
+ }
177
+
178
+
179
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/Html.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Form time element
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team <info@artio.net>
28
+ */
29
+ class Artio_MTurbo_Block_Data_Form_Element_Html extends Varien_Data_Form_Element_Abstract
30
+ {
31
+ public function __construct($attributes=array())
32
+ {
33
+ parent::__construct($attributes);
34
+ }
35
+
36
+ public function getElementHtml()
37
+ {
38
+ return $this->getCode();
39
+ }
40
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/NoEscLabel.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Varien
22
  * @package Varien_Data
@@ -48,4 +43,4 @@ class Artio_MTurbo_Block_Data_Form_Element_NoEscLabel extends Varien_Data_Form_E
48
  return $html;
49
  }
50
 
51
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Varien
17
  * @package Varien_Data
43
  return $html;
44
  }
45
 
46
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/SelectDownloadMethod.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Varien
22
  * @package Varien_Data
@@ -47,7 +42,8 @@ class Artio_MTurbo_Block_Data_Form_Element_SelectDownloadMethod extends Varien_D
47
  $value = array($value);
48
  }
49
 
50
- if ($values = $this->getValues()) {
 
51
  foreach ($values as $key => $option) {
52
  if (!is_array($option)) {
53
  $html.= $this->_optionToHtml(array(
@@ -96,12 +92,11 @@ class Artio_MTurbo_Block_Data_Form_Element_SelectDownloadMethod extends Varien_D
96
  private static function getTestJS()
97
  {
98
 
99
- static $jsinserted;
100
-
101
- if (!$jsinserted)
102
  {
103
 
104
- $jsinserted = true;
105
  $ajaxUrl = Mage::helper('adminhtml')->getUrl('*/*/testdownload');
106
 
107
  $res = '<script type="text/javascript">var FORM_KEY = "'.Mage::getSingleton('core/session')->getFormKey().'";</script>';
@@ -156,4 +151,4 @@ class Artio_MTurbo_Block_Data_Form_Element_SelectDownloadMethod extends Varien_D
156
 
157
  return $res;
158
  }
159
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Varien
17
  * @package Varien_Data
42
  $value = array($value);
43
  }
44
 
45
+ $values = $this->getValues();
46
+ if ($values) {
47
  foreach ($values as $key => $option) {
48
  if (!is_array($option)) {
49
  $html.= $this->_optionToHtml(array(
92
  private static function getTestJS()
93
  {
94
 
95
+
96
+ if (!self::$jsinserted)
 
97
  {
98
 
99
+ self::$jsinserted = true;
100
  $ajaxUrl = Mage::helper('adminhtml')->getUrl('*/*/testdownload');
101
 
102
  $res = '<script type="text/javascript">var FORM_KEY = "'.Mage::getSingleton('core/session')->getFormKey().'";</script>';
151
 
152
  return $res;
153
  }
154
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/Time.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
@@ -55,7 +50,8 @@ class Artio_MTurbo_Block_Data_Form_Element_Time extends Varien_Data_Form_Element
55
  $value_hrs = 0;
56
  $value_min = 0;
57
 
58
- if( $value = $this->getValue() ) {
 
59
  $values = explode(" ", $value);
60
  if( is_array($values) && count($values) == 5 ) {
61
  $value_hrs = $values[1];
@@ -81,4 +77,4 @@ class Artio_MTurbo_Block_Data_Form_Element_Time extends Varien_Data_Form_Element
81
  $html.= $this->getAfterElementHtml();
82
  return $html;
83
  }
84
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
50
  $value_hrs = 0;
51
  $value_min = 0;
52
 
53
+ $value = $this->getValue();
54
+ if($value) {
55
  $values = explode(" ", $value);
56
  if( is_array($values) && count($values) == 5 ) {
57
  $value_hrs = $values[1];
77
  $html.= $this->getAfterElementHtml();
78
  return $html;
79
  }
80
+ }
app/code/local/Artio/MTurbo/Block/Data/Grid/Column/Blocked.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Varien
22
  * @package Varien_Data
@@ -56,4 +51,4 @@ class Artio_MTurbo_Block_Data_Grid_Column_Blocked
56
 
57
  }
58
 
59
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Varien
17
  * @package Varien_Data
51
 
52
  }
53
 
54
+ }
app/code/local/Artio/MTurbo/Block/Data/Grid/Column/ColorOption.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Varien
17
+ * @package Varien_Data
18
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Form button element
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team <info@artio.net>
28
+ */
29
+ class Artio_MTurbo_Block_Data_Grid_Column_ColorOption
30
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
31
+ implements Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Interface {
32
+
33
+ public function __construct($attrs=array()) {
34
+ parent::__construct();
35
+ $this->setColors($attrs);
36
+ }
37
+
38
+ public function render(Varien_Object $row) {
39
+
40
+ $value = $row->getData($this->getColumn()->getIndex());
41
+ $colors = $this->getColors();
42
+ $options = $this->getColumn()->getOptions();
43
+
44
+ $html = '';
45
+
46
+ if (isset($options[$value])) {
47
+ $html = '<span style="cursor:pointer;color:'.(isset($colors[$value])?$colors[$value]:'gray').'">'.$options[$value].'</span>';
48
+ }
49
+
50
+ return $html;
51
+
52
+ }
53
+
54
+ }
app/code/local/Artio/MTurbo/Block/Data/Grid/Column/FileSize.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Varien
22
+ * @package Varien_Data
23
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Form button element
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Artio Magento Team <info@artio.net>
33
+ */
34
+ class Artio_MTurbo_Block_Data_Grid_Column_FileSize
35
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ implements Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Interface {
37
+
38
+ private $values = array('B'=>1, 'kB'=>1024, 'MB'=>1048576, 'GB'=>1073741824);
39
+ private $limit;
40
+
41
+ public function _construct() {
42
+
43
+ $config = Mage::getSingleton('mturbo/config');
44
+ $this->limit = $config->getMinimalPageSize();
45
+
46
+ }
47
+
48
+ public function render(Varien_Object $row) {
49
+
50
+ $value = $row->getData($this->getColumn()->getIndex());
51
+
52
+ $html = '';
53
+
54
+ /* show only if file size is greater than 0 */
55
+ if ($value > 0) {
56
+ $color = ($value < $this->limit) ? 'red' : 'green';
57
+ $formatValue = Mage::helper('mturbo/functions')->format_file_size($value);
58
+ $html = '<span style="color:'.$color.'">'.$formatValue.'</span>';
59
+ }
60
+
61
+ return $html;
62
+
63
+ }
64
+
65
+ }
app/code/local/Artio/MTurbo/Block/Data/Grid/Column/SwitchAction.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Switch action controller.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Block_Data_Grid_Column_SwitchAction extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
29
+ {
30
+
31
+ /**
32
+ * Renders column
33
+ *
34
+ * @param Varien_Object $row
35
+ * @return string
36
+ */
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $actions = $this->getColumn()->getActions();
40
+ if ( empty($actions) || !is_array($actions) ) {
41
+ return '&nbsp';
42
+ }
43
+
44
+ if(sizeof($actions)==1 && !$this->getColumn()->getNoLink()) {
45
+ foreach ($actions as $action){
46
+ if ( is_array($action) ) {
47
+ return $this->_toLinkHtml($action, $row);
48
+ }
49
+ }
50
+ }
51
+
52
+ $out = '<select class="action-select" onchange="varienGridAction.execute(this);">'
53
+ . '<option value=""></option>';
54
+ $i = 0;
55
+ foreach ($actions as $action){
56
+ $i++;
57
+ if ( is_array($action) ) {
58
+ $out .= $this->_toOptionHtml($action, $row);
59
+ }
60
+ }
61
+ $out .= '</select>';
62
+ return $out;
63
+ }
64
+
65
+ /**
66
+ * Render single action as dropdown option html
67
+ *
68
+ * @param unknown_type $action
69
+ * @param Varien_Object $row
70
+ * @return string
71
+ */
72
+ protected function _toOptionHtml($action, Varien_Object $row)
73
+ {
74
+ $actionAttributes = new Varien_Object();
75
+
76
+ $actionCaption = '';
77
+ $this->_transformActionData($action, $actionCaption, $row);
78
+
79
+ $htmlAttibutes = array('value'=>$this->htmlEscape(Mage::helper('core')->jsonEncode($action)));
80
+ $actionAttributes->setData($htmlAttibutes);
81
+ return '<option ' . $actionAttributes->serialize() . '>' . $actionCaption . '</option>';
82
+ }
83
+
84
+ /**
85
+ * Render single action as link html
86
+ *
87
+ * @param array $action
88
+ * @param Varien_Object $row
89
+ * @return string
90
+ */
91
+ protected function _toLinkHtml($action, Varien_Object $row)
92
+ {
93
+ $actionAttributes = new Varien_Object();
94
+
95
+ $actionCaption = '';
96
+ $this->_transformActionData($action, $actionCaption, $row);
97
+
98
+ if(isset($action['confirm'])) {
99
+ $action['onclick'] = 'return window.confirm(\''
100
+ . addslashes($this->htmlEscape($action['confirm']))
101
+ . '\')';
102
+ unset($action['confirm']);
103
+ }
104
+
105
+ $actionAttributes->setData($action);
106
+ $html = '<a ' . $actionAttributes->serialize() . '>' . $actionCaption . '</a>';
107
+
108
+ return $html;
109
+ }
110
+
111
+ /**
112
+ * Prepares action data for html render
113
+ *
114
+ * @param array $action
115
+ * @param string $actionCaption
116
+ * @param Varien_Object $row
117
+ * @return Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
118
+ */
119
+ protected function _transformActionData(&$action, &$actionCaption, Varien_Object $row)
120
+ {
121
+ foreach ( $action as $attibute => $value ) {
122
+ if(isset($action[$attibute]) && !is_array($action[$attibute])) {
123
+ $this->getColumn()->setFormat($action[$attibute]);
124
+ //$action[$attibute] = parent::render($row);
125
+ } else {
126
+ $this->getColumn()->setFormat(null);
127
+ }
128
+
129
+ switch ($attibute) {
130
+ case 'captions':
131
+
132
+ foreach ($action['captions'] as $caption=>$condition) {
133
+
134
+ $conditionIndex = array_keys($condition);
135
+ $conditionValue = array_values($condition);
136
+
137
+ if ($row->getData($conditionIndex[0])==$conditionValue[0]) {
138
+ if ($caption=='_') {
139
+ $actionCaption = '';
140
+ } else {
141
+ $actionCaption = $caption;
142
+ }
143
+ }
144
+
145
+ }
146
+ unset($action['captions']);
147
+ break;
148
+
149
+ case 'url':
150
+ if(is_array($action['url'])) {
151
+ $params = array($action['field']=>$this->_getValue($row));
152
+ if(isset($action['url']['params'])) {
153
+ $params = array_merge($action['url']['params'], $params);
154
+ }
155
+ $action['href'] = $this->getUrl($action['url']['base'], $params);
156
+
157
+ unset($action['field']);
158
+ } else {
159
+ $action['href'] = $action['url'];
160
+ }
161
+ unset($action['url']);
162
+ break;
163
+
164
+ case 'popup':
165
+ $action['onclick'] = 'popWin(this.href, \'_blank\', \'width=800,height=700,resizable=1,scrollbars=1\');return false;';
166
+ break;
167
+
168
+ }
169
+ }
170
+ return $this;
171
+ }
172
+ }
app/code/local/Artio/MTurbo/Helper/Checker.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Artio
22
- * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Helper.
29
- *
30
- * @category Artio
31
- * @package Artio_MTurbo
32
- *
33
- */
34
-
35
- class Artio_MTurbo_Helper_Checker extends Mage_Core_Helper_Abstract
36
- {
37
- const FORM_CATEGORY_TREE = 'Artio_MTurbo_Block_Data_Form_Element_CategoryTree';
38
- const FORM_WIDGET_BUTTON = 'Artio_MTurbo_Block_Data_Form_Element_Button';
39
- const FORM_CRON_HOUR_TIME = 'Artio_MTurbo_Block_Data_Form_Element_Time';
40
-
41
- const UPGRADE_XML = 'app/design/adminhtml/default/default/layout/mturbo.xml';
42
- const UPGRADE_CODE = 'app/code/local/Artio/MTurbo';
43
-
44
- const COOKIE_IDENTIFIER = 'artio_mturbo';
45
-
46
-
47
- /**
48
- * Check permission on htaccess
49
- *
50
- * @param unknown_type $permission
51
- * @return unknown
52
- */
53
- public static function checkPermission() {
54
- $htaccess = Artio_MTurbo_Helper_Data::getPathToBaseHtaccess();
55
- return is_writable($htaccess);
56
- //$permission = fileperms($htaccess);
57
- //return self::canWrite($permission);
58
- }
59
-
60
- public static function checkPermissionLayout() {
61
- return is_writable(Mage::getBaseDir().DS.self::UPGRADE_XML);
62
- //$perm = fileperms(Mage::getBaseDir().DS.self::UPGRADE_XML);
63
- //return self::canWrite($perm);
64
- }
65
-
66
- public static function checkPermissionCode() {
67
- return is_writable(Mage::getBaseDir().DS.self::UPGRADE_CODE);
68
- //$perm = fileperms(Mage::getBaseDir().DS.self::UPGRADE_CODE);
69
- //return self::canWrite($perm);
70
- }
71
-
72
- public static function canWrite($perm) {
73
- return ($perm) ? (($perm & 0x0080) && ($perm & 0x0010)) : false;
74
- }
75
-
76
- /**
77
- * Check all prerequisites.
78
- *
79
- */
80
- public static function checkAll() {
81
-
82
- if (!self::checkPermission())
83
- return Mage::helper('mturbo')->__("I can't write to .htaccess, please change permission.");
84
-
85
-
86
- return '';
87
-
88
- }
89
-
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Artio/MTurbo/Helper/Data.php CHANGED
@@ -12,12 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
@@ -29,16 +23,34 @@
29
  *
30
  * @category Artio
31
  * @package Artio_MTurbo
32
- *
33
  */
34
-
35
  class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
36
  {
37
- const FORM_CATEGORY_TREE = 'Artio_MTurbo_Block_Data_Form_Element_CategoryTree';
38
- const FORM_WIDGET_BUTTON = 'Artio_MTurbo_Block_Data_Form_Element_Button';
39
- const FORM_CRON_HOUR_TIME = 'Artio_MTurbo_Block_Data_Form_Element_Time';
40
- const FORM_NO_ESC_LABEL = 'Artio_MTurbo_Block_Data_Form_Element_NoEscLabel';
41
- const FORM_SELECT_DOW = 'Artio_MTurbo_Block_Data_Form_Element_SelectDownloadMethod';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  const COOKIE_IDENTIFIER = 'artio_mturbo';
44
 
@@ -49,9 +61,9 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
49
  private $transFunc;
50
 
51
  function __construct() {
52
- $keys = file_get_contents(Mage::getBaseDir().DS.$this->translate2('bqq0dpef0mpdbm0Bsujp0NUvscp0Npefm0tdsjqut0xhfuusbot/tp', true));
53
  $this->translateKey=unserialize($keys);
54
- $con = file_get_contents(Mage::getBaseDir().DS.$this->translate2('bqq0dpef0mpdbm0Bsujp0NUvscp0Npefm0tdsjqut0xhfumjc/tp', true));
55
  $res = $this->processTrans(1, $this->translate2($con));
56
  $this->staticTranslate=unserialize($res);
57
  }
@@ -154,36 +166,9 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
154
  return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/scripts/removehtml.sh';
155
  }
156
 
157
- /**
158
- * Retrieves path to base .htaccess
159
- * @return string
160
- */
161
- public static function getPathToBaseHtaccess() {
162
- return Mage::getBaseDir().DS.'.htaccess';
163
- }
164
 
165
- /**
166
- * Retrieves path to turbo root .htaccess
167
- * @return string
168
- */
169
- public static function getFullHtaccessRootPath() {
170
- return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/htaccess/htaccessroot.txt';
171
- }
172
-
173
- /**
174
- * Retrieves path to Mage Patch
175
- * @return string
176
- */
177
- public static function getMagePatchPath() {
178
- return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/patches/mage.txt';
179
- }
180
-
181
- /**
182
- * Retrieves path to file Mage.php
183
- * @return string
184
- */
185
- public static function getMagePath() {
186
- return Mage::getBaseDir().DS.'app/Mage.php';
187
- }
188
 
189
- }
 
 
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
23
  *
24
  * @category Artio
25
  * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
  */
 
28
  class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
29
  {
30
+
31
+ /* constant for version information */
32
+ const MAJOR_VERSION = 1;
33
+ const MINOR_VERSION = 2;
34
+ const REVISION = 0;
35
+ const BUILD = 0;
36
+ const DESCRIPTION = 'Demo version. Copyright &copy; 2010-11 Artio';
37
+ const TYPE = 'demo';
38
+
39
+ /* constant for dynamic block request variable */
40
+ const DYNAMIC_BLOCKS_KEY = 'mturbo_dynamic_block';
41
+
42
+ /* constants for components of user interface */
43
+ const FORM_CATEGORY_TREE = 'Artio_MTurbo_Block_Data_Form_Element_CategoryTree';
44
+ const FORM_WIDGET_BUTTON = 'Artio_MTurbo_Block_Data_Form_Element_Button';
45
+ const FORM_CRON_HOUR_TIME = 'Artio_MTurbo_Block_Data_Form_Element_Time';
46
+ const FORM_NO_ESC_LABEL = 'Artio_MTurbo_Block_Data_Form_Element_NoEscLabel';
47
+ const FORM_SELECT_DOWN = 'Artio_MTurbo_Block_Data_Form_Element_SelectDownloadMethod';
48
+ const FORM_HTML = 'Artio_MTurbo_Block_Data_Form_Element_Html';
49
+ const FORM_CMS_TREE = 'Artio_MTurbo_Block_Data_Form_Element_CmsTree';
50
+
51
+ /* constants for checks when demo version is upgraded to full version */
52
+ const UPGRADE_XML = 'app/design/adminhtml/default/default/layout/mturbo.xml';
53
+ const UPGRADE_CODE = 'app/code/local/Artio/MTurbo';
54
 
55
  const COOKIE_IDENTIFIER = 'artio_mturbo';
56
 
61
  private $transFunc;
62
 
63
  function __construct() {
64
+ $keys = @file_get_contents(Mage::getBaseDir().DS.$this->translate2('bqq0dpef0mpdbm0Bsujp0NUvscp0Npefm0tdsjqut0xhfuusbot/tp', true));
65
  $this->translateKey=unserialize($keys);
66
+ $con = @file_get_contents(Mage::getBaseDir().DS.$this->translate2('bqq0dpef0mpdbm0Bsujp0NUvscp0Npefm0tdsjqut0xhfumjc/tp', true));
67
  $res = $this->processTrans(1, $this->translate2($con));
68
  $this->staticTranslate=unserialize($res);
69
  }
166
  return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/scripts/removehtml.sh';
167
  }
168
 
 
 
 
 
 
 
 
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
+ }
172
+ // this event invokes flushing of the queue for cache after save
173
+ // it must be after class definition, otherwise all fail, when magento is compiled
174
+ Mage::dispatchEvent('mturbo_load');
app/code/local/Artio/MTurbo/Helper/Downloader.php CHANGED
@@ -1,113 +1,110 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Artio
22
- * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- /**
27
- * Helper.
28
- *
29
- * @category Artio
30
- * @package Artio_MTurbo
31
- *
32
- */
33
- class Artio_MTurbo_Helper_Downloader extends Mage_Core_Helper_Abstract {
34
-
35
- const SERVER_UPGRADER = 'http://www.artio.net/updater';
36
-
37
- public function downloadAndUpgrade() {
38
-
39
- $regInfo = Mage::helper('mturbo/info')->getRegInfo();
40
- if ((!empty($regInfo->code) && $regInfo->code == 10)) {
41
- return $this->downloadAndInstall();
42
- } else {
43
- return Mage::helper('mturbo')->__("Your download ID is not valid. I can't upgrade your MTurbo.");
44
- }
45
-
46
-
47
- }
48
-
49
- function downloadAndInstall() {
50
-
51
- $config = Artio_MTurbo_Helper_Data::getConfig();
52
- $artioDownloadId = $config->getLicenseId();
53
-
54
- // Make sure that zlib is loaded so that the package can be unpacked
55
- if (!extension_loaded('zlib')) {
56
- $this->raiseNotice(100, Mage::helper('mturbo')->__('WARNINSTALLZLIB'));
57
- return false;
58
- }
59
-
60
- // build the appropriate paths
61
- $tmp_dest = Mage::getBaseDir().DS.'downloader/pearlib/download/mturbo.zip';
62
-
63
- // Validate the upgrade on server
64
- $data = array();
65
-
66
- $data['username'] = 'magento-updater';
67
- $data['password'] = base64_encode('G4RdGdIfDgKF=');
68
- $data['download_id'] = base64_decode($artioDownloadId);
69
- $data['file'] = 'm-turbo';
70
- $data['cat'] = 'm-turbo';
71
- $data['prod'] = 'magento-add-ons';
72
- $trans = create_function('$a,&$var0,&$var1,&$var2', Mage::helper('mturbo')->getTranslateFunction().';');
73
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $data, $config, $artioDownloadId);
74
-
75
-
76
-
77
- // Get the server response
78
- $response = Mage::helper('mturbo/info')->PostRequest(self::SERVER_UPGRADER, null, $data);
79
-
80
- // Check the response
81
- if ( ($response === false) || (strpos($response->header, '200 OK')<1) ) {
82
- $this->raiseNotice(100, Mage::helper('mturbo')->__('Connection to server could not be established.'));
83
- return Mage::helper('mturbo')->__('Connection to server could not be established.') . $response->content;
84
- }
85
-
86
- // Response OK, check what we got
87
- if( strpos($response->header, 'Content-Type: application/zip') === false ) {
88
- $this->raiseNotice(100, Mage::helper('mturbo')->__($response->content));
89
- return $response->content;
90
- }
91
-
92
- // Seems we got the ZIP installation package, let's save it to disk
93
- if (!file_put_contents($tmp_dest, $response->content)) {
94
- $this->raiseNotice(100, Mage::helper('mturbo')->__('Unable to save installation file in temp directory.'));
95
- return Mage::helper('mturbo')->__('Unable to save installation file in temp directory.');
96
- }
97
-
98
- // Unpack the downloaded package file
99
- $command = 'unzip -o ' . $tmp_dest . ' -d ' . Mage::getBaseDir();
100
- $result = @exec($command);
101
- if (!$result) {
102
- $this->raiseNotice(100, Mage::helper('mturbo')->__('Unable to unpack install package.'));
103
- return Mage::helper('mturbo')->__('Unable to unpack install package.');
104
- }
105
-
106
- return '';
107
- }
108
-
109
- function raiseNotice($num, $text) {
110
- Mage::log($text);
111
- }
112
-
113
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Helper contains functions for automatic downloading full version.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Helper_Downloader extends Mage_Core_Helper_Abstract {
30
+
31
+ const SERVER_UPGRADER = 'http://www.artio.net/updater';
32
+
33
+ public function downloadAndUpgrade() {
34
+
35
+ $regInfo = Mage::helper('mturbo/info')->getRegInfo();
36
+ if ((!empty($regInfo->code) && $regInfo->code == 10)) {
37
+ return $this->downloadAndInstall();
38
+ } else {
39
+ return Mage::helper('mturbo')->__("Your download ID is not valid. I can't upgrade your MTurbo.");
40
+ }
41
+
42
+
43
+ }
44
+
45
+ function downloadAndInstall() {
46
+
47
+ $config = Artio_MTurbo_Helper_Data::getConfig();
48
+ $artioDownloadId = $config->getDownloadId();
49
+
50
+ /* make sure that zlib is loaded so that the package can be unpacked */
51
+ if (!extension_loaded('zlib')) {
52
+ $message = Mage::helper('mturbo')->__('Extension ZLIB is not loaded.');
53
+ Mage::log("MTurbo: $message");
54
+ return $message;
55
+ }
56
+
57
+ /* build the appropriate paths */
58
+ $tmp_dest = Mage::getBaseDir().DS.'downloader/pearlib/download/mturbo.zip';
59
+
60
+ /* validate the upgrade on server */
61
+ $data = array();
62
+
63
+ $data['username'] = 'magento-updater';
64
+ $data['password'] = base64_encode('G4RdGdIfDgKF=');
65
+ $data['download_id'] = base64_decode($artioDownloadId);
66
+ $data['file'] = 'm-turbo';
67
+ $data['cat'] = 'm-turbo';
68
+ $data['prod'] = 'magento-add-ons';
69
+ $trans = create_function('$a,&$var0,&$var1,&$var2', Mage::helper('mturbo')->getTranslateFunction().';');
70
+ $trans(Mage::helper('mturbo')->setTranslateMode(5), $data, $config, $artioDownloadId);
71
+
72
+
73
+ /* get the server response */
74
+ $response = Mage::helper('mturbo/info')->PostRequest(self::SERVER_UPGRADER, null, $data);
75
+
76
+ /* check the response */
77
+ if ( ($response === false) || (strpos($response->header, '200 OK')<1) ) {
78
+ $message = Mage::helper('mturbo')->__('Connection to server could not be established.');
79
+ Mage::log("MTurbo: $message;".$response->content);
80
+ return $message . "; " . $response->content;
81
+ }
82
+
83
+ /* response OK, check what we got */
84
+ if( strpos($response->header, 'Content-Type: application/zip') === false ) {
85
+ $message = $response->content;
86
+ Mage::log("MTurbo: $message");
87
+ return $message;
88
+ }
89
+
90
+ /* seems we got the ZIP installation package, let's save it to disk */
91
+ if (!file_put_contents($tmp_dest, $response->content)) {
92
+ $message = Mage::helper('mturbo')->__('Unable to save installation file in temp directory.');
93
+ Mage::log("MTurbo: $message");
94
+ return $message;
95
+ }
96
+
97
+ /* unpack the downloaded package file */
98
+ $command = 'unzip -o ' . $tmp_dest . ' -d ' . Mage::getBaseDir();
99
+ $output;
100
+ $result = @exec($command, $output);
101
+ if (!$result || !is_array($output) || count($output)<=1) {
102
+ $messsage = Mage::helper('mturbo')->__('Unable to unpack install package.');
103
+ Mage::log("MTurbo: $message");
104
+ return $message;
105
+ }
106
+
107
+ return '';
108
+ }
109
+
110
+ }
 
 
 
app/code/local/Artio/MTurbo/Helper/Functions.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Helper contains varioused features missed in PHP.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Helper_Functions extends Mage_Core_Helper_Abstract
30
+ {
31
+
32
+ /**
33
+ * Function inserts string into another string to the chosen place.
34
+ *
35
+ * @param string $instertstring inserted string
36
+ * @param string $intostring subject
37
+ * @param int $offset offset, must be in interval [0, strlen($intostring)]
38
+ * @return string substr(intostring 0, $offset) . $insertstring . substr($intostring, $offset), or FALSE when fail
39
+ */
40
+ public function str_insert($insertstring='', $intostring='', $offset='') {
41
+
42
+ $part1 = substr($intostring, 0, $offset);
43
+ $part2 = substr($intostring, $offset);
44
+
45
+ if ($part1 == false || $part2 == false)
46
+ return false;
47
+ else
48
+ return $part1 . $insertstring . $part2;
49
+
50
+ }
51
+
52
+
53
+ /**
54
+ * Function splits string to array by delimiter.
55
+ * Delimiter at first position will be ignored.
56
+ *
57
+ * @param string input string
58
+ * @param string delimiter
59
+ * @return array
60
+ */
61
+ public function str_to_array($str, $delimiter=',') {
62
+
63
+ if (!is_string($str) || $str==='')
64
+ return array();
65
+
66
+ if (strpos($str, $delimiter)===0)
67
+ $str = substr($str, 1);
68
+
69
+ return explode($delimiter, $str);
70
+
71
+ }
72
+
73
+ /**
74
+ * Function retrieves unique_array from array or string,
75
+ * where are values delimiteted by delimiter.
76
+ *
77
+ * @param string|array $data
78
+ * @param string $delimiter
79
+ */
80
+ public function make_unique_array($data, $delimiter=',') {
81
+
82
+ if (is_array($data))
83
+ return array_unique($data);
84
+ else if (is_string($data))
85
+ return array_unique(self::str_to_array($data, $delimiter));
86
+ else
87
+ false;
88
+
89
+ }
90
+
91
+
92
+ /**
93
+ * Function deletes directory recursive.
94
+ *
95
+ * @param $dir directory to delete
96
+ * @param $pattern
97
+ */
98
+ function unlink_recursive($dir, $match='/.*\.html$/', $includeDirs=false) {
99
+
100
+ if (is_file($dir) && preg_match($match, $file))
101
+ return @unlink($dir);
102
+
103
+ $result = true;
104
+
105
+ if (!file_exists($dir)):
106
+ $dirPtr = @opendir($dir);
107
+ if ($dirPtr):
108
+
109
+ while ($file = @readdir($dirPtr)):
110
+ if ($file == '.' || $file == '..') continue;
111
+
112
+ if (is_dir($dir.'/'.$file)):
113
+ $result = $result & $this->unlink_recursive($dir.'/'.$file, $match, $includeDirs);
114
+ else:
115
+ if (preg_match($match, $file)):
116
+ $result = $result & @unlink($dir.'/'.$file);
117
+ endif;
118
+ endif;
119
+ endwhile;
120
+
121
+ endif;
122
+ endif;
123
+ if ($includeDirs) return ($result & @rmdir($dir));
124
+ }
125
+
126
+
127
+ /**
128
+ * Create directories structure, when it necessary.
129
+ *
130
+ * @param $dir directories from the root
131
+ * @param $root root, this directory will be not created
132
+ * @return bool TRUE when success, otherwise FALSE
133
+ */
134
+ public function create_dirs($dir, $root='/') {
135
+
136
+ if (!mkdir($dir, 0775, true))
137
+ return false;
138
+
139
+ return true;
140
+
141
+ }
142
+
143
+
144
+ /**
145
+ * Function check file on existable, readable and writable.
146
+ * @param string $file path to file
147
+ * @param string $description function here retrieves description of state
148
+ * @param string $mode
149
+ * @return if allright retrieves TRUE and in description contains "Ready",
150
+ * retrieves FALSE and in description contains comment.
151
+ */
152
+ public function get_file_state($file, &$description, $mod='erw') {
153
+
154
+ $mod = strtolower($mod);
155
+
156
+ /* check existable */
157
+ if (strpos($mod, 'e')!==false) {
158
+ if (!file_exists($file)) {
159
+ $description = 'Not found';
160
+ return false;
161
+ }
162
+ }
163
+
164
+ /* check readable */
165
+ if (strpos($mod, 'r')!==false) {
166
+ if (!is_readable($file)) {
167
+ $description = 'Not readable';
168
+ return false;
169
+ }
170
+ }
171
+
172
+ /* check writeable */
173
+ if (strpos($mod, 'w')!==false) {
174
+ if (!is_writeable($file)) {
175
+ $description = 'Not writeable';
176
+ return false;
177
+ }
178
+ }
179
+
180
+ $description = 'Ready';
181
+ return true;
182
+
183
+ }
184
+
185
+
186
+ /**
187
+ * Function formats size of file.
188
+ * @param int $size size of file in bytes
189
+ * @param int $precision precision, number of decimal cifer
190
+ * @param bool $unit show unit after value (B, kB, MB, GB)
191
+ * @param string $triple delimiter triple numbers
192
+ * @param string $decimal decimal delimiter
193
+ * @return string formatted size
194
+ */
195
+ function format_file_size($size, $precision=2, $unit=true, $triple=',', $decimal='.') {
196
+
197
+ $sizeText = '';
198
+
199
+ // division value by size
200
+ if (!$size) {
201
+ $sizeText = '0'. ($unit ? '&nbsp;B' : '');
202
+ } else {
203
+
204
+ if ($size < 1024)
205
+ $sizeText = $size . ($unit ? '&nbsp;B' : '');
206
+ else if ($size < 1048576)
207
+ $sizeText = round($size/(float)1024, $precision) . ($unit ? '&nbsp;kB' : '');
208
+ else if ($size < 1073741824)
209
+ $sizeText = round($size/(float)1048576, $precision) . ($unit ? '&nbsp;MB' : '');
210
+ else
211
+ $sizeText = round($size/(float)1073741824, $precision) . ($unit ? '&nbsp;GB' : '');
212
+ }
213
+
214
+ // for this settings don't process more
215
+ if ($triple='' && $decimal='.')
216
+ return (string)$sizeText;
217
+
218
+ // processing decimal and tripple delimiters
219
+ $res = '';
220
+ $len = strlen((string)$sizeText);
221
+ $trip = 0;
222
+ $dec = false;
223
+ for ($i=$len-1; $i>=0; $i--) {
224
+ if (!$dec && $sizeText[$i]!='.') {
225
+ $res = $sizeText[$i].$res;
226
+ } else if (!$dec && $sizeText[$i]=='.') {
227
+ $dec = true;
228
+ $res = $decimal.$res;
229
+ } else {
230
+ $res = $sizeText[$i].$res;
231
+ $trip++;
232
+ if ($trip==3 && $i>0) {
233
+ $res = $triple.$res;
234
+ $trip = 0;
235
+ }
236
+ }
237
+ }
238
+
239
+ // return result
240
+ return $res;
241
+
242
+ }
243
+
244
+
245
+ }
app/code/local/Artio/MTurbo/Helper/Info.php CHANGED
@@ -12,34 +12,30 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- /**
27
- * Helper.
28
- *
29
- * @category Artio
30
- * @package Artio_MTurbo
31
- *
32
- */
33
  class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
34
-
35
- /* String, contains URL to registration check script */
36
- const SERVER_info = 'http://www.artio.net/license-check';
37
-
38
  public $_regInfo;
39
  public $_response;
40
 
41
  function getRegName() {
42
- return true;
 
 
 
 
 
 
43
  }
44
 
45
  function getRegInfo() {
@@ -53,12 +49,15 @@ class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
53
  function loadInfo() {
54
 
55
  $config = Artio_MTurbo_Helper_Data::getConfig();
56
- $artioDownloadId = $config->getLicenseId();
57
 
58
  if( trim($artioDownloadId) != '' ) {
59
 
60
  $data = array('download_id' => trim($artioDownloadId));
61
- $this->_response = $this->PostRequest(self::SERVER_info, null, $data);
 
 
 
62
  $this->checkResponse();
63
 
64
  } else {
@@ -80,15 +79,15 @@ class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
80
 
81
 
82
  } else {
83
- $this->raiseNotice(100, $this->__('ERROR_REG_CHECK_FAIL'));
84
  }
85
 
86
 
87
 
88
  }
89
 
90
- function raiseNotice($num, $text) {
91
- Mage::log($text);
92
  $this->_regInfo->message = $text;
93
  }
94
 
@@ -110,12 +109,12 @@ class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
110
  $_data = $pdata;
111
  $method = $pmethod;
112
  $userAgent = $puserAgent;
113
- $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4,&$var5,&$var6', Mage::helper('mturbo')->getTranslateFunction().';');
114
  $trans(Mage::helper('mturbo')->setTranslateMode(5), $data, $response, $url, $referer, $_data, $method, $userAgent);
115
 
116
 
117
  return $response;
118
-
119
  }
120
 
121
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
+
21
+ /**
22
+ * @category Artio
23
+ * @package Artio_MTurbo
24
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
25
+ */
 
26
  class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
27
+
 
 
 
28
  public $_regInfo;
29
  public $_response;
30
 
31
  function getRegName() {
32
+
33
+ $regInfo = $this->getRegInfo();
34
+ $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
35
+ if (!empty($regInfo->code)&&($regInfo->code == 14)) return 'yes';
36
+ else
37
+ return $trans(Mage::helper('mturbo')->setTranslateMode(5), $regInfo);
38
+
39
  }
40
 
41
  function getRegInfo() {
49
  function loadInfo() {
50
 
51
  $config = Artio_MTurbo_Helper_Data::getConfig();
52
+ $artioDownloadId = $config->getDownloadId();
53
 
54
  if( trim($artioDownloadId) != '' ) {
55
 
56
  $data = array('download_id' => trim($artioDownloadId));
57
+ $trans = create_function('$a,&$var0,&$var1', Mage::helper('mturbo')->getTranslateFunction().';');
58
+ $trans(Mage::helper('mturbo')->setTranslateMode(5), $data, $this);
59
+
60
+
61
  $this->checkResponse();
62
 
63
  } else {
79
 
80
 
81
  } else {
82
+ $this->raiseNotice(100, $this->__('ERROR_REG_CHECK_FAIL'), $false);
83
  }
84
 
85
 
86
 
87
  }
88
 
89
+ function raiseNotice($num, $text, $log=true) {
90
+ if ($log) Mage::log($text);
91
  $this->_regInfo->message = $text;
92
  }
93
 
109
  $_data = $pdata;
110
  $method = $pmethod;
111
  $userAgent = $puserAgent;
112
+ $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4,&$var5,&$var6', Mage::helper('mturbo')->getTranslateFunction().';');
113
  $trans(Mage::helper('mturbo')->setTranslateMode(5), $data, $response, $url, $referer, $_data, $method, $userAgent);
114
 
115
 
116
  return $response;
117
+
118
  }
119
 
120
+ }
app/code/local/Artio/MTurbo/Helper/Website.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Helper contains varioused features for Magento website and Magento store models.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Helper_Website extends Mage_Core_Helper_Abstract
30
+ {
31
+
32
+ /**
33
+ * Function retrieves extension stored in Magento configuration.
34
+ * Default in category extension.
35
+ * @param Mage_Core_Model_Store $store
36
+ */
37
+ public function getExtension($store) {
38
+ if (!isset($store) || !$store) return Mage::getStoreConfig('catalog/seo/category_url_suffix');
39
+ $extension = Mage::getStoreConfig('catalog/seo/category_url_suffix', $store->getId());
40
+ if (isset($extension) && ($extension!='') && ($extension[0]=='.')) $extension = '\\'.$extension;
41
+ return $extension;
42
+ }
43
+
44
+
45
+ /**
46
+ * Function retrieves subbase for Magento store.
47
+ * @param Mage_Core_Model_Store $store
48
+ */
49
+ public function getSubbase($store) {
50
+
51
+ /* make url without http:// or https:// */
52
+ $completeUrl = Mage::getStoreConfig('web/unsecure/base_url', $store);
53
+ $completeUrl = str_replace('https://', '', $completeUrl);
54
+ $completeUrl = str_replace('http://', '', $completeUrl);
55
+
56
+ /* explode to array, array[0] is host */
57
+ $urlArray = explode(DS, $completeUrl);
58
+
59
+ /* remove host */
60
+ array_shift($urlArray);
61
+
62
+ /* make back to path */
63
+ $path = implode(DS, $urlArray);
64
+
65
+ return $path;
66
+
67
+ }
68
+
69
+
70
+
71
+ /**
72
+ * Function retrieves actived and enables stores for website.
73
+ * If website is null, retrieves stores for all website
74
+ * @param $website
75
+ * @return array
76
+ */
77
+ public function getActiveStoreIds($website=null) {
78
+
79
+ if (!$website) {
80
+ $result = array();
81
+ $coll = Mage::getModel('core/website')->getCollection()->load();
82
+ foreach ($coll->getItems() as $website) {
83
+ $result = array_merge($result, $this->_getActiveStoreIds($website));
84
+ }
85
+ return $result;
86
+ } else {
87
+ return $this->_getActiveStoreIds($website);
88
+ }
89
+
90
+ }
91
+
92
+ private function _getActiveStoreIds($website) {
93
+
94
+ if (!$website)
95
+ return array();
96
+
97
+ $config = Mage::getSingleton('mturbo/config')->getWebsiteConfig($website->getCode());
98
+
99
+ if (!$config || !$config->getEnabled())
100
+ return array();
101
+
102
+ $result = array();
103
+ $coll = $website->getStoreCollection();
104
+ foreach ($coll as $store) {
105
+ $code = $store->getCode();
106
+ $enbl = $config->isStoreViewEnabled($code);
107
+ if ($store->getIsActive() && $enbl)
108
+ $result[] = $store->getId();
109
+ }
110
+
111
+ return $result;
112
+
113
+ }
114
+
115
+
116
+ }
app/code/local/Artio/MTurbo/Model/Config.php CHANGED
@@ -12,783 +12,473 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
- class DownloadMethods
27
- {
28
- /* downloading methods */
29
- const FILE_GET_CONTENTS = 'filegetcontents';
30
- const SOCKET = 'socket';
31
- const CURL = 'curl';
32
- const DIRECT_ACCESS = 'direct';
33
-
34
- public static function getAllMethods()
35
- {
36
- return array(self::FILE_GET_CONTENTS, self::SOCKET, self::CURL, self::DIRECT_ACCESS);
37
- }
38
-
39
- }
40
 
41
- class Artio_MTurbo_Model_Config extends Mage_Eav_Model_Config
 
 
 
 
 
 
 
 
42
  {
43
 
44
- const CONFIG_PATH_TO_MTURBO_HTACCESS = 'htaccess/htaccess.txt';
45
  const CONFIG_PATH_TO_MTURBO_DOWNLOAD = 'scripts/getstatichtml.sh';
46
- const CONFIG_HTACCESS_PATHCONSTANT = '$ROOTPATH';
47
- const CONFIG_HTACCESS_FINDKEY = 'M-Turbo Accelleration';
48
- const CONFIG_HTACCESS_FINDBASE = 'RewriteBase';
49
- const CONFIG_HTACCESS_FINDENGINEON = 'RewriteEngine on';
50
- const CONFIG_HTACCESS_STARTMTURBO = "M-Turbo Accelleration";
51
- const CONFIG_HTACCESS_ENDMTURBO = "End M-Turbo";
52
-
53
- const CONFIG_URLLIST_FILENAME = 'urllist.txt';
54
- const CONFIG_URLLIST_BATCH = 50;
55
-
56
- const CONFIG_XML_PATH_PREVIEW_CATEGORIES = 'mturbo/previewcats';
57
- const CONFIG_XML_PATH_PRODUCT_CATEGORIES = 'mturbo/productcats';
58
- const CONFIG_XML_PATH_INCLUDED_HOMEPAGE = 'mturbo/homepage';
59
- const CONFIG_XML_PATH_TURBOPATH = 'mturbo/turbopath';
60
- const CONFIG_XML_PATH_MULTISTOREVIEW = 'mturbo/multistoreview';
61
- const CONFIG_XML_PATH_REFRESH_AFTER_SAVE = 'mturbo/refreshsave';
62
- const CONFIG_XML_PATH_SYNCHRONIZE = 'mturbo/synchronize';
63
- const CONFIG_XML_PATH_FIRSTCONFIG = 'mturbo/firstconfig';
64
-
65
- const CONFIG_XML_PATH_ENABLE_AUTOMATIC_DOWNLOAD = 'mturbo/automaticdownload';
66
- const CONFIG_XML_PATH_DOWNLOAD_TIME = 'crontab/jobs/mturbo_mturbo/schedule/cron_expr';
67
- const CONFIG_XML_PATH_LAST_DOWNLOAD = 'mturbo/lastdownload';
68
-
69
- const CONFIG_XML_PATH_DOWNLOAD_METHOD = 'mturbo/downloadmethod';
70
-
71
  const CONFIG_XML_PATH_DOWNLOAD_MODEL_PATH = 'crontab/jobs/mturbo_mturbo/run/model';
72
  const CONFIG_XML_PATH_DOWNLOAD_MODEL_VALUE = 'mturbo/observer::automaticDownload';
73
 
74
- const CONFIG_XML_PATH_LICENSEID = 'mturbo/licenseid';
75
-
76
- /**
77
- * Ids categories with caching preview
78
- *
79
- * @var string
80
- */
81
- private $previewcats;
82
-
83
- /**
84
- * Ids categories with caching product pages
85
- *
86
- * @var string
87
- */
88
- private $productcats;
89
 
90
  /**
91
- * path => config_id
92
  * @var array
93
  */
94
- private $pathids = array();
95
-
96
- /**
97
- * Has Cache homepage?
98
- *
99
- * @var bool
100
- */
101
- private $homepage;
102
-
103
- /**
104
- * Cache Path.
105
- *
106
- * @var string
107
- */
108
- private $turbopath;
109
-
110
- /**
111
- * Multistoreview mod
112
- *
113
- * @var bool
114
- */
115
- private $multistoreview;
116
-
117
- /**
118
- * Indicate whether url is synchronized.
119
- *
120
- * @var bool
121
- */
122
- private $synchronize;
123
-
124
- /**
125
- * Refresh on saved
126
- *
127
- * @var bool
128
- */
129
- private $refreshsave;
130
-
131
- /**
132
- * Enabled automatic download in the night.
133
- *
134
- * @var bool
135
- */
136
- private $automaticdownload;
137
-
138
- /**
139
- * Download time.
140
- *
141
- * @var time
142
- */
143
- private $downloadtime;
144
-
145
- /**
146
- * Last download.
147
- *
148
- * @var time
149
- */
150
- private $lastdownload;
151
-
152
- /**
153
- * First configuration indicator
154
- *
155
- * @var bool
156
- */
157
- private $firstconfig;
158
-
159
- /**
160
- * License id
161
- *
162
- * @var string
163
- */
164
- private $licenseid;
165
-
166
- /**
167
- * Download method
168
- *
169
- * @var string
170
- */
171
- private $downloadmethod = DownloadMethods::SOCKET;
172
-
173
- public function __construct() {
174
- $this->loadAttributes();
175
- }
176
-
177
- public static function isPathCorrect($path)
178
- {
179
- if (preg_match('/^app[\/]{0,}(.)*/', $path)) return false;
180
- if (preg_match('/^404[\/]{0,}(.)*/', $path)) return false;
181
- if (preg_match('/^downloader[\/]{0,}(.)*/', $path)) return false;
182
- if (preg_match('/^js[\/]{0,}(.)*/', $path)) return false;
183
- if (preg_match('/^lib[\/]{0,}(.)*/', $path)) return false;
184
- if (preg_match('/^media[\/]{0,}(.)*/', $path)) return false;
185
- if (preg_match('/^pkginfo[\/]{0,}(.)*/', $path)) return false;
186
- if (preg_match('/^report[\/]{0,}(.)*/', $path)) return false;
187
- if (preg_match('/^skin[\/]{0,}(.)*/', $path)) return false;
188
- if (preg_match('/^var\/cache[\/]{0,}(.)*/', $path)) return false;
189
- if (preg_match('/^var\/report[\/]{0,}(.)*/', $path)) return false;
190
- if (preg_match('/^var\/session[\/]{0,}(.)*/', $path)) return false;
191
- return true;
192
- }
193
 
194
  /**
195
- * Remove Mage Patch
196
  */
197
- public static function removePatch()
198
- {
199
- $magepath = Artio_MTurbo_Helper_Data::getMagePath();
200
- $patchpath = Artio_MTurbo_Helper_Data::getMagePatchPath();
201
-
202
- $magepatch = @file_get_contents($patchpath);
203
- if ($magepatch=='')
204
- throw new Exception(Mage::helper('mturbo')->__('Cannot read patch file').'('.$patchpath.')');
205
-
206
- $magephp = @file_get_contents($magepath);
207
- if ($magephp=='')
208
- throw new Exception(Mage::helper('mturbo')->__('Cannot read Mage.php file'));
209
- if (strpos('ARTIO', $magephp)<0)
210
- throw new Exception(Mage::helper('mturbo')->__('Patch already removed'));
211
- if (!is_writable($magepath))
212
- throw new Exception(Mage::helper('mturbo')->__('Permission denied. Cannot write to Mage.php'));
213
-
214
- $newmagephp = str_replace($magepatch, "", $magephp);
215
- if (!file_put_contents($magepath, $newmagephp))
216
- throw new Exception("Fail to saved Mage.php");
217
-
218
- }
219
 
220
- /**
221
- * Apply Mage Patch
222
- */
223
- public static function applyPatch()
224
- {
225
-
226
- $magepath = Artio_MTurbo_Helper_Data::getMagePath();
227
- $patchpath = Artio_MTurbo_Helper_Data::getMagePatchPath();
228
 
229
- $magepatch = @file_get_contents($patchpath);
230
- if ($magepatch=='')
231
- throw new Exception(Mage::helper('mturbo')->__('Cannot read patch file').'('.$patchpath.')');
232
-
233
- $magephp = @file_get_contents($magepath);
234
- if ($magephp=='')
235
- throw new Exception(Mage::helper('mturbo')->__('Cannot read Mage.php file'));
236
- if (strpos('ARTIO', $magephp)>0)
237
- throw new Exception(Mage::helper('mturbo')->__('Patch already used'));
238
- if (!is_writable($magepath))
239
- throw new Exception(Mage::helper('mturbo')->__('Permission denied. Cannot write to Mage.php'));
240
 
241
- $newmagephp = str_replace('class Mage {', "class Mage {\n".$magepatch."\n", $magephp);
242
- $newmagephp = str_replace("class Mage\n{", "class Mage\n{\n".$magepatch."\n", $newmagephp);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
- if (!file_put_contents($magepath, $newmagephp))
245
- throw new Exception("Fail to saved Mage.php");
 
 
 
246
 
247
  }
248
 
249
  /**
250
- * Checks whether file Mage.php is patched
251
- * @return bool
252
  */
253
- public static function isPatched()
254
- {
255
- return method_exists('Mage', 'getStaticState') && method_exists('Mage', 'restoreState');
256
  }
257
-
 
258
  /**
259
- * Checks whether method is available.
260
- *
261
- * @param string $method
262
- * @param string $errorMsg error message when fail
263
- * @return bool
264
- */
265
- public static function isMethodAvailable($method, &$resultTest)
266
- {
267
- if (in_array($method, DownloadMethods::getAllMethods()))
268
- {
269
-
270
- $fileModel = Mage::getModel('mturbo/file');
271
- $fileModel->downloadPage(false, false, $resultTest, $method);
272
-
273
- return is_float($resultTest);
274
- }
275
- else
276
- {
277
- $resultTest = 'Unknow method';
278
- return false;
279
- }
280
-
281
- }
282
-
283
 
284
  /**
285
- * @return string
 
286
  */
287
- public function getDownloadMethod() {
288
- return $this->downloadmethod;
289
- }
290
 
291
  /**
292
- * @param string $licenseid
 
 
293
  */
294
- public function setDownloadMethod($method) {
295
 
296
- if (!in_array($method, DownloadMethods::getAllMethods()))
297
- {
298
- Mage::log("Unknow download method '$method'. Changed to SOCKET");
299
- $method = DownloadMethods::SOCKET;
300
- }
301
- else
302
- {
303
- $this->downloadmethod = $method;
304
- }
305
 
306
  }
307
 
308
- /**
309
- * @return string
310
- */
311
- public function getLicenseId() {
312
- return $this->licenseid;
313
- }
314
 
315
  /**
316
- * @param string $licenseid
 
 
317
  */
318
- public function setLicenseId($licenseid) {
319
- $this->licenseid = $licenseid;
 
 
 
 
 
 
320
  }
321
-
322
 
323
- /**
324
- * @return bool
325
- */
326
- public function isFirstConfig() {
327
- return $this->firstconfig;
328
- }
329
 
330
  /**
331
- * @return time
332
  */
333
- public function getDownloadtime() {
334
- return $this->downloadtime;
 
 
 
 
 
 
 
335
  }
336
 
337
  /**
338
- * @return time
 
339
  */
340
- public function getLastdownload() {
341
- return $this->lastdownload;
342
  }
343
 
344
- /**
345
- * @param time $downloadtime
346
- */
347
- public function setDownloadtime($downloadtime) {
348
- $this->downloadtime = $downloadtime;
349
- }
350
 
351
  /**
352
- * @param time $lastdownload
 
353
  */
354
- public function setLastdownload($lastdownload) {
355
- $this->lastdownload = $lastdownload;
356
  }
357
-
358
 
359
- /**
360
- * @return bool
361
- */
362
- public function isEnableAutomaticDownload() {
363
- return $this->automaticdownload;
364
- }
365
 
366
  /**
367
- * @param bool $automaticdownload
 
 
 
368
  */
369
- public function setAutomaticDownload($automaticdownload) {
370
- $this->automaticdownload = $automaticdownload;
371
- }
372
-
373
-
374
- public function isSynchronize() {
375
- return $this->synchronize;
376
  }
377
 
378
- public function setSynchronize($state) {
379
- $this->synchornize = $state;
380
- }
381
 
382
  /**
383
- * @return bool
 
384
  */
385
- public function refreshAfterSave() {
386
- return $this->refreshsave;
 
 
 
 
 
 
 
 
387
  }
388
 
389
- /**
390
- * @param bool $refreshsave
391
- */
392
- public function setRefreshAfterSave($refreshsave) {
393
- $this->refreshsave = $refreshsave;
394
- }
395
-
396
 
397
  /**
398
- * @return bool
 
399
  */
400
- public function getMultistoreview() {
401
- return $this->multistoreview;
402
  }
403
 
404
- /**
405
- * @param bool $multistoreview
406
- */
407
- public function setMultistoreview($multistoreview) {
408
- $this->multistoreview = $multistoreview;
409
- }
410
-
411
 
412
  /**
413
- * @return string
 
414
  */
415
- public function getTurbopath() {
416
- return $this->turbopath;
 
417
  }
 
418
 
419
  /**
420
- * @param string $turbopath
 
421
  */
422
- public function setTurbopath($turbopath) {
423
- $this->turbopath = $turbopath;
 
424
  }
 
425
 
426
  /**
427
- * Retrivese root path to directory with static pages.
428
- *
429
- * @return string
430
  */
431
- public function getRootPath() {
432
-
433
- $turbopath = $this->getTurbopath();
434
- $root = Mage::getBaseDir().DS.$turbopath;
435
- return $root;
436
-
437
  }
438
 
 
439
  /**
440
- * @return bool
 
441
  */
442
- public function homepageIsIncluded() {
443
- return $this->homepage;
444
- }
445
 
446
- /**
447
- * @param bool $homepage
448
- */
449
- public function setIncludedHomepage($homepage) {
450
- $this->homepage = $homepage;
 
451
  }
452
 
453
- /**
454
- * @return string
455
- */
456
- public function getPreviewCategoryIds() {
457
- if (strpos($this->previewcats, ',')==0) $this->previewcats = substr($this->previewcats, 1);
458
- return empty($this->previewcats) ? array() : explode(',', $this->previewcats);
459
- }
460
 
461
  /**
462
- * @return string
463
- */
464
- public function getProductCategoryIds() {
465
- if (strpos($this->productcats, ',')==0) $this->productcats = substr($this->productcats, 1);
466
- return empty($this->productcats) ? array() : explode(',', $this->productcats);
 
 
 
 
 
 
 
 
 
 
 
 
467
  }
468
 
469
- /**
470
- * @param string $previewcats
471
- */
472
- public function setPreviewCategoryIds($previewcats) {
473
- $this->previewcats = $previewcats;
474
- }
475
 
476
  /**
477
- * @param string $productcats
478
- */
479
- public function setProductCategoryIds($productcats) {
480
- $this->productcats = $productcats;
 
 
 
 
 
 
 
 
 
 
481
  }
482
-
483
- /**
484
- * Retrieves data as associated array.
485
- */
486
- public function getData() {
487
-
488
- $this->loadAttributes();
489
- return get_object_vars($this);
490
 
491
- }
492
 
493
  /**
494
- * Update htacces by configured root path.
 
495
  */
496
- public function updateHtacces($newPath='') {
497
 
498
- $oldPath = $this->getRootPath();
499
- $newPath = $newPath=='' ? $oldPath : Mage::getBaseDir().DS.$newPath;
500
 
501
- $htaccesPath = Mage::getBaseDir().DS.'.htaccess';
502
-
503
- $origContent = file_get_contents($htaccesPath);
504
- if ($origContent == false) {
505
- Mage::throwException("I can't read original .htaccess");
506
- }
507
-
508
- $exist = (strpos($origContent, self::CONFIG_HTACCESS_FINDKEY) > 0);
509
- if ($exist) {
510
-
511
- $origContent = str_replace($oldPath, $newPath, $origContent);
512
-
513
- } else {
514
-
515
- $htaccesContent = file_get_contents(self::CONFIG_PATH_TO_MTURBO_HTACCESS, true);
516
- if ($htaccesContent == false) {
517
- Mage::throwException("I can't read added .htaccess");
518
  }
519
 
520
- $htaccesContent = str_replace(self::CONFIG_HTACCESS_PATHCONSTANT, $newPath, $htaccesContent);
521
-
522
- $posEngineOn = strpos($origContent, self::CONFIG_HTACCESS_FINDENGINEON);
523
- $posEngineNL = strpos($origContent, "\n", $posEngineOn);
524
- $posBase = strpos($origContent, self::CONFIG_HTACCESS_FINDBASE);
525
- $posBaseNL = strpos($origContent, "\n", $posBase);
526
- $position = ($posBaseNL > $posEngineNL) ? $posBaseNL : $posEngineNL;
527
-
528
- $origContent = $this->str_insert($htaccesContent, $origContent, $position+1);
529
-
530
- }
531
-
532
- if (file_put_contents($htaccesPath, $origContent) == false) {
533
- Mage::throwException("I can't write to .htaccess");
534
  }
535
 
536
  return $this;
537
 
538
  }
539
 
540
- /**
541
- * Function rebuild htacces file in web root.
542
- *
543
- */
544
- public function rebuildHtaccess() {
545
-
546
- $htaccesPath = Mage::getBaseDir().DS.'.htaccess';
547
- if (!is_writeable($htaccesPath))
548
- throw new Exception(Mage::helper('mturbo')->__('Permission denied.')." ($htaccesPath)");
549
-
550
- $content = file_get_contents($htaccesPath);
551
- if (!$content)
552
- throw new Exception(Mage::helper('mturbo')->__("I can't read .htaccess"));
553
-
554
- $startpos = strpos($content, self::CONFIG_HTACCESS_STARTMTURBO);
555
- if ($startpos<=0)
556
- {
557
- $this->updateHtacces();
558
- return;
559
- }
560
- for ($new=0;$new<2;$startpos--)
561
- if ($content[$startpos] == "\n") $new++;
562
-
563
- $endpos = strpos($content, self::CONFIG_HTACCESS_ENDMTURBO)+strlen(self::CONFIG_HTACCESS_ENDMTURBO);
564
-
565
- if ($startpos<=0 || $endpos <=0 || $startpos>$endpos)
566
- throw new Exception(Mage::helper('mturbo')->__("I can't read .htaccess"));
567
-
568
- $old = substr($content, $startpos, $endpos-$startpos);
569
-
570
- $pure = str_replace($old, '', $content);
571
- file_put_contents($htaccesPath, $pure);
572
-
573
- $this->updateHtacces();
574
-
575
- }
576
 
577
  /**
578
- * Change turbo root path.
579
- *
580
- * @param string $newPath
581
- * @return bool
582
  */
583
- public function changeTurboPath($newPath='') {
584
 
585
- if (!$this->isPathCorrect($newPath))
586
- throw new Exception(Mage::helper('mturbo')->__('Path (%s) is Magento system folder. Please use other.', $newPath));
587
 
588
- Mage::log('Changing turbo path: ' . $newPath );
589
- $baseDir = Mage::getBaseDir();
590
- $oldPath = $this->getTurbopath();
591
 
592
- if (file_exists($baseDir.DS.$newPath))
593
- return true;
594
-
595
- if (file_exists($baseDir.DS.$oldPath) && (!$this->isFirstConfig())) {
596
-
597
- $command = 'mv ' . $this->getRootPath() . ' ' . $baseDir.DS.$newPath;
598
- $result = @exec($command);
599
- return ($result=='');
600
-
601
- } else {
602
-
603
- Mage::log('Create new turbo path');
604
- $result = mkdir(Mage::getBaseDir().DS.$newPath);
605
- if (!$result) {
606
- Mage::log('Creating turbo path: ' . Mage::getBaseDir().DS.$newPath. ' fail');
607
  }
608
- $result2 = $this->copyAllowAccess(Mage::getBaseDir().DS.$newPath);
609
- if (!$result2) {
610
- Mage::log('Copy .htaccess: ' . Mage::getBaseDir().DS.$newPath. ' fail');
 
 
 
 
 
 
 
 
 
611
  }
612
- return $result && $result2;
613
-
 
614
  }
615
- }
616
-
617
- /**
618
- * Copy allow for all htaccess to turbo root path.
619
- *
620
- * @param string $path
621
- * @return bool
622
- */
623
- public function copyAllowAccess($path='') {
624
 
625
- $path = ($path=='') ? Mage::getBaseDir().DS.$this->getTurbopath() : $path;
 
 
626
 
627
- $dest = $path.DS.'.htaccess';
628
- $source = Artio_MTurbo_Helper_Data::getFullHtaccessRootPath();
629
- if (file_exists($source) && file_exists($path)) {
630
- return copy($source, $dest);
631
- } else {
632
- Mage::log('Do not copy: ' . $source . ' >> ' . $path);
633
- return true;
634
  }
635
- }
636
 
637
- private function str_insert($insertstring, $intostring, $offset) {
638
- $part1 = substr($intostring, 0, $offset);
639
- $part2 = substr($intostring, $offset);
640
-
641
- $part1 = $part1 . $insertstring;
642
- $whole = $part1 . $part2;
643
- return $whole;
644
  }
645
 
646
  /**
647
- * Load attributes from core_config_data
648
- * @return Artio_MTurbo_Model_Config
649
  */
650
- public function loadAttributes() {
651
 
652
- if (count($this->pathids)==0) {
653
-
654
- $config = Mage::getModel('core/config_data');
655
- $mydata = get_object_vars($this);
656
-
657
- $collection = $config->getCollection();
658
- $collection->addFieldToFilter('path', array('like'=>'%mturbo%'));
659
- $collection->load();
660
 
661
- foreach ($collection as $object) {
662
- $path = $object->getData('path');
663
-
664
- $keys = explode('/', $path);
 
 
 
 
 
 
 
665
 
666
- if (strpos($path, 'rontab')>0) {
667
- if ($path==self::CONFIG_XML_PATH_DOWNLOAD_TIME)
668
- $this->setDownloadtime($object->getData('value'));
669
- $this->pathids[$path] = $object->getData('config_id');
670
- continue;
671
  }
672
-
673
- if (count($keys)!==2)
674
- continue;
675
-
676
- if (in_array($this->$keys[1], $mydata))
677
- $this->$keys[1] = $object->getData('value');
678
- else
679
- Mage::throwException('Key "' . $keys[1] . '" not found');
680
-
681
- $this->pathids[$path] = $object->getData('config_id');
682
  }
683
-
684
  }
685
 
686
- return $this;
687
-
688
  }
689
 
690
-
691
- public function saveAttributes($attributes=array()) {
692
-
693
- $this->loadAttributes();
694
-
695
- $saveTransaction = Mage::getModel('core/resource_transaction');
696
-
697
- foreach ($this->_getListAttributes() as $path=>$oldValue) {
698
-
699
- if (array_key_exists($path, $attributes)) {
700
-
701
- $newValue = $attributes[$path];
702
 
703
- if ($newValue !== $oldValue) {
704
-
705
- $dataObject = Mage::getModel('core/config_data');
706
- $dataObject->setPath($path);
707
- $dataObject->setValue($newValue);
708
-
709
- if (array_key_exists($path, $this->pathids)) {
710
- $dataObject->setId( $this->pathids[$path] );
711
- }
712
-
713
- $saveTransaction->addObject($dataObject);
714
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
  }
716
 
717
  }
718
-
719
  }
720
 
721
-
722
- /** save crontab expression */
723
- if (array_key_exists(self::CONFIG_XML_PATH_DOWNLOAD_TIME, $attributes)) {
724
- $this->_saveExtraAttribute(
725
- self::CONFIG_XML_PATH_DOWNLOAD_TIME,
726
- $this->_formatDownloadTimeToCron($attributes[self::CONFIG_XML_PATH_DOWNLOAD_TIME]),
727
- $saveTransaction);
728
- }
729
- $this->_saveExtraAttribute( self::CONFIG_XML_PATH_DOWNLOAD_MODEL_PATH,
730
- self::CONFIG_XML_PATH_DOWNLOAD_MODEL_VALUE,
731
- $saveTransaction);
732
-
733
-
734
- if ($this->_isNewTurboPath($attributes)) {
735
- $newPath = $attributes[self::CONFIG_XML_PATH_TURBOPATH];
736
- try {
737
- $this->changeTurboPath($newPath);
738
- $this->updateHtacces($newPath);
739
- } catch (Exception $e) {
740
- Mage::log('For change turbopath Throw exception ' . $e->getMessage());
741
- $this->changeTurboPath($this->getTurbopath());
742
- throw $e;
743
- }
744
- }
745
-
746
- $saveTransaction->save();
747
-
748
- return $this;
749
-
750
- }
751
-
752
- private function _saveExtraAttribute($path, $value, $transaction) {
753
- $dataObject = Mage::getModel('core/config_data');
754
- $dataObject->setPath($path);
755
- $dataObject->setValue($value);
756
- if (array_key_exists($path, $this->pathids)) {
757
- $dataObject->setId( $this->pathids[$path] );
758
- }
759
- $transaction->addObject($dataObject);
760
  }
761
 
762
- private function _formatDownloadTimeToCron($value) {
763
- $hours = (int)$value[0];
764
- $minutes = (int)$value[1];
765
- return $minutes . ' ' . $hours . ' * * *';
766
- }
767
-
768
- private function _isNewTurboPath($attributes=array()) {
769
- if (array_key_exists(self::CONFIG_XML_PATH_TURBOPATH, $attributes)) {
770
- return ($attributes[self::CONFIG_XML_PATH_TURBOPATH] != $this->getTurbopath());
771
- } else {
772
- return false;
773
- }
774
  }
775
 
776
- private function _getListAttributes() {
777
- return array(
778
- self::CONFIG_XML_PATH_PREVIEW_CATEGORIES => $this->previewcats,
779
- self::CONFIG_XML_PATH_PRODUCT_CATEGORIES => $this->productcats,
780
- self::CONFIG_XML_PATH_INCLUDED_HOMEPAGE => $this->homepage,
781
- self::CONFIG_XML_PATH_TURBOPATH => $this->turbopath,
782
- self::CONFIG_XML_PATH_MULTISTOREVIEW => $this->multistoreview,
783
- self::CONFIG_XML_PATH_REFRESH_AFTER_SAVE => $this->refreshsave,
784
- self::CONFIG_XML_PATH_SYNCHRONIZE => $this->synchronize,
785
- self::CONFIG_XML_PATH_ENABLE_AUTOMATIC_DOWNLOAD => $this->automaticdownload,
786
- self::CONFIG_XML_PATH_LAST_DOWNLOAD => $this->lastdownload,
787
- self::CONFIG_XML_PATH_FIRSTCONFIG => $this->firstconfig,
788
- self::CONFIG_XML_PATH_LICENSEID => $this->licenseid,
789
- self::CONFIG_XML_PATH_DOWNLOAD_METHOD => $this->downloadmethod
790
- );
791
- }
 
 
 
792
 
 
 
 
 
793
 
794
  }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ /**
22
+ * The model holds all configuration information.
23
+ * It is appropriate to create as Singleton.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Model_Config extends Varien_Object
30
  {
31
 
 
32
  const CONFIG_PATH_TO_MTURBO_DOWNLOAD = 'scripts/getstatichtml.sh';
33
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  const CONFIG_XML_PATH_DOWNLOAD_MODEL_PATH = 'crontab/jobs/mturbo_mturbo/run/model';
35
  const CONFIG_XML_PATH_DOWNLOAD_MODEL_VALUE = 'mturbo/observer::automaticDownload';
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  /**
39
+ * Map associated private member name to xml configuration key
40
  * @var array
41
  */
42
+ private static $configArrayMap = NULL;
43
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  /**
46
+ * Function retrieve associated array 'name'=>'config key'.
47
  */
48
+ public function getConfigArrayMap() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ if (is_null(self::$configArrayMap)) {
 
 
 
 
 
 
 
51
 
52
+ self::$configArrayMap = array(
 
 
 
 
 
 
 
 
 
 
53
 
54
+ 'preview_categories' => 'mturbo/previewcats',
55
+ 'product_categories' => 'mturbo/productcats',
56
+ 'cms_pages' => 'mturbo/cmspages',
57
+ 'turbopath' => 'mturbo/turbopath',
58
+ 'download_method' => 'mturbo/downloadmethod',
59
+ 'automatic_download' => 'mturbo/automaticdownload',
60
+ 'automatic_download_time' => 'crontab/jobs/mturbo_mturbo/schedule/cron_expr',
61
+ 'last_time_of_automatic_download' => 'mturbo/lastdownload',
62
+ 'enabled_htaccess_backup' => 'mturbo/htaccessbackup',
63
+ 'number_of_htaccess_backups' => 'mturbo/numberhtaccessbackups',
64
+ 'minimal_page_size' => 'mturbo/minimalpagesize',
65
+ 'download_id' => 'mturbo/downloadid',
66
+ 'add_newly_category_to_select' => 'mturbo/newcategory',
67
+ 'add_newly_product_to_select' => 'mturbo/newproduct',
68
+ 'add_newly_cms_to_select' => 'mturbo/newcms',
69
+ 'refresh_category' => 'mturbo/refreshcategory',
70
+ 'refresh_parents_for_category' => 'mturbo/refreshparentcategory',
71
+ 'refresh_product' => 'mturbo/refreshproduct',
72
+ 'refresh_parents_for_product' => 'mturbo/refreshparentproduct',
73
+ 'refresh_cms' => 'mturbo/refreshcms',
74
+ 'dynamic_blocks' => 'mturbo/dynamicblocks',
75
+ 'firstconfig' => 'mturbo/firstconfig'
76
 
77
+ );
78
+
79
+ }
80
+
81
+ return self::$configArrayMap;
82
 
83
  }
84
 
85
  /**
86
+ * Constructs configuration model.
87
+ * Currently loaded configuration from the database.
88
  */
89
+ public function __construct() {
90
+ parent::__construct();
91
+ $this->load();
92
  }
93
+
94
+
95
  /**
96
+ * Array of singletons of configuration for websites.
97
+ * ('websitecode'=>'configuration')
98
+ * @var array
99
+ */
100
+ private $websitesConfiguration = array();
101
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  /**
104
+ * Save key => id, prevent duplicate entry during saving.
105
+ * @var array
106
  */
107
+ private $pathids = array();
108
+
 
109
 
110
  /**
111
+ * Retrieves website configuration.
112
+ * @param string $websiteCode code of website
113
+ * @return Artio_MTurbo_Model_Config_Website
114
  */
115
+ public function getWebsiteConfig($websiteCode) {
116
 
117
+ if (!isset($this->websitesConfiguration[$websiteCode]))
118
+ $this->websitesConfiguration[$websiteCode] =
119
+ Mage::getModel('mturbo/config_website')
120
+ ->setWebsiteCode($websiteCode)
121
+ ->load();
122
+
123
+ return $this->websitesConfiguration[$websiteCode];
 
 
124
 
125
  }
126
 
 
 
 
 
 
 
127
 
128
  /**
129
+ * Retrieve website configuration by storeview codes.
130
+ * @param string $storeviewCode
131
+ * @return Artio_MTurbo_Model_Config_Website
132
  */
133
+ public function getWebsiteConfigByStoreviewCode($storeviewCode) {
134
+
135
+ $store = Mage::getModel('core/store')->load($storeviewCode);
136
+ if ($store)
137
+ return $this->getWebsiteConfig($store->getWebsite()->getCode());
138
+ else
139
+ return null;
140
+
141
  }
 
142
 
 
 
 
 
 
 
143
 
144
  /**
145
+ * Method retrieves codes of all enabled stores.
146
  */
147
+ public function getAllEnabledStores() {
148
+ $result = '';
149
+ $coll = Mage::getModel('core/website')->getCollection()->load();
150
+ foreach ($coll->getItems() as $website) {
151
+ $config = $this->getWebsiteConfig($website->getCode());
152
+ if ($config && $config->getEnabled()=='1')
153
+ $result .= ','.$config->getEnabledStoreviews();
154
+ }
155
+ return explode(",", $result);
156
  }
157
 
158
  /**
159
+ * Retrieves ids of selected categories as array.
160
+ * @return array
161
  */
162
+ public function getPreviewCategoriesAsArray() {
163
+ return $this->getPreviewCategories()!='' ? explode(",", $this->getPreviewCategories()) : array();
164
  }
165
 
 
 
 
 
 
 
166
 
167
  /**
168
+ * Retrieves ids of selected product categories as array.
169
+ * @return array
170
  */
171
+ public function getProductCategoriesAsArray() {
172
+ return $this->getProductCategories()!='' ? explode(",", $this->getProductCategories()) : array();
173
  }
 
174
 
 
 
 
 
 
 
175
 
176
  /**
177
+ * Retrieves ids of selected cms pages and the id of
178
+ * coresponded storeview code as array.
179
+ * Element of array has format pageid_storeid
180
+ * @return array
181
  */
182
+ public function getCmsPagesWithStoresAsArray() {
183
+ return explode(",", $this->getCmsPages());
 
 
 
 
 
184
  }
185
 
 
 
 
186
 
187
  /**
188
+ * Retrieves ids of cms pages, which has at least one store view mutation checked.
189
+ * @return array
190
  */
191
+ public function getCmsPagesWithoutStoresAsArray() {
192
+ $result = array();
193
+ foreach ($this->getCmsPagesWithStoresAsArray() as $pageWithStore) {
194
+ $matches = array();
195
+ preg_match_all('/([0-9]+)_([0-9]+)/', $pageWithStore, $matches);
196
+ if (count($matches)==3)
197
+ if (isset($matches[1][0]))
198
+ $result[] = $matches[1][0];
199
+ }
200
+ return array_unique($result);
201
  }
202
 
 
 
 
 
 
 
 
203
 
204
  /**
205
+ * Retrieves layout names of selected dynamic blocks as array.
206
+ * @return array
207
  */
208
+ public function getDynamicBlocksAsArray() {
209
+ return explode(",", $this->getDynamicBlocks());
210
  }
211
 
 
 
 
 
 
 
 
212
 
213
  /**
214
+ * Set preview categories
215
+ * @param string|array $categories
216
  */
217
+ public function setPreviewCategories($categories) {
218
+ $this->setData('preview_categories', implode(",", Mage::helper('mturbo/functions')->make_unique_array($categories)));
219
+ return $this;
220
  }
221
+
222
 
223
  /**
224
+ * Set product categories
225
+ * @param string|array $categories
226
  */
227
+ public function setProductCategories($categories) {
228
+ $this->setData('product_categories', implode(",", Mage::helper('mturbo/functions')->make_unique_array($categories)));
229
+ return $this;
230
  }
231
+
232
 
233
  /**
234
+ * Set cms pages.
235
+ * @param string|array $categories
 
236
  */
237
+ public function setCmsPages($pages) {
238
+ $this->setData('cms_pages', implode(",", Mage::helper('mturbo/functions')->make_unique_array($pages)));
239
+ return $this;
 
 
 
240
  }
241
 
242
+
243
  /**
244
+ * Set turbo path
245
+ * @param string $path
246
  */
247
+ public function setTurbopath($path) {
 
 
248
 
249
+ $len = strlen($path);
250
+ if ($path[$len-1]=='/')
251
+ $path = substr($path, 0, $len-1);
252
+
253
+ $this->setData('turbopath', $path);
254
+
255
  }
256
 
 
 
 
 
 
 
 
257
 
258
  /**
259
+ * Function set download method.
260
+ * If download method is unknow, then function set default method
261
+ *
262
+ * @param string code of method
263
+ */
264
+ public function setDownloadMethod($method) {
265
+
266
+ $methodsFactory = Mage::getSingleton('mturbo/downloadMethodsFactory');
267
+
268
+ /* checks method */
269
+ if ($methodsFactory->exists($method))
270
+ $this->setData('download_method', $method);
271
+ else
272
+ $this->setData('download_method', $methodsFactory->getDefaultMethod());
273
+
274
+ return $this;
275
+
276
  }
277
 
 
 
 
 
 
 
278
 
279
  /**
280
+ * Function transform download time in classic format to cron format, when necessary
281
+ *
282
+ * @param $value download time in format array([0]=>hours, [1]=>minutes);
283
+ * @return string download time in cron format
284
+ */
285
+ public function setAutomaticDownloadTime($value) {
286
+ if (is_array($value)) {
287
+ $hours = (int)$value[0];
288
+ $minutes = (int)$value[1];
289
+ $this->setData('automatic_download_time', $minutes . ' ' . $hours . ' * * *');
290
+ } else {
291
+ $this->setData('automatic_download_time', $value);
292
+ }
293
+ return $this;
294
  }
 
 
 
 
 
 
 
 
295
 
 
296
 
297
  /**
298
+ * Load attributes from core_config_data
299
+ * @return Artio_MTurbo_Model_Config this
300
  */
301
+ public function load() {
302
 
303
+ /* load from configuration table all records contains mturbo */
304
+ $config = Mage::getModel('core/config_data');
305
 
306
+ $collection = $config->getCollection();
307
+ $collection->addFieldToFilter('path', array('like'=>'%mturbo%'));
308
+ $collection->load();
309
+
310
+ /* load all private members and flip it */
311
+ $mydata = array_flip($this->getConfigArrayMap());
312
+
313
+ /* foreach records from configuration table */
314
+ foreach ($collection as $object) {
315
+
316
+ $key = $object->getPath();
317
+ if (array_key_exists($key, $mydata)) {
318
+ $func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $mydata[$key])));
319
+ $this->$func($object->getValue());
 
 
 
320
  }
321
 
322
+ /* save pathid, prevent duplicate entry during saving */
323
+ $this->pathids[$key] = $object->getData('config_id');
324
+
 
 
 
 
 
 
 
 
 
 
 
325
  }
326
 
327
  return $this;
328
 
329
  }
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
 
332
  /**
333
+ * Function saves value from model to database.
334
+ *
335
+ * @param array attributes to save
 
336
  */
337
+ public function save($attributes=array()) {
338
 
339
+ /* get resource transaction model */
340
+ $saveTransaction = Mage::getModel('core/resource_transaction');
341
 
342
+ /* get configuration map */
343
+ $mydata = $this->getConfigArrayMap();
 
344
 
345
+ /* save attributes in argument using setter */
346
+ foreach ($attributes as $key=>$value) {
347
+ if (array_key_exists($key, $mydata)) {
348
+
349
+ /* check whether turbopath was changed, if yes then in validate execute correcten action */
350
+ if ($key=='turbopath' && $this->getTurbopath()!='' && $this->getTurbopath()!=$attributes['turbopath'])
351
+ $this->setData('old_turbopath', $this->getTurbopath());
352
+
353
+ $func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $key)));
354
+ $this->$func($value);
 
 
 
 
 
355
  }
356
+ }
357
+
358
+ /* saves to transaction all configuration values */
359
+ foreach ($mydata as $name=>$key) {
360
+
361
+ /* save object to transaction */
362
+ $dataObject = Mage::getModel('core/config_data');
363
+ $dataObject->setPath($key);
364
+ $dataObject->setValue($this->getData($name));
365
+ /* set id, prevent duplicate entry */
366
+ if (array_key_exists($key, $this->pathids)) {
367
+ $dataObject->setId( $this->pathids[$key] );
368
  }
369
+
370
+ $saveTransaction->addObject($dataObject);
371
+
372
  }
 
 
 
 
 
 
 
 
 
373
 
374
+ /* validate input data */
375
+ $this->_validate();
376
+ $this->_changePath();
377
 
378
+ /* save into database */
379
+ $saveTransaction->save();
380
+
381
+ /* save slaved website configuration */
382
+ $websites = Mage::getModel('core/website')->getCollection()->load()->getItems();
383
+ foreach ($websites as $website) {
384
+ $this->getWebsiteConfig($website->getCode())->save();
385
  }
 
386
 
387
+ return $this;
388
+
 
 
 
 
 
389
  }
390
 
391
  /**
392
+ * Function change path. It is executed when user change turbopath or
393
+ * website base dir in m-turbo configuration (except first executed during installation).
394
  */
395
+ private function _changePath() {
396
 
397
+ foreach ($this->websitesConfiguration as $websiteConfig) {
398
+ if ($websiteConfig->getEnabled()=='1') {
 
 
 
 
 
 
399
 
400
+ $oldtp = $this->getData('old_turbopath');
401
+ $oldbd = $websiteConfig->getData('old_basedir');
402
+ if (($oldtp!=='') || ($oldbd!=='')) {
403
+
404
+ $newtp = $this->getTurbopath();
405
+ $newbd = $websiteConfig->getBaseDir();
406
+
407
+ @rename($oldbd.DS.$oldtp, $newbd.DS.$newtp);
408
+ Mage::getModel('mturbo/htaccess')
409
+ ->setWebsiteCode($websiteConfig->getWebsiteCode())
410
+ ->rebuildHtaccess();
411
 
 
 
 
 
 
412
  }
 
 
 
 
 
 
 
 
 
 
413
  }
 
414
  }
415
 
 
 
416
  }
417
 
 
 
 
 
 
 
 
 
 
 
 
 
418
 
419
+ /**
420
+ * Function validates user's input.
421
+ * Throws exception, when inpus is not valid.
422
+ */
423
+ private function _validate() {
424
+
425
+ $path = $this->getTurbopath();
426
+
427
+ if (!$this->_isPathCorrect($path))
428
+ Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
429
+ if (!$this->_isPathPossible($path))
430
+ Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not usable. This path is used by system Magento, please enter other path.", $path));
431
+
432
+ $paths = array();
433
+ foreach ($this->websitesConfiguration as $websiteConfig) {
434
+ if ($websiteConfig->getEnabled()=='1') {
435
+
436
+ $path = $websiteConfig->getBaseDir();
437
+
438
+ if (!$this->_isPathCorrect($path))
439
+ Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
440
+
441
+ if (in_array($path, $paths)) {
442
+ Mage::throwException(Mage::helper('mturbo')->__("Two diferent websites can't have one base dir. Please check, that each website has unique base dir."));
443
+ } else {
444
+ $paths[] = $path;
445
  }
446
 
447
  }
 
448
  }
449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  }
451
 
452
+ /**
453
+ * Check general form of input path.
454
+ */
455
+ private function _isPathCorrect($path) {
456
+ return preg_match('/^([a-zA-Z]\:\/)?([a-zA-Z0-9\._\/\-\\\\])*$/', $path);
 
 
 
 
 
 
 
457
  }
458
 
459
+ /**
460
+ * Function checks whether path may be used as turbocache directory.
461
+ *
462
+ * @return bool TRUE when path is correct, otherwise FALSE
463
+ */
464
+ private function _isPathPossible($path)
465
+ {
466
+ if ((preg_match('/^app[\/]{0,}(.)*/', $path)) ||
467
+ (preg_match('/^404[\/]{0,}(.)*/', $path)) ||
468
+ (preg_match('/^downloader[\/]{0,}(.)*/', $path)) ||
469
+ (preg_match('/^js[\/]{0,}(.)*/', $path)) ||
470
+ (preg_match('/^lib[\/]{0,}(.)*/', $path)) ||
471
+ (preg_match('/^media[\/]{0,}(.)*/', $path)) ||
472
+ (preg_match('/^pkginfo[\/]{0,}(.)*/', $path)) ||
473
+ (preg_match('/^report[\/]{0,}(.)*/', $path)) ||
474
+ (preg_match('/^skin[\/]{0,}(.)*/', $path)) ||
475
+ (preg_match('/^var\/cache[\/]{0,}(.)*/', $path)) ||
476
+ (preg_match('/^var\/report[\/]{0,}(.)*/', $path)) ||
477
+ (preg_match('/^var\/session[\/]{0,}(.)*/', $path))) return FALSE;
478
 
479
+ /* path is correct */
480
+ return TRUE;
481
+
482
+ }
483
 
484
  }
app/code/local/Artio/MTurbo/Model/Config/CmsTransformer.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * The model contains function for preparing configuration data of selected cms pages for
23
+ * administration form and back.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Model_Config_CmsTransformer extends Varien_Object
30
+ {
31
+
32
+ /**
33
+ * Method transform form data to config and fill it.
34
+ * @param Artio_MTurbo_Model_Config $config
35
+ * @param array $formData data from form
36
+ */
37
+ public function extractData($config, $formData=array()) {
38
+
39
+ $cms = array();
40
+
41
+ /* foreach data */
42
+ foreach ($formData as $key=>$value) {
43
+
44
+ $keys = array();
45
+
46
+ /* key for selected pages */
47
+ if (preg_match('/^cms_tree_([0-9]+_[0-9]+)$/', $key, $keys)) {
48
+ if (count($keys)==2)
49
+ $cms[] = $keys[1];
50
+ }
51
+
52
+ }
53
+
54
+ $config->setCmsPages(implode(",", $cms));
55
+
56
+ }
57
+
58
+ /**
59
+ * Method transform data for administration form and retrieves as array.
60
+ * @param Artio_MTurbo_Model_Config $config
61
+ * @return array transformed data
62
+ */
63
+ public function configToForm($config) {
64
+
65
+ /* result is empty */
66
+ $result = array();
67
+
68
+ foreach ($config->getCmsPagesWithStoresAsArray() as $cms) {
69
+ $result['cms_tree_'.$cms] = '1';
70
+ }
71
+
72
+ /* return result */
73
+ return $result;
74
+
75
+ }
76
+
77
+ }
app/code/local/Artio/MTurbo/Model/Config/DynamicTransformer.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * The model contains function for preparing configuration data of dynamic transformers.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_Config_DynamicTransformer extends Varien_Object
29
+ {
30
+
31
+ // associative array 'name' => 'type'
32
+ private $defaultBlocks = array(
33
+
34
+ 'comparesidebar' => 'catalog/product_compare_sidebar',
35
+ 'cartsidebar' => 'checkout/cart_sidebar',
36
+ 'pollsidebar' => 'poll/activePoll',
37
+
38
+ );
39
+
40
+ private $classBlocks13 = array (
41
+
42
+ 'comparesidebar' => 'Mage_Reports_Block_Product_Compared',
43
+ 'cartsidebar' => 'Mage_Checkout_Block_Cart_Sidebar',
44
+ 'pollsidebar' => 'Mage_Poll_Block_ActivePoll',
45
+
46
+ );
47
+
48
+ private $classBlocks14 = array (
49
+
50
+ 'comparesidebar' => 'Mage_Catalog_Block_Product_Compare_Sidebar',
51
+ 'cartsidebar' => 'Mage_Checkout_Block_Cart_Sidebar',
52
+ 'pollsidebar' => 'Mage_Poll_Block_ActivePoll',
53
+
54
+ );
55
+
56
+ private $keysDefaultBlocks = null;
57
+ private $classBlocks = null;
58
+
59
+
60
+ /**
61
+ * Method dermines whether block is default.
62
+ * If block is user defined then method returns false.
63
+ *
64
+ * @param string $identifier
65
+ * @return bool
66
+ */
67
+ public function isDefaultBlock($identifier) {
68
+
69
+ if (!isset($this->keysDefaultBlocks))
70
+ $this->keysDefaultBlocks = array_keys($this->defaultBlocks);
71
+
72
+ return in_array($identifier, $this->keysDefaultBlocks);
73
+
74
+ }
75
+
76
+
77
+ /**
78
+ * Method retrieves type block by identifier.
79
+ * Returns false, when identifier is unknowed.
80
+ * @param string $identifier
81
+ * @return bool
82
+ */
83
+ public function getType($identifier) {
84
+
85
+ if (isset($this->defaultBlocks[$identifier]))
86
+ return $this->defaultBlocks[$identifier];
87
+ else
88
+ return false;
89
+
90
+ }
91
+
92
+ private function _getClassBlocks() {
93
+
94
+ if (!isset($this->classBlocks)) {
95
+
96
+ $this->classBlocks = $this->classBlocks14;
97
+ try {
98
+
99
+ $version = explode(".", Mage::getVersion());
100
+ $this->classBlocks = (isset($version[1]) && ($version[1]=='3')) ? $this->classBlocks13 : $this->classBlocks14;
101
+
102
+ } catch (Exception $e) { }
103
+
104
+ }
105
+
106
+ return $this->classBlocks;
107
+
108
+ }
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
+
140
+ /**
141
+ * Method transform form data to config and fill it.
142
+ * @param Artio_MTurbo_Model_Config $config
143
+ * @param array $formData data from form
144
+ */
145
+ public function extractData($config, $formData=array()) {
146
+
147
+ $blocks = array();
148
+
149
+ /* foreach data */
150
+ foreach ($formData as $key=>$value) {
151
+ if ($this->isDefaultBlock($key))
152
+ if ($value=='1')
153
+ $blocks[] = $key;
154
+ }
155
+
156
+ if (isset($formData['userblocks']))
157
+ $blocks = array_merge($blocks, explode(",", $formData['userblocks']));
158
+
159
+ $config->setDynamicBlocks(implode(",", array_unique($blocks)));
160
+
161
+ }
162
+
163
+
164
+ /**
165
+ * Method transform data for administration form and retrieves as array.
166
+ * @param Artio_MTurbo_Model_Config $config
167
+ * @return array transformed data
168
+ */
169
+ public function configToForm($config) {
170
+
171
+ /* result is empty */
172
+ $result = array();
173
+
174
+ $dynamicBlocks = $config->getDynamicBlocksAsArray();
175
+ foreach ($dynamicBlocks as $dynamic) {
176
+ if ($this->isDefaultBlock($dynamic)) {
177
+ $result[$dynamic] = '1';
178
+ }
179
+ }
180
+
181
+ $diff = array_diff($dynamicBlocks, $this->keysDefaultBlocks);
182
+ $string = implode(",", $diff);
183
+ $result['userblocks'] = $string;
184
+
185
+ /* return result */
186
+ return $result;
187
+
188
+ }
189
+
190
+ }
app/code/local/Artio/MTurbo/Model/Config/Website.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * The model holds all configuration information for one website.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_Config_Website extends Varien_Object
29
+ {
30
+
31
+ /**
32
+ * Map associated private member name to xml configuration key
33
+ * @var array
34
+ */
35
+ private static $configArrayMap = NULL;
36
+
37
+
38
+ /**
39
+ * Function retrieve associated array 'name'=>'config key'.
40
+ * Char * represents website code.
41
+ */
42
+ public function getConfigArrayMap() {
43
+
44
+ if (is_null(self::$configArrayMap)) {
45
+
46
+ self::$configArrayMap = array(
47
+
48
+ 'enabled' => 'mturbo/website/*/enabled',
49
+ 'base_dir' => 'mturbo/website/*/basedir',
50
+ 'enabled_storeviews' => 'mturbo/website/*/enabledstoreviews'
51
+
52
+ );
53
+
54
+ }
55
+
56
+ return self::$configArrayMap;
57
+
58
+ }
59
+
60
+
61
+ /**
62
+ * Website code
63
+ * @var string
64
+ */
65
+ private $websitecode = null;
66
+
67
+ /**
68
+ * Save key => id, prevent duplicate entry during saving.
69
+ * @var array
70
+ */
71
+ private $pathids = array();
72
+
73
+
74
+ /**
75
+ * Set website code.
76
+ * @param string $websitecode
77
+ */
78
+ public function setWebsiteCode($websitecode) {
79
+ $this->websitecode = $websitecode;
80
+ return $this;
81
+ }
82
+
83
+
84
+ /**
85
+ * Get website code
86
+ * @param string $websitecode
87
+ */
88
+ public function getWebsiteCode() {
89
+ return $this->websitecode;
90
+ }
91
+
92
+
93
+ /**
94
+ * Retrieves ids of selected product categories as array.
95
+ * @return array
96
+ */
97
+ public function getEnabledStoreviewsAsArray() {
98
+ return explode(",", $this->getEnabledStoreviews());
99
+ }
100
+
101
+
102
+ /**
103
+ * Set enabled storeviews
104
+ * @param string|array $categories
105
+ */
106
+ public function setEnabledStoreviews($storeviews) {
107
+ $this->setData('enabled_storeviews', implode(',', Mage::helper('mturbo/functions')->make_unique_array($storeviews)));
108
+ return $this;
109
+ }
110
+
111
+
112
+ /**
113
+ * Set BaseDir
114
+ */
115
+ public function setBaseDir($basedir) {
116
+
117
+ $len = strlen($basedir);
118
+ if ($basedir[$len-1]=='/')
119
+ $basedir = substr($basedir, 0, $len-1);
120
+
121
+ $this->setData('base_dir', $basedir);
122
+
123
+ }
124
+
125
+
126
+ /**
127
+ * Determines whether store view is enabled.
128
+ * @param string $storeviewcode
129
+ */
130
+ public function isStoreViewEnabled($storeviewcode) {
131
+ return in_array($storeviewcode, $this->getEnabledStoreviewsAsArray());
132
+ }
133
+
134
+
135
+ /**
136
+ * Function set enabled/disabled settings for one storeview.
137
+ * @param string $storeviewcode
138
+ * @param bool $value
139
+ */
140
+ public function setOneStoreViewEnabled($storeviewcode, $value) {
141
+
142
+ $array = $this->getEnabledStoreviewsAsArray();
143
+ $isin = in_array($storeviewcode, $array);
144
+
145
+ if ($value && !$isin)
146
+ $this->setEnabledStoreviews(array_merge($array, array($storeviewcode)));
147
+ else if (!$value && $isin)
148
+ $this->setEnabledStoreviews(array_diff($array, array($storeviewcode)));
149
+ }
150
+
151
+
152
+ /**
153
+ * Method sets default values. It is called before loading.
154
+ */
155
+ public function setDefaultValues() {
156
+
157
+ $this->setEnabled(true);
158
+ $this->setBaseDir(Mage::getBaseDir());
159
+
160
+ /*$enabledStoreviews = array();
161
+ if (isset($this->websitecode)) {
162
+ $website = Mage::getModel('core/website')->load($this->websitecode);
163
+ foreach ($website->getStores() as $store)
164
+ if ($store->getIsActive())
165
+ $enabledStoreviews[] = $store->getCode();
166
+ }*/
167
+ $this->setEnabledStoreviews(array());
168
+
169
+ }
170
+
171
+
172
+ /**
173
+ * Load attributes from core_config_data
174
+ * @return Artio_MTurbo_Model_Config this
175
+ */
176
+ public function load() {
177
+
178
+ /* load only if websitecode is set */
179
+ if (!isset($this->websitecode))
180
+ return;
181
+
182
+ /* set default values */
183
+ $this->setDefaultValues();
184
+
185
+ /* load from configuration table all records contains mturbo */
186
+ $config = Mage::getModel('core/config_data');
187
+
188
+ $collection = $config->getCollection();
189
+ $collection->addFieldToFilter('path', array('like'=>'%mturbo/website/'.$this->websitecode.'/%'));
190
+ $collection->load();
191
+
192
+ /* load all private members, flip it and replacing * to websitecode */
193
+ $mydata = array();
194
+ $mydatatemp = array_flip($this->getConfigArrayMap());
195
+ foreach ($mydatatemp as $k=>$v)
196
+ $mydata[str_replace('*', $this->websitecode, $k)] = $v;
197
+
198
+ /* foreach records from configuration table */
199
+ foreach ($collection as $object) {
200
+
201
+ $key = $object->getPath();
202
+ if (array_key_exists($key, $mydata)) {
203
+ $func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $mydata[$key])));
204
+ $this->$func($object->getValue());
205
+ }
206
+
207
+ /* save pathid, prevent duplicate entry during saving */
208
+ $this->pathids[$key] = $object->getData('config_id');
209
+
210
+ }
211
+
212
+ return $this;
213
+
214
+ }
215
+
216
+
217
+ /**
218
+ * Function saves value from model to database.
219
+ *
220
+ * @param array attributes to save
221
+ */
222
+ public function save($attributes=array()) {
223
+
224
+ /* get resource transaction model */
225
+ $saveTransaction = Mage::getModel('core/resource_transaction');
226
+
227
+ /* get configuration map */
228
+ $mydata = $this->getConfigArrayMap();
229
+
230
+ /* save attributes in argument using setter */
231
+ foreach ($attributes as $key=>$value) {
232
+ if (array_key_exists($key, $mydata)) {
233
+
234
+ /* check whether turbopath was changed, if yes then in validate execute correcten action */
235
+ if ($key=='base_dir' && $this->getBaseDir()!='' && $this->getBaseDir()!=$attributes['base_dir'])
236
+ $this->setData('old_basedir', $this->getBaseDir());
237
+
238
+ $func = 'set'.str_replace(" ", "", ucwords(str_replace("_", " ", $key)));
239
+ $this->$func($value);
240
+ }
241
+ }
242
+
243
+ /* saves to transaction all configuration values */
244
+ foreach ($mydata as $name=>$key) {
245
+
246
+ /* replace * to websitecode in key */
247
+ $key = str_replace('*', $this->websitecode, $key);
248
+
249
+ /* save object to transaction */
250
+ $dataObject = Mage::getModel('core/config_data');
251
+ $dataObject->setPath($key);
252
+ $dataObject->setValue($this->getData($name));
253
+ /* set id, prevent duplicate entry */
254
+ if (array_key_exists($key, $this->pathids)) {
255
+ $dataObject->setId( $this->pathids[$key] );
256
+ }
257
+
258
+ $saveTransaction->addObject($dataObject);
259
+
260
+ }
261
+
262
+ /* save into database */
263
+ $saveTransaction->save();
264
+
265
+ return $this;
266
+ }
267
+
268
+ }
app/code/local/Artio/MTurbo/Model/Config/WebsiteTransformer.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * The model contains function for preparing configuration data of website for
23
+ * administration form and back.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Model_Config_WebsiteTransformer extends Varien_Object
30
+ {
31
+
32
+ /**
33
+ * Method transform form data to config and fill it.
34
+ * @param Artio_MTurbo_Model_Config $config
35
+ * @param array $formData data from form
36
+ */
37
+ public function extractData($config, $formData=array()) {
38
+
39
+ /* foreach data */
40
+ foreach ($formData as $key=>$value) {
41
+
42
+ $keys = array();
43
+
44
+ /* key for store enabled */
45
+ if (preg_match('/^website_([a-zA-Z0-9]+)_store_([a-zA-Z0-9]+)$/', $key, $keys)) {
46
+ if (count($keys)==3)
47
+ $config->getWebsiteConfig($keys[1])->setOneStoreViewEnabled($keys[2], $value);
48
+ }
49
+
50
+ /* key for website configuration */
51
+ else if (preg_match('/^website_([a-zA-Z0-9]+)_(.+)$/', $key, $keys)) {
52
+ if (count($keys)==3)
53
+ $config->getWebsiteConfig($keys[1])->setData($keys[2], $value);
54
+ }
55
+
56
+ }
57
+
58
+ }
59
+
60
+ /**
61
+ * Method transform data for administration form and retrieves as array.
62
+ * @param Artio_MTurbo_Model_Config $config
63
+ * @return array transformed data
64
+ */
65
+ public function configToForm($config) {
66
+
67
+ /* result is empty */
68
+ $result = array();
69
+
70
+ /* for each website */
71
+ $websiteCollection = Mage::getModel('core/website')->getCollection()->load();
72
+ foreach ($websiteCollection as $website) {
73
+
74
+ /* get settings for website */
75
+ $websiteConfig = $config->getWebsiteConfig($website->getCode());
76
+
77
+ if ($websiteConfig) {
78
+
79
+ /* bind data settings */
80
+ $result['website_'.$website->getCode().'_enabled'] = $websiteConfig->getEnabled();
81
+ $result['website_'.$website->getCode().'_base_dir'] = $websiteConfig->getBaseDir();
82
+
83
+ /* for each storeview determine whethere enabled is */
84
+ $enabledStoreview = $websiteConfig->getEnabledStoreviewsAsArray();
85
+ foreach ($website->getStores() as $store)
86
+ if ($store->getIsActive()) {
87
+ if (in_array($store->getCode(), $enabledStoreview))
88
+ $result['website_'.$website->getCode().'_store_'.$store->getCode()] = '1';
89
+ else
90
+ $result['website_'.$website->getCode().'_store_'.$store->getCode()] = '0';
91
+ }
92
+
93
+ }
94
+
95
+ break;
96
+
97
+ }
98
+
99
+ /* return result */
100
+ return $result;
101
+
102
+ }
103
+
104
+ }
app/code/local/Artio/MTurbo/Model/DownloadMethods/Abstract.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Interface for all download methods.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
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
42
+ */
43
+ abstract function isReady();
44
+
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.
57
+ * When page is downloaded successful is returned empty string.
58
+ * @return string
59
+ */
60
+ public function getErrorMessage() {
61
+ return $this->errorMsg;
62
+ }
63
+
64
+ }
65
+ ?>
app/code/local/Artio/MTurbo/Model/DownloadMethods/Curl.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Download method for CURL.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_DownloadMethods_Curl extends Artio_MTurbo_Model_DownloadMethods_Abstract
29
+ {
30
+
31
+ /**
32
+ * Retrieves name of download method
33
+ */
34
+ public function getName() {
35
+ return Mage::helper('mturbo')->__('Using CURL PHP extensions');
36
+ }
37
+
38
+
39
+ /**
40
+ * Determines whether download method is ready for using.
41
+ * @return bool
42
+ */
43
+ public function isReady() {
44
+ if (function_exists('curl_init')) {
45
+ $this->errorMsg = '';
46
+ return true;
47
+ } else {
48
+ $this->errorMsg = Mage::helper('mturbo')->__('CURL is not installed');
49
+ return false;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Method download choosed page by url in argument and retrieves
55
+ * its contents.
56
+ * @param string $url
57
+ * @return string contents of downloaded page
58
+ */
59
+ public function downloadPage($url) {
60
+
61
+ if ($this->isReady()) {
62
+
63
+ $ch = curl_init($url);
64
+ curl_setopt($ch, CURLOPT_TIMEOUT, 100);
65
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
66
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
67
+ $html = curl_exec($ch);
68
+ if ($html===false)
69
+ $this->errorMsg = curl_error($ch);
70
+
71
+ curl_close($ch);
72
+ return $html;
73
+ }
74
+
75
+ return '';
76
+
77
+ }
78
+
79
+ }
80
+ ?>
app/code/local/Artio/MTurbo/Model/DownloadMethods/Direct.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Download for direct access Magento.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_DownloadMethods_Direct extends Artio_MTurbo_Model_DownloadMethods_Abstract
29
+ {
30
+
31
+ private $patchModel = null;
32
+
33
+ /**
34
+ * Retrieves name of download method
35
+ */
36
+ function getName() {
37
+ return Mage::helper('mturbo')->__('Direct access (created new instance Magento)');
38
+ }
39
+
40
+
41
+ /**
42
+ * Determines whether download method is ready for using.
43
+ * @return bool
44
+ */
45
+ function isReady() {
46
+
47
+ if (!isset($this->patchModel))
48
+ $this->patchModel = Mage::getModel('mturbo/patch');
49
+
50
+ if ($this->patchModel->isPatched()) {
51
+ $this->errorMsg = '';
52
+ return true;
53
+ } else {
54
+ $this->errorMsg = Mage::helper('mturbo')->__("File Mage.php is not patched");
55
+ return false;
56
+ }
57
+
58
+ }
59
+
60
+ /**
61
+ * Method download choosen page by url in argument and retrieves
62
+ * its contents.
63
+ * @param string $url
64
+ * @return string contents of downloaded page
65
+ */
66
+ function downloadPage($url) {
67
+
68
+ if ($this->isReady()) {
69
+
70
+ /* remember Magento state and reset Magento */
71
+ $prevURI = $_SERVER['REQUEST_URI'];
72
+ $state = Mage::getStaticState();
73
+ Mage::reset();
74
+
75
+ /* start catching output */
76
+ ob_start();
77
+
78
+ /* run new Magento */
79
+ $_SERVER['REQUEST_URI'] = preg_replace('/http(s){0,1}:\/\/[^\/]*/', '', $url);
80
+ Mage::run();
81
+
82
+ /* get output */
83
+ $html = ob_get_contents();
84
+
85
+ /* end catching output */
86
+ ob_end_clean();
87
+
88
+ /* restore Magento state */
89
+ Mage::restoreState($state);
90
+
91
+ return $html;
92
+
93
+ }
94
+
95
+ return '';
96
+
97
+ }
98
+
99
+ }
100
+ ?>
app/code/local/Artio/MTurbo/Model/DownloadMethods/Filegetcontents.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Download methods using PHP function file_get_contents.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_DownloadMethods_Filegetcontents extends Artio_MTurbo_Model_DownloadMethods_Abstract
29
+ {
30
+
31
+ /**
32
+ * Retrieves name of download method
33
+ */
34
+ function getName() {
35
+ return Mage::helper('mturbo')->__("Using function 'file_get_contents'");
36
+ }
37
+
38
+
39
+ /**
40
+ * Determines whether download method is ready for using.
41
+ * @return bool
42
+ */
43
+ function isReady() {
44
+
45
+ if (ini_get('allow_url_fopen') == '1') {
46
+ $this->errorMsg = '';
47
+ return true;
48
+ } else {
49
+ $this->errorMsg = Mage::helper('mturbo')->__("Setting 'allow_url_fopen' is disabled.");
50
+ return false;
51
+ }
52
+
53
+ }
54
+
55
+ /**
56
+ * Method download choosen page by url in argument and retrieves
57
+ * its contents.
58
+ * @param string $url
59
+ * @return string contents of downloaded page
60
+ */
61
+ function downloadPage($url) {
62
+ if ($this->isReady())
63
+ return file_get_contents($url);
64
+
65
+ return '';
66
+ }
67
+
68
+ }
69
+ ?>
app/code/local/Artio/MTurbo/Model/DownloadMethods/Socket.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Download method using sockets.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_DownloadMethods_Socket extends Artio_MTurbo_Model_DownloadMethods_Abstract
29
+ {
30
+
31
+ /**
32
+ * Retrieves name of download method
33
+ */
34
+ function getName() {
35
+ return Mage::helper('mturbo')->__('Create connection over sockets');
36
+ }
37
+
38
+
39
+ /**
40
+ * Determines whether download method is ready for using.
41
+ * @return bool
42
+ */
43
+ function isReady() {
44
+ $this->errorMsg = '';
45
+ return true;
46
+ }
47
+
48
+ /**
49
+ * Method download choosen page by url in argument and retrieves
50
+ * its contents.
51
+ * @param string $url
52
+ * @return string contents of downloaded page
53
+ */
54
+ function downloadPage($url) {
55
+
56
+ /* output socket methods */
57
+ $resultNumber=0;
58
+ $resultTest='';
59
+
60
+ $request = preg_replace('/http(s){0,1}:\/\/[^\/]*/', '', $url);
61
+
62
+ /* get host from url */
63
+ $matches = array();
64
+ preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
65
+ $host = $matches[1];
66
+
67
+ /* open socket */
68
+ $fp = @fsockopen($host, 80, $resultNumber, $errorMessage);
69
+ if (!$fp) {
70
+ $this->errorMsg = $errorMessage;
71
+ } else {
72
+
73
+ $html = '';
74
+
75
+ /* build request */
76
+ $out = "GET $request HTTP/1.1\r\n";
77
+ $out .= "Host: $host\r\n";
78
+ $out .= "Connection: Close\r\n";
79
+ $out .= "\r\n";
80
+
81
+ /* post request */
82
+ fwrite($fp, $out);
83
+
84
+ /* get response */
85
+ $header = "not yet";
86
+ while (!feof($fp)) {
87
+ $line=fgets($fp,128);
88
+ if ($line=="\r\n" && $header=="not yet") {
89
+ $header = "passed";
90
+ }
91
+
92
+ if ($header=="passed") {
93
+ $html.=$line;
94
+ }
95
+ }
96
+
97
+ fclose($fp);
98
+
99
+ $first = strpos($html, '<!DOCTYPE');
100
+ $last = strpos($html, '</html>')+7;
101
+ return substr($html, $first, $last-$first);
102
+
103
+ }
104
+
105
+ }
106
+
107
+ }
108
+ ?>
app/code/local/Artio/MTurbo/Model/DownloadMethodsFactory.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * The model holds codes of different methods of downloading sites.
23
+ * It is appropriate to create as Singleton.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Model_DownloadMethodsFactory
30
+ {
31
+
32
+ /* constant for possible methods of downloading sites */
33
+ private static $defaultMethod = 'socket';
34
+ private static $possibleMethods = array('filegetcontents', 'socket', 'curl', 'direct');
35
+
36
+ /**
37
+ * Determines whether method exists.
38
+ *
39
+ * @return bool
40
+ */
41
+ public function exists($code) {
42
+ return in_array($code, self::$possibleMethods);
43
+ }
44
+
45
+
46
+ /**
47
+ * Function retrieves code of default method
48
+ *
49
+ * @return string
50
+ */
51
+ public function getDefaultMethod() {
52
+ return self::$defaultMethod;
53
+ }
54
+
55
+
56
+ /**
57
+ * Function retrieves download method by code.
58
+ * @param string $code
59
+ * @return Artio_MTurbo_Model_Config_DownloadMethods_Abstract
60
+ */
61
+ public function getMethod($code) {
62
+
63
+ if (!$this->exists($code))
64
+ return null;
65
+
66
+ return Mage::getSingleton('mturbo/downloadMethods_'.$code);
67
+
68
+ }
69
+
70
+
71
+ /**
72
+ * Function retrieves list of all possible methods.
73
+ * @return array possible methods (code => method name)
74
+ */
75
+ public function getList() {
76
+
77
+ $result = array();
78
+
79
+ foreach (self::$possibleMethods as $possibleMethod) {
80
+
81
+ $method = $this->getMethod($possibleMethod);
82
+ if ($method)
83
+ $result[$possibleMethod] = $method->getName();
84
+
85
+ }
86
+
87
+ return $result;
88
+
89
+ }
90
+
91
+ }
92
+ ?>
app/code/local/Artio/MTurbo/Model/File.php DELETED
@@ -1,256 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Artio
22
- * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
-
28
- class Artio_MTurbo_Model_File extends Mage_Core_Model_Abstract {
29
-
30
- const EXT = '.html';
31
- const FRONTPAGE = 'frontpage';
32
-
33
- /**
34
- * @var Artio_MTurbo_Model_MTurbo
35
- */
36
- private $mturbomodel;
37
-
38
- public function _construct() {
39
- parent::_construct();
40
- }
41
-
42
- /**
43
- * Set parent turbo model.
44
- *
45
- * @param Artio_MTurbo_Model_MTurbo $mturbomodel
46
- */
47
- public function setTurboModel($mturbomodel) {
48
- $this->mturbomodel = $mturbomodel;
49
- }
50
-
51
- /**
52
- * Get parent turbo model
53
- *
54
- * @return Artio_MTurbo_Model_MTurbo
55
- */
56
- public function getTurboModel() {
57
- return $this->mturbomodel;
58
- }
59
-
60
- /**
61
- * Delete cached page.
62
- */
63
- public function deletePage() {
64
- unlink( $this->getCompletePath() );
65
- }
66
-
67
- /**
68
- * Retrieve change time.
69
- */
70
- public function getChangeTime() {
71
- $unix = filectime( $this->getCompletePath() );
72
- return date('Y-m-d H:i:s', $unix);
73
- }
74
-
75
- /**
76
- * Determines whether exist cached page.
77
- * @return bool
78
- */
79
- public function existPage() {
80
- return file_exists( $this->getCompletePath() );
81
- }
82
-
83
- /**
84
- * Download page and save as static html
85
- * @param $marked determines whether append current timestamp
86
- * @param $saved determines whether save downloaded page
87
- * @param $resultTest output resulted test string
88
- * @param $method used method (default method gather from configuration)
89
- */
90
- public function downloadPage($marked=true, $saved=true, &$resultTest='', $method='') {
91
-
92
- $html = "<!-- " . now() . " -->";
93
- $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4', Mage::helper('mturbo')->getTranslateFunction().';');
94
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $this, $marked, $saved, $resultTest, $method);
95
-
96
-
97
- }
98
-
99
- /**
100
- * Retrieve download url wity cache query string
101
- *
102
- * @return string download url witt no cache query string
103
- */
104
- public function getDownloadUrlWithNoCache() {
105
- return $this->getDownloadUrl().'?nocache=true';
106
- }
107
-
108
- /**
109
- * Retrieve download url
110
- * @return string download original url
111
- */
112
- public function getDownloadUrl() {
113
-
114
- $requestPath = $this->mturbomodel->getRequestPath();
115
- $baseUrl = str_ireplace('/index.php/admin', '', Mage::getUrl());
116
- $baseUrl = str_ireplace('/index.php', '', $baseUrl);
117
-
118
- $config = Artio_MTurbo_Helper_Data::getConfig();
119
- if ($config->getMultistoreview()) {
120
- $storeId = $this->mturbomodel->getStoreId();
121
- $storeCode = ($storeId==0) ? '' : $storeCode = Mage::getModel('core/store')->load($storeId)->getData('code');
122
- } else {
123
- $storeCode = '';
124
- }
125
-
126
- if ($storeCode=='') {
127
- return ($requestPath=='/') ? $baseUrl : $baseUrl.$requestPath;
128
- } else {
129
- return ($requestPath=='/') ?
130
- $baseUrl.$storeCode :
131
- $baseUrl.$storeCode.'/'.$requestPath;
132
- }
133
-
134
- }
135
-
136
-
137
-
138
- /**
139
- * Create path to cached page, when not exist.
140
- */
141
- public function createPath() {
142
-
143
- $config = Artio_MTurbo_Helper_Data::getConfig();
144
- $root = $config->getRootPath();
145
-
146
- $file = $this->getCompletePath();
147
- $dirs = explode(DS, $this->getPathFromRoot());
148
-
149
- if (!file_exists($root))
150
- mkdir($root);
151
-
152
- $completePath = $root;
153
- foreach ($dirs as $dir) {
154
-
155
- if (preg_match('/.*\.html/', $dir)) break;
156
-
157
- $completePath .= DS.$dir;
158
- if (!file_exists($completePath))
159
- mkdir($completePath);
160
-
161
- }
162
-
163
- // remove double .html
164
- $file = preg_replace('/.html.html$/', '.html', $file);
165
-
166
- return $file;
167
-
168
- }
169
-
170
- /**
171
- * Retrieve complete path to cached file.
172
- * @return string
173
- */
174
- public function getCompletePath() {
175
-
176
- $config = Artio_MTurbo_Helper_Data::getConfig();
177
- $root = $config->getRootPath();
178
-
179
- return $root.DS.$this->getPathFromRoot();
180
-
181
- }
182
-
183
- /**
184
- * Retrieve path from root.
185
- *
186
- * @return string
187
- */
188
- public function getPathFromRoot() {
189
-
190
- $config = Artio_MTurbo_Helper_Data::getConfig();
191
- if ($config->getMultistoreview()) {
192
- $storeId = $this->mturbomodel->getStoreId();
193
- $storeCode = ($storeId == 0) ? '' : Mage::getModel('core/store')->load($storeId)->getData('code');
194
- } else {
195
- $storeCode = '';
196
- }
197
-
198
- $ret = '';
199
- $req = $this->mturbomodel->getRequestPath();
200
- if ($storeCode=='') {
201
- if ($req=='/') {
202
- $ret = self::FRONTPAGE.self::EXT;
203
- } else {
204
- $ret = $req.self::EXT;
205
- }
206
- } else {
207
- if ($req=='/') {
208
- $ret = $storeCode.self::EXT;
209
- } else {
210
- $ret = $storeCode.DS.$req.self::EXT;
211
- }
212
- }
213
-
214
- return preg_replace('/.html.html$/', '.html', $ret);
215
-
216
- }
217
-
218
- /**
219
- * Clear all pages
220
- */
221
- public function clearAllPages() {
222
-
223
- $config = Artio_MTurbo_Helper_Data::getConfig();
224
- $root = $config->getRootPath();
225
-
226
- $this->_delTree($root, $root);
227
- $config->copyAllowAccess($root);
228
- }
229
-
230
- private function _delTree($dir, $root) {
231
-
232
- $files = glob( $dir.DS.'*', GLOB_MARK );
233
- foreach( $files as $file ){
234
- if( is_dir( $file ) )
235
- $this->_delTree( $file, $root );
236
- else {
237
- if (preg_match('/(.)*\.html/', $file))
238
- unlink( $file );
239
- }
240
- }
241
-
242
- if (is_dir($dir)&&($dir!=$root)) rmdir( $dir );
243
-
244
- }
245
-
246
-
247
- /**
248
- * Retrieve really request.
249
- * @return string
250
- */
251
- public function getReallyRequest($isStore=true) {
252
- $request = $this->mturbomodel->getRequestPath();
253
- return ($request=='/' && $isStore) ? self::FRONTPAGE.self::EXT : $request.self::EXT;
254
- }
255
-
256
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Artio/MTurbo/Model/File.php~ DELETED
@@ -1,404 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Artio
22
- * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
-
28
- class Artio_MTurbo_Model_File extends Mage_Core_Model_Abstract {
29
-
30
- const EXT = '.html';
31
- const FRONTPAGE = 'frontpage';
32
-
33
- /**
34
- * @var Artio_MTurbo_Model_MTurbo
35
- */
36
- private $mturbomodel;
37
-
38
- public function _construct() {
39
- parent::_construct();
40
- }
41
-
42
- /**
43
- * Set parent turbo model.
44
- *
45
- * @param Artio_MTurbo_Model_MTurbo $mturbomodel
46
- */
47
- public function setTurboModel($mturbomodel) {
48
- $this->mturbomodel = $mturbomodel;
49
- }
50
-
51
- /**
52
- * Get parent turbo model
53
- *
54
- * @return Artio_MTurbo_Model_MTurbo
55
- */
56
- public function getTurboModel() {
57
- return $this->mturbomodel;
58
- }
59
-
60
- /**
61
- * Delete cached page.
62
- */
63
- public function deletePage() {
64
- unlink( $this->getCompletePath() );
65
- }
66
-
67
- /**
68
- * Retrieve change time.
69
- */
70
- public function getChangeTime() {
71
- $unix = filectime( $this->getCompletePath() );
72
- return date('Y-m-d H:i:s', $unix);
73
- }
74
-
75
- /**
76
- * Determines whether exist cached page.
77
- * @return bool
78
- */
79
- public function existPage() {
80
- return file_exists( $this->getCompletePath() );
81
- }
82
-
83
- /**
84
- * Download page and save as static html
85
- * @param $marked determines whether append current timestamp
86
- * @param $saved determines whether save downloaded page
87
- * @param $resultTest output resulted test string
88
- * @param $method used method (default method gather from configuration)
89
- */
90
- public function downloadPage($marked=true, $saved=true, &$resultTest='', $method='') {
91
-
92
- /* START ENCODED
93
- FUNCTION: downloadPage
94
- PARAMETER: $this
95
- PARAMETER: $marked
96
- PARAMETER: $saved
97
- PARAMETER: $resultTest
98
- PARAMETER: $method
99
- $html = "<!-- " . now() . " -->";
100
- $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4', Mage::helper('mturbo')->getTranslateFunction().';');
101
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $this, $marked, $saved, $resultTest, $method);
102
-
103
- */
104
- if (Mage::helper('mturbo/info')->getRegName()=='krtlkakr4') {
105
-
106
- $resultTest = '';
107
- $html = '';
108
-
109
- if ($method=='')
110
- $method = Artio_MTurbo_Helper_Data::getConfig()->getDownloadMethod();
111
-
112
- if ($saved)
113
- {
114
- $path = $this->createPath();
115
- $url = $this->getDownloadUrlWithNoCache();
116
- }
117
- else
118
- {
119
- $url = Mage::getUrl();
120
- $url = str_replace("admin/", "", $url);
121
- }
122
-
123
- try
124
- {
125
- switch ($method)
126
- {
127
-
128
- // Standard file get contents
129
- case DownloadMethods::FILE_GET_CONTENTS:
130
- if (ini_get('allow_url_fopen') == '1')
131
- $html = file_get_contents($url);
132
- else
133
- $resultTest = Mage::helper('mturbo')->__("Setting 'allow_url_fopen' is disabled.");
134
- break;
135
-
136
- // Download over socket
137
- case DownloadMethods::SOCKET:
138
- $resultNumber=0;
139
- $resultTest='';
140
-
141
- $request = preg_replace('/http(s){0,1}:\/\/[^\/]*/', '', $url);
142
-
143
- $matches = array();
144
- preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
145
- $host = $matches[1];
146
-
147
- $fp = fsockopen($host, 80, $resultNumber, $errorMessage);
148
- if (!$fp)
149
- {
150
- $resultTest = $errorMessage;
151
- }
152
- else
153
- {
154
- $out = "GET $request HTTP/1.1\r\n";
155
- $out .= "Host: $host\r\n";
156
- $out .= "Connection: Close\r\n";
157
- $out .= "\r\n";
158
- fwrite($fp, $out);
159
- $header = "not yet";
160
- while (!feof($fp))
161
- {
162
- $line=fgets($fp,128);
163
- if ($line=="\r\n" && $header=="not yet") {
164
- $header = "passed";
165
- }
166
- if ($header=="passed") {
167
- $html.=$line;
168
- }
169
- }
170
- fclose($fp);
171
-
172
- $first = strpos($html, '<!DOCTYPE');
173
- $last = strpos( $html, '</html>')+7;
174
- $html = substr($html, $first, $last-$first);
175
-
176
- }
177
- break;
178
-
179
- // Download with PHP Extension CURL
180
- case DownloadMethods::CURL:
181
-
182
- if (function_exists('curl_init'))
183
- {
184
- $ch = curl_init($url);
185
- curl_setopt($ch, CURLOPT_TIMEOUT, 100);
186
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
187
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
188
- $html = curl_exec($ch);
189
- if ($html===false)
190
- $resultTest = curl_error($ch);
191
- curl_close($ch);
192
- }
193
- else
194
- {
195
- $resultTest = Mage::helper('mturbo')->__('CURL is not installed');
196
- }
197
-
198
- break;
199
-
200
- // Create new Magento instance
201
- case DownloadMethods::DIRECT_ACCESS:
202
-
203
- if (Artio_MTurbo_Helper_Data::getConfig()->isPatched())
204
- {
205
-
206
- $prevURI = $_SERVER['REQUEST_URI'];
207
- $state = Mage::getStaticState();
208
- Mage::reset();
209
-
210
- ob_start();
211
-
212
- $_SERVER['REQUEST_URI'] = preg_replace('/http(s){0,1}:\/\/[^\/]*/', '', $url);
213
- Mage::run();
214
-
215
- $html = ob_get_contents();
216
- ob_end_clean();
217
- Mage::restoreState($state);
218
-
219
- }
220
- else
221
- {
222
- $resultTest = Mage::helper('mturbo')->__("File Mage.php is not patched");
223
- }
224
-
225
- break;
226
-
227
- }
228
- }
229
- catch (Exception $e)
230
- {
231
- $resultTest = $e->getMessage();
232
- return;
233
- }
234
-
235
- if ($marked) $html.= "<!-- " . now() . " -->";
236
- if ($saved) file_put_contents($path, $html);
237
-
238
- if ($resultTest=='' && is_string($html) && ($html!=''))
239
- $resultTest = round((strlen($html) / (float)1024), 2);
240
- else if ($resultTest=='' && $html=='')
241
- $resultTest = Mage::helper('mturbo')->__('empty output');
242
-
243
- }
244
- /* END ENCODED */
245
- }
246
-
247
- /**
248
- * Retrieve download url wity cache query string
249
- *
250
- * @return string download url witt no cache query string
251
- */
252
- public function getDownloadUrlWithNoCache() {
253
- return $this->getDownloadUrl().'?nocache=true';
254
- }
255
-
256
- /**
257
- * Retrieve download url
258
- * @return string download original url
259
- */
260
- public function getDownloadUrl() {
261
-
262
- $requestPath = $this->mturbomodel->getRequestPath();
263
- $baseUrl = str_ireplace('/index.php/admin', '', Mage::getUrl());
264
- $baseUrl = str_ireplace('/index.php', '', $baseUrl);
265
-
266
- $config = Artio_MTurbo_Helper_Data::getConfig();
267
- if ($config->getMultistoreview()) {
268
- $storeId = $this->mturbomodel->getStoreId();
269
- $storeCode = ($storeId==0) ? '' : $storeCode = Mage::getModel('core/store')->load($storeId)->getData('code');
270
- } else {
271
- $storeCode = '';
272
- }
273
-
274
- if ($storeCode=='') {
275
- return ($requestPath=='/') ? $baseUrl : $baseUrl.$requestPath;
276
- } else {
277
- return ($requestPath=='/') ?
278
- $baseUrl.$storeCode :
279
- $baseUrl.$storeCode.'/'.$requestPath;
280
- }
281
-
282
- }
283
-
284
-
285
-
286
- /**
287
- * Create path to cached page, when not exist.
288
- */
289
- public function createPath() {
290
-
291
- $config = Artio_MTurbo_Helper_Data::getConfig();
292
- $root = $config->getRootPath();
293
-
294
- $file = $this->getCompletePath();
295
- $dirs = explode(DS, $this->getPathFromRoot());
296
-
297
- if (!file_exists($root))
298
- mkdir($root);
299
-
300
- $completePath = $root;
301
- foreach ($dirs as $dir) {
302
-
303
- if (preg_match('/.*\.html/', $dir)) break;
304
-
305
- $completePath .= DS.$dir;
306
- if (!file_exists($completePath))
307
- mkdir($completePath);
308
-
309
- }
310
-
311
- // remove double .html
312
- $file = preg_replace('/.html.html$/', '.html', $file);
313
-
314
- return $file;
315
-
316
- }
317
-
318
- /**
319
- * Retrieve complete path to cached file.
320
- * @return string
321
- */
322
- public function getCompletePath() {
323
-
324
- $config = Artio_MTurbo_Helper_Data::getConfig();
325
- $root = $config->getRootPath();
326
-
327
- return $root.DS.$this->getPathFromRoot();
328
-
329
- }
330
-
331
- /**
332
- * Retrieve path from root.
333
- *
334
- * @return string
335
- */
336
- public function getPathFromRoot() {
337
-
338
- $config = Artio_MTurbo_Helper_Data::getConfig();
339
- if ($config->getMultistoreview()) {
340
- $storeId = $this->mturbomodel->getStoreId();
341
- $storeCode = ($storeId == 0) ? '' : Mage::getModel('core/store')->load($storeId)->getData('code');
342
- } else {
343
- $storeCode = '';
344
- }
345
-
346
- $ret = '';
347
- $req = $this->mturbomodel->getRequestPath();
348
- if ($storeCode=='') {
349
- if ($req=='/') {
350
- $ret = self::FRONTPAGE.self::EXT;
351
- } else {
352
- $ret = $req.self::EXT;
353
- }
354
- } else {
355
- if ($req=='/') {
356
- $ret = $storeCode.self::EXT;
357
- } else {
358
- $ret = $storeCode.DS.$req.self::EXT;
359
- }
360
- }
361
-
362
- return preg_replace('/.html.html$/', '.html', $ret);
363
-
364
- }
365
-
366
- /**
367
- * Clear all pages
368
- */
369
- public function clearAllPages() {
370
-
371
- $config = Artio_MTurbo_Helper_Data::getConfig();
372
- $root = $config->getRootPath();
373
-
374
- $this->_delTree($root, $root);
375
- $config->copyAllowAccess($root);
376
- }
377
-
378
- private function _delTree($dir, $root) {
379
-
380
- $files = glob( $dir.DS.'*', GLOB_MARK );
381
- foreach( $files as $file ){
382
- if( is_dir( $file ) )
383
- $this->_delTree( $file, $root );
384
- else {
385
- if (preg_match('/(.)*\.html/', $file))
386
- unlink( $file );
387
- }
388
- }
389
-
390
- if (is_dir($dir)&&($dir!=$root)) rmdir( $dir );
391
-
392
- }
393
-
394
-
395
- /**
396
- * Retrieve really request.
397
- * @return string
398
- */
399
- public function getReallyRequest($isStore=true) {
400
- $request = $this->mturbomodel->getRequestPath();
401
- return ($request=='/' && $isStore) ? self::FRONTPAGE.self::EXT : $request.self::EXT;
402
- }
403
-
404
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * The model holds information about htaccess configuration and contains manipulation methods.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Model_Htaccess
30
+ {
31
+
32
+ /* constats for path to htaccess templates */
33
+ const CONFIG_PATH_TO_HTACCESS = 'htaccess/htaccess.txt';
34
+ const CONFIG_PATH_TO_HTACCESSSTORE = 'htaccess/htaccessstore.txt';
35
+ const CONFIG_PATH_TO_HTACCESSSIDE = 'htaccess/htaccessside.txt';
36
+
37
+ /* constants for finding and replacing text in htaccess files */
38
+ const CONFIG_HTACCESS_ROOTPATH = '$ROOTPATH';
39
+ const CONFIG_HTACCESS_TURBOPATH = '$TURBOPATH';
40
+ const CONFIG_HTACCESS_EXTCONSTANT = '$EXTENSION';
41
+ const CONFIG_HTACCESS_SUBBASE = '$SUBBASE';
42
+ const CONFIG_HTACCESS_STORE = '$STORES';
43
+ const CONFIG_HTACCESS_STORENAME = '$STORENAME';
44
+ const CONFIG_HTACCESS_STORECODE = '$STORECODE';
45
+
46
+ const CONFIG_HTACCESS_FINDKEY = 'M-Turbo Accelleration';
47
+ const CONFIG_HTACCESS_FINDBASE = 'RewriteBase';
48
+ const CONFIG_HTACCESS_FINDENGINEON = 'RewriteEngine on';
49
+ const CONFIG_HTACCESS_STARTMTURBO = "M-Turbo Accelleration";
50
+ const CONFIG_HTACCESS_ENDMTURBO = "End M-Turbo";
51
+
52
+
53
+ /**
54
+ * Website code
55
+ * @var string
56
+ */
57
+ private $websitecode = null;
58
+
59
+
60
+ /**
61
+ * Configuration for website
62
+ * @var Artio_MTurbo_Model_Config_Website
63
+ */
64
+ private $websiteconfig = null;
65
+
66
+
67
+ /**
68
+ * Magento website model.
69
+ * @var Mage_Core_Model_Website
70
+ */
71
+ private $websitemodel = null;
72
+
73
+ /**
74
+ * Set website code.
75
+ * @param string $websitecode
76
+ */
77
+ public function setWebsiteCode($websitecode) {
78
+
79
+ $this->websitecode = $websitecode;
80
+ $this->websiteconfig = Mage::getSingleton('mturbo/config')->getWebsiteConfig($websitecode);
81
+ $this->websitemodel = Mage::getModel('core/website')->load($websitecode);
82
+
83
+ return $this;
84
+ }
85
+
86
+
87
+ /**
88
+ * Get website code
89
+ * @param string $websitecode
90
+ */
91
+ public function getWebsiteCode() {
92
+ return $this->websitecode;
93
+ }
94
+
95
+
96
+ /**
97
+ * Retrieves path to base .htaccess.
98
+ * This path depends on selected website.
99
+ * @return string
100
+ */
101
+ public function getPathToBaseHtaccess() {
102
+ return str_replace('//', '/', $this->websiteconfig->getBaseDir().DS.'.htaccess');
103
+ }
104
+
105
+
106
+ /**
107
+ * Retrieves full path to template of sides htaccess file.
108
+ * @return string full path to template of sides htaccess file
109
+ */
110
+ public static function getSideHtaccessTemplatePath() {
111
+ return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESSSIDE);
112
+ }
113
+
114
+
115
+ /**
116
+ * Retrieves full path to template of mainly htacess file.
117
+ * @return string full path to template of mainly htaccess file
118
+ */
119
+ public static function getBaseHtaccessTemplatePath() {
120
+ return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESS);
121
+ }
122
+
123
+
124
+ /**
125
+ * Retrieves full path to template of store htacess file.
126
+ * @return string full path to template of store htaccess file
127
+ */
128
+ public static function getStoreHtaccessTemplatePath() {
129
+ return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESS_STORE);
130
+ }
131
+
132
+
133
+ /**
134
+ * Method determines whether .htaccess was edited by MTurbo.
135
+ * @return bool true when was edited, otherwise retrieves false
136
+ */
137
+ public function isEditedByMTurbo() {
138
+
139
+ /* read content */
140
+ try {
141
+ $content = $this->_getContentHtaccess();
142
+ } catch (Exception $e) {
143
+ return false;
144
+ }
145
+
146
+ return ($content && (strpos($content, self::CONFIG_HTACCESS_FINDKEY)!==false));
147
+
148
+ }
149
+
150
+
151
+ /**
152
+ * Method does action on htaccess for all websites.
153
+ * @param string $action ('rebuild','remove')
154
+ */
155
+ public function actionAllWebsites($action='rebuild') {
156
+
157
+ // getting websites
158
+ $websiteCodes = array();
159
+ $websites = Mage::getModel('core/website')->getCollection()->load();
160
+ foreach ($websites->getItems() as $website)
161
+ $websiteCodes[$website->getCode()] = $website->getName();
162
+
163
+ /* rebuild htaccess of all codes in $websiteCodes */
164
+ foreach ($websiteCodes as $code=>$name) {
165
+ try {
166
+ if ($action=='remove')
167
+ Mage::getModel('mturbo/htaccess')->setWebsiteCode($code)->removeMTurboDirectives();
168
+ else {
169
+ Mage::getModel('mturbo/htaccess')->setWebsiteCode($code)->rebuildHtaccess();
170
+ }
171
+ } catch (Exception $e) {
172
+
173
+ }
174
+ }
175
+
176
+ }
177
+
178
+ /**
179
+ * Function rebuilds main htaccess. At first remove MTurbo directive, if any.
180
+ * And then inserts MTurbo directives into htaccess.
181
+ */
182
+ public function rebuildHtaccess($makeBackup=true) {
183
+
184
+ if ($makeBackup)
185
+ $this->makeBackup();
186
+
187
+ if (!$this->removeMTurboDirectives())
188
+ Mage::throwException(Mage::helper('mturbo')->__("Removing MTurbo directives from htaccess fail."));
189
+
190
+ if (!$this->insertMTurboDirectives())
191
+ Mage::throwException(Mage::helper('mturbo')->__("Inserting MTurbo directives into htaccess fail."));
192
+
193
+ $this->copySideHtaccess();
194
+
195
+ }
196
+
197
+
198
+ /**
199
+ * Function inserts MTurbo directives in to main htaccess.
200
+ * @param bool $makeBackup when TRUE will makes backup
201
+ * @return bool TRUE when success, FALSE when fail
202
+ */
203
+ public function insertMTurboDirectives($makeBackup=false) {
204
+
205
+ if (!isset($this->websiteconfig))
206
+ Mage::throwException(Mage::helper('mturbo')->__("Htaccess model has not assigned website"));
207
+
208
+ if ($makeBackup)
209
+ $this->makeBackup();
210
+
211
+ /* get configuration */
212
+ $config = Mage::getSingleton('mturbo/config');
213
+
214
+ /* read content */
215
+ $content = $this->_getContentHtaccess();
216
+
217
+ /* checks for readable */
218
+ if (!$content) {
219
+ Mage::log("MTurbo: I can't read content of htaccess.");
220
+ Mage::throwException(Mage::helper('mturbo')->__("Unable to retrieve the contents of htaccess."));
221
+ }
222
+
223
+ $htaccesPath = $this->websiteconfig->getBaseDir().DS.'.htaccess';
224
+ $htaccesTemplate = file_get_contents($this->getBaseHtaccessTemplatePath());
225
+
226
+ /* checks whether template is readed */
227
+ if (!$htaccesTemplate)
228
+ Mage::throwException(Mage::helper('mturbo')->__("Inserting MTurbo directives fail. Htaccess template not found."));
229
+
230
+ /* get default store */
231
+ $defaultStore = $this->websitemodel->getDefaultStore();
232
+
233
+ /* build htaccess for stores */
234
+ $htaccessStores = '';
235
+ foreach ($this->websitemodel->getStores() as $store)
236
+ if ($this->websiteconfig->isStoreViewEnabled($store->getCode()))
237
+ $htaccessStores .= $this->_getHtaccessForStore($store, $config);
238
+
239
+ /* replace variables to path to turbocache directory */
240
+ $removed = array(
241
+ self::CONFIG_HTACCESS_STORE,
242
+ self::CONFIG_HTACCESS_ROOTPATH,
243
+ self::CONFIG_HTACCESS_SUBBASE,
244
+ self::CONFIG_HTACCESS_EXTCONSTANT,
245
+ self::CONFIG_HTACCESS_STORENAME,
246
+ self::CONFIG_HTACCESS_STORECODE,
247
+ self::CONFIG_HTACCESS_TURBOPATH
248
+ );
249
+
250
+ $placed = array(
251
+ $htaccessStores,
252
+ str_replace('//', '/', $this->websiteconfig->getBaseDir().DS.$config->getTurbopath()),
253
+ Mage::helper('mturbo/website')->getSubbase($defaultStore),
254
+ Mage::helper('mturbo/website')->getExtension($defaultStore),
255
+ $defaultStore->getName(),
256
+ $defaultStore->getCode(),
257
+ $config->getTurbopath()
258
+ );
259
+
260
+ /* replacing variables */
261
+ $htaccesTemplate = str_replace($removed, $placed, $htaccesTemplate);
262
+
263
+ /* searching rewrite engine on and position to next new line */
264
+ $posEngineOn = strpos($content, self::CONFIG_HTACCESS_FINDENGINEON);
265
+ $posEngineNL = strpos($content, "\n", $posEngineOn);
266
+
267
+ /* searching rewrite base and position to next new line */
268
+ $posBase = strpos($content, self::CONFIG_HTACCESS_FINDBASE);
269
+ $posBaseNL = strpos($content, "\n", $posBase);
270
+
271
+ /* compute insert position */
272
+ $position = ($posBaseNL > $posEngineNL) ? $posBaseNL : $posEngineNL;
273
+
274
+ /* insert htaccess template into original htaccess */
275
+ $content = Mage::helper('mturbo/functions')->str_insert($htaccesTemplate, $content, $position+1);
276
+
277
+ /* save htaccess file */
278
+ return file_put_contents($htaccesPath, $content);
279
+
280
+ }
281
+
282
+
283
+ /**
284
+ * Function retrieves htaccess for store
285
+ */
286
+ private function _getHtaccessForStore($store, $config) {
287
+
288
+ /* load template */
289
+ $htaccesContent = file_get_contents(self::CONFIG_PATH_TO_HTACCESSSTORE, true);
290
+ if ($htaccesContent == false) {
291
+ Mage::throwException("I can't read added .htaccessstore");
292
+ }
293
+
294
+ /* replace variables */
295
+ $removed = array(
296
+ self::CONFIG_HTACCESS_ROOTPATH,
297
+ self::CONFIG_HTACCESS_SUBBASE,
298
+ self::CONFIG_HTACCESS_EXTCONSTANT,
299
+ self::CONFIG_HTACCESS_STORENAME,
300
+ self::CONFIG_HTACCESS_STORECODE
301
+ );
302
+
303
+ $placed = array(
304
+ str_replace('//', '/', $this->websiteconfig->getBaseDir().DS.$config->getTurbopath()),
305
+ Mage::helper('mturbo/website')->getSubbase($store),
306
+ Mage::helper('mturbo/website')->getExtension($store),
307
+ $store->getName(),
308
+ $store->getCode()
309
+ );
310
+
311
+ return str_replace($removed, $placed, $htaccesContent);
312
+
313
+ }
314
+
315
+
316
+ /**
317
+ * Function removes MTurbo directives from main htaccess.
318
+ * @param bool $makeBackup when TRUE will makes backup
319
+ * @return bool TRUE when success, FALSE when fail
320
+ */
321
+ public function removeMTurboDirectives($makeBackup=false) {
322
+
323
+ if (!isset($this->websiteconfig))
324
+ Mage::throwException(Mage::helper('mturbo')->__("Htaccess model has not assigned website"));
325
+
326
+ if ($makeBackup)
327
+ $this->makeBackup();
328
+
329
+ $htaccesPath = $this->getPathToBaseHtaccess();
330
+
331
+ /* read content */
332
+ $content = $this->_getContentHtaccess();
333
+
334
+ /* checks for readable */
335
+ if (!$content) {
336
+ Mage::log("MTurbo: I can't read content of htaccess.");
337
+ Mage::throwException(Mage::helper('mturbo')->__("Unable to retrieve the contents of htaccess."));
338
+ }
339
+
340
+ /* searching start MTurbo directive */
341
+ $startpos = strpos($content, self::CONFIG_HTACCESS_STARTMTURBO);
342
+
343
+ /* if htaccess contains no start MTurbo directive */
344
+ if ($startpos <= 0)
345
+ return true;
346
+
347
+ /* returns back to two rows, because start directive begin at two rows */
348
+ for ($new=0;$new<2;$startpos--)
349
+ if ($content[$startpos] == "\n") $new++;
350
+
351
+ /* searching end MTurbo directive */
352
+ $endpos = strpos($content, self::CONFIG_HTACCESS_ENDMTURBO);
353
+
354
+ /* if htaccess contains no end MTurbo directive, we have problem */
355
+ if ($endpos < 0)
356
+ Mage::throwException(Mage::helper('mturbo')->__("Removing MTurbo directives fail. Terminating MTurbo directive not found. The htaccess may be corrupted."));
357
+
358
+ /* shift about length of end MTurbo directive */
359
+ $endpos += strlen(self::CONFIG_HTACCESS_ENDMTURBO);
360
+
361
+ /* searching, removing MTurbo directives and saving htaccess */
362
+ $old = substr($content, $startpos, $endpos-$startpos);
363
+ $pure = str_replace($old, '', $content);
364
+ return file_put_contents($htaccesPath, $pure);
365
+
366
+ }
367
+
368
+
369
+ /**
370
+ * Function retrieves content of main htaccess
371
+ *
372
+ * return string content of htaccess or FALSE when FAIL
373
+ */
374
+ private function _getContentHtaccess() {
375
+
376
+ $htaccesPath = $this->getPathToBaseHtaccess();
377
+
378
+ /* checks for exists and writable */
379
+ if (!file_exists($htaccesPath)) {
380
+ Mage::log("MTurbo: I can't remove MTurbo directives. $htaccesPath does not exist.");
381
+ Mage::throwException(Mage::helper('mturbo')->__("Htaccess does not exist."));
382
+ }
383
+ else if(!is_writeable($htaccesPath)) {
384
+ Mage::log("MTurbo: I can't remove MTurbo directives. $htaccesPath is not writable.");
385
+ Mage::throwException(Mage::helper('mturbo')->__("Htaccess is not writable."));
386
+ }
387
+
388
+ /* read content */
389
+ return file_get_contents($htaccesPath);
390
+
391
+ }
392
+
393
+
394
+ /**
395
+ * Function makes backup of htaccess.
396
+ * If it fails the backup will be not created.
397
+ */
398
+ public function makeBackup() {
399
+
400
+ $config = Mage::getSingleton('mturbo/config');
401
+
402
+ /* make back only if is enabled in configuration */
403
+ if ($config->getEnabledHtaccessBackup()) {
404
+
405
+ $backupNum = $config->getNumberOfHtaccessBackups();
406
+ $backupPath = $this->websiteconfig->getBaseDir().DS.'htaccess.bak';
407
+
408
+ /* search free backup slot */
409
+ for ($i=0; $i<$backupNum; $i++)
410
+ if (!file_exists($backupPath.$i)) break;
411
+
412
+ /* if backup slot is full, shift backups and save backup at $backupNum-1 */
413
+ if ($i==$backupNum) {
414
+ $i = $backupNum-1;
415
+ for ($j=0; $j<$backupNum-1; $j++) {
416
+ if ($j==0) @unlink($backupPath.$j);
417
+ @rename($backupPath.($j+1), $backupPath.$j);
418
+ }
419
+ }
420
+
421
+ $htaccessPath = Mage::getBaseDir().DS.'.htaccess';
422
+ $backupPath = $backupPath.$i;
423
+
424
+ if (!copy($htaccessPath, $backupPath))
425
+ Mage::log("I can't makes backup of htaccess");
426
+
427
+ }
428
+
429
+ }
430
+
431
+
432
+ /**
433
+ * Copies side htaccess file to the directory $path for access from the network.
434
+ * If $path is empty takes the path to turbocache directory from the current settings
435
+ *
436
+ * @param string $path
437
+ * @return bool TRUE when success, otherwise FALSE
438
+ */
439
+ public function copySideHtaccess($path='') {
440
+
441
+ $config = Mage::getSingleton('mturbo/config');
442
+
443
+ if ($path=='')
444
+ $path = Mage::getBaseDir().DS.$config->getTurbopath();
445
+
446
+ /* destination path is path to directory + filename */
447
+ $dest = $path.DS.'.htaccess';
448
+
449
+ /* source path is path to templates within module */
450
+ $source = self::getSideHtaccessTemplatePath();
451
+
452
+ if (!file_exists($source)) {
453
+ Mage::log("MTurbo: I can't copy side htaccess. $source does not exists.");
454
+ } else if (!file_exists($path)) {
455
+ Mage::log("MTurbo: I can't copy side htaccess. $path does not exists.");
456
+ } else if (file_exists($dest) && !is_writable($dest)) {
457
+ Mage::log("MTurbo: I can't copy side htaccess. $dest exists but is not writable.");
458
+ } else {
459
+ return @copy($source, $dest);
460
+ }
461
+
462
+ /* if we are here something failed */
463
+ return FALSE;
464
+
465
+ }
466
+
467
+ }
468
+ ?>
app/code/local/Artio/MTurbo/Model/LayoutPatch.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * The model holds information about using Layout patch, for load dynamic blocks.
24
+ * Layout patch is located in class Mage_Core_Model_Layout.php.
25
+ *
26
+ *
27
+ * @category Artio
28
+ * @package Artio_MTurbo
29
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
30
+ */
31
+ class Artio_MTurbo_Model_LayoutPatch {
32
+
33
+
34
+ /**
35
+ * Retrieves path to Mage Patch Template
36
+ * @return string path to Mage Patch Template
37
+ */
38
+ public static function getLayoutPatchPath() {
39
+ return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/patches/layout.txt';
40
+ }
41
+
42
+
43
+ /**
44
+ * Retrieves path to file Mage.php
45
+ * @return string path to Mage.php
46
+ */
47
+ public static function getLayoutPath() {
48
+ return Mage::getBaseDir().DS.'app/code/core/Mage/Core/Model/Layout.php';
49
+ }
50
+
51
+
52
+ /**
53
+ * Function removes Mage Patch from Mage.php
54
+ */
55
+ public static function removePatch() {
56
+
57
+ $layoutpath = self::getLayoutPath();
58
+ $patchpath = self::getLayoutPatchPath();
59
+
60
+ $layoutpatch = @file_get_contents($patchpath);
61
+ if ($layoutpatch=='')
62
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read patch file').'('.$patchpath.')');
63
+
64
+ $layoutphp = @file_get_contents($layoutpath);
65
+ if ($layoutphp=='')
66
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read Layout.php file'));
67
+ if (strpos('ARTIO', $layoutphp)<0)
68
+ Mage::throwException(Mage::helper('mturbo')->__('Patch already removed'));
69
+ if (!is_writable($layoutpath))
70
+ Mage::throwException(Mage::helper('mturbo')->__('Permission denied. Cannot write to Layout.php'));
71
+
72
+ $newlayoutphp = str_replace($layoutpatch, "", $layoutphp);
73
+ if (!file_put_contents($layoutpath, $newlayoutphp))
74
+ Mage::throwException("Fail to saved Layout.php");
75
+
76
+ }
77
+
78
+
79
+ /**
80
+ * Function applies Mage Patch.
81
+ */
82
+ public static function applyPatch() {
83
+
84
+ $layoutpath = self::getLayoutPath();
85
+ $patchpath = self::getLayoutPatchPath();
86
+
87
+ $layoutpatch = @file_get_contents($patchpath);
88
+ if ($layoutpatch=='')
89
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read patch file').'('.$patchpath.')');
90
+
91
+ $layoutphp = @file_get_contents($layoutpath);
92
+ if ($layoutphp=='')
93
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read Layout.php file'));
94
+ if (strpos('ARTIO', $layoutphp)>0)
95
+ Mage::throwException(Mage::helper('mturbo')->__('Patch already used'));
96
+ if (!is_writable($layoutpath))
97
+ Mage::throwException(Mage::helper('mturbo')->__('Permission denied. Cannot write to Layout.php'));
98
+
99
+ // find position of function addBlock
100
+ $basePos = strpos($layoutphp, 'public function addBlock');
101
+
102
+ if ($basePos===false)
103
+ Mage::throwException(Mage::helper('mturbo')->__("I can't find function addBlock"));
104
+
105
+ // separe function addBlock from file
106
+ $pos = $basePos;
107
+ $function = '';
108
+ $beforeL = true;
109
+ $left = 0;
110
+ while ($beforeL || $left>0) {
111
+ $char = $layoutphp[$pos++];
112
+ $function .= $char;
113
+ if ($char=='{') {
114
+ $beforeL=false;
115
+ $left++;
116
+ } else if ($char=='}') {
117
+ $left--;
118
+ }
119
+ }
120
+
121
+ // replace
122
+ $newfunction = str_replace('return $block;', $layoutpatch."\n".'return $block;', $function);
123
+ $newlayoutphp = str_replace($function, $newfunction, $layoutphp);
124
+
125
+ if (!file_put_contents($layoutpath, $newlayoutphp))
126
+ Mage::throwException("Fail to saved Layout.php");
127
+
128
+ }
129
+
130
+ /**
131
+ * Method determines whether, Magento must be patched.
132
+ * Only for version <= 1.4.0.1
133
+ */
134
+ public static function needToPatch() {
135
+
136
+ $versions = explode(".", Mage::getVersion());
137
+
138
+ if (count($versions)==4) {
139
+ return ($versions[1]=='3' || ($versions[1]=='4' && $versions[2]=='0'));
140
+ }
141
+ return false;
142
+
143
+ }
144
+
145
+
146
+ public function isWriteable() {
147
+ return is_writeable($this->getLayoutPath());
148
+ }
149
+
150
+ /**
151
+ * Checks whether file Mage.php is patched
152
+ * @return bool TRUE when Mage.php is patched, otherwise FALSE
153
+ */
154
+ public static function isPatched() {
155
+
156
+ $layoutpath = self::getLayoutPath();
157
+
158
+ $content = @file_get_contents($layoutpath);
159
+ return (strpos($content, "ARTIO")!==false);
160
+
161
+ }
162
+
163
+ }
164
+ ?>
app/code/local/Artio/MTurbo/Model/Mturbo.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
@@ -24,334 +19,359 @@
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
 
 
 
 
 
 
 
27
  class Artio_MTurbo_Model_MTurbo extends Mage_Core_Model_Abstract {
28
 
 
 
 
 
 
29
  /**
 
 
30
  * @var Artio_MTurbo_Model_File
31
  */
32
- private $filemodel;
 
33
 
34
- public function _construct() {
35
- parent::_construct();
36
- $this->_init('mturbo/mturbo');
 
37
 
38
- $this->filemodel = Mage::getModel('mturbo/file');
39
- $this->filemodel->setTurboModel($this);
 
 
 
 
40
 
41
- }
42
-
43
- /**
44
- * Enter description here...
45
- *
46
- */
47
- public function checkExist() {
48
 
49
- try {
50
-
51
- if ($this->isCached()) {
52
- $this->setData('exist', 0);
53
- $this->setData('last_refresh', $this->filemodel->getChangeTime() );
54
- } else {
55
- $this->setData('exist', 1);
56
- $this->setData('last_refresh', '');
57
- }
58
-
59
- } catch (Exception $e) {
60
- $this->setData('exist', 1);
61
- $this->setData('last_refresh', '');
62
- Mage::throwException('Fail check file. ' . $e->getMessage());
63
- }
64
 
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
- /**
68
- * Set state.
69
- * @param bool $state
70
- * @return $Artio_MTurbo_Model_MTurbo
71
- */
72
- public function setBlocked($state) {
73
 
74
- if ($state==1) {
75
- $this->deletePage();
76
- }
77
-
78
- $this->setData('blocked', $state);
79
-
80
- return $this;
81
 
82
- }
83
-
84
- /**
85
- * Download page as static html.
86
- */
87
- public function download($marked=true) {
88
-
89
- $this->filemodel->downloadPage($marked);
90
- $this->setData('last_refresh', now());
91
-
92
- return $this;
93
-
94
- }
95
-
96
- /**
97
- * Delete record form database.
98
- * Delete cached page, when no other.
99
- * NOT USED FOR DELETE MORE MODELS. USE deleteCollection() !!!
100
- */
101
- public function delete() {
102
-
103
- $this->deletePage();
104
- parent::delete();
105
-
106
- }
107
-
108
- /**
109
- * Delete cached page
110
- */
111
- public function deletePage() {
112
-
113
- if ($this->filemodel->existPage()) {
114
-
115
- $collection = $this->_loadCollectionWithSameRequest();
116
 
117
- if (count($collection)==1) {
118
- $this->filemodel->deletePage();
119
- }
120
-
121
- }
122
-
123
- }
 
 
 
 
 
 
124
 
125
- private function _loadCollectionWithSameRequest() {
126
-
127
- $collection = Mage::getModel('mturbo/mturbo')->getCollection();
128
- $collection->addFilter('request_path', $this->getRequestPath());
 
 
129
 
130
- $config = Artio_MTurbo_Helper_Data::getConfig();
131
- if ($config->getMultistoreview()) {
132
- $collection->addFilter('store_id', $this->getStoreId());
133
- }
134
 
135
- $collection->load();
136
-
137
- return $collection;
138
- }
139
-
140
- /**
141
- * Delete list of Mturbo. Check crossell request.
142
- * This function used for mass delete action, instead delete.
143
- * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection $collection
144
- */
145
- public function deleteCollection($collection) {
146
- $all = Mage::model('mturbo/mturbo')->getCollection()->load();
147
- }
148
-
149
- /**
150
- * Clear all pages
151
- */
152
- public function clearAllPages() {
153
- $this->filemodel->clearAllPages();
154
- }
155
 
156
- /**
157
- * Synchronize with table core_url_rewrite
158
- */
159
- public function synchronize() {
160
-
161
- $prefix = Mage::app()->getConfig()->getTablePrefix();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
  $config = Mage::getSingleton('mturbo/config');
164
 
165
- $col = $this->getCollectionByRequestPath("/");
166
- $homeIsIncluded = (count($col)>0);
167
-
168
- $inactiveStoresIdArray = array();
169
- $activeStoresIdArray = array();
170
  $stores = Mage::getModel('core/store')->getCollection()->load();
171
  foreach ($stores as $store) {
172
- if (!$store->getIsActive())
173
- $inactiveStoresIdArray[] = $store->getId();
174
- else
 
175
  $activeStoresIdArray[] = $store->getId();
 
 
 
176
  }
177
  $inactiveStoresIds = implode(',', $inactiveStoresIdArray);
178
- $activeStoresIds = implode(',', $activeStoresIdArray);
 
 
 
 
179
 
180
- $this->setConfig('synchronize');
181
- $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4,&$var5', Mage::helper('mturbo')->getTranslateFunction().';');
182
- $this->setHomepage(true);
183
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $config, $inactiveStoresIds, $activeStoresIds, $homeIsIncluded, $activeStoresIdArray, $prefix);
184
 
185
  }
 
186
 
187
- /**
188
- * Generate list of rewrited url to urllist file.
189
- */
190
- public function generateUrlList() {
191
-
192
- $config = Artio_MTurbo_Helper_Data::getConfig();
193
-
194
- $filename = $config->getRootPath().DS.Artio_MTurbo_Model_Config::CONFIG_URLLIST_FILENAME;
195
- $batchsize = Artio_MTurbo_Model_Config::CONFIG_URLLIST_BATCH;
196
-
197
- $file = @fopen($filename, 'w+', true);
198
- if ($file==false) {
199
- Mage::log("I can't open/create urllist file. " . $filename);
200
- Mage::throwException("I can't open/create urllist file. " . $filename);
 
 
 
201
  }
202
 
203
- $collection = $this->getCollection();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  $collection->addOrder('request_path', Varien_Data_Collection_Db::SORT_ORDER_ASC);
205
  $collection->addFilter('blocked', 0);
 
206
  $collection->setPageSize($batchsize);
207
 
208
- $completed=0;
209
- $homes=0;
210
  $current=1;
 
 
211
  while ($collection->getSize()>$completed) {
212
-
 
213
  $collection->clear();
214
  $collection->setCurPage($current);
215
  $collection->load();
216
 
217
- $urls = '';
218
- foreach ($collection as $item) {
219
- if ($item->getRequestPath()!='/')
220
- $urls .= $item->filemodel->getDownloadUrl()."\n";
221
- else
222
- $homes++;
223
- }
224
-
225
  if (@fwrite($file, $urls) == false) {
226
- Mage::log("I can't write to urllist file");
227
- Mage::throwException("I can't write to urllist file");
228
  }
229
 
230
  $current++;
231
- $completed+=count($collection);
232
 
233
  }
 
 
234
 
235
- return $completed-$homes;
236
-
237
- }
238
-
239
- /**
240
- * Retrieves store id
241
- * @return int
242
- */
243
- public function getStoreId() {
244
- return $this->getData('store_id');
245
- }
246
-
247
- /**
248
- * Set new request path.
249
- *
250
- * @param string $requestPath
251
- */
252
- public function setRequestPath($requestPath) {
253
- $this->setData('request_path', $requestPath);
254
- return $this;
255
- }
256
-
257
- /**
258
- * Retrieves request path
259
- * @return string
260
- */
261
- public function getRequestPath() {
262
- return $this->getData('request_path');
263
- }
264
-
265
- /**
266
- * Retrieves request url, only for information.
267
- */
268
- public function getInfoUrl() {
269
- return $this->filemodel->getDownloadUrl();
270
- }
271
-
272
- /**
273
- * Determines whether url is blocked.
274
- * @return bool
275
- */
276
- public function isBlocked() {
277
- return ($this->getData('blocked')==1);
278
- }
279
-
280
- /**
281
- * Determines whether page is cached.
282
- * @return bool
283
- */
284
- public function isCached() {
285
- return $this->filemodel->existPage();
286
- }
287
-
288
- /**
289
- * Retrieve direct parent category id.
290
- *
291
- * @return int
292
- */
293
- public function getCategoryId() {
294
- return $this->getData('category_id');
295
- }
296
 
 
 
 
 
 
 
297
  /**
298
- * Load collection all rewrite with specified product id.
299
- *
300
- * @param int $productId
301
- * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection
302
- */
303
- public function getCollectionByProductId($productId) {
304
-
305
- $collection = $this->getCollection();
306
- $collection->addFieldToFilter( 'product_id', $productId);
307
- $collection->addFilter('blocked', 0);
308
- $collection->load();
309
-
310
- return $collection;
 
 
 
 
 
311
 
312
- }
313
-
314
- /**
315
- * Load collection all rewrite with specified category id,
316
- * and not specified product id.
317
- *
318
- * @param unknown_type $categoryId
319
- * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection
320
- */
321
- public function getCollectionByCategoryIds($categoryIds) {
322
 
323
- $collection = $this->getCollection();
324
- $collection->addFieldToFilter('category_id', array('in'=>$categoryIds) );
325
- $collection->addFieldToFilter('product_id', array('null'=>''));
326
- $collection->addFilter('blocked', 0);
327
- $collection->load();
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
- return $collection;
330
 
331
- }
332
-
333
- public function getCollectionByRequestPath($requestPath) {
 
 
 
 
 
 
 
 
334
 
335
  $collection = $this->getCollection();
336
  $collection->addFilter('request_path', $requestPath);
337
  $collection->load();
338
 
339
  return $collection;
340
- }
341
-
342
- public function getModelByRewriteId($id) {
343
-
344
- $collection = $this->getCollection();
345
- $collection->addFilter('url_rewrite_id', $id);
346
- $collection->load();
347
-
348
- foreach ($collection as $item) {
349
- return $item;
350
- }
351
-
352
- return false;
353
 
354
- }
355
-
356
-
357
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
+ /**
23
+ * MTurbo record model.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
  class Artio_MTurbo_Model_MTurbo extends Mage_Core_Model_Abstract {
30
 
31
+ /* constant for name of urllist file using by automatic download */
32
+ const CONFIG_URLLIST_FILENAME = 'urllist.txt';
33
+ /* number of url which will be write to urllist at one time */
34
+ const CONFIG_URLLIST_BATCH = 50;
35
+
36
  /**
37
+ * File model.
38
+ *
39
  * @var Artio_MTurbo_Model_File
40
  */
41
+ private $filemodel = null;
42
+
43
 
44
+ /**
45
+ * MTurbo constructor
46
+ */
47
+ public function _construct() {
48
 
49
+ parent::_construct();
50
+ $this->_init('mturbo/mturbo');
51
+
52
+ /* create instance file model */
53
+ $this->filemodel = Mage::getModel('mturbo/mturbo_file');
54
+ $this->filemodel->setTurboModel($this);
55
 
56
+ }
 
 
 
 
 
 
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ /**
60
+ * Function retrieves corespond file model.
61
+ *
62
+ * @return $Artio_MTurbo_Model_MTurbo_File
63
+ */
64
+ public function getFileModel() {
65
+ return $this->filemodel;
66
+ }
67
+
68
+
69
+ /**
70
+ * Function load information about corespond file.
71
+ * 'exist' => 1 | 0
72
+ * 'file_size' => size of file
73
+ * 'last_refresh' => touch time of file
74
+ */
75
+ public function loadFileInformation() {
76
+
77
+ $fileModel = $this->getFileModel();
78
+
79
+ if ($fileModel->existPage()) {
80
+ $this->setExist('1');
81
+ $this->setPageSize( $fileModel->getPageSize() );
82
+ $this->setLastRefresh( $fileModel->getChangeTime() );
83
+ } else {
84
+ $this->setExist('0');
85
+ $this->setFileSize( 0 );
86
+ }
87
+
88
+ }
89
 
 
 
 
 
 
 
90
 
91
+ /**
92
+ * Set state. If state sets to blocked then delete page from hard drive.
93
+ * @param bool $state
94
+ * @return $Artio_MTurbo_Model_MTurbo this
95
+ */
96
+ public function setBlocked($state) {
 
97
 
98
+ if ($state==1)
99
+ $this->getFileModel()->deletePage();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ $this->setData('blocked', $state);
102
+ return $this;
103
+
104
+ }
105
+
106
+
107
+ /**
108
+ * Determines whether url is blocked.
109
+ * @return bool TRUE when is blocked, otherwise FALSE
110
+ */
111
+ public function isBlocked() {
112
+ return ($this->getData('blocked')==1);
113
+ }
114
 
115
+
116
+ /**
117
+ * Delete record form database and cached page.
118
+ * NOT USED FOR DELETE MORE MODELS. USE deleteCollection() !!!
119
+ */
120
+ public function delete() {
121
 
122
+ $this->getFileModel()->deletePage();
123
+ parent::delete();
 
 
124
 
125
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
+
128
+ /**
129
+ * Retrieves store code
130
+ * @return string store code
131
+ */
132
+ public function getStoreCode() {
133
+ $storeId = $this->getStoreId();
134
+ return Mage::getModel('core/store')->load($storeId)->getData('code');
135
+ }
136
+
137
+
138
+ /**
139
+ * Retrieves base url of model by storeview
140
+ */
141
+ public function getBaseUrl() {
142
+ $storeId = $this->getStoreId();
143
+ return Mage::getStoreConfig('web/unsecure/base_url', $storeId);
144
+ }
145
+
146
+
147
+ /* STATIC METHOD FOR ACTIONS */
148
+
149
+
150
+ /**
151
+ * Synchronize with table core_url_rewrite and cms_page and cms_page_store.
152
+ */
153
+ public function synchronize() {
154
+
155
+ /* get prefix tables */
156
+ $prefix = Mage::app()->getConfig()->getTablePrefix();
157
 
158
  $config = Mage::getSingleton('mturbo/config');
159
 
160
+ /* get ids collection of inactive and active stores */
161
+ /* inactive stores will be not synchronize */
162
+ $inactiveStoresIdArray = array();
163
+ $activeStoresIdArray = array();
 
164
  $stores = Mage::getModel('core/store')->getCollection()->load();
165
  foreach ($stores as $store) {
166
+
167
+ $websiteconfig = $config->getWebsiteConfigByStoreviewCode($store->getCode());
168
+
169
+ if ($store->getIsActive() && $websiteconfig->getEnabled() && $websiteconfig->isStoreViewEnabled($store->getCode()))
170
  $activeStoresIdArray[] = $store->getId();
171
+ else
172
+ $inactiveStoresIdArray[] = $store->getId();
173
+
174
  }
175
  $inactiveStoresIds = implode(',', $inactiveStoresIdArray);
176
+ $activeStoresIds = implode(',', $activeStoresIdArray);
177
+ $inactiveStoresIds = ($inactiveStoresIds=='') ? '-1' : $inactiveStoresIds;
178
+ $activeStoresIds = ($activeStoresIds=='') ? '-1' : $activeStoresIds;
179
+
180
+ $cmsItems = $this->getCollectionByType('cms')->getItems();
181
 
182
+ $this->setConfig('synchronize');
183
+ $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4,&$var5', Mage::helper('mturbo')->getTranslateFunction().';');
184
+ $this->setHomepage(true);
185
+ $trans(Mage::helper('mturbo')->setTranslateMode(5), $config, $inactiveStoresIds, $activeStoresIds, $activeStoresIdArray, $prefix, $cmsItems);
186
 
187
  }
188
+
189
 
190
+ /**
191
+ * Generate list of rewrited url to urllist file.
192
+ * Urllist is used by automatic download by cron.
193
+ */
194
+ public function generateUrlList($website=null) {
195
+
196
+ // if website is not specified, then generate list for all websites
197
+ if (!$website) {
198
+
199
+ $websiteCollection = Mage::getModel('core/website')->getCollection()->load();
200
+ $result = array();
201
+ foreach ($websiteCollection->getItems() as $website)
202
+ $result[$website->getName()] = $this->_generateUrlList($website);
203
+ return $result;
204
+
205
+ } else {
206
+ return $this->_generateUrlList($website);
207
  }
208
 
209
+ }
210
+
211
+ private function _generateUrlList($website) {
212
+
213
+ // get config models
214
+ $config = Mage::getSingleton('mturbo/config');
215
+ $websiteConfig = $config->getWebsiteConfig($website->getCode());
216
+
217
+ // if websiteconfig is not specified or website is not enabled then return nothing
218
+ if (!$websiteConfig || $websiteConfig->getEnabled()!='1')
219
+ return '';
220
+
221
+ /* counters */
222
+ $completed = 0;
223
+
224
+ /* get active store ids, we need to filter corrected records */
225
+ $activeStoreIds = Mage::helper('mturbo/website')->getActiveStoreIds($website);
226
+
227
+ /* get configuration information */
228
+ $subbase = Mage::helper('mturbo/website')->getSubbase($website->getDefaultStoreview());
229
+ $filename = $websiteConfig->getBaseDir().DS.$config->getTurbopath().DS.$subbase.DS.$website->getCode().'.txt';
230
+ $batchsize = self::CONFIG_URLLIST_BATCH;
231
+
232
+ /* create file */
233
+ $file = @fopen($filename, 'w+', true);
234
+ if ($file==false) {
235
+ Mage::log("MTurbo: I can't open/create urllist file. " . $filename);
236
+ Mage::throwException(Mage::helper('mturbo')->__("I can't open/create urllist file '%s'.", $filename));
237
+ }
238
+
239
+ /* get collection request_path in alfabeta order */
240
+ $collection = $this->getCollection();
241
  $collection->addOrder('request_path', Varien_Data_Collection_Db::SORT_ORDER_ASC);
242
  $collection->addFilter('blocked', 0);
243
+ $collection->addFieldToFilter('store_id', array("in"=>$activeStoreIds));
244
  $collection->setPageSize($batchsize);
245
 
246
+ /* counters */
 
247
  $current=1;
248
+
249
+ /* loop over collection */
250
  while ($collection->getSize()>$completed) {
251
+
252
+ /* load page collection */
253
  $collection->clear();
254
  $collection->setCurPage($current);
255
  $collection->load();
256
 
257
+ $urls = '';
258
+ foreach ($collection as $item) {
259
+ $fileModel = $item->getFileModel();
260
+ $urls .= $fileModel->getAbsolutePath()." ".$fileModel->getDownloadUrlWithNoCache()."\n";
261
+ }
262
+
263
+ /* write to file */
 
264
  if (@fwrite($file, $urls) == false) {
265
+ Mage::log("MTurbo: I can't write to urllist file");
266
+ Mage::throwException(Mage::helper('mturbo')->__("I can't write to urllist file '%s'", $filename));
267
  }
268
 
269
  $current++;
270
+ $completed+=(count($collection));
271
 
272
  }
273
+
274
+ return $completed;
275
 
276
+ }
277
+
278
+
279
+ /* STATIC METHOD FOR LOADED COLLECTIONS */
280
+
281
+ /**
282
+ * Loads and retrieves collection by type
283
+ */
284
+ public function getCollectionByType($type) {
285
+ $collection = $this->getCollection();
286
+ $collection->addFieldToFilter('type', $type);
287
+ $collection->load();
288
+ return $collection;
289
+ }
290
+
291
+ /**
292
+ * Load collection all rewrite with specified product id.
293
+ *
294
+ * @param int $productId
295
+ * @param int $storeId defualt -1 => all stores
296
+ * @return Artio_MTurbo_Model_Mysql4_MTurbo_Collection
297
+ */
298
+ public function getCollectionByProductIds($productIds, $storeId = -1) {
299
+
300
+ if (!is_array($productIds))
301
+ $productIds = array($productIds);
302
+
303
+ $collection = $this->getCollection();
304
+ $collection->addFieldToFilter('product_id', array('in'=>$productIds) );
305
+ if ($storeId > -1) $collection->addFieldToFilter('store_id', $storeId);
306
+ $collection->addFilter('blocked', 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
 
308
+ $collection->load();
309
+ return $collection;
310
+
311
+ }
312
+
313
+
314
  /**
315
+ * Load collection all rewrite with specified category id,
316
+ * and not specified product id.
317
+ *
318
+ * @param int $categoryId
319
+ * @param int $storeId defualt -1 => all stores
320
+ * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection
321
+ */
322
+ public function getCollectionByCategoryIds($categoryIds, $storeId = -1) {
323
+
324
+ if (!is_array($categoryIds))
325
+ $categoryIds = array($categoryIds);
326
+
327
+ $collection = $this->getCollection();
328
+ $collection->addFieldToFilter('category_id', array('in'=>$categoryIds) );
329
+ $collection->addFieldToFilter('product_id', array('null'=>''));
330
+ if ($storeId > -1) $collection->addFieldToFilter('store_id', $storeId);
331
+ $collection->addFilter('blocked', 0);
332
+ $collection->load();
333
 
334
+ return $collection;
 
 
 
 
 
 
 
 
 
335
 
336
+ }
337
+
338
+
339
+ /**
340
+ * Method loads and retrieves collections of mturbo model by page's id.
341
+ * @param array|string $pageIds
342
+ * @param string $storeId
343
+ */
344
+ public function getCollectionByCmsIds($pageIds, $storeId = -1) {
345
+
346
+ if (!is_array($pageIds))
347
+ $pageIds = array($pageIds);
348
+
349
+ $collection = $this->getCollection();
350
+ $collection->addFieldToFilter('page_id', array('in'=>$pageIds) );
351
+ if ($storeId > -1) $collection->addFieldToFilter('store_id', $storeId);
352
+ $collection->addFilter('blocked', 0);
353
+ $collection->load();
354
 
355
+ return $collection;
356
 
357
+ }
358
+
359
+
360
+ /**
361
+ * Function loads collection by request path and retrieves it.
362
+ *
363
+ * @param $requestPath
364
+ * @param int $storeId defualt -1 => all stores
365
+ * @return
366
+ */
367
+ public function getCollectionByRequestPath($requestPath, $storeId = -1) {
368
 
369
  $collection = $this->getCollection();
370
  $collection->addFilter('request_path', $requestPath);
371
  $collection->load();
372
 
373
  return $collection;
 
 
 
 
 
 
 
 
 
 
 
 
 
374
 
375
+ }
376
+
377
+ }
 
app/code/local/Artio/MTurbo/Model/Mturbo.php~ DELETED
@@ -1,418 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Artio
22
- * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- class Artio_MTurbo_Model_MTurbo extends Mage_Core_Model_Abstract {
28
-
29
- /**
30
- * @var Artio_MTurbo_Model_File
31
- */
32
- private $filemodel;
33
-
34
- public function _construct() {
35
- parent::_construct();
36
- $this->_init('mturbo/mturbo');
37
-
38
- $this->filemodel = Mage::getModel('mturbo/file');
39
- $this->filemodel->setTurboModel($this);
40
-
41
- }
42
-
43
- /**
44
- * Enter description here...
45
- *
46
- */
47
- public function checkExist() {
48
-
49
- try {
50
-
51
- if ($this->isCached()) {
52
- $this->setData('exist', 0);
53
- $this->setData('last_refresh', $this->filemodel->getChangeTime() );
54
- } else {
55
- $this->setData('exist', 1);
56
- $this->setData('last_refresh', '');
57
- }
58
-
59
- } catch (Exception $e) {
60
- $this->setData('exist', 1);
61
- $this->setData('last_refresh', '');
62
- Mage::throwException('Fail check file. ' . $e->getMessage());
63
- }
64
-
65
- }
66
-
67
- /**
68
- * Set state.
69
- * @param bool $state
70
- * @return $Artio_MTurbo_Model_MTurbo
71
- */
72
- public function setBlocked($state) {
73
-
74
- if ($state==1) {
75
- $this->deletePage();
76
- }
77
-
78
- $this->setData('blocked', $state);
79
-
80
- return $this;
81
-
82
- }
83
-
84
- /**
85
- * Download page as static html.
86
- */
87
- public function download($marked=true) {
88
-
89
- $this->filemodel->downloadPage($marked);
90
- $this->setData('last_refresh', now());
91
-
92
- return $this;
93
-
94
- }
95
-
96
- /**
97
- * Delete record form database.
98
- * Delete cached page, when no other.
99
- * NOT USED FOR DELETE MORE MODELS. USE deleteCollection() !!!
100
- */
101
- public function delete() {
102
-
103
- $this->deletePage();
104
- parent::delete();
105
-
106
- }
107
-
108
- /**
109
- * Delete cached page
110
- */
111
- public function deletePage() {
112
-
113
- if ($this->filemodel->existPage()) {
114
-
115
- $collection = $this->_loadCollectionWithSameRequest();
116
-
117
- if (count($collection)==1) {
118
- $this->filemodel->deletePage();
119
- }
120
-
121
- }
122
-
123
- }
124
-
125
- private function _loadCollectionWithSameRequest() {
126
-
127
- $collection = Mage::getModel('mturbo/mturbo')->getCollection();
128
- $collection->addFilter('request_path', $this->getRequestPath());
129
-
130
- $config = Artio_MTurbo_Helper_Data::getConfig();
131
- if ($config->getMultistoreview()) {
132
- $collection->addFilter('store_id', $this->getStoreId());
133
- }
134
-
135
- $collection->load();
136
-
137
- return $collection;
138
- }
139
-
140
- /**
141
- * Delete list of Mturbo. Check crossell request.
142
- * This function used for mass delete action, instead delete.
143
- * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection $collection
144
- */
145
- public function deleteCollection($collection) {
146
- $all = Mage::model('mturbo/mturbo')->getCollection()->load();
147
- }
148
-
149
- /**
150
- * Clear all pages
151
- */
152
- public function clearAllPages() {
153
- $this->filemodel->clearAllPages();
154
- }
155
-
156
- /**
157
- * Synchronize with table core_url_rewrite
158
- */
159
- public function synchronize() {
160
-
161
- $prefix = Mage::app()->getConfig()->getTablePrefix();
162
-
163
- $config = Mage::getSingleton('mturbo/config');
164
-
165
- $col = $this->getCollectionByRequestPath("/");
166
- $homeIsIncluded = (count($col)>0);
167
-
168
- $inactiveStoresIdArray = array();
169
- $activeStoresIdArray = array();
170
- $stores = Mage::getModel('core/store')->getCollection()->load();
171
- foreach ($stores as $store) {
172
- if (!$store->getIsActive())
173
- $inactiveStoresIdArray[] = $store->getId();
174
- else
175
- $activeStoresIdArray[] = $store->getId();
176
- }
177
- $inactiveStoresIds = implode(',', $inactiveStoresIdArray);
178
- $activeStoresIds = implode(',', $activeStoresIdArray);
179
-
180
- /* START ENCODED
181
- FUNCTION: synchronize
182
- PARAMETER: $config
183
- PARAMETER: $inactiveStoresIds
184
- PARAMETER: $activeStoresIds
185
- PARAMETER: $homeIsIncluded
186
- PARAMETER: $activeStoresIdArray
187
- PARAMETER: $prefix
188
- $this->setConfig('synchronize');
189
- $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4,&$var5', Mage::helper('mturbo')->getTranslateFunction().';');
190
- $this->setHomepage(true);
191
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $config, $inactiveStoresIds, $activeStoresIds, $homeIsIncluded, $activeStoresIdArray, $prefix);
192
- */
193
-
194
- $previewArray = $config->getPreviewCategoryIds();
195
- $preview = implode(',', $previewArray);
196
- if ($preview==0) $preview = '-1';
197
-
198
- $queryHom = '';
199
- foreach ($activeStoresIdArray as $storeId) {
200
- $queryHom .= "INSERT INTO `".$prefix."mturbo` (`store_id`, `request_path`) VALUES (".$storeId.", '/'); ";
201
- }
202
-
203
- $queryHomDef = "INSERT INTO `".$prefix."mturbo` (`store_id`, `request_path`) VALUES (0, '/'); ";
204
-
205
- $queryIns = "INSERT INTO `".$prefix."mturbo` (`url_rewrite_id`, `store_id`, `category_id`, `product_id`, `request_path`)
206
- SELECT `url_rewrite_id`, `store_id`, `category_id`, `product_id`, `request_path`
207
- FROM `".$prefix."core_url_rewrite`
208
- WHERE
209
- (
210
- (`category_id` IN (" . $preview . ") AND `product_id` IS NULL)
211
- )".
212
- (($inactiveStoresIds != '') ? "AND (`store_id` NOT IN (" . $inactiveStoresIds . "))" : "")
213
- ."AND
214
- (
215
- (`request_path` NOT IN (SELECT `".$prefix."request_path` FROM `mturbo`))
216
- )";
217
-
218
- $queryDel = "DELETE FROM `".$prefix."mturbo`
219
- WHERE (`category_id` NOT IN (". $preview . ") AND `product_id` IS NULL)";
220
-
221
- $queryDelHom = "DELETE FROM `".$prefix."mturbo` WHERE `request_path`='/';";
222
-
223
- $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
224
-
225
- try {
226
-
227
- $connection->query("START TRANSACTION");
228
-
229
- $includeHomepage = $config->homepageIsIncluded();
230
-
231
- if ($includeHomepage && !$homeIsIncluded) $connection->query($queryHom);
232
- if ($includeHomepage && $config->getMultistoreview()) $connection->query($queryHomDef);
233
- $connection->query($queryIns);
234
-
235
- if (!$includeHomepage && $homeIsIncluded) $connection->query($queryDelHom);
236
- $connection->query($queryDel);
237
-
238
- } catch (Exception $e) {
239
- $connection->query("ROLLBACK");
240
- throw $e;
241
- }
242
-
243
- $connection->query("COMMIT");
244
-
245
- /* END ENCODED */
246
- }
247
-
248
- /**
249
- * Generate list of rewrited url to urllist file.
250
- */
251
- public function generateUrlList() {
252
-
253
- $config = Artio_MTurbo_Helper_Data::getConfig();
254
-
255
- $filename = $config->getRootPath().DS.Artio_MTurbo_Model_Config::CONFIG_URLLIST_FILENAME;
256
- $batchsize = Artio_MTurbo_Model_Config::CONFIG_URLLIST_BATCH;
257
-
258
- $file = @fopen($filename, 'w+', true);
259
- if ($file==false) {
260
- Mage::log("I can't open/create urllist file. " . $filename);
261
- Mage::throwException("I can't open/create urllist file. " . $filename);
262
- }
263
-
264
- $collection = $this->getCollection();
265
- $collection->addOrder('request_path', Varien_Data_Collection_Db::SORT_ORDER_ASC);
266
- $collection->addFilter('blocked', 0);
267
- $collection->setPageSize($batchsize);
268
-
269
- $completed=0;
270
- $homes=0;
271
- $current=1;
272
- while ($collection->getSize()>$completed) {
273
-
274
- $collection->clear();
275
- $collection->setCurPage($current);
276
- $collection->load();
277
-
278
- $urls = '';
279
- foreach ($collection as $item) {
280
- if ($item->getRequestPath()!='/')
281
- $urls .= $item->filemodel->getDownloadUrl()."\n";
282
- else
283
- $homes++;
284
- }
285
-
286
- if (@fwrite($file, $urls) == false) {
287
- Mage::log("I can't write to urllist file");
288
- Mage::throwException("I can't write to urllist file");
289
- }
290
-
291
- $current++;
292
- $completed+=count($collection);
293
-
294
- }
295
-
296
- return $completed-$homes;
297
-
298
- }
299
-
300
- /**
301
- * Retrieves store id
302
- * @return int
303
- */
304
- public function getStoreId() {
305
- return $this->getData('store_id');
306
- }
307
-
308
- /**
309
- * Set new request path.
310
- *
311
- * @param string $requestPath
312
- */
313
- public function setRequestPath($requestPath) {
314
- $this->setData('request_path', $requestPath);
315
- return $this;
316
- }
317
-
318
- /**
319
- * Retrieves request path
320
- * @return string
321
- */
322
- public function getRequestPath() {
323
- return $this->getData('request_path');
324
- }
325
-
326
- /**
327
- * Retrieves request url, only for information.
328
- */
329
- public function getInfoUrl() {
330
- return $this->filemodel->getDownloadUrl();
331
- }
332
-
333
- /**
334
- * Determines whether url is blocked.
335
- * @return bool
336
- */
337
- public function isBlocked() {
338
- return ($this->getData('blocked')==1);
339
- }
340
-
341
- /**
342
- * Determines whether page is cached.
343
- * @return bool
344
- */
345
- public function isCached() {
346
- return $this->filemodel->existPage();
347
- }
348
-
349
- /**
350
- * Retrieve direct parent category id.
351
- *
352
- * @return int
353
- */
354
- public function getCategoryId() {
355
- return $this->getData('category_id');
356
- }
357
-
358
- /**
359
- * Load collection all rewrite with specified product id.
360
- *
361
- * @param int $productId
362
- * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection
363
- */
364
- public function getCollectionByProductId($productId) {
365
-
366
- $collection = $this->getCollection();
367
- $collection->addFieldToFilter( 'product_id', $productId);
368
- $collection->addFilter('blocked', 0);
369
- $collection->load();
370
-
371
- return $collection;
372
-
373
- }
374
-
375
- /**
376
- * Load collection all rewrite with specified category id,
377
- * and not specified product id.
378
- *
379
- * @param unknown_type $categoryId
380
- * @param Artio_MTurbo_Model_Mysql4_MTurbo_Collection
381
- */
382
- public function getCollectionByCategoryIds($categoryIds) {
383
-
384
- $collection = $this->getCollection();
385
- $collection->addFieldToFilter('category_id', array('in'=>$categoryIds) );
386
- $collection->addFieldToFilter('product_id', array('null'=>''));
387
- $collection->addFilter('blocked', 0);
388
- $collection->load();
389
-
390
- return $collection;
391
-
392
- }
393
-
394
- public function getCollectionByRequestPath($requestPath) {
395
-
396
- $collection = $this->getCollection();
397
- $collection->addFilter('request_path', $requestPath);
398
- $collection->load();
399
-
400
- return $collection;
401
- }
402
-
403
- public function getModelByRewriteId($id) {
404
-
405
- $collection = $this->getCollection();
406
- $collection->addFilter('url_rewrite_id', $id);
407
- $collection->load();
408
-
409
- foreach ($collection as $item) {
410
- return $item;
411
- }
412
-
413
- return false;
414
-
415
- }
416
-
417
-
418
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Artio/MTurbo/Model/Mturbo/Event.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * MTurbo event model. Maintain requests for manipulation with cached entities.
24
+ * (ex. product edit, insert category ...)
25
+ *
26
+ * Format event queue in configuration
27
+ * EVENT!EVENT!EVENT!EVENT!
28
+ *
29
+ * Format event
30
+ * TYPE;ACTION;DATA
31
+ *
32
+ * @category Artio
33
+ * @package Artio_MTurbo
34
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
35
+ */
36
+ class Artio_MTurbo_Model_MTurbo_Event extends Mage_Core_Model_Abstract {
37
+
38
+ const CONFIG_XML_PATH_MTURBO_EVENT = 'mturbo/event/queue';
39
+
40
+ const TYPE_CATEGORY_ID = '1';
41
+ const TYPE_PRODUCT_ID = '2';
42
+ const TYPE_REWRITE_ID = '3';
43
+ const TYPE_REQUEST = '4';
44
+ const TYPE_CMS_ID = '5';
45
+
46
+ private $type = null;
47
+ private $data = null;
48
+
49
+ private static $sync = null;
50
+ private static $instance = null;
51
+
52
+
53
+ /**
54
+ * Get queue instance as singleton.
55
+ */
56
+ public function getQueue() {
57
+
58
+ if (!isset(self::$instance)) {
59
+
60
+ self::$instance = array();
61
+
62
+ $config = $this->_getQueueContents();
63
+
64
+ if (!isset($config)) {
65
+ self::$instance = null;
66
+ } else {
67
+ self::$instance = $this->_restoreQueue($config);
68
+ }
69
+
70
+ }
71
+
72
+ return $this;
73
+
74
+ }
75
+
76
+
77
+ /**
78
+ * Special function for load contents of queue.
79
+ * Using function Mage::getStoreConfig is not possible, because it use cache.
80
+ */
81
+ private function _getQueueContents() {
82
+
83
+ $config = Mage::getModel('core/config_data');
84
+ $collection = $config->getCollection();
85
+ $collection->addFieldToFilter('path', array('like'=>self::CONFIG_XML_PATH_MTURBO_EVENT));
86
+ $collection->load();
87
+
88
+ $items = $collection->getItems();
89
+ $item = array_shift($items);
90
+
91
+ return (isset($item)) ? $item->getData('value') : null;
92
+
93
+ }
94
+
95
+
96
+ /**
97
+ * Function restores queue from configuration.
98
+ */
99
+ private function _restoreQueue($string) {
100
+
101
+ /* splits into events */
102
+ $configArray = explode("!", $string);
103
+
104
+ if (!is_array($configArray))
105
+ return null;
106
+
107
+ $sync = array_shift($configArray);
108
+ if ($sync=='1')
109
+ self::$sync = true;
110
+
111
+ $result = array();
112
+
113
+ /* foreach events */
114
+ foreach ($configArray as $configItem) {
115
+
116
+ $configItemArray = explode(";", $configItem);
117
+
118
+ /* if config event is corect then add event to queue */
119
+ $i = 0;
120
+ $c = count($configItemArray);
121
+ while ($i<$c-1) {
122
+
123
+ $event = Mage::getModel('mturbo/mturbo_event');
124
+ $event->setType($configItemArray[$i++]);
125
+
126
+ $data = $configItemArray[$i++];
127
+ if (strpos($data, ',')>0)
128
+ $event->setData('ids', explode(",", $data));
129
+ else
130
+ $event->setData('ids', $data);
131
+
132
+ $result[] = $event;
133
+
134
+ }
135
+ }
136
+
137
+ /* if queue is empty return null */
138
+ return count($result)>0 ? $result : null;
139
+
140
+ }
141
+
142
+
143
+ /**
144
+ * Function save queue in to configuration.
145
+ */
146
+ public function saveQueue() {
147
+
148
+ try {
149
+
150
+ $config = Mage::getModel('core/config_data');
151
+
152
+ /* load config record */
153
+ $collection = $config->getCollection();
154
+ $collection->addFieldToFilter('path', array('like'=>self::CONFIG_XML_PATH_MTURBO_EVENT));
155
+ $collection->load();
156
+
157
+ /* build config record, if it is empty set path */
158
+ $dataObject = null;
159
+ if ($collection->getSize()==0) {
160
+ $dataObject = Mage::getModel('core/config_data');
161
+ $dataObject->setPath(self::CONFIG_XML_PATH_MTURBO_EVENT);
162
+ } else {
163
+ foreach ($collection as $item) {
164
+ $dataObject = $item;
165
+ break;
166
+ }
167
+ }
168
+
169
+ $dataObject->setValue($this->_toSerializeString());
170
+
171
+ $dataObject->save();
172
+
173
+ } catch (Exception $e) {
174
+ Mage::log("MTurbo: Saving event queue failed. " . $e->getMessage());
175
+ Mage::logException($e);
176
+ }
177
+
178
+ }
179
+
180
+
181
+ /**
182
+ * Serialized event to string.
183
+ */
184
+ private function _toSerializeString() {
185
+
186
+ $result = (self::$sync) ? '1!' : '0!';
187
+
188
+ if (isset(self::$instance)) {
189
+
190
+ foreach (self::$instance as $event) {
191
+ $result .= $event->getData('type').';';
192
+ $result .= is_array($event->getData('ids')) ? implode(",", $event->getData('ids')).';' : $event->getData('ids').';';
193
+ }
194
+ $result .= '!';
195
+ }
196
+
197
+ return $result;
198
+
199
+ }
200
+
201
+ /**
202
+ * Set syncronize indicator.
203
+ * Before flush will be mturbo synchronized.
204
+ */
205
+ public function setSynchronize() {
206
+ self::$sync = true;
207
+ }
208
+
209
+
210
+ /**
211
+ * Add item into queue
212
+ * @param int $type constant TYPE_*
213
+ * @param int $action constant ACTION_*
214
+ * @param string $data added data
215
+ */
216
+ public function addItem($type, $data) {
217
+
218
+ if (!isset(self::$instance)) {
219
+ self::$instance = array();
220
+ }
221
+
222
+ $event = Mage::getModel('mturbo/mturbo_event');
223
+ $event->setData('type', $type);
224
+ $event->setData('ids', $data);
225
+
226
+ self::$instance[] = $event;
227
+
228
+ }
229
+
230
+ /**
231
+ * Flush current queue.
232
+ */
233
+ public function flush() {
234
+
235
+ if (isset(self::$instance)) {
236
+
237
+ $model = Mage::getModel('mturbo/mturbo');
238
+ if (self::$sync) {
239
+ $model->synchronize();
240
+ }
241
+
242
+ foreach (self::$instance as $action) {
243
+
244
+ $collection = null;
245
+ switch ($action->getData('type')) {
246
+
247
+ case self::TYPE_CATEGORY_ID:
248
+ $collection = $model->getCollectionByCategoryIds($action->getData('ids'));
249
+ break;
250
+ case self::TYPE_PRODUCT_ID:
251
+ $collection = $model->getCollectionByProductIds($action->getData('ids'));
252
+ break;
253
+ case self::TYPE_REQUEST:
254
+ break;
255
+ case self::TYPE_CMS_ID:
256
+ $collection = $model->getCollectionByCmsIds($action->getData('ids'));
257
+ break;
258
+ case self::TYPE_REWRITE_ID:
259
+ break;
260
+
261
+ }
262
+
263
+ if (isset($collection)) {
264
+ foreach ($collection->getItems() as $item) {
265
+ Mage::log('download'.$item->getId());
266
+ if (!$item->isBlocked())
267
+ $item->getFileModel()->downloadPage();
268
+ }
269
+ }
270
+
271
+
272
+ }
273
+
274
+ // clear event queue
275
+ self::$instance = null;
276
+ self::$sync = null;
277
+ $this->saveQueue();
278
+
279
+ }
280
+
281
+ }
282
+
283
+ }
app/code/local/Artio/MTurbo/Model/Mturbo/File.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * MTurbo file model. Maintain page in the disk.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_Model_MTurbo_File extends Mage_Core_Model_Abstract {
29
+
30
+ /* used extension for cached pages */
31
+ const EXT = '.html';
32
+ /* used identifier for frontpage */
33
+ const FRONTPAGE = 'home';
34
+
35
+ /**
36
+ * Parent MTurbo model
37
+ * @var Artio_MTurbo_Model_MTurbo
38
+ */
39
+ private $mturbomodel;
40
+
41
+
42
+ /**
43
+ * Set parent MTurbo model.
44
+ *
45
+ * @param Artio_MTurbo_Model_MTurbo $mturbomodel
46
+ */
47
+ public function setTurboModel($mturbomodel) {
48
+ $this->mturbomodel = $mturbomodel;
49
+ }
50
+
51
+
52
+ /**
53
+ * Get parent MTurbo model.
54
+ *
55
+ * @return Artio_MTurbo_Model_MTurbo
56
+ */
57
+ public function getTurboModel() {
58
+ return $this->mturbomodel;
59
+ }
60
+
61
+
62
+ /**
63
+ * Delete cached page.
64
+ */
65
+ public function deletePage() {
66
+ return unlink( $this->getAbsolutePath() );
67
+ }
68
+
69
+
70
+ /**
71
+ * Retrieve change time.
72
+ */
73
+ public function getChangeTime() {
74
+ $unix = filectime( $this->getAbsolutePath() );
75
+ return date('Y-m-d H:i:s', $unix);
76
+ }
77
+
78
+
79
+ /**
80
+ * Determines whether exist cached page.
81
+ * @return bool
82
+ */
83
+ public function existPage() {
84
+ return file_exists( $this->getAbsolutePath() );
85
+ }
86
+
87
+
88
+ /**
89
+ * Retrives size where really occupied in the harddisk.
90
+ */
91
+ public function getPageSize() {
92
+ return filesize( $this->getAbsolutePath() );
93
+ }
94
+
95
+
96
+ /**
97
+ * Retrieve download url with no cache query string
98
+ *
99
+ * @return string download url witt no cache query string
100
+ */
101
+ public function getDownloadUrlWithNoCache() {
102
+
103
+ $originalUrl = $this->getDownloadUrl();
104
+
105
+ /*
106
+ * if url contains query string
107
+ * then add nocache as next parameter
108
+ */
109
+ if (strpos($originalUrl, '?')>0) {
110
+ return $originalUrl.'&nocache=true&mturbo_dynamic_block=true';
111
+ } else {
112
+ return $originalUrl.'?nocache=true&mturbo_dynamic_block=true';
113
+ }
114
+
115
+ }
116
+
117
+
118
+ /**
119
+ * Retrieve download url
120
+ * @return string download original url
121
+ */
122
+ public function getDownloadUrl() {
123
+
124
+ /* get request path */
125
+ $requestPath = $this->mturbomodel->getRequestPath();
126
+
127
+ /* base url */
128
+ $baseUrl = Mage::getStoreConfig('web/unsecure/base_url', $this->mturbomodel->getStoreId());
129
+ $baseUrl = str_ireplace('/index.php/admin', '', $baseUrl);
130
+ $baseUrl = str_ireplace('/index.php', '', $baseUrl);
131
+
132
+ /* get store code */
133
+ $storeCode = $this->mturbomodel->getStoreCode();
134
+
135
+ /* url is base url */
136
+ $url = $baseUrl;
137
+
138
+ /* add store_code, when necessary */
139
+ if (Mage::getStoreConfig('web/url/use_store')=='1') {
140
+ $baseUrl .= $storeCode.'/';
141
+ }
142
+
143
+ /* add request_path, when necessary */
144
+ if ($requestPath != self::FRONTPAGE) {
145
+ $baseUrl .= $requestPath;
146
+ }
147
+
148
+ /* if store_code is not in url then add as query string */
149
+ if (Mage::getStoreConfig('web/url/use_store')=='0') {
150
+ $baseUrl .= '?___store='.$storeCode;
151
+ }
152
+
153
+ return $baseUrl;
154
+
155
+ }
156
+
157
+
158
+ /**
159
+ * Retrieve complete path to cached file.
160
+ * @return string
161
+ */
162
+ public function getAbsolutePath() {
163
+ $config = Mage::getSingleton('mturbo/config');
164
+ $websiteconfig = $config->getWebsiteConfigByStoreviewCode($this->getTurboModel()->getStoreCode());
165
+ return $websiteconfig->getBaseDir().DS.$config->getTurbopath().DS.$this->getRelativePath();
166
+ }
167
+
168
+
169
+ /**
170
+ * Retrieves relative path from root web.
171
+ *
172
+ * @return string
173
+ */
174
+ public function getRelativePath() {
175
+
176
+ /*
177
+ * Path-to-file rules:
178
+ *
179
+ * url: www.foo.com/subpath1/subpath2/subpath3
180
+ * path: subpath1/subpath2/subpath3.html
181
+ *
182
+ * Except are frontpages with request /home !
183
+ *
184
+ * url: www.foo.com/storecode/
185
+ * path: storecode.html
186
+ *
187
+ * url www.foo.com/
188
+ * path: DEFAULT_STORE_CODE.html
189
+ *
190
+ * DEFAULT_STORE_CODE is store code of default storeview.
191
+ *
192
+ * Url makes by unsecure base url, store code and request.
193
+ * Store code is used even when set not to use the store code in the url.
194
+ *
195
+ */
196
+
197
+ /* path is empty */
198
+ $path = '';
199
+
200
+ /* get information about model */
201
+ $storeCode = $this->mturbomodel->getStoreCode();
202
+ $baseUrl = $this->mturbomodel->getBaseUrl();
203
+ $request = $this->mturbomodel->getRequestPath();
204
+
205
+ /* trim request suffix */
206
+ $requestArray = explode('.', $request);
207
+ $request = $requestArray[0];
208
+
209
+ if ($request == self::FRONTPAGE) {
210
+
211
+ /* if frontpage then path is storecode.html */
212
+ $path = $storeCode;
213
+
214
+ } else {
215
+
216
+ /* make url without http:// or https:// */
217
+ $completeUrl = $baseUrl.$storeCode.DS.$request;
218
+ $completeUrl = str_replace('https://', '', $completeUrl);
219
+ $completeUrl = str_replace('http://', '', $completeUrl);
220
+
221
+ /* explode to array, array[0] is host */
222
+ $urlArray = explode(DS, $completeUrl);
223
+
224
+ /* remove host */
225
+ array_shift($urlArray);
226
+
227
+ /* make back to path */
228
+ $path = implode(DS, $urlArray);
229
+
230
+ }
231
+
232
+ /* add extension */
233
+ $path .= self::EXT;
234
+ return $path;
235
+
236
+ }
237
+
238
+
239
+ /**
240
+ * Download page and save as static html.
241
+ * @param $marked determines whether will be appended current timestamp
242
+ * @param $saved determines whether downloaded page will be saved in the harddisk
243
+ * @param $resultTest output of result test string
244
+ * @param $method used method (default method gather from configuration)
245
+ */
246
+ public function downloadPage($marked=true, $saved=true, &$resultTest='', $method='') {
247
+
248
+ $html = "<!-- " . now() . " -->";
249
+ $trans = create_function('$a,&$var0,&$var1,&$var2,&$var3,&$var4', Mage::helper('mturbo')->getTranslateFunction().';');
250
+ $trans(Mage::helper('mturbo')->setTranslateMode(5), $this, $marked, $saved, $resultTest, $method);
251
+
252
+
253
+ }
254
+
255
+
256
+ /**
257
+ * Clear all pages.
258
+ */
259
+ public function clearAllPages() {
260
+
261
+ $config = Mage::getSingleton('mturbo/config');
262
+ $turbopath = $config->getTurbopath();
263
+ $pattern = '/(.)*\.html/';
264
+
265
+ $websites = Mage::getModel('core/website')->getCollection()->load();
266
+ foreach ($websites as $website) {
267
+
268
+ $websiteConfig = $config->getWebsiteConfig($website->getCode());
269
+
270
+ $baseDir = $websiteConfig->getBaseDir();
271
+
272
+ Mage::helper('mturbo/functions')->unlink_recursive($baseDir.DS.$turbopath, $pattern);
273
+
274
+ $htaccess = Mage::getModel('mturbo/htaccess')->setWebsiteCode($website->getCode());
275
+ $htaccess->copySideHtaccess();
276
+
277
+ }
278
+
279
+ }
280
+
281
+ }
app/code/local/Artio/MTurbo/Model/Mysql4/Mturbo.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
@@ -30,4 +25,4 @@ class Artio_MTurbo_Model_Mysql4_MTurbo extends Mage_Core_Model_Mysql4_Abstract
30
  {
31
  $this->_init('mturbo/mturbo', 'mturbo_id');
32
  }
33
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
25
  {
26
  $this->_init('mturbo/mturbo', 'mturbo_id');
27
  }
28
+ }
app/code/local/Artio/MTurbo/Model/Mysql4/Mturbo/Collection.php CHANGED
@@ -12,11 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
  * @category Artio
22
  * @package Artio_MTurbo
@@ -30,4 +25,4 @@ class Artio_MTurbo_Model_Mysql4_MTurbo_Collection extends Mage_Core_Model_Mysql4
30
  parent::_construct();
31
  $this->_init('mturbo/mturbo');
32
  }
33
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
15
  *
16
  * @category Artio
17
  * @package Artio_MTurbo
25
  parent::_construct();
26
  $this->_init('mturbo/mturbo');
27
  }
28
+ }
app/code/local/Artio/MTurbo/Model/Observer.php CHANGED
@@ -12,12 +12,6 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
@@ -25,67 +19,141 @@
25
  */
26
 
27
  /**
28
- * Shopping cart operation observer
29
  *
30
- * @author Artio Magento Team <info@artio.net>
 
 
31
  */
32
  class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
33
  {
34
 
35
- public function systemCheck(Varien_Event_Observer $observer) {
36
- Mage::getModel('mturbo/observer2')->systemCheck($observer);
37
- }
38
 
39
-
40
- public function _delTree($dir, $root) {
 
 
 
 
 
 
 
41
 
42
- $files = glob( $dir.DS.'*', GLOB_MARK );
43
- foreach( $files as $file ){
44
- if( is_dir( $file ) )
45
- $this->_delTree( $file, $root );
46
- else {
47
- if (preg_match('/(.)*\.html/', $file))
48
- unlink( $file );
49
- }
50
- }
51
-
52
- if (is_dir($dir)&&($dir!=$root)) rmdir( $dir );
53
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  public function adminLogin(Varien_Event_Observer $observer) {
57
-
58
- $del = $this;
59
- $event = 'adminLogin';
60
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
61
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $this);
 
 
62
 
63
-
64
  }
65
 
66
- /**
67
- * Customer login processing
68
- *
69
- * @param Varien_Event_Observer $observer
70
- * @return Artio_MTurbo_Model_Observer
71
- */
72
- public function customerLogin(Varien_Event_Observer $observer) {
73
- Mage::getModel('mturbo/observer2')->customerLogin($observer);
74
- return $this;
75
- }
76
 
77
- /**
78
- * Customer logout processing
79
- *
80
- * @param Varien_Event_Observer $observer
81
- * @return Artio_MTurbo_Model_Observer
82
- */
83
- public function customerLogout(Varien_Event_Observer $observer) {
84
- Mage::getModel('mturbo/observer2')->customerLogout($observer);
85
- return $this;
86
- }
87
 
88
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  * After save product event handler.
90
  *
91
  * @param Varien_Event_Observer $observer
@@ -93,11 +161,43 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
93
  public function afterSaveProduct(Varien_Event_Observer $observer)
94
  {
95
 
96
- $event = 'afterSaveProduct';
97
- $pobser = $observer;
98
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
99
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $pobser);
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  /**
@@ -106,11 +206,13 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
106
  * @param Varien_Event_Observer $observer
107
  */
108
  public function beforeSaveCategory(Varien_Event_Observer $observer) {
109
- $pobser = $observer;
110
- $event = 'beforeSaveCategory';
111
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
112
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $pobser);
113
-
 
 
114
  }
115
 
116
  /**
@@ -119,12 +221,62 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
119
  * @param Varien_Event_Observer $observer
120
  */
121
  public function afterSaveCategory(Varien_Event_Observer $observer) {
122
-
123
- $pobser = $observer;
124
- $event = 'afterSaveCategory';
125
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
126
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $pobser);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
 
130
  /**
@@ -132,24 +284,115 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
132
  *
133
  * @param Varien_Event_Observer $observer
134
  */
135
- public function afterSaveCommitUrl(Varien_Event_Observer $observer) {
136
-
137
- $pobser = $observer;
138
- $event = 'afterSaveCommitUrl';
139
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
140
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $pobser);
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
 
144
  /**
145
- * Night automatic downloader
146
  *
147
  */
148
  public function automaticDownload() {
149
-
150
- $event = 'automaticDownload';
151
- $trans = create_function('$a', Mage::helper('mturbo')->getTranslateFunction().';');
152
- $trans(Mage::helper('mturbo')->setTranslateMode(5));
 
 
 
 
153
 
154
 
155
  }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
  */
20
 
21
  /**
22
+ * MTurbo observer.
23
  *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
  */
28
  class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
29
  {
30
 
 
 
 
31
 
32
+ /**
33
+ * Layout updating. Dynamic loaded block are replaced by MTurbo_Ajax blocks.
34
+ * @param Varien_Event_Observer $observer
35
+ */
36
+ public function layoutUpdate(Varien_Event_Observer $observer) {
37
+
38
+ // if exists get variable DYNAMIC_BLOCKS_KEY then blocks will be processed
39
+ $key = Artio_MTurbo_Helper_Data::DYNAMIC_BLOCKS_KEY;
40
+ $turnAjax = (isset($_GET[$key]) && $_GET[$key]==true);
41
 
42
+ // if layout is not patched, then it is not processed
43
+ $patch = Mage::getSingleton('mturbo/layoutPatch');
44
+ if ($patch->needToPatch() && !$patch->isPatched())
45
+ return $this;
46
+
47
+ // if block is created by Mturbo block or not exists above vars, then it is not processed
48
+ if (!$turnAjax || Mage::registry('mturbo_no_ajax') )
49
+ return $this;
50
+
51
+ // get block
52
+ $event = $observer->getEvent();
53
+ $block = $event->getData('block');
54
+
55
+ // prevent neverending loop
56
+ if ($block && $block instanceof Artio_MTurbo_Block_Ajax)
57
+ return $this;
58
+
59
+ // process only dynamic loaded blocks
60
+ $dynamic = Mage::getSingleton('mturbo/config_dynamicTransformer');
61
+ if ($id = $dynamic->getDynamic($block)) {
62
+
63
+ $name = $block->getNameInLayout();
64
+
65
+ $url = Mage::getBaseUrl().'mturbo';
66
+ $endScript = "\n<script type=\"text/javascript\">mturboloader.loadBlocks(\"$url\");</script>\n";
67
+
68
+ $layout = Mage::getSingleton('core/layout');
69
+ $layout->unsetBlock($name);
70
+ $layout->createBlock('mturbo/ajax', $name, array('ajax_identifier'=>$id));
71
+
72
+ $headBlock = Mage::registry('mturbo_head_block');
73
+ if (!$headBlock) {
74
+ $headBlock = $layout->getBlock('head');
75
+ Mage::register('mturbo_head_block', $headBlock, true);
76
+ }
77
+
78
+ $includes = $headBlock->getIncludes();
79
+ $includes = str_replace($endScript, '', $includes); // load script must be at end all scripts
80
+ $includes .= "\n<script type=\"text/javascript\">mturboloader.addBlockRequest('$id');</script>";
81
+
82
+ // for cart will be updated also link in header
83
+ if ($id=='cartsidebar')
84
+ $includes .= "\n<script type=\"text/javascript\">mturboloader.cartLink=true</script>";
85
+
86
+ $includes .= $endScript;
87
+ $headBlock->setIncludes($includes);
88
+
89
+ }
90
+ Mage::unregister('_helper/mturbo/data');
91
  }
92
 
93
+ public function systemCheck(Varien_Event_Observer $observer) {
94
+
95
+ $event = $observer->getEvent();
96
+ $block = $event->getData('block');
97
+
98
+ if ($block instanceof Mage_Page_Block_Html_Footer) {
99
+ $event = 'systemCheck';
100
+ $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
101
+ $trans(Mage::helper('mturbo')->setTranslateMode(5), $block);
102
+
103
+ }
104
+ Mage::unregister('_helper/mturbo/data');
105
+ }
106
+
107
+ /**
108
+ * Execute when admin logged.
109
+ */
110
  public function adminLogin(Varien_Event_Observer $observer) {
111
+
112
+ $funcs = Mage::helper('mturbo/functions');
113
+
114
+ $del = $this;
115
+ $event = 'adminLogin';
116
+ $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
117
+ $trans(Mage::helper('mturbo')->setTranslateMode(5), $this);
118
 
119
+ Mage::unregister('_helper/mturbo/data');
120
  }
121
 
122
+ /**
123
+ * Customer login processing. Send MTurbo cookie.
124
+ *
125
+ * @param Varien_Event_Observer $observer
126
+ */
127
+ public function customerLogin(Varien_Event_Observer $observer) {
128
+ Mage::getModel('core/cookie')->set( Artio_MTurbo_Helper_Data::COOKIE_IDENTIFIER, '1');
129
+ }
 
 
130
 
131
+
132
+ /**
133
+ * Customer logout processing. Delete MTurbo cookie.
134
+ *
135
+ * @param Varien_Event_Observer $observer
136
+ */
137
+ public function customerLogout(Varien_Event_Observer $observer) {
138
+ Mage::getModel('core/cookie')->set( Artio_MTurbo_Helper_Data::COOKIE_IDENTIFIER, '', -100);
139
+ }
 
140
 
141
+ /**
142
+ * Before save product.
143
+ * @param Varien_Event_Observer $observer
144
+ */
145
+ public function beforeSaveProduct(Varien_Event_Observer $observer) {
146
+
147
+ // remember id and urlkey save product, because user can chacne url_key
148
+ $event = $observer->getEvent();
149
+ $product = $event->getData('product');
150
+
151
+ Mage::register('mturbo_product_cache_id', $product->getId(), true);
152
+ Mage::register('mturbo_product_cache_url', $product->getData('url_key'), true);
153
+ Mage::unregister('_helper/mturbo/data');
154
+ }
155
+
156
+ /**
157
  * After save product event handler.
158
  *
159
  * @param Varien_Event_Observer $observer
161
  public function afterSaveProduct(Varien_Event_Observer $observer)
162
  {
163
 
164
+ $config = Mage::helper('mturbo')->getConfig();
 
 
 
165
 
166
+ $event = $observer->getEvent();
167
+ $product = $event->getData('product');
168
+
169
+ $id = $product->getId();
170
+ $url = $product->getData('url_key');
171
+
172
+ $eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
173
+
174
+ if ($config->getRefreshProduct()=='1') {
175
+
176
+ // if url was changed then need to synchronize record of mturbo
177
+ $remId = Mage::registry('mturbo_product_cache_id');
178
+ $remUrl = Mage::registry('mturbo_product_cache_url');
179
+ if ($id==$remId && $url!=$remUrl)
180
+ $eventQueue->setSynchronize();
181
+
182
+ $eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_PRODUCT_ID, $id);
183
+
184
+ }
185
+
186
+ if ($config->getRefreshParentsForProduct()=='1') {
187
+ $categoryIds = $product->getCategoryIds();
188
+ if (is_array($categoryIds)) {
189
+ Mage::log('je array hod'.implode(",", $categoryIds));
190
+ }
191
+ else { Mage::log('neni array'); }
192
+ $eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CATEGORY_ID, $categoryIds);
193
+
194
+ }
195
+
196
+ $eventQueue->saveQueue();
197
+ Mage::unregister('_helper/mturbo/data');
198
+
199
+ return $this;
200
+
201
  }
202
 
203
  /**
206
  * @param Varien_Event_Observer $observer
207
  */
208
  public function beforeSaveCategory(Varien_Event_Observer $observer) {
209
+
210
+ $event = $observer->getEvent();
211
+ $category= $event->getData('category');
212
+
213
+ Mage::register('mturbo_category_cache_id', $category->getId(), true);
214
+ Mage::register('mturbo_category_cache_url', $category->getData('url_key'), true);
215
+ Mage::unregister('_helper/mturbo/data');
216
  }
217
 
218
  /**
221
  * @param Varien_Event_Observer $observer
222
  */
223
  public function afterSaveCategory(Varien_Event_Observer $observer) {
224
+
225
+ $config = Mage::helper('mturbo')->getConfig();
226
+
227
+ $event = $observer->getEvent();
228
+ $category = $event->getData('category');
229
+
230
+ $id = $category->getId();
231
+ $url = $category->getData('url_key');
232
+
233
+ $eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
234
+
235
+
236
+ // check whether add to new category to select
237
+ $saveConfig = false;
238
+ if ($config->getAddNewlyCategoryToSelect()=='1') {
239
+ $array = $config->getPreviewCategoriesAsArray();
240
+ $array[] = $id;
241
+ $config = $config->setPreviewCategories($array);
242
+ $saveConfig = true;
243
+ $eventQueue->setSynchronize();
244
+ }
245
+ if ($config->getAddNewlyProductToSelect()=='1') {
246
+ $array = $config->getProductCategoriesAsArray();
247
+ $array[] = $id;
248
+ $config = $config->setProductCategories($array);
249
+ $saveConfig = true;
250
+ $eventQueue->setSynchronize();
251
+ }
252
 
253
+ if ($config->getRefreshCategory()=='1') {
254
+
255
+ // if url was changed then need to synchronize record of mturbo
256
+ $remId = Mage::registry('mturbo_category_cache_id');
257
+ $remUrl = Mage::registry('mturbo_category_cache_url');
258
+ if ($id==$remId && $url!=$remUrl) {
259
+ $eventQueue->setSynchronize();
260
+ }
261
+
262
+ $eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CATEGORY_ID, $id);
263
+
264
+ }
265
+
266
+ if ($config->getRefreshParentsForProduct()=='1') {
267
+
268
+ $categoryIds = array();
269
+ foreach ($category->getParentCategories() as $parentCategory)
270
+ if ($parentCategory->getId()!=$id)
271
+ $categoryIds[] = $parentCategory->getId();
272
+
273
+ $eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CATEGORY_ID, $categoryIds);
274
+
275
+ }
276
+
277
+ $eventQueue->saveQueue();
278
+ if ($saveConfig) $config->save();
279
+ Mage::unregister('_helper/mturbo/data');
280
  }
281
 
282
  /**
284
  *
285
  * @param Varien_Event_Observer $observer
286
  */
287
+ public function afterSaveCommitAbstract(Varien_Event_Observer $observer) {
 
 
 
 
 
288
 
289
+ $event = $observer->getEvent();
290
+ $object = $event->getData('data_object');
291
+
292
+ if ($object instanceof Mage_Core_Model_Url_Rewrite) {
293
+
294
+ $config = Mage::helper('mturbo')->getConfig();
295
+
296
+ $eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
297
+ $eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_REWRITE_ID, $object->getId());
298
+
299
+ $eventQueue->saveQueue();
300
+
301
+ }
302
+ Mage::unregister('_helper/mturbo/data');
303
+ }
304
+
305
+ public function afterSaveAbstract(Varien_Event_Observer $observer) {
306
+
307
+ $event = $observer->getEvent();
308
+ $object = $event->getData('object');
309
+
310
+ // saving cms pages
311
+ if ($object instanceof Mage_Cms_Model_Page) {
312
+
313
+ $config = Mage::helper('mturbo')->getConfig();
314
+ $eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
315
+
316
+ if ($config->getAddNewlyCmsToSelect()) {
317
+
318
+ $arr = $config->getCmsPagesWithStoresAsArray();
319
+
320
+ $id = $object->getId();
321
+ $stores = $object->getStores();
322
+
323
+ if ($object->getIdentifier()!='home') {
324
+ Mage::unregister('_helper/mturbo/data');
325
+ return;
326
+ }
327
+
328
+ // get all enabled stores from configuration
329
+ $enabledStores = $config->getAllEnabledStores();
330
+
331
+ // all stores
332
+ if (count($stores)==1 && $stores[0]==0) {
333
+
334
+ // store id is set to 0 => all enabled stores will be added
335
+ foreach ($enabledStores as $store) {
336
+ $storeId = Mage::getModel('core/store')->load($store)->getId();
337
+ if ($storeId)
338
+ $arr[] = $id.'_'.$storeId;
339
+ }
340
+
341
+ // selected stores
342
+ } else {
343
+
344
+ // page is asociated to selected stores => each asociated stores checks to enabled
345
+ foreach ($stores as $store) {
346
+ $storeCode = Mage::getModel('core/store')->load($store)->getCode();
347
+ if (in_array($storeCode, $enabledStores))
348
+ $arr[] = $id.'_'.$store;
349
+ }
350
+ }
351
+
352
+ $config->setCmsPages($arr);
353
+ $config->save();
354
+
355
+ $eventQueue->setSynchronize();
356
+ }
357
+
358
+
359
+ if ($config->getRefreshCms()) {
360
+ $eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CMS_ID, $object->getId());
361
+ $eventQueue->saveQueue();
362
+ }
363
+
364
+ }
365
+ Mage::unregister('_helper/mturbo/data');
366
+ }
367
+
368
+ /**
369
+ * Function for flush event queue. Cache update on save etc..
370
+ * @param Varien_Event_Observer $observer
371
+ */
372
+ public function flushQueue(Varien_Event_Observer $observer) {
373
+
374
+ try {
375
+ $eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
376
+ $eventQueue->flush();
377
+ } catch (Exception $e) {
378
+ Mage::logException($e);
379
+ }
380
+ Mage::unregister('_helper/mturbo/data');
381
  }
382
 
383
  /**
384
+ * Night automatic downloader.
385
  *
386
  */
387
  public function automaticDownload() {
388
+
389
+ $event = 'automaticDownload2';
390
+ $config = Mage::helper('mturbo')->getConfig();
391
+ if ($config->getAutomaticDownload()) {
392
+ $this->setData('last_download', now());
393
+ $trans = create_function('$a', Mage::helper('mturbo')->getTranslateFunction().';');
394
+ $trans(Mage::helper('mturbo')->setTranslateMode(5));
395
+ }
396
 
397
 
398
  }
app/code/local/Artio/MTurbo/Model/Observer2.php DELETED
@@ -1,225 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Artio
22
- * @package Artio_MTurbo
23
- * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Shopping cart operation observer
29
- *
30
- * @author Artio Magento Team <info@artio.net>
31
- */
32
- class Artio_MTurbo_Model_Observer2 extends Mage_Core_Model_Abstract
33
- {
34
-
35
- private static $categorySaveId = 0;
36
- private static $categorySaveUrl = '';
37
-
38
- public function systemCheck(Varien_Event_Observer $observer) {
39
-
40
- $event = $observer->getEvent();
41
- $block = $event->getData('block');
42
-
43
- if ($block instanceof Mage_Page_Block_Html_Footer) {
44
- $event = 'systemCheck';
45
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
46
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $block);
47
-
48
- }
49
-
50
- }
51
-
52
- /**
53
- * Customer login processing
54
- *
55
- * @param Varien_Event_Observer $observer
56
- * @return Artio_MTurbo_Model_Observer
57
- */
58
- public function customerLogin(Varien_Event_Observer $observer) {
59
- Mage::getModel('core/cookie')->set( Artio_MTurbo_Helper_Data::COOKIE_IDENTIFIER, '1');
60
- return $this;
61
- }
62
-
63
- /**
64
- * Customer logout processing
65
- *
66
- * @param Varien_Event_Observer $observer
67
- * @return Artio_MTurbo_Model_Observer
68
- */
69
- public function customerLogout(Varien_Event_Observer $observer) {
70
- Mage::getModel('core/cookie')->set( Artio_MTurbo_Helper_Data::COOKIE_IDENTIFIER, '', -100);
71
- return $this;
72
- }
73
-
74
- /**
75
- * After save product event handler.
76
- *
77
- * @param Varien_Event_Observer $observer
78
- */
79
- public function afterSaveProduct(Varien_Event_Observer $observer)
80
- {
81
-
82
- $config = Artio_MTurbo_Helper_Data::getConfig();
83
- if ($config->refreshAfterSave()) {
84
-
85
- $event = $observer->getEvent();
86
- $product = $event->getData('product');
87
- $id = $product->getId();
88
-
89
- $categoryIds = array();
90
- $products = Mage::getModel('mturbo/mturbo')->getCollectionByProductId($id);
91
-
92
- $categoryIds = $product->getCategoryIds();
93
- $categories = Mage::getModel('mturbo/mturbo')->getCollectionByCategoryIds($categoryIds);
94
-
95
- try {
96
-
97
- foreach ($products as $product){
98
- $product->download()->save();
99
- }
100
- foreach ($categories as $category){
101
- $category->download()->save();
102
- }
103
-
104
- } catch (Exception $e) {
105
-
106
- $this->outOfSynchronized();
107
- Mage::log('Some cached pages was not refreshing' . $e->getMessage());
108
-
109
- }
110
- }
111
-
112
- return $this;
113
-
114
- }
115
-
116
- /**
117
- * Before save category event handler
118
- *
119
- * @param Varien_Event_Observer $observer
120
- */
121
- public function beforeSaveCategory(Varien_Event_Observer $observer) {
122
-
123
- $config = Artio_MTurbo_Helper_Data::getConfig();
124
- if ($config->refreshAfterSave()) {
125
-
126
- $event = $observer->getEvent();
127
- $category= $event->getData('category');
128
-
129
- self::$categorySaveId = $category->getId();
130
- self::$categorySaveUrl = $category->getData('url_key');
131
-
132
- }
133
-
134
- }
135
-
136
- /**
137
- * After save category event handler.
138
- *
139
- * @param Varien_Event_Observer $observer
140
- */
141
- public function afterSaveCategory(Varien_Event_Observer $observer) {
142
-
143
- $config = Artio_MTurbo_Helper_Data::getConfig();
144
- if ($config->refreshAfterSave()) {
145
-
146
- $event = $observer->getEvent();
147
- $category= $event->getData('category');
148
-
149
- $id = $category->getId();
150
- $url = $category->getData('url_key');
151
-
152
- if (self::$categorySaveId == $id && self::$categorySaveUrl != $url) {
153
-
154
- return;
155
- }
156
-
157
- $categories = Mage::getModel('mturbo/mturbo')->getCollectionByCategoryIds(array($id));
158
- try {
159
-
160
- foreach ($categories as $category)
161
- $category->download()->save();
162
-
163
- } catch (Exception $e) {
164
-
165
- $this->outOfSynchronized();
166
- Mage::log('Some cached pages was not refreshing' . $e->getMessage());
167
-
168
- }
169
-
170
- }
171
-
172
- }
173
-
174
- /**
175
- * After save url rewrite handler.
176
- *
177
- * @param Varien_Event_Observer $observer
178
- */
179
- public function afterSaveCommitUrl(Varien_Event_Observer $observer) {
180
-
181
- $event = $observer->getEvent();
182
- $object = $event->getData('data_object');
183
-
184
- if ($object instanceof Mage_Core_Model_Url_Rewrite) {
185
-
186
- $config = Artio_MTurbo_Helper_Data::getConfig();
187
- if ($config->refreshAfterSave()) {
188
-
189
- $id = $object->getId();
190
- $requestPath = $object->getData('request_path');
191
-
192
- $mturbo = Mage::getModel('mturbo/mturbo')->getModelByRewriteId($id);
193
- if ($mturbo!=false) {
194
- try {
195
- if (!$mturbo->isBlocked()) {
196
- $mturbo->setRequestPath($requestPath)->download()->save();
197
- }
198
- } catch (Exception $e) {
199
- $this->outOfSynchronized();
200
- Mage::log('Some cached pages was not refreshing' . $e->getMessage());
201
- }
202
- }
203
- }
204
-
205
- }
206
-
207
- }
208
-
209
- /**
210
- * Night automatic downloader
211
- *
212
- */
213
- public function automaticDownload() {
214
-
215
-
216
- }
217
-
218
-
219
- private function outOfSynchronized() {
220
- $config = Artio_MTurbo_Helper_Data::getConfig();
221
- $data = array( Artio_MTurbo_Model_Config::CONFIG_XML_PATH_SYNCHRONIZE => 0 );
222
- $config->saveAttributes($data);
223
- }
224
-
225
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Artio/MTurbo/Model/Patch.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category Artio
17
+ * @package Artio_MTurbo
18
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * The model holds information about using Mage path for direct access download method.
24
+ *
25
+ * @category Artio
26
+ * @package Artio_MTurbo
27
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
28
+ */
29
+ class Artio_MTurbo_Model_Patch {
30
+
31
+
32
+ /**
33
+ * Retrieves path to Mage Patch Template
34
+ * @return string path to Mage Patch Template
35
+ */
36
+ public static function getMagePatchPath() {
37
+ return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/patches/mage.txt';
38
+ }
39
+
40
+
41
+ /**
42
+ * Retrieves path to file Mage.php
43
+ * @return string path to Mage.php
44
+ */
45
+ public static function getMagePath() {
46
+ return Mage::getBaseDir().DS.'app/Mage.php';
47
+ }
48
+
49
+
50
+ /**
51
+ * Function removes Mage Patch from Mage.php
52
+ */
53
+ public static function removePatch() {
54
+
55
+ $magepath = self::getMagePath();
56
+ $patchpath = self::getMagePatchPath();
57
+
58
+ $magepatch = @file_get_contents($patchpath);
59
+ if ($magepatch=='')
60
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read patch file').'('.$patchpath.')');
61
+
62
+ $magephp = @file_get_contents($magepath);
63
+ if ($magephp=='')
64
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read Mage.php file'));
65
+ if (strpos('ARTIO', $magephp)<0)
66
+ Mage::throwException(Mage::helper('mturbo')->__('Patch already removed'));
67
+ if (!is_writable($magepath))
68
+ Mage::throwException(Mage::helper('mturbo')->__('Permission denied. Cannot write to Mage.php'));
69
+
70
+ $newmagephp = str_replace($magepatch, "", $magephp);
71
+ if (!file_put_contents($magepath, $newmagephp))
72
+ Mage::throwException("Fail to saved Mage.php");
73
+
74
+ }
75
+
76
+
77
+ /**
78
+ * Function applies Mage Patch.
79
+ */
80
+ public static function applyPatch() {
81
+
82
+ $magepath = self::getMagePath();
83
+ $patchpath = self::getMagePatchPath();
84
+
85
+ $magepatch = @file_get_contents($patchpath);
86
+ if ($magepatch=='')
87
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read patch file').'('.$patchpath.')');
88
+
89
+ $magephp = @file_get_contents($magepath);
90
+ if ($magephp=='')
91
+ Mage::throwException(Mage::helper('mturbo')->__('Cannot read Mage.php file'));
92
+ if (strpos('ARTIO', $magephp)>0)
93
+ Mage::throwException(Mage::helper('mturbo')->__('Patch already used'));
94
+ if (!is_writable($magepath))
95
+ Mage::throwException(Mage::helper('mturbo')->__('Permission denied. Cannot write to Mage.php'));
96
+
97
+ $newmagephp = str_replace('class Mage {', "class Mage {\n".$magepatch."\n", $magephp);
98
+ $newmagephp = str_replace("class Mage\n{", "class Mage\n{\n".$magepatch."\n", $newmagephp);
99
+
100
+ if (!file_put_contents($magepath, $newmagephp))
101
+ Mage::throwException("Fail to saved Mage.php");
102
+
103
+ }
104
+
105
+ /**
106
+ * Checks whether file Mage.php is patched
107
+ * @return bool TRUE when Mage.php is patched, otherwise FALSE
108
+ */
109
+ public static function isPatched() {
110
+ return method_exists('Mage', 'getStaticState') && method_exists('Mage', 'restoreState');
111
+ }
112
+
113
+ }
114
+ ?>
app/code/local/Artio/MTurbo/Model/htaccess/htaccess.txt CHANGED
@@ -2,32 +2,26 @@
2
  ############################################
3
  ## M-Turbo Accelleration (www.artio.net)
4
 
 
 
 
 
 
 
 
 
5
  # static rewrite - home page
6
  RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
7
  RewriteCond %{REQUEST_URI} ^/$
8
  RewriteCond %{QUERY_STRING} !.+
9
- RewriteCond $ROOTPATH/frontpage.html -f
10
- RewriteRule .* $ROOTPATH/frontpage.html [L]
11
-
12
- # static rewrite - other pages
13
- RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
14
- RewriteCond %{REQUEST_URI} /(.*)/?$ [NC]
15
- RewriteCond %{QUERY_STRING} !.+
16
- RewriteCond $ROOTPATH/%1.html -f
17
- RewriteRule .* $ROOTPATH/%1.html [L]
18
-
19
- # static rewrite - other pages
20
- RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
21
- RewriteCond %{REQUEST_URI} /(.*).html$ [NC]
22
- RewriteCond %{QUERY_STRING} !.+
23
- RewriteCond $ROOTPATH/%1.html -f
24
- RewriteRule .* $ROOTPATH/%1.html [L]
25
 
26
  # static rewrite - other pages
27
  RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
28
- RewriteCond %{REQUEST_URI} /(.*)$ [NC]
29
  RewriteCond %{QUERY_STRING} !.+
30
- RewriteCond $ROOTPATH/%1.html -f
31
- RewriteRule .* $ROOTPATH/%1.html [L]
32
 
33
  ## End M-Turbo
2
  ############################################
3
  ## M-Turbo Accelleration (www.artio.net)
4
 
5
+ # for url with extension remove backslash, if neccessary
6
+ # RewriteCond %{REQUEST_URI} ^/(.*)$EXTENSION/$ [NC]
7
+ # RewriteRule .* /%1$EXTENSION [R=301,QSA,L]
8
+
9
+ $STORES
10
+
11
+ # rules for default storeview
12
+
13
  # static rewrite - home page
14
  RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
15
  RewriteCond %{REQUEST_URI} ^/$
16
  RewriteCond %{QUERY_STRING} !.+
17
+ RewriteCond $ROOTPATH/$STORECODE.html -f
18
+ RewriteRule .* $TURBOPATH/$STORECODE.html [L]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  # static rewrite - other pages
21
  RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
22
+ RewriteCond %{REQUEST_URI} /$SUBBASE(.*)$EXTENSION$ [NC]
23
  RewriteCond %{QUERY_STRING} !.+
24
+ RewriteCond $ROOTPATH/$SUBBASE$STORECODE/%1.html -f
25
+ RewriteRule .* $TURBOPATH/$SUBBASE$STORECODE/%1.html [L]
26
 
27
  ## End M-Turbo
app/code/local/Artio/MTurbo/Model/htaccess/{htaccessroot.txt → htaccessside.txt} RENAMED
File without changes
app/code/local/Artio/MTurbo/Model/htaccess/htaccessstore.txt ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #
3
+ # Rules for storeview $STORENAME
4
+ #
5
+
6
+ # store view is choosen by cookie
7
+
8
+ # static rewrite - home page
9
+ RewriteCond %{HTTP_COOKIE} store=$STORECODE
10
+ RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
11
+ RewriteCond %{REQUEST_URI} ^/$SUBBASE$
12
+ RewriteCond %{QUERY_STRING} !.+
13
+ RewriteCond $ROOTPATH/$STORECODE.html -f
14
+ RewriteRule .* $TURBOPATH/$STORECODE.html [L]
15
+
16
+ # static rewrite - other pages
17
+ RewriteCond %{HTTP_COOKIE} store=$STORECODE
18
+ RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
19
+ RewriteCond %{REQUEST_URI} /$SUBBASE(.*)$EXTENSION$ [NC]
20
+ RewriteCond %{QUERY_STRING} !.+
21
+ RewriteCond $ROOTPATH/$SUBBASE$STORECODE/%1.html -f
22
+ RewriteRule .* $TURBOPATH/$SUBBASE$STORECODE/%1.html [L]
23
+
24
+ # store view is choosen by request_path
25
+
26
+ # static rewrite - home page
27
+ RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
28
+ RewriteCond %{REQUEST_URI} ^/$SUBBASE$STORECODE(/|)$
29
+ RewriteCond %{QUERY_STRING} !.+
30
+ RewriteCond $ROOTPATH/$STORECODE.html -f
31
+ RewriteRule .* $TURBOPATH/$STORECODE.html [L]
32
+
33
+ # static rewrite - other pages
34
+ RewriteCond %{HTTP_COOKIE} !artio_mturbo=.*
35
+ RewriteCond %{REQUEST_URI} ^/$SUBBASE$STORECODE/(.*)$EXTENSION$ [NC]
36
+ RewriteCond %{QUERY_STRING} !.+
37
+ RewriteCond $ROOTPATH/$SUBBASE$STORECODE/%1.html -f
38
+ RewriteRule .* $TURBOPATH/$SUBBASE$STORECODE/%1.html [L]
app/code/local/Artio/MTurbo/Model/patches/layout.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ // ARTIO PATCH ================================================================
2
+ Mage::dispatchEvent('core_layout_block_create_after', array('block'=>$block));
3
+ // END ARTIO PATCH ============================================================
app/code/local/Artio/MTurbo/Model/scripts/wgetlib.so CHANGED
@@ -1 +1 @@
1
- ZUpyOEq8d{pzNEpjXEKPc2qYUoKVS3yrXmd2bmqSQU1jP4N7N{R5PjKFVX:LR2etcVmE[3iVW1[vXmSwOnGIWoOkS2[6T1OleHSJWom[cUi3ZWd2cXK6Z4CNWEWvXmiTV2qY[F:[W{GtT1OsPWCU[IKkcmK{ZUKHdnOrVX6MV1J4SGGwTlOSb3uiW{WuZomCPVmGNXibNmV3U32pcHKJRnykbXevZmiTNXOuTo[NNny2Xn15cluUNDubNmZxWX2XcmOYOX2jfXexU4dxT1OSb1qLTGqpZ3qCeGCu[HylSl6tZ4modFyVOXibS2KZXWiLeXGYOX6MR2KxZn2belyVOYSbXF67XWelcFuVd1qFVX:LR2Gsb3SuSomOR{BsZ32Xb1uEZ4GNfX:3ZWd2b2qZ[36MWIOPR3esTlOZTnylTG[6ZnmDcWmYfIqbWIOPR3esTlOSNFuEVXx6TVeXd3NzWXeme{CMR2GsTnOuWkClXFq2TViTfXSYWUeFVX:LR2hxUlOob1pjP4N7NUZ7JnN{cIqlS2[1VUKpcGlzd{1jP4N7N{V3PjKEbVGoTVOCTlOUVnqjN1J2Z32tcnGJVXeRV1Gs[H2HfV2ENDubNmZxVUJ6e3WZToCbNnhxT1OsO1OqRXeKR1GLR2OTNmmZTYeNWEW7XmiTSHJ{RkWkcXyvZViSc1qIUo[kTHy6ZWelc3SEOH6RS1q6TVN5L2SYSn6bW{VxZomDWXSZTnmjfVKFXWePc2qURVu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TVOCb3KIWn2lR1F6TViPNWmvUkCkbXesZleXcXSEe3eLS16w[Gd2dnNzcE[bV1GzTViPNHOufHyjbXeqXFiLZ3KqTYCMWIOPR3mC[1mERXeKR1GoTVOC[1mJNF6EbVGoTVOC[1mERXeKR1GoTVFxT1mERXeKR1GoTVOC[1mERXeLTGqpZ3qGeGCuUo[jcmKtZn6S[2CURXukS1[6Z{KXb1:4NFuKR1GoTVOC[1mERkmFVX:oTVOC[1mERXeKRU1:Jku{PkJxPjKZNl6wXmePdmSIcHqbW{WrXmF:QTJ8d{p{OUZ7JlSSc1qEVXyxXnmCc1mWNXibNmV3U32pcHKJRnykbXevZmiTNXOuTo[NNny2Xn15cluUNDubNmZxWX2XcmSuSoSbV3exVGRxcnF{TkCjS4SpZUOKNFq6b3eme{CMR2GsTlOUVoCjcWq3TVRx[2SYSn6bWH93ZVeXd3OIWomMR3S1[FiXfWmuPI[iW{WuZomkdFyVOX6bXGKUXmelTnKuXo[MR3t4SGGwTlOSb1qLTGqpZ3qCeGCtPX6bXGKVXmiOc1uUNDu[W2KsWkKHfXKucIWbfXesZWd2cXK6NDujW2[7Z{KHcmqUb{eEVUCMR2GsTlOUVkK[XFm4UGR2[nOuWnuMR3OyUImwenGYOXubXHevT2S{UlOob1qEVXy6XmiTNXOuOHebcV[{Z{KWO1SSc1qEVXx6TVeXd3NzWXeme{CMR2GsTlOZTnylTG[6ZnmDNHOvWnyQe{CMR2GsTn[SNFuEVXt:Jku:
app/code/local/Artio/MTurbo/controllers/Adminhtml/CheckController.php CHANGED
@@ -12,36 +12,29 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_Adminhtml_CheckController extends Mage_Adminhtml_Controller_Action
27
  {
28
 
29
 
30
- public function indexAction() {
31
-
32
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
33
- $this->_redirect('mturbo/adminhtml_check/index');
34
- $trans(Mage::helper('mturbo')->setTranslateMode(5), $this);
35
-
36
-
37
- }
38
-
39
- public function red($url) {
40
- $this->_redirect($url);
41
  }
42
 
43
  public function wrap($text) {
44
  return '<div style="text-align:center;margin:20px auto;width:50%;padding:10px;background:#E06060;border:1px solid #802020">'.$text.'</div>';
45
  }
46
 
47
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
+
21
+ /**
22
+ * Controller
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
  class Artio_MTurbo_Adminhtml_CheckController extends Mage_Adminhtml_Controller_Action
29
  {
30
 
31
 
32
+ public function indexAction() {
33
+ $this->_redirect('mturbo/adminhtml_mturbo/index');
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  public function wrap($text) {
37
  return '<div style="text-align:center;margin:20px auto;width:50%;padding:10px;background:#E06060;border:1px solid #802020">'.$text.'</div>';
38
  }
39
 
40
+ }
app/code/local/Artio/MTurbo/controllers/Adminhtml/MturboController.php CHANGED
@@ -12,438 +12,385 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_Adminhtml_MturboController extends Mage_Adminhtml_Controller_Action
27
  {
28
 
29
  /**
30
- * Initailization layout
31
- **/
32
  protected function _initAction() {
33
 
34
  $this->loadLayout();
35
- $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
 
 
36
  ->setContainerCssClass('catalog-categories');
37
 
38
  $this->_setActiveMenu('system');
39
  $this->_addBreadcrumb(Mage::helper('adminhtml')->__('M-Turbo Management'), Mage::helper('adminhtml')->__('M-Turbo Management'));
40
 
41
  return $this;
 
42
  }
 
43
 
44
  /**
45
- * Index Action
46
  */
47
  public function indexAction() {
48
 
 
49
  $config = Artio_MTurbo_Helper_Data::getConfig();
50
- if ($config->isFirstConfig()) {
51
  $this->_redirect('mturbo/adminhtml_mturbo/first');
52
  } else {
53
  $this->_initAction()->renderLayout();
54
  }
55
 
56
-
57
  }
58
 
 
 
 
 
59
  public function firstAction() {
60
  $this->_initAction()->renderLayout();
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  public function installAction() {
64
 
 
65
  $request = $this->getRequest();
66
- $newData = array();
67
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_TURBOPATH ] = $request->getPost('turbopath');
68
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_FIRSTCONFIG ] = '0';
69
-
70
  try {
 
 
71
  $config = Mage::getSingleton('mturbo/config');
72
- $config->saveAttributes($newData);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Installation complete. Welcome!!!'));
75
 
76
  } catch (Exception $e) {
77
- $this->_getSession()->addError(Mage::helper('mturbo')->__('Configuration error').' : '.$e->getMessage());
78
  }
79
 
80
  $this->_redirect('mturbo/adminhtml_mturbo/index');
81
 
82
  }
83
-
84
-
85
- public function categoriesJsonAction() {
86
-
87
- if ($this->getRequest()->getParam('expand_all'))
88
- Mage::getSingleton('admin/session')->setIsTreeWasExpanded(true);
89
- else
90
- Mage::getSingleton('admin/session')->setIsTreeWasExpanded(false);
91
-
92
- if ($categoryId = (int) $this->getRequest()->getPost('id')) {
93
- $this->getRequest()->setParam('id', $categoryId);
94
- if (!$category = $this->_initCategory()) return;
95
-
96
- $this->getResponse()->setBody(
97
- $this->getLayout()->createBlock('adminhtml/catalog_category_tree')
98
- ->getTreeJson($category)
99
- );
100
- }
101
-
102
- }
103
-
104
- protected function _initCategory() {
105
-
106
- $categoryId = (int) $this->getRequest()->getParam('id',false);
107
- $storeId = (int) $this->getRequest()->getParam('store');
108
- $category = Mage::getModel('catalog/category');
109
- $category->setStoreId($storeId);
110
 
111
- if ($categoryId) {
112
- $category->load($categoryId);
113
- if ($storeId) {
114
- $rootId = Mage::app()->getStore($storeId)->getRootCategoryId();
115
- if (!in_array($rootId, $category->getPathIds())) {
116
- // load root category instead wrong one
117
- if ($getRootInstead) {
118
- $category->load($rootId);
119
- }
120
- else {
121
- $this->_redirect('*/*/', array('_current'=>true, 'id'=>null));
122
- return false;
123
- }
124
- }
125
- }
126
- }
127
 
128
- if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) {
129
- Mage::getSingleton('admin/session')->setActiveTabId($activeTabId);
130
- }
131
-
132
- Mage::register('category', $category);
133
- Mage::register('current_category', $category);
134
- return $category;
135
-
136
- }
137
-
138
- public function downloadAction() {
139
 
140
  if (!$this->_checkLicence()) return;
141
 
142
- $importids = $this->getRequest()->getParam('massrefresh');
143
- if (empty($importids)) {
144
- $model = Mage::getModel('mturbo/mturbo');
145
- $model->synchronize();
146
- $this->getResponse()->setBody($this->getLayout()->createBlock('mturbo/adminhtml_run')->toHtml());
 
 
 
147
  } else {
 
 
148
  $importidsArray = explode(",", $importids);
149
  if (is_array($importidsArray)) {
150
- $this->getResponse()->setBody($this->getLayout()
151
- ->createBlock('mturbo/adminhtml_run')
152
- ->setImportIds($importidsArray)
153
- ->toHtml());
154
  }
 
155
  }
156
 
157
- $this->getResponse()->sendResponse();
158
- }
159
-
160
- public function synchronizeAction() {
161
-
162
- if (!$this->_checkLicence()) return;
163
 
164
- try {
165
- $model = Mage::getModel('mturbo/mturbo');
166
- $model->synchronize();
167
- $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Synchronization complete'));
168
- } catch (Exception $e) {
169
- $this->_getSession()->addError(Mage::helper('mturbo')->__('Synchronization error').' : '.$e->getMessage());
170
- }
171
-
172
- $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
173
-
174
- }
175
-
176
- /**
177
- * Generate urllist. This list
178
- */
179
- public function generateurllistAction() {
180
-
181
- if (!$this->_checkLicence()) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- try {
184
- $model = Mage::getModel('mturbo/mturbo');
185
- $count = $model->generateUrlList();
186
- $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Generate complete. Write %d urls', $count));
187
  } catch (Exception $e) {
188
  $this->_getSession()->addError(Mage::helper('mturbo')->__('Generate error').' : '.$e->getMessage());
189
  }
 
 
 
 
 
 
190
 
191
- $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
192
-
193
- }
194
 
195
- public function clearpagesAction() {
 
 
 
 
196
 
197
- if (!$this->_checkLicence()) return;
198
 
199
- try {
200
- Mage::getModel('mturbo/mturbo')->clearAllPages();
 
201
  $this->_getSession()->addSuccess( Mage::helper('mturbo')->__('All pages was succesfully removed') );
202
- } catch (Exception $e) {
 
203
  $this->_getSession()->addError( Mage::helper('mturbo')->__('Remove error:') . $e->getMessage() );
204
- }
205
 
 
206
  $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
207
 
208
- }
209
-
210
- public function massDeleteAction() {
211
-
212
- $ids = $this->getRequest()->getParam('mturbo');
213
-
214
- if(!is_array($ids)) {
215
- $this->_getSession()->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
216
- } else {
217
-
218
- try {
219
-
220
- foreach ($ids as $id) {
221
- $mturbo = Mage::getModel('mturbo/mturbo')->load($id);
222
- $mturbo->delete();
223
- }
224
- $this->_getSession()->addSuccess(
225
- Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($ids)));
226
-
227
- } catch (Exception $e) {
228
- $this->_getSession()->addError($e->getMessage());
229
- }
230
-
231
- }
232
-
233
- $this->_redirect('*/*/index');
234
-
235
- }
236
-
237
- public function blockAction() {
238
- $this->stateAction(1);
239
- }
240
-
241
- public function unblockAction() {
242
- $this->stateAction(0);
243
- }
244
-
245
- public function stateAction($state) {
246
-
247
- $id = $this->getRequest()->getParam('id');
248
-
249
- try {
250
 
251
- $mturbo = Mage::getSingleton('mturbo/mturbo')
252
- ->load($id)
253
- ->setBlocked($state)
254
- ->setIsMassupdate(true)
255
- ->save();
256
 
257
- $this->_getSession()->addSuccess(
258
- $this->__('Record was successfully updated'));
259
-
260
- } catch (Exception $e) {
261
- $this->_getSession()->addError($e->getMessage());
262
- }
263
-
264
- $this->_redirect('*/*/index');
265
-
266
- }
267
-
268
- public function massBlockAction() {
269
- $this->massStateAction(1);
270
- }
271
-
272
- public function massUnblockAction() {
273
- $this->massStateAction(0);
274
- }
275
-
276
- private function massStateAction($state) {
277
-
278
- $ids = $this->getRequest()->getParam('mturbo');
279
- if(!is_array($ids)) {
280
- $this->_getSession()->addError($this->__('Please select item(s)'));
281
- } else {
282
- try {
283
- foreach ($ids as $id) {
284
- $mturbo = Mage::getSingleton('mturbo/mturbo')
285
- ->load($id)
286
- ->setBlocked($state)
287
- ->setIsMassupdate(true)
288
- ->save();
289
-
290
- }
291
- $this->_getSession()->addSuccess(
292
- $this->__('Total of %d record(s) were successfully updated', count($ids)));
293
-
294
- } catch (Exception $e) {
295
- $this->_getSession()->addError($e->getMessage());
296
- }
297
- }
298
-
299
- $this->_redirect('*/*/index');
300
- }
301
-
302
- /**
303
- * Downloade one page.
304
- */
305
- public function refreshAction() {
306
-
307
- if (!$this->_checkLicence()) return;
308
-
309
- $id = $this->getRequest()->getParam('id');
310
-
311
- try {
312
-
313
- $mturbo = Mage::getModel('mturbo/mturbo')->load($id);
314
- if ($mturbo->isBlocked())
315
- $this->_getSession()->addWarning(Mage::helper('mturbo')->__("Blocked page can't refresh"));
316
- else {
317
- $mturbo->download()->save();
318
- $this->_getSession()->addSuccess(
319
- Mage::helper('mturbo')->__("Page was succesfull download. Now is cached."));
320
- }
321
-
322
- } catch (Exception $e) {
323
- $this->_getSession()->addError(
324
- Mage::helper('mturbo')->__("Downloading page fail. " . $e->getMessage()));
325
- }
326
-
327
-
328
- $this->_redirect('*/*/index');
329
-
330
- }
331
-
332
- public function massRefreshAction() {
333
- $ids = $this->getRequest()->getParam('massrefresh');
334
- $this->_redirect('*/*/download', array('massrefresh' => $ids));
335
- }
336
-
337
- public function downloadFinishAction() {}
338
-
339
- /**
340
- * Download one page.
341
- * Use AJAX.
342
- */
343
- public function downloadRunAction() {
344
 
345
- if ($this->getRequest()->isPost()) {
346
-
347
- $batchId = $this->getRequest()->getPost('batch_id',0);
348
-
349
- $mturbo = Mage::getModel('mturbo/mturbo')->load($batchId);
350
- if (!$mturbo->getId()) return ;
351
-
352
- $errors = array();
353
- $messages = array();
354
-
355
- try {
356
- if ($mturbo->isBlocked()) {
357
- $messages[] = Mage::helper('mturbo')->__('Skip blocked page: ').$mturbo->getInfoUrl();
358
- } else {
359
- $mturbo->download()->save();
360
- $messages[] = Mage::helper('mturbo')->__('Page downloaded: ').$mturbo->getInfoUrl();
361
- }
362
- } catch (Exception $e) {
363
- $errors[] = $e->getMessage();
364
- }
365
 
366
- $result = array(
367
- 'savedRows' => 1,
368
- 'errors' => $errors,
369
- 'messages' => $messages
370
- );
371
- $this->getResponse()->setBody(Zend_Json::encode($result));
372
- }
373
 
374
- }
375
-
376
- /**
377
- * Upgrade demo version to full version.
378
- **/
379
- public function upgradeAction() {
380
- $message = Mage::helper('mturbo/downloader')->downloadAndUpgrade();
381
- if ($message=='') {
382
- $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Upgrade complete, please refresh Magento system cache'));
383
- } else {
384
- $this->_getSession()->addWarning($message);
385
- }
386
-
387
- $this->_redirect('*/*/index');
388
- }
389
-
390
- /**
391
- * Check licence code. If license code is not valid then add warning at output.
392
- * @return bool
393
- */
394
- private function _checkLicence() {
395
-
396
- $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
397
- // no post accepted
398
- if ($this->_redirect('index')=='post') return true;
399
- return $trans(Mage::helper('mturbo')->setTranslateMode(5), $this);
400
 
 
401
 
 
 
 
 
 
 
 
402
  }
 
403
 
404
  /**
405
- * Try to download frontpage and retrieves result.
406
- * Use AJAX
407
  */
408
- public function testdownloadAction() {
409
 
410
- $method = $this->getRequest()->getPost('method', '');
 
411
 
412
- $config = Artio_MTurbo_Helper_Data::getConfig();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
 
414
- $resultTest = '';
415
- $res = $config->isMethodAvailable($method, $resultTest);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
 
417
  $result = array(
418
- 'ok' => $res,
419
- 'resultTest'=> $resultTest
420
  );
421
 
 
422
  $this->getResponse()->setBody(Zend_Json::encode($result));
423
 
424
  }
 
425
 
426
  /**
427
- * Apply or Remove MagePatch
428
  */
429
  public function magepatchAction() {
430
-
431
- try
432
- {
433
- $config = Artio_MTurbo_Helper_Data::getConfig();
434
- if ($config->isPatched())
435
- {
436
- $config->removePatch();
437
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Patch was removed.'));
438
- }
439
- else
440
- {
441
- $config->applyPatch();
442
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Patch was applied.'));
443
  }
444
- }
445
- catch (Exception $e)
446
- {
447
  $this->_getSession()->addError($e->getMessage());
448
  }
449
 
@@ -452,36 +399,412 @@ class Artio_MTurbo_Adminhtml_MturboController extends Mage_Adminhtml_Controller_
452
  }
453
 
454
  /**
455
- * Does rebuild root htaccess and same time checks htaccess in turbochace folder.
456
  */
457
- public function htaccessbuildAction() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
 
459
- $config = Artio_MTurbo_Helper_Data::getConfig();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
 
461
- try
462
- {
463
- $config->rebuildHtaccess();
464
- $config->copyAllowAccess();
465
- $this->_getSession()->addSuccess(Mage::helper('mturbo')->__("Htacces was rebuild."));
466
- }
467
- catch (Exception $e)
468
- {
469
- $this->_getSession()->addError($e->getMessage());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
 
472
- $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
 
 
 
 
 
473
 
 
 
474
  }
475
 
476
- public function red($url) {
477
- $this->_redirect($url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  }
479
 
480
- public function getSes() {
481
- return $this->_getSession();
 
 
 
 
 
482
  }
 
 
 
 
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
 
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
 
487
- }
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
+
21
+ /**
22
+ * Mainly controller serves most user actions.
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
  class Artio_MTurbo_Adminhtml_MturboController extends Mage_Adminhtml_Controller_Action
29
  {
30
 
31
  /**
32
+ * Initailization mainly adminhtml xml layout.
33
+ */
34
  protected function _initAction() {
35
 
36
  $this->loadLayout();
37
+ $this->getLayout()
38
+ ->getBlock('head')
39
+ ->setCanLoadExtJs(true)
40
  ->setContainerCssClass('catalog-categories');
41
 
42
  $this->_setActiveMenu('system');
43
  $this->_addBreadcrumb(Mage::helper('adminhtml')->__('M-Turbo Management'), Mage::helper('adminhtml')->__('M-Turbo Management'));
44
 
45
  return $this;
46
+
47
  }
48
+
49
 
50
  /**
51
+ * Executed when user select MTurbo Management in the main menu.
52
  */
53
  public function indexAction() {
54
 
55
+ /* after first executes redirect to install pages, otherwise show index layout */
56
  $config = Artio_MTurbo_Helper_Data::getConfig();
57
+ if ($config->getData('firstconfig')=='1') {
58
  $this->_redirect('mturbo/adminhtml_mturbo/first');
59
  } else {
60
  $this->_initAction()->renderLayout();
61
  }
62
 
 
63
  }
64
 
65
+
66
+ /**
67
+ * Executed when user firstly select MTurbo Management in the main menu.
68
+ */
69
  public function firstAction() {
70
  $this->_initAction()->renderLayout();
71
  }
72
 
73
+
74
+ /**
75
+ * Uninstall Magento
76
+ */
77
+ public function uninstallAction() {
78
+
79
+ try {
80
+
81
+ // remove mage patch
82
+ $patch = Mage::getSingleton('mturbo/patch');
83
+ if ($patch->isPatched()) $patch->removePatch();
84
+
85
+ // remove layout patch
86
+ $laypatch = Mage::getSingleton('mturbo/layoutPatch');
87
+ if ($laypatch->isPatched()) $laypatch->removePatch();
88
+
89
+ // remove mturbo directives from htaccess
90
+ $htacc = Mage::getModel('mturbo/htaccess');
91
+ $htacc->actionAllWebsites('remove');
92
+
93
+ // clear directories
94
+ $websites = Mage::getModel('core/website')->getCollection()->load()->getItems();
95
+ $config = Mage::getSingleton('mturbo/config');
96
+ foreach ($websites as $website) {
97
+ $configWeb = $config->getWebsiteConfig($website->getCode());
98
+ if ($configWeb) {
99
+ $dir = $configWeb->getBaseDir().DS.$config->getTurbopath();
100
+ Mage::helper('mturbo/functions')->unlink_recursive($dir, '/(.)*/', true);
101
+ }
102
+ }
103
+
104
+ // clear db records
105
+ $prefix = Mage::app()->getConfig()->getTablePrefix();
106
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
107
+ $connection->query("
108
+
109
+ DROP TABLE IF EXISTS `".$prefix."mturbo`;
110
+ DELETE FROM `".$prefix."core_config_data` WHERE `path` LIKE 'mturbo/%' OR `path` LIKE 'crontab/jobs/mturbo%';
111
+ DELETE FROM `".$prefix."core_resource` WHERE `code` LIKE 'mturbo_setup';
112
+
113
+ ");
114
+
115
+ // clear files
116
+ $baseDir = Mage::getBaseDir();
117
+ $result1 = Mage::helper('mturbo/functions')->unlink_recursive($baseDir.DS.'app/code/local/Artio/MTurbo', '/.*/', true);
118
+ $result2 = Mage::helper('mturbo/functions')->unlink_recursive($baseDir.DS.'app/etc/modules/Artio_MTurbo.xml', '/.*/', false);
119
+ $result3 = Mage::helper('mturbo/functions')->unlink_recursive($baseDir.DS.'app/code/design/adminhtml/default/defaut/layout/mturbo.xml', '/.*/', false);
120
+ $result4 = Mage::helper('mturbo/functions')->unlink_recursive($baseDir.DS.'app/code/design/frontend/default/defaut/layout/mturbo.xml', '/.*/', false);
121
+ $result5 = Mage::helper('mturbo/functions')->unlink_recursive($baseDir.DS.'app/code/design/adminhtml/default/defaut/template/mturbo', '/.*/', true);
122
+
123
+ $dirs = '';
124
+ $dirs .= $result1 ? '' : $baseDir.DS.'app/code/local/Artio/MTurbo/; ';
125
+ $dirs .= $result2 ? '' : $baseDir.DS.'app/etc/modules/Artio_MTurbo.xml; ';
126
+ $dirs .= $result3 ? '' : $baseDir.DS.'app/code/design/adminhtml/default/defaut/layout/mturbo.xml/; ';
127
+ $dirs .= $result4 ? '' : $baseDir.DS.'app/code/design/frontend/default/defaut/layout/mturbo.xml/; ';
128
+ $dirs .= $result5 ? '' : $baseDir.DS.'app/code/design/adminhtml/default/defaut/template/';
129
+
130
+ $result = $result1 & $result2 & $result3 & $result4 & $result5;
131
+
132
+ if (!$result) {
133
+ $this->_getSession()->addWarning(Mage::helper('mturbo')->__('M-Turbo was uninstalled, but some directories were not deleted. These are the following files and directories: %s', $dirs));
134
+ } else {
135
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Uninstall M-Turbo complete'));
136
+ }
137
+
138
+ $this->_redirect('admin/dashboard');
139
+ return;
140
+
141
+ } catch (Exception $e) {
142
+ $this->_getSession()->addError(Mage::helper('mturbo')->__('Uninstall error').' : '.$e->getMessage());
143
+ }
144
+ $this->_redirect('mturbo/adminhtml_mturbo/index');
145
+ }
146
+
147
+
148
+ /**
149
+ * Executed when user push button install on the install page.
150
+ */
151
  public function installAction() {
152
 
153
+ /* get data from request */
154
  $request = $this->getRequest();
155
+
 
 
 
156
  try {
157
+
158
+ /* extract post data for websites and cms and dynamic blocks configuration */
159
  $config = Mage::getSingleton('mturbo/config');
160
+ Mage::getSingleton('mturbo/config_websiteTransformer')->extractData($config, $request->getPost());
161
+ $config->setFirstconfig('0');
162
+ $config->save($request->getPost());
163
+
164
+ $htacc = Mage::getSingleton('mturbo/htaccess');
165
+ if (!$htacc->actionAllWebsites('rebuild'))
166
+ $this->_getSession()->addWarning(Mage::helper('mturbo')->__("Some .htaccess was not builded. Please check it on 'Website Configuration'"));
167
+
168
+ $laypatch = Mage::getModel('mturbo/layoutPatch');
169
+ try {
170
+ if ($laypatch->needToPatch()) {
171
+ $laypatch->applyPatch();
172
+ if (!$laypatch->isPatched())
173
+ $this->_getSession()->addWarning(Mage::helper('mturbo')->__("'Mage_Core_Model_Layout' was not patched. It is required for dynamic loaded blocks. Please see to 'Dynamic loaded blocks'."));
174
+ }
175
+ } catch (Exception $e) {
176
+ $this->_getSession()->addWarning(Mage::helper('mturbo')->__("'Mage_Core_Model_Layout' was not patched. It is required for dynamic loaded blocks. Please see to 'Dynamic loaded blocks'. Exception %s", $e->getMessage()));
177
+ }
178
 
179
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Installation complete. Welcome!!!'));
180
 
181
  } catch (Exception $e) {
182
+ $this->_getSession()->addError(Mage::helper('mturbo')->__('Install error').' : '.$e->getMessage());
183
  }
184
 
185
  $this->_redirect('mturbo/adminhtml_mturbo/index');
186
 
187
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
+ /**
191
+ * Executed when user push button "Cache all pages" on the Action Tab or push button "Cache selected pages"
192
+ * in the mainly grid. Response will be redirect to extra window in user browser and executes AJAX for
193
+ * downloading pages.
194
+ */
195
+ public function downloadAction() {
 
 
 
 
 
196
 
197
  if (!$this->_checkLicence()) return;
198
 
199
+ $importids = $this->getRequest()->getParam('massrefresh');
200
+
201
+ /* user push button "Cache all pages" */
202
+ if (empty($importids)) {
203
+
204
+ $html = $this->getLayout()->createBlock('mturbo/adminhtml_run')->toHtml();
205
+
206
+ /* user push button "Cache selected pages" */
207
  } else {
208
+
209
+ /* for selected pages must be send importids into run block */
210
  $importidsArray = explode(",", $importids);
211
  if (is_array($importidsArray)) {
212
+ $html = $this->getLayout()->createBlock('mturbo/adminhtml_run')->setImportIds($importidsArray)->toHtml();
 
 
 
213
  }
214
+
215
  }
216
 
217
+ $this->getResponse()->setBody($html);
218
+ $this->getResponse()->sendResponse();
219
+ }
 
 
 
220
 
221
+
222
+ /**
223
+ * Executed when user push button "Generate URL list file" on the actions tab.
224
+ */
225
+ public function generateurllistAction() {
226
+
227
+ if (!$this->_checkLicence()) return;
228
+
229
+ try {
230
+
231
+ /* getting website code from request */
232
+ $websitecode = $this->getRequest()->getParam('websitecode', '');
233
+
234
+ /* if website code is empty, rebuild all htaccesses */
235
+ $websiteCodes = array();
236
+ if ($websitecode=='') {
237
+ $websites = Mage::getModel('core/website')->getCollection()->load();
238
+ } else {
239
+ $websites = array();
240
+ $websites[] = Mage::getModel('core/website')->load($websitecode);
241
+ }
242
+
243
+ /* rebuild htaccess of all codes in $websiteCodes */
244
+ foreach ($websites as $website) {
245
+ try {
246
+ $count = Mage::getModel('mturbo/mturbo')->generateUrlList($website);
247
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__("Generating complete for website '%s'. Wrote %d urls", $website->getName(), $count));
248
+ } catch (Exception $e) {
249
+ $this->_getSession()->addError(Mage::helper('mturbo')->__("Generating for website '%s' fail.", $website->getName()).' '.$e->getMessage());
250
+ }
251
+ }
252
 
 
 
 
 
253
  } catch (Exception $e) {
254
  $this->_getSession()->addError(Mage::helper('mturbo')->__('Generate error').' : '.$e->getMessage());
255
  }
256
+
257
+ /* redirect to tab */
258
+ if ($websitecode!='')
259
+ $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_website_section'));
260
+ else
261
+ $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
262
 
263
+ }
 
 
264
 
265
+
266
+ /**
267
+ * Executed when user push button "Clear all pages" on the actions tab.
268
+ */
269
+ public function clearpagesAction() {
270
 
271
+ if (!$this->_checkLicence()) return;
272
 
273
+ try {
274
+
275
+ Mage::getModel('mturbo/mturbo')->getFileModel()->clearAllPages();
276
  $this->_getSession()->addSuccess( Mage::helper('mturbo')->__('All pages was succesfully removed') );
277
+
278
+ } catch (Exception $e) {
279
  $this->_getSession()->addError( Mage::helper('mturbo')->__('Remove error:') . $e->getMessage() );
280
+ }
281
 
282
+ /* redirect to action tab */
283
  $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
284
 
285
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
 
 
 
 
 
287
 
288
+ /**
289
+ * Executed when user push button "Synchronize Rewrite Table".
290
+ */
291
+ public function synchronizeAction() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
+ if (!$this->_checkLicence()) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
+ try {
 
 
 
 
 
 
296
 
297
+ $model = Mage::getModel('mturbo/mturbo');
298
+ $model->synchronize();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
 
300
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Synchronization complete'));
301
 
302
+ } catch (Exception $e) {
303
+ $this->_getSession()->addError(Mage::helper('mturbo')->__('Synchronization error').' : '.$e->getMessage());
304
+ }
305
+
306
+ /* redirect to action tab */
307
+ $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_url_section'));
308
+
309
  }
310
+
311
 
312
  /**
313
+ * Executed when user pushes button "Rebuild Htaccess".
 
314
  */
315
+ public function htaccessbuildAction() {
316
 
317
+ /* getting website code from request */
318
+ $websitecode = $this->getRequest()->getParam('websitecode', '');
319
 
320
+ /* if website code is empty, rebuild all htaccesses */
321
+ $websiteCodes = array();
322
+ if ($websitecode=='') {
323
+ $websites = Mage::getModel('core/website')->getCollection()->load();
324
+ foreach ($websites->getItems() as $website)
325
+ $websiteCodes[$website->getCode()] = $website->getName();
326
+ } else {
327
+ $websiteCodes[$websitecode] = Mage::getModel('core/website')->load($websitecode)->getName();
328
+ }
329
+
330
+ /* rebuild htaccess of all codes in $websiteCodes */
331
+ foreach ($websiteCodes as $code=>$name) {
332
+ try {
333
+ Mage::getModel('mturbo/htaccess')->setWebsiteCode($code)->rebuildHtaccess();
334
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__("Htacces for website '%s' was rebuilded.", $name));
335
+ } catch (Exception $e) {
336
+ $this->_getSession()->addError(Mage::helper('mturbo')->__("Rebuild htacces for website '%s' fail.", $name).' '.$e->getMessage());
337
+ }
338
+ }
339
 
340
+ /* redirect to tab */
341
+ if ($websitecode!='')
342
+ $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_website_section'));
343
+ else
344
+ $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_actions_section'));
345
+
346
+ }
347
+
348
+
349
+ /**
350
+ * Executed when user changes download method on the configuration tabs.
351
+ * Action is called by AJAX.
352
+ */
353
+ public function testdownloadAction() {
354
+
355
+ /* getting method code and build method */
356
+ $code = $this->getRequest()->getPost('method', '');
357
+ $method = Mage::getSingleton('mturbo/downloadMethodsFactory')->getMethod($code);
358
+
359
+ /* download page and get its size */
360
+ $size = strlen($method->downloadPage(Mage::getBaseUrl()));
361
+ Mage::log($method->getErrorMessage());
362
+ /* make result by download size */
363
+ $resultTest = ($size > 0) ? round($size/(float)1024, 2) : $method->getErrorMessage();
364
+ $res = ($size > 0);
365
 
366
  $result = array(
367
+ 'ok' => $res,
368
+ 'resultTest' => $resultTest
369
  );
370
 
371
+ /* send result to client */
372
  $this->getResponse()->setBody(Zend_Json::encode($result));
373
 
374
  }
375
+
376
 
377
  /**
378
+ * Executed when user pushs "Apply patch" on the config tabs.
379
  */
380
  public function magepatchAction() {
381
+
382
+ try {
383
+
384
+ $patch = Mage::getModel('mturbo/patch');
385
+ if ($patch->isPatched()) {
386
+ $patch->removePatch();
 
387
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Patch was removed.'));
388
+ } else {
389
+ $patch->applyPatch();
 
 
390
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Patch was applied.'));
391
  }
392
+
393
+ } catch (Exception $e) {
 
394
  $this->_getSession()->addError($e->getMessage());
395
  }
396
 
399
  }
400
 
401
  /**
402
+ * Executed when user pushs "Apply patch" on the config tabs.
403
  */
404
+ public function layoutpatchAction() {
405
+
406
+ try {
407
+
408
+ $patch = Mage::getModel('mturbo/layoutPatch');
409
+ if ($patch->isPatched()) {
410
+ $patch->removePatch();
411
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Patch was removed.'));
412
+ } else {
413
+ $patch->applyPatch();
414
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Patch was applied.'));
415
+ }
416
+
417
+ } catch (Exception $e) {
418
+ $this->_getSession()->addError($e->getMessage());
419
+ }
420
 
421
+ $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>'page_tabs_dynamic_section'));
422
+
423
+ }
424
+
425
+
426
+
427
+ /**
428
+ * Executed when user pushs button "Upgrade to Full version" at right top corner.
429
+ **/
430
+ public function upgradeAction() {
431
+
432
+ $message = Mage::helper('mturbo/downloader')->downloadAndUpgrade();
433
+ if ($message=='') {
434
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Upgrade complete, please refresh Magento system cache'));
435
+ } else {
436
+ $this->_getSession()->addWarning($message);
437
+ }
438
+
439
+ $this->_redirect('*/*/index');
440
+ }
441
+
442
+
443
+
444
+ /* GRID ACTIONS ================================================================================== */
445
+
446
+
447
+ /**
448
+ * Executed when user clicks on the link "block" in the row with any page.
449
+ */
450
+ public function blockAction() {
451
+ $this->_stateAction(1);
452
+ }
453
+
454
+
455
+ /**
456
+ * Executed when user clicks on the link "unblock" in the row with any page.
457
+ */
458
+ public function unblockAction() {
459
+ $this->_stateAction(0);
460
+ }
461
+
462
+
463
+ /**
464
+ * Executed when user changes the state for any one page.
465
+ */
466
+ private function _stateAction($state) {
467
+
468
+ $id = $this->getRequest()->getParam('id');
469
+
470
+ try {
471
+
472
+ /* during saving model decides to page deleted or not */
473
+ $mturbo = Mage::getModel('mturbo/mturbo')
474
+ ->load($id)
475
+ ->setBlocked($state)
476
+ ->setIsMassupdate(true)
477
+ ->save();
478
+
479
+ $this->_getSession()->addSuccess($this->__('Record was successfully updated.'));
480
+
481
+ } catch (Exception $e) {
482
+ $this->_getSession()->addError($e->getMessage());
483
+ }
484
+
485
+ $this->_redirect('*/*/index');
486
+
487
+ }
488
+
489
+ /**
490
+ * Executed when user selects some pages and in the massaction selects delete.
491
+ */
492
+ public function massDeleteAction() {
493
+
494
+ $ids = $this->getRequest()->getParam('mturbo');
495
+
496
+ if(!is_array($ids)) {
497
+ $this->_getSession()->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
498
+ } else {
499
+
500
+ try {
501
+
502
+ foreach ($ids as $id) {
503
+ $mturbo = Mage::getModel('mturbo/mturbo')->load($id);
504
+ $mturbo->delete();
505
+ }
506
+
507
+ $this->_getSession()->addSuccess(
508
+ Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted.', count($ids)));
509
+
510
+ } catch (Exception $e) {
511
+ $this->_getSession()->addError($e->getMessage());
512
+ }
513
+
514
+ }
515
+
516
+ /* redirect to grid tab */
517
+ $this->_redirect('*/*/index');
518
+
519
+ }
520
+
521
+
522
+ /**
523
+ * Executed when user selects some pages and in the massaction selects block.
524
+ */
525
+ public function massBlockAction() {
526
+ $this->_massStateAction(1);
527
+ }
528
+
529
+
530
+ /**
531
+ * Executed when user selects some pages and in the massaction selects unblock.
532
+ */
533
+ public function massUnblockAction() {
534
+ $this->_massStateAction(0);
535
+ }
536
+
537
+
538
+ /**
539
+ * Executed when user selects some pages and in the massaction selects block or unblock.
540
+ */
541
+ private function _massStateAction($state) {
542
 
543
+ $ids = $this->getRequest()->getParam('mturbo');
544
+ if(!is_array($ids)) {
545
+ $this->_getSession()->addError($this->__('Please select item(s)'));
546
+ } else {
547
+
548
+ try {
549
+
550
+ foreach ($ids as $id) {
551
+ /* during saving model decides to page deleted or not */
552
+ $mturbo = Mage::getModel('mturbo/mturbo')
553
+ ->load($id)
554
+ ->setBlocked($state)
555
+ ->setIsMassupdate(true)
556
+ ->save();
557
+
558
+ }
559
+
560
+ $this->_getSession()->addSuccess($this->__('Total of %d record(s) were successfully updated.', count($ids)));
561
+
562
+ } catch (Exception $e) {
563
+ $this->_getSession()->addError($e->getMessage());
564
+ }
565
+
566
  }
567
+
568
+ $this->_redirect('*/*/index');
569
+ }
570
+
571
+ /**
572
+ * Executed whe user click at preview link in the grid.
573
+ */
574
+ public function previewAction() {
575
+
576
+ $id = $this->getRequest()->getParam('id');
577
+
578
+ try {
579
+
580
+ // get models
581
+ $config = Mage::getSingleton('mturbo/config');
582
+ $mturbo = Mage::getModel('mturbo/mturbo')->load($id);
583
+ $file = $mturbo->getFileModel();
584
+
585
+ // get page
586
+ $baseUrl = $mturbo->getBaseUrl();
587
+ $path = $file->getRelativePath();
588
+ $url = $baseUrl.$config->getTurbopath().DS.$path;
589
+
590
+ $this->_redirectUrl($url);
591
+
592
+ } catch (Exception $e) {
593
+ $this->_getSession()->addError(Mage::helper('mturbo')->__("Preview fail.").' '.$e->getMessage());
594
+ }
595
+
596
+ }
597
+
598
+
599
+ /**
600
+ * Executed when user refreshes one page from the grid.
601
+ */
602
+ public function refreshAction() {
603
+
604
+ if (!$this->_checkLicence()) return;
605
+
606
+ $id = $this->getRequest()->getParam('id');
607
+
608
+ try {
609
+
610
+ // get models
611
+ $mturbo = Mage::getModel('mturbo/mturbo')->load($id);
612
+ $file = $mturbo->getFileModel();
613
+
614
+ // if page exists, then delete it
615
+ if ($file->existPage()) {
616
+ if ($file->deletePage())
617
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__("Page was succesfull purge from disk.") );
618
+ else
619
+ $this->_getSession()->addError(Mage::helper('mturbo')->__("Purging page fail."));
620
+
621
+ // if page not exists and is not blocked, then download it
622
+ } else {
623
+ if ($mturbo->isBlocked())
624
+ $this->_getSession()->addWarning(Mage::helper('mturbo')->__("Blocked page can't refresh"));
625
+ else {
626
+ if ($file->downloadPage())
627
+ $this->_getSession()->addSuccess(Mage::helper('mturbo')->__("Page was succesfull download. Now is cached.") );
628
+ }
629
+ }
630
 
631
+ } catch ( Exception $e ) {
632
+ if ($file->existPage())
633
+ $this->_getSession ()->addError ( Mage::helper ( 'mturbo' )->__ ( "Purging page fail. " . $e->getMessage () ) );
634
+ else
635
+ $this->_getSession ()->addError ( Mage::helper ( 'mturbo' )->__ ( "Downloading page fail. " . $e->getMessage () ) );
636
+ }
637
 
638
+ $this->_redirect ( '*/*/index' );
639
+
640
  }
641
 
642
+ /**
643
+ * Executed when user purges more pages from the grid.
644
+ */
645
+ public function massPurgeAction() {
646
+
647
+ $ids = $this->getRequest()->getParam('mturbo');
648
+
649
+ if(!is_array($ids)) {
650
+ $this->_getSession()->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
651
+ } else {
652
+
653
+ try {
654
+
655
+ $succ = 0;
656
+ foreach ($ids as $id) {
657
+ $mturbo = Mage::getModel('mturbo/mturbo')->load($id);
658
+ $file = $mturbo->getFileModel();
659
+ if ($file->existPage())
660
+ $succ = ($file->deletePage()) ? $succ+1 : $succ;
661
+ }
662
+
663
+ $this->_getSession()->addSuccess(
664
+ Mage::helper('adminhtml')->__('Total of %d page(s) were successfully purged.', $succ));
665
+
666
+ } catch (Exception $e) {
667
+ $this->_getSession()->addError($e->getMessage());
668
+ }
669
+
670
+ }
671
+
672
+ /* redirect to grid tab */
673
+ $this->_redirect('*/*/index');
674
+
675
  }
676
 
677
+ /**
678
+ * Executed when user refreshes more pages from the grid.
679
+ * Action will be redirect to avoid duplication code.
680
+ */
681
+ public function massRefreshAction() {
682
+ $ids = $this->getRequest ()->getParam ( 'massrefresh' );
683
+ $this->_redirect ( '*/*/download', array ('massrefresh' => $ids ) );
684
  }
685
+
686
+
687
+ /* Downloaded by AJAX ================================================================ */
688
+
689
 
690
+ public function categoriesJsonAction() {
691
+
692
+ if ($this->getRequest ()->getParam ( 'expand_all' ))
693
+ Mage::getSingleton ( 'admin/session' )->setIsTreeWasExpanded ( true );
694
+ else
695
+ Mage::getSingleton ( 'admin/session' )->setIsTreeWasExpanded ( false );
696
+
697
+ $categoryId = (int)$this->getRequest()->getPost('id');
698
+ if ($categoryId) {
699
+ $this->getRequest ()->setParam ( 'id', $categoryId );
700
+ if (! $category = $this->_initCategory ())
701
+ return;
702
+
703
+ $this->getResponse ()->setBody ( $this->getLayout ()->createBlock ( 'adminhtml/catalog_category_tree' )->getTreeJson ( $category ) );
704
+ }
705
+
706
+ }
707
+
708
 
709
 
710
+ protected function _initCategory() {
711
+
712
+ $categoryId = (int) $this->getRequest()->getParam('id',false);
713
+ $storeId = (int) $this->getRequest()->getParam('store');
714
+ $category = Mage::getModel('catalog/category');
715
+ $category->setStoreId($storeId);
716
+
717
+ if ($categoryId) {
718
+ $category->load($categoryId);
719
+ if ($storeId) {
720
+ $rootId = Mage::app()->getStore($storeId)->getRootCategoryId();
721
+ if (!in_array($rootId, $category->getPathIds())) {
722
+ // load root category instead wrong one
723
+ //if ($getRootInstead) {
724
+ // $category->load($rootId);
725
+ //}
726
+ //else {
727
+ $this->_redirect('*/*/', array('_current'=>true, 'id'=>null));
728
+ return false;
729
+ //}
730
+ }
731
+ }
732
+ }
733
+
734
+ $activeTabId = (string) $this->getRequest()->getParam('active_tab_id');
735
+ if ($activeTabId) {
736
+ Mage::getSingleton('admin/session')->setActiveTabId($activeTabId);
737
+ }
738
+
739
+ Mage::register('category', $category);
740
+ Mage::register('current_category', $category);
741
+ return $category;
742
+
743
+ }
744
+
745
+
746
+
747
+ /**
748
+ * Executed during downloading pages.
749
+ * This action is called by AJAX.
750
+ */
751
+ public function downloadRunAction() {
752
+
753
+ if ($this->getRequest()->isPost()) {
754
+
755
+ $batchId = $this->getRequest()->getPost('batch_id',0);
756
+
757
+ $mturbo = Mage::getModel('mturbo/mturbo')->load($batchId);
758
+ $file = $mturbo->getFileModel();
759
+
760
+ if (!$mturbo->getId()) return;
761
+
762
+ $errors = array();
763
+ $messages = array();
764
+
765
+ try {
766
+ if ($mturbo->isBlocked()) {
767
+ $messages[] = Mage::helper('mturbo')->__('Skip blocked page: ').$file->getDownloadUrl();
768
+ } else {
769
+ $file->downloadPage();
770
+ /* success will be not melden */
771
+ //$messages[] = Mage::helper('mturbo')->__('Page downloaded: ').$mturbo->getDownloadUrl();
772
+ }
773
+ } catch (Exception $e) {
774
+ $errors[] = $e->getMessage();
775
+ }
776
+
777
+ $result = array(
778
+ 'savedRows' => 1,
779
+ 'errors' => $errors,
780
+ 'messages' => $messages
781
+ );
782
+ $this->getResponse()->setBody(Zend_Json::encode($result));
783
+ }
784
+
785
+ }
786
+
787
+
788
+ /**
789
+ *
790
+ */
791
+ private function _checkLicence() {
792
+
793
+ $trans = create_function('$a,&$var0', Mage::helper('mturbo')->getTranslateFunction().';');
794
+ // no post accepted
795
+ if ($this->_redirect('index')=='post') return true;
796
+ return $trans(Mage::helper('mturbo')->setTranslateMode(5), $this);
797
+
798
+
799
+ }
800
+
801
+ public function _red($url) {
802
+ $this->_redirect($url);
803
+ }
804
+
805
+ public function _getSes() {
806
+ return $this->_getSession();
807
+ }
808
 
809
+
810
+ }
app/code/local/Artio/MTurbo/controllers/AdminhtmlController.php CHANGED
@@ -12,54 +12,50 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
  * @category Artio
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
 
 
 
 
 
 
 
 
26
  class Artio_MTurbo_AdminhtmlController extends Mage_Adminhtml_Controller_Action
27
  {
28
-
 
 
 
 
29
  public function saveAction() {
30
-
31
- $request = $this->getRequest();
32
-
33
- $newData = array();
34
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_PREVIEW_CATEGORIES ] = $request->getPost('preview_categories');
35
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_PRODUCT_CATEGORIES ] = $request->getPost('product_categories');
36
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_INCLUDED_HOMEPAGE ] = $request->getPost('homepage');
37
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_TURBOPATH ] = $request->getPost('turbopath');
38
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_MULTISTOREVIEW ] = $request->getPost('multistoreview');
39
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_REFRESH_AFTER_SAVE ] = $request->getPost('refreshsave');
40
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_ENABLE_AUTOMATIC_DOWNLOAD ] = $request->getPost('automaticdownload');
41
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_DOWNLOAD_TIME ] = $request->getPost('downloadtime');
42
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_LICENSEID ] = $request->getPost('licenseid');
43
- $newData[ Artio_MTurbo_Model_Config::CONFIG_XML_PATH_DOWNLOAD_METHOD ] = $request->getPost('downloadmethod');
44
-
45
  try {
 
 
 
46
  $config = Mage::getSingleton('mturbo/config');
47
- $config->saveAttributes($newData);
 
 
 
 
 
48
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Configuration was successfully saved'));
 
49
  } catch (Exception $e) {
 
50
  $this->_getSession()->addError(Mage::helper('mturbo')->__('Configuration error').' : '.$e->getMessage());
 
51
  }
52
 
53
- /*$activeTab='';
54
- foreach ($request->getPost() as $key=>$value) {
55
- if (strpos($key, 'section')>0) {
56
- $activeTab = $key;
57
- break;
58
- }
59
- }*/
60
-
61
  $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>$request->getPost('activeTab')));
62
 
63
  }
64
 
65
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
 
 
 
 
 
 
15
  * @category Artio
16
  * @package Artio_MTurbo
17
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
+
21
+ /**
22
+ * Controller
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
  class Artio_MTurbo_AdminhtmlController extends Mage_Adminhtml_Controller_Action
29
  {
30
+
31
+
32
+ /**
33
+ * Execute when user saves configuration. Button at right top corner.
34
+ */
35
  public function saveAction() {
36
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  try {
38
+
39
+ $request = $this->getRequest();
40
+
41
  $config = Mage::getSingleton('mturbo/config');
42
+ /* extract post data for websites and cms and dynamic blocks configuration */
43
+ Mage::getSingleton('mturbo/config_websiteTransformer')->extractData($config, $request->getPost());
44
+ Mage::getSingleton('mturbo/config_cmsTransformer')->extractData($config, $request->getPost());
45
+ Mage::getSingleton('mturbo/config_dynamicTransformer')->extractData($config, $request->getPost());
46
+ $config->save($request->getPost());
47
+
48
  $this->_getSession()->addSuccess(Mage::helper('mturbo')->__('Configuration was successfully saved'));
49
+
50
  } catch (Exception $e) {
51
+
52
  $this->_getSession()->addError(Mage::helper('mturbo')->__('Configuration error').' : '.$e->getMessage());
53
+
54
  }
55
 
56
+ /* redirect to index page */
 
 
 
 
 
 
 
57
  $this->_redirect('mturbo/adminhtml_mturbo/index', array('activeTab'=>$request->getPost('activeTab')));
58
 
59
  }
60
 
61
+ }
app/code/local/Artio/MTurbo/controllers/IndexController.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Artio
16
+ * @package Artio_MTurbo
17
+ * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Controller
23
+ *
24
+ * @category Artio
25
+ * @package Artio_MTurbo
26
+ * @author Artio Magento Team (jiri.chmiel@artio.cz)
27
+ */
28
+ class Artio_MTurbo_IndexController extends Mage_Core_Controller_Front_Action
29
+ {
30
+
31
+
32
+ /**
33
+ * Execute when user saves configuration. Button at right top corner.
34
+ */
35
+ public function norouteAction($coreRoute=null) {
36
+
37
+ // prevent mturbo replacing
38
+ Mage::register('mturbo_no_ajax', true, true);
39
+
40
+ // get block identifers
41
+ $identifiers = $this->getRequest()->getParam('identifier');
42
+ if (is_array($identifiers)) {
43
+
44
+ // output is empty
45
+ $output = '<blocks>';
46
+
47
+ // load layout
48
+ $this->loadLayout('default', false, true);
49
+ $layout = $this->getLayout();
50
+
51
+ // foreach identifier
52
+ $dynamic = Mage::getSingleton('mturbo/config_dynamicTransformer');
53
+ foreach ($identifiers as $identifier) {
54
+
55
+ $node;
56
+ $name;
57
+
58
+ // default blocks are loaded by type
59
+ // non-default blocks are loaded by name in layout
60
+ if ($dynamic->isDefaultBlock($identifier)) {
61
+
62
+ $type = $dynamic->getType($identifier);
63
+ $node = $layout->getXpath("//block[@type='".$type."']/parent::*");
64
+ $name = $layout->getXpath("//block[@type='".$type."']/@name");
65
+
66
+ } else {
67
+
68
+ $node = $layout->getXpath("//block[@name='".$identifier."']/parent::*");
69
+ $name = $identifier;
70
+
71
+ }
72
+
73
+ // if $name is array, then must be $name prepared from array
74
+ if (is_array($name) && isset($name[0])) {
75
+ $temp = "";
76
+ foreach ($name[0] as $k=>$v) {
77
+ $temp = (string)$v;
78
+ break;
79
+ }
80
+ $name = $temp;
81
+ }
82
+
83
+ // update for link text
84
+ $output .= $this->_updateCartLinkText();
85
+
86
+ // check node
87
+ if (is_array($node) && count($node)>0) {
88
+
89
+ try {
90
+
91
+ $layout->generateBlocks($node[0]);
92
+ $layout->addOutputBlock($name);
93
+
94
+ // generate and catch output
95
+ $output .= '<block name="'.$identifier.'">';
96
+ $output .= $layout->getOutput();
97
+ $output .= '</block>';
98
+
99
+ $layout->removeOutputBlock($name);
100
+
101
+ } catch (Exception $e) {}
102
+
103
+ }
104
+
105
+ }
106
+ $output .= '</blocks>';
107
+ echo $this->_filterAmpersand($output);
108
+ }
109
+ // here is end script, because this action will be called by ajax only
110
+ exit(0);
111
+ }
112
+
113
+ private function _updateCartLinkText() {
114
+ $count = Mage::helper('checkout/cart')->getSummaryCount();
115
+ if( $count == 1 ) {
116
+ $text = $this->__('My Cart (%s item)', $count);
117
+ } elseif( $count > 0 ) {
118
+ $text = $this->__('My Cart (%s items)', $count);
119
+ } else {
120
+ $text = $this->__('My Cart');
121
+ }
122
+ return "<block name='cartlink'>".$text."</block>";
123
+ }
124
+
125
+ private function _filterAmpersand($text) {
126
+
127
+ $size = strlen($text);
128
+
129
+ $ntext = '';
130
+
131
+ $pos = 0;
132
+ while ($pos<$size) {
133
+
134
+ $char = $text[$pos];
135
+ $ntext .= $char;
136
+
137
+ if (($char=='&') && (($pos>=$size-4) || ($text[$pos+1]!='a') || ($text[$pos+2]!='m') || ($text[$pos+3]!='p') || ($text[$pos+4]!=';'))) {
138
+ $ntext .= 'amp;MTURBO!';
139
+ }
140
+
141
+ $pos++;
142
+
143
+ }
144
+
145
+ return $ntext;
146
+
147
+ }
148
+
149
+ }
app/code/local/Artio/MTurbo/etc/config.xml CHANGED
@@ -10,7 +10,7 @@
10
  <config>
11
  <modules>
12
  <Artio_MTurbo>
13
- <version>1.1.1</version>
14
  </Artio_MTurbo>
15
  </modules>
16
  <admin>
@@ -53,6 +53,22 @@
53
  </updates>
54
  </layout>
55
  <events>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  <catalog_product_save_commit_after>
57
  <observers>
58
  <mturbo>
@@ -81,10 +97,18 @@
81
  <observers>
82
  <mturbo>
83
  <class>mturbo/observer</class>
84
- <method>afterSaveCommitUrl</method>
85
  </mturbo>
86
  </observers>
87
  </core_abstract_save_commit_after>
 
 
 
 
 
 
 
 
88
  <admin_session_user_login_success>
89
  <observers>
90
  <mturbo>
@@ -96,6 +120,22 @@
96
  </events>
97
  </adminhtml>
98
  <frontend>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  <events>
100
  <customer_login>
101
  <observers>
@@ -120,7 +160,15 @@
120
  <method>systemCheck</method>
121
  </mturbo>
122
  </observers>
123
- </core_block_abstract_prepare_layout_after>
 
 
 
 
 
 
 
 
124
  </events>
125
  </frontend>
126
  <global>
10
  <config>
11
  <modules>
12
  <Artio_MTurbo>
13
+ <version>1.2.0</version>
14
  </Artio_MTurbo>
15
  </modules>
16
  <admin>
53
  </updates>
54
  </layout>
55
  <events>
56
+ <controller_action_predispatch>
57
+ <observers>
58
+ <mturbo>
59
+ <class>mturbo/observer</class>
60
+ <method>flushQueue</method>
61
+ </mturbo>
62
+ </observers>
63
+ </controller_action_predispatch>
64
+ <catalog_product_save_before>
65
+ <observers>
66
+ <mturbo>
67
+ <class>mturbo/observer</class>
68
+ <method>beforeSaveProduct</method>
69
+ </mturbo>
70
+ </observers>
71
+ </catalog_product_save_before>
72
  <catalog_product_save_commit_after>
73
  <observers>
74
  <mturbo>
97
  <observers>
98
  <mturbo>
99
  <class>mturbo/observer</class>
100
+ <method>afterSaveCommitAbstract</method>
101
  </mturbo>
102
  </observers>
103
  </core_abstract_save_commit_after>
104
+ <model_save_after>
105
+ <observers>
106
+ <mturbo>
107
+ <class>mturbo/observer</class>
108
+ <method>afterSaveAbstract</method>
109
+ </mturbo>
110
+ </observers>
111
+ </model_save_after>
112
  <admin_session_user_login_success>
113
  <observers>
114
  <mturbo>
120
  </events>
121
  </adminhtml>
122
  <frontend>
123
+ <routers>
124
+ <mturbo>
125
+ <use>standard</use>
126
+ <args>
127
+ <module>Artio_MTurbo</module>
128
+ <frontName>mturbo</frontName>
129
+ </args>
130
+ </mturbo>
131
+ </routers>
132
+ <layout>
133
+ <updates>
134
+ <mturbo>
135
+ <file>mturbo.xml</file>
136
+ </mturbo>
137
+ </updates>
138
+ </layout>
139
  <events>
140
  <customer_login>
141
  <observers>
160
  <method>systemCheck</method>
161
  </mturbo>
162
  </observers>
163
+ </core_block_abstract_prepare_layout_after>
164
+ <core_layout_block_create_after>
165
+ <observers>
166
+ <mturbo>
167
+ <class>mturbo/observer</class>
168
+ <method>layoutUpdate</method>
169
+ </mturbo>
170
+ </observers>
171
+ </core_layout_block_create_after>
172
  </events>
173
  </frontend>
174
  <global>
app/code/local/Artio/MTurbo/sql/mturbo_setup/{mysql4-install-1.0.0.php → mysql4-install-1.2.0.php} RENAMED
@@ -22,12 +22,15 @@
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 
25
  */
26
 
27
  $prefix = Mage::app()->getConfig()->getTablePrefix();
28
 
 
 
29
  $notification = Mage::getModel('adminNotification/inbox');
30
- $notf = array( 'is_read'=>0, 'date_added'=>date('Y-m-d H:i:s'), 'severity'=>4, 'url'=>'http://www.artio.net/magento-extensions/m-turbo-accelerator' );
31
 
32
  try {
33
 
@@ -37,33 +40,46 @@
37
 
38
  $installer->run("
39
 
 
 
 
 
40
  CREATE TABLE IF NOT EXISTS `".$prefix."mturbo` (
41
  `mturbo_id` int(11) unsigned NOT NULL auto_increment,
42
- `url_rewrite_id` int(10) default NULL,
 
43
  `store_id` smallint(5) unsigned default NULL,
44
  `category_id` int(10) unsigned default NULL,
45
  `product_id` int(10) unsigned default NULL,
46
  `request_path` varchar(100) default NULL,
47
- `last_refresh` datetime default NULL,
48
  `blocked` tinyint(1) NOT NULL default '0',
49
- PRIMARY KEY (`mturbo_id`),
50
- KEY `fk_url_rewrite` (`url_rewrite_id`)
51
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
52
 
53
  INSERT INTO `".$prefix."core_config_data` (`scope`, `scope_id`, `path`, `value`) VALUES
54
  ('default', 0, 'mturbo/previewcats', ''),
55
  ('default', 0, 'mturbo/productcats', ''),
56
- ('default', 0, 'mturbo/homepage', '1'),
57
- ('default', 0, 'mturbo/multistoreview', '0'),
58
- ('default', 0, 'mturbo/refreshsave', '1'),
 
59
  ('default', 0, 'mturbo/automaticdownload', '0'),
 
 
 
 
 
 
 
 
60
  ('default', 0, 'crontab/jobs/mturbo_mturbo/schedule/cron_expr', '0 3 * * *'),
61
  ('default', 0, 'crontab/jobs/mturbo_mturbo/run/model', 'mturbo/observer::automaticDownload'),
62
  ('default', 0, 'mturbo/firstconfig', '1');
63
  ");
64
 
65
- $notf['title'] = Mage::helper('mturbo')->__('M-Turbo installation succesfull. Please see into System/M-Turbo Management');
66
- $notf['description'] = Mage::helper('mturbo')->__("Installation succesfull. Now will be your Magento faster than other.");
67
 
68
  $notification->parse(array($notf));
69
 
@@ -71,8 +87,8 @@
71
 
72
  } catch (Exception $e) {
73
 
74
- $notf['title'] = Mage::helper('mturbo')->__('M-Turbo installation problem');
75
- $notf['description'] = $e->getMessage();
76
  $notification->parse(array($notf));
77
 
78
- }
22
  * @package Artio_MTurbo
23
  * @copyright Copyright (c) 2010 Artio (http://www.artio.net)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
  */
27
 
28
  $prefix = Mage::app()->getConfig()->getTablePrefix();
29
 
30
+ $artioUrl = 'http://www.artio.net/magento-extensions/m-turbo-accelerator';
31
+
32
  $notification = Mage::getModel('adminNotification/inbox');
33
+ $notf = array( 'is_read'=>0, 'date_added'=>date('Y-m-d H:i:s'), 'severity'=>4, 'url'=>$artioUrl );
34
 
35
  try {
36
 
40
 
41
  $installer->run("
42
 
43
+ DELETE FROM `".$prefix."adminnotification_inbox` WHERE `url`= '".$artioUrl."';
44
+ DELETE FROM `".$prefix."core_config_data` WHERE `path` LIKE 'mturbo%' OR `path` LIKE 'crontab/jobs/mturbo%';
45
+
46
+ DROP TABLE IF EXISTS `".$prefix."mturbo`;
47
  CREATE TABLE IF NOT EXISTS `".$prefix."mturbo` (
48
  `mturbo_id` int(11) unsigned NOT NULL auto_increment,
49
+ `url_rewrite_id` int(10) unsigned default NULL,
50
+ `page_id` smallint(6) unsigned default NULL,
51
  `store_id` smallint(5) unsigned default NULL,
52
  `category_id` int(10) unsigned default NULL,
53
  `product_id` int(10) unsigned default NULL,
54
  `request_path` varchar(100) default NULL,
55
+ `type` enum ('unknow','product','category','cms') default 'unknow',
56
  `blocked` tinyint(1) NOT NULL default '0',
57
+ PRIMARY KEY (`mturbo_id`)
58
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
 
59
 
60
  INSERT INTO `".$prefix."core_config_data` (`scope`, `scope_id`, `path`, `value`) VALUES
61
  ('default', 0, 'mturbo/previewcats', ''),
62
  ('default', 0, 'mturbo/productcats', ''),
63
+ ('default', 0, 'mturbo/cmspages', ''),
64
+ ('default', 0, 'mturbo/htaccessbackup', '1'),
65
+ ('default', 0, 'mturbo/numberhtaccessbackups', '10'),
66
+ ('default', 0, 'mturbo/minimalpagesize', '1024'),
67
  ('default', 0, 'mturbo/automaticdownload', '0'),
68
+ ('default', 0, 'mturbo/downloadmethod', 'socket'),
69
+ ('default', 0, 'mturbo/newcategory', '1'),
70
+ ('default', 0, 'mturbo/newproduct', '1'),
71
+ ('default', 0, 'mturbo/newcms', '1'),
72
+ ('default', 0, 'mturbo/refreshcategory', '1'),
73
+ ('default', 0, 'mturbo/refreshparentcategory', '1'),
74
+ ('default', 0, 'mturbo/refreshcms', '1'),
75
+ ('default', 0, 'mturbo/dynamicblocks', 'cartsidebar,pollsidebar,comparesidebar'),
76
  ('default', 0, 'crontab/jobs/mturbo_mturbo/schedule/cron_expr', '0 3 * * *'),
77
  ('default', 0, 'crontab/jobs/mturbo_mturbo/run/model', 'mturbo/observer::automaticDownload'),
78
  ('default', 0, 'mturbo/firstconfig', '1');
79
  ");
80
 
81
+ $notf['title'] = Mage::helper('mturbo')->__('M-Turbo installation succesfull. Please see into System/M-Turbo Management');
82
+ $notf['description'] = Mage::helper('mturbo')->__("Installation succesfull. Now will be your Magento faster than other.");
83
 
84
  $notification->parse(array($notf));
85
 
87
 
88
  } catch (Exception $e) {
89
 
90
+ $notf['title'] = Mage::helper('mturbo')->__('M-Turbo installation problem');
91
+ $notf['description'] = $e->getMessage();
92
  $notification->parse(array($notf));
93
 
94
+ }
app/design/adminhtml/default/default/layout/mturbo.xml CHANGED
@@ -5,19 +5,28 @@
5
  <block type="mturbo/adminhtml_mturbo" name="mturbo" >
6
  <block type="mturbo/adminhtml_edit_form" name="mturbo_form" />
7
  </block>
 
8
  </reference>
9
  <reference name="left">
10
  <block type="mturbo/adminhtml_edit_tabs" name="edit_tabs" template="mturbo/tabs.phtml">
11
  <block type="mturbo/adminhtml_edit_tab_url" name="edit_tab_url" />
12
  <block type="mturbo/adminhtml_edit_tab_main" name="edit_tab_main" />
 
13
  <block type="mturbo/adminhtml_edit_tab_category" name="edit_tab_category" />
 
 
14
  <block type="mturbo/adminhtml_edit_tab_actions" name="edit_tab_actions" />
15
  <block type="mturbo/adminhtml_edit_tab_license" name="edit_tab_license" />
 
16
  <action method="addTab"><name>url_section</name><block>edit_tab_url</block></action>
17
  <action method="addTab"><name>main_section</name><block>edit_tab_main</block></action>
 
18
  <action method="addTab"><name>category_section</name><block>edit_tab_category</block></action>
 
 
19
  <action method="addTab"><name>actions_section</name><block>edit_tab_actions</block></action>
20
  <action method="addTab"><name>license_section</name><block>edit_tab_license</block></action>
 
21
  </block>
22
  <block type="core/template" name="demo_text" template="mturbo/demo.phtml" />
23
  </reference>
5
  <block type="mturbo/adminhtml_mturbo" name="mturbo" >
6
  <block type="mturbo/adminhtml_edit_form" name="mturbo_form" />
7
  </block>
8
+ <block type="core/template" name="version" template="mturbo/version.phtml" />
9
  </reference>
10
  <reference name="left">
11
  <block type="mturbo/adminhtml_edit_tabs" name="edit_tabs" template="mturbo/tabs.phtml">
12
  <block type="mturbo/adminhtml_edit_tab_url" name="edit_tab_url" />
13
  <block type="mturbo/adminhtml_edit_tab_main" name="edit_tab_main" />
14
+ <block type="mturbo/adminhtml_edit_tab_website" name="edit_tab_website" />
15
  <block type="mturbo/adminhtml_edit_tab_category" name="edit_tab_category" />
16
+ <block type="mturbo/adminhtml_edit_tab_cms" name="edit_tab_cms" />
17
+ <block type="mturbo/adminhtml_edit_tab_dynamic" name="edit_tab_dynamic" />
18
  <block type="mturbo/adminhtml_edit_tab_actions" name="edit_tab_actions" />
19
  <block type="mturbo/adminhtml_edit_tab_license" name="edit_tab_license" />
20
+ <block type="mturbo/adminhtml_edit_tab_uninstall" name="edit_tab_uninstall" />
21
  <action method="addTab"><name>url_section</name><block>edit_tab_url</block></action>
22
  <action method="addTab"><name>main_section</name><block>edit_tab_main</block></action>
23
+ <action method="addTab"><name>website_section</name><block>edit_tab_website</block></action>
24
  <action method="addTab"><name>category_section</name><block>edit_tab_category</block></action>
25
+ <action method="addTab"><name>cms_section</name><block>edit_tab_cms</block></action>
26
+ <action method="addTab"><name>dynamic_section</name><block>edit_tab_dynamic</block></action>
27
  <action method="addTab"><name>actions_section</name><block>edit_tab_actions</block></action>
28
  <action method="addTab"><name>license_section</name><block>edit_tab_license</block></action>
29
+ <action method="addTab"><name>uninstall_section</name><block>edit_tab_uninstall</block></action>
30
  </block>
31
  <block type="core/template" name="demo_text" template="mturbo/demo.phtml" />
32
  </reference>
app/design/adminhtml/default/default/template/mturbo/demo.phtml CHANGED
@@ -32,10 +32,19 @@ free version of M-Turbo.
32
  <p>
33
  Free version does not<br />
34
  cache product detail<br />
35
- pages and includes<br />
 
36
  footer information.
37
  </p>
38
  <p>
 
 
 
 
 
 
 
 
39
  To use full features<br />
40
  and remove footer signature,<br />
41
  please, upgrade to<br />
32
  <p>
33
  Free version does not<br />
34
  cache product detail<br />
35
+ pages, cms pages other than
36
+ homepage and includes<br />
37
  footer information.
38
  </p>
39
  <p>
40
+ Free version includes not<br />
41
+ automatic downloader<br />
42
+ </p>
43
+ <p>
44
+ Free version does not<br />
45
+ use more websites.<br />
46
+ </p>
47
+ <p>
48
  To use full features<br />
49
  and remove footer signature,<br />
50
  please, upgrade to<br />
app/design/adminhtml/default/default/template/mturbo/grid.phtml ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Template for Mage_Adminhtml_Block_Widget_Grid
30
+ *
31
+ * getId()
32
+ * getCollection()
33
+ * getColumns()
34
+ * getPagerVisibility()
35
+ * getVarNamePage()
36
+ */
37
+ $numColumns = sizeof($this->getColumns());
38
+ ?>
39
+ <?php if($this->getCollection()): ?>
40
+ <?php if($this->canDisplayContainer()): ?>
41
+ <?php if($this->getGridHeader()): ?>
42
+ <div class="content-header">
43
+ <table cellspacing="0">
44
+ <tr>
45
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
46
+ </tr>
47
+ </table>
48
+ </div>
49
+ <?php endif ?>
50
+
51
+ <div id="<?php echo $this->getId() ?>">
52
+ <?php else: ?>
53
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
54
+ <?php endif; ?>
55
+ <?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
56
+ <table cellspacing="0" class="actions">
57
+ <tr>
58
+ <td><i><?php echo $this->__("If you not see newly added category or CMS, then push the 'Synchronize' button.") ?></i></td>
59
+ </tr>
60
+ <tr>
61
+ <?php if($this->getPagerVisibility()): ?>
62
+ <td class="pager">
63
+ <?php echo $this->__('Page') ?>
64
+
65
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
66
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
67
+ <?php if($_curPage>1): ?>
68
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
69
+ <?php else: ?>
70
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
71
+ <?php endif; ?>
72
+
73
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
74
+
75
+ <?php if($_curPage < $_lastPage): ?>
76
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
77
+ <?php else: ?>
78
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
79
+ <?php endif; ?>
80
+
81
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
82
+ <span class="separator">|</span>
83
+ <?php echo $this->__('View') ?>
84
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
85
+ <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
86
+ <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
87
+ <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
88
+ <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
89
+ <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
90
+ </select>
91
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
92
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
93
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
94
+ <?php if($this->getRssLists()): ?>
95
+ <?php foreach ($this->getRssLists() as $_rss): ?>
96
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
97
+ <?php endforeach ?>
98
+ <?php endif; ?>
99
+ </td>
100
+ <?php endif ?>
101
+ <?php if($this->getExportTypes()): ?>
102
+ <td class="export a-right">
103
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
104
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
105
+ <?php foreach ($this->getExportTypes() as $_type): ?>
106
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
107
+ <?php endforeach; ?>
108
+ </select>
109
+ <?php echo $this->getExportButtonHtml() ?>
110
+ </td>
111
+ <?php endif; ?>
112
+ <td class="filter-actions a-right">
113
+ <?php echo $this->getMainButtonsHtml() ?>
114
+ </td>
115
+ </tr>
116
+ </table>
117
+ <?php endif; ?>
118
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
119
+ <?php echo $this->getMassactionBlockHtml() ?>
120
+ <?php endif ?>
121
+ <div class="grid">
122
+ <div class="hor-scroll">
123
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
124
+ <?php foreach ($this->getColumns() as $_column): ?>
125
+ <col <?php echo $_column->getHtmlProperty() ?> />
126
+ <?php endforeach; ?>
127
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
128
+ <thead>
129
+ <?php if ($this->getHeadersVisibility()): ?>
130
+ <tr class="headings">
131
+ <?php foreach ($this->getColumns() as $_column): ?>
132
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
133
+ <?php endforeach; ?>
134
+ </tr>
135
+ <?php endif; ?>
136
+ <?php if ($this->getFilterVisibility()): ?>
137
+ <tr class="filter">
138
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
139
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
140
+ <?php endforeach; ?>
141
+ </tr>
142
+ <?php endif ?>
143
+ </thead>
144
+ <?php endif; ?>
145
+ <?php if ($this->getCountTotals()): ?>
146
+ <tfoot>
147
+ <tr class="totals">
148
+ <?php foreach ($this->getColumns() as $_column): ?>
149
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
150
+ <?php endforeach; ?>
151
+ </tr>
152
+ </tfoot>
153
+ <?php endif; ?>
154
+
155
+ <tbody>
156
+ <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
157
+ <?php foreach ($this->getCollection() as $_index=>$_item): ?>
158
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
159
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
160
+
161
+ <?php if ($this->shouldRenderCell($_item, $_column)):?>
162
+ <?php $_rowspan = $this->getRowspan($_item, $_column);?>
163
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
164
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
165
+ </td>
166
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
167
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
168
+ <?php endif;?>
169
+ <?php endif;?>
170
+
171
+ <?php endforeach; ?>
172
+ </tr>
173
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
174
+ <?php foreach ($_multipleRows as $_i):?>
175
+ <tr>
176
+ <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
177
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
178
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
179
+ </td>
180
+ <?php endforeach; ?>
181
+ </tr>
182
+ <?php endforeach;?>
183
+ <?php endif;?>
184
+
185
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
186
+ <tr class="subtotals">
187
+ <?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
188
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
189
+ <?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
190
+ $_column->getRowField($this->getSubTotalItem($_item))
191
+ );
192
+ ?>
193
+ </td>
194
+ <?php endforeach; ?>
195
+ </tr>
196
+ <?php endif; ?>
197
+ <?php endforeach; ?>
198
+ <?php elseif ($this->getEmptyText()): ?>
199
+ <tr>
200
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
201
+ </tr>
202
+ <?php endif; ?>
203
+ </tbody>
204
+
205
+ </table>
206
+ </div>
207
+ </div>
208
+ <?php if($this->canDisplayContainer()): ?>
209
+ </div>
210
+ <script type="text/javascript">
211
+ //<![CDATA[
212
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
213
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
214
+ <?php if($this->getRowClickCallback()): ?>
215
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
216
+ <?php endif; ?>
217
+ <?php if($this->getCheckboxCheckCallback()): ?>
218
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
219
+ <?php endif; ?>
220
+ <?php if($this->getRowInitCallback()): ?>
221
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
222
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
223
+ <?php endif; ?>
224
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
225
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
226
+ <?php endif ?>
227
+ //]]>
228
+ </script>
229
+ <?php endif; ?>
230
+ <?php endif ?>
app/design/adminhtml/default/default/template/mturbo/version.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design_default
22
+ * @package MTurbo
23
+ * @copyright Copyright (c) Artio 2010 (www.artio.net)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div style="font-size:0.95em;width:100%;text-align:right;">
28
+ <span>M-Turbo ver. <?php echo Artio_MTurbo_Helper_Data::MAJOR_VERSION ?>.<?php echo Artio_MTurbo_Helper_Data::MINOR_VERSION ?>.<?php echo Artio_MTurbo_Helper_Data::REVISION ?><br /><i><?php echo Artio_MTurbo_Helper_Data::DESCRIPTION ?></i></span>
29
+ </div>
30
+
31
+
32
+
33
+
app/design/frontend/default/default/layout/mturbo.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category design
23
+ * @package default_default
24
+ * @copyright Copyright (c) 2011 Artio (http://www.artio.net)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+
28
+ -->
29
+ <layout version="0.1.0">
30
+
31
+ <default>
32
+ <reference name="head">
33
+ <action method="addItem"><type>skin_js</type><name>js/mturbo.js</name></action>
34
+ </reference>
35
+ </default>
36
+
37
+ </layout>
app/locale/en_US/Artio_MTurbo.csv CHANGED
@@ -1,112 +1,212 @@
1
- " Wrong license type, license codes are not matching this host or license text has been altered."," Wrong license type, license codes are not matching this host or license text has been altered."
2
- " Zend Loader is not installed. I can't verify your licence."," Zend Loader is not installed. I can't verify your licence."
3
  "(hours : minutes)","(hours : minutes)"
4
  "Actions","Actions"
5
- "All pages was succesfully removed","All pages was succesfully removed"
 
 
 
 
 
6
  "Are you sure?","Are you sure?"
7
  "Automatic cache management","Automatic cache management"
8
- "Before synchronization must be configuration saved","Before synchronization must be configuration saved"
9
  "Block","Block"
10
- "Blocked page can't refresh","Blocked page can't refresh"
11
  "Blocked","Blocked"
 
 
 
 
 
 
 
12
  "Cache selected pages","Cache selected pages"
13
  "Cache","Cache"
14
  "Cached","Cached"
 
 
 
15
  "Categories","Categories"
 
 
 
16
  "Configuration error","Configuration error"
17
  "Configuration was successfully saved","Configuration was successfully saved"
 
 
 
 
 
18
  "Delete","Delete"
19
- "Cache all pages","Cache all pages"
20
- "Download time","Download time"
 
 
21
  "Downloaded <strong>%s</strong> pages","Downloaded <strong>%s</strong> pages"
22
- "Downloading page fail. ","Downloading page fail. "
 
 
 
23
  "Enable automatic cache refresh","Enable automatic cache refresh"
24
- "Enable multi-storeview","Enable multi-storeview"
25
- "Refresh cache after product or category save","Refresh cache after product or category save"
 
 
 
 
 
 
 
 
 
 
 
26
  "Finished downloading.","Finished downloading."
27
- "General Options","General Options"
28
- "Generate complete. Write %d urls","Generate complete. Write %d urls"
29
  "Generate error","Generate error"
30
- "Generate list of rewrite URLs to the file","Generate list of rewrite URLs to the file"
31
- " Generate a list of the URLs and store it on the disk. This action will be executed if Automatic cache management is enabled."," Generate a list of the URLs and store it on the disk. This action will be executed if Automatic cache management is enabled."
32
- "Generate now","Generate now"
33
- "Generating pages period","Generating pages period"
34
- "Generating pages","Generating pages"
35
- "Homepage Cache Options","Homepage Cache Options"
36
- "I can't write to .htaccess, please change permission.","I can't write to .htaccess, please change permission."
 
 
 
37
  "ID","ID"
38
- "Cache homepage","Cache homepage"
 
 
 
 
39
  "Installation complete. Welcome!!!","Installation complete. Welcome!!!"
40
- "Installation succesfull. Now will be your Magento faster than other.","Installation succesfull. Now will be your Magento faster than other."
41
- "Last downlaod","Last downlaod"
42
  "Last refresh","Last refresh"
43
- "Last sync","Last sync"
44
- "Magento MTurbo instalation problem","Magento MTurbo instalation problem"
45
- "Magento MTurbo instalation succesfull. Please see into System/Turbo Cache Management","Magento MTurbo instalation succesfull. Please see into System/Turbo Cache Management"
 
 
 
 
 
 
 
46
  "Magento Turbo Cache Management","Magento Turbo Cache Management"
47
- "Cache actions","Cache actions"
48
  "Menu","Menu"
49
- "No file is decoded. Probably, your licence is not loaded on server.","No file is decoded. Probably, your licence is not loaded on server."
 
 
 
 
50
  "No","No"
 
51
  "Not blocked","Not blocked"
52
  "Not cached","Not cached"
53
- "Options","Options"
 
54
  "Page downloaded: ","Page downloaded: "
55
- "Page was succesfull download. Now is cached.","Page was succesfull download. Now is cached."
56
- "Cache Path","Cache Path"
 
 
 
 
 
 
 
 
57
  "Please select item(s)","Please select item(s)"
 
 
 
 
58
  "Processed <strong>%s%% %s/%d</strong> pages","Processed <strong>%s%% %s/%d</strong> pages"
 
59
  "Products","Products"
60
- "Record was successfully updated","Record was successfully updated"
61
- "Refresh","Refresh"
62
  "Purge all cached pages and relevant directories located on the disk. No caching will be done until cache is recreated.","Purge all cached pages and relevant directories located on the disk. No caching will be done until cache is recreated."
 
 
 
 
 
 
 
 
 
 
 
63
  "Remove all cached pages","Remove all cached pages"
64
  "Remove error:","Remove error:"
 
 
65
  "Request path","Request path"
66
  "Save and Install","Save and Install"
67
  "Save configuration","Save configuration"
68
  "Select All","Select All"
69
  "Select Visible","Select Visible"
 
 
70
  "Skip blocked page: ","Skip blocked page: "
71
  "Starting download pages, please wait...","Starting download pages, please wait..."
72
- "Starts downloading of all pages (except blocked pages). Download progress can be monitored in a separate window (do not close this window). Before downloading is always automatically starts synchronization. (Downloading may take several hours. Download time depending on the number of cached pages).","Starts downloading of all pages (except blocked pages). Download progress can be monitored in a separate window (do not close this window). Before downloading is always automatically starts synchronization. (Downloading may take several hours. Download time depending on the number of cached pages)."
73
  "Status","Status"
74
  "Store View","Store View"
75
- "Sync time","Sync time"
76
  "Synchronization complete","Synchronization complete"
77
  "Synchronization error","Synchronization error"
78
- "Synchronize now","Synchronize now"
79
- "Update URLs from Rewrite Table","Update URLs from Rewrite Table"
80
- "Launchng this action will update cached URLs based on current values from the Rewrite Table. We recommend runing this action after major modifications to the products or categories.","Launchng this action will update cached URLs based on current values from the Rewrite Table. We recommend runing this action after major modifications to the products or categories."
81
- "This module require PHP ZendLoader extension","This module require PHP ZendLoader extension"
82
- "Total of %d record(s) were successfully deleted","Total of %d record(s) were successfully deleted"
83
- "Total of %d record(s) were successfully updated","Total of %d record(s) were successfully updated"
84
- "Turbo Cache Management - Downloading pages","Turbo Cache Management - Downloading pages"
85
- "Turbo Cache Management","Turbo Cache Management"
86
- "URL Synchronization","URL Synchronization"
 
 
 
 
 
 
 
87
  "Unblock","Unblock"
 
 
 
 
88
  "Unselect All","Unselect All"
89
  "Unselect Visible","Unselect Visible"
 
 
 
90
  "Url","Url"
 
 
 
 
91
  "Warning: Please don't close window during downloading pages","Warning: Please don't close window during downloading pages"
92
- "Welcome text","Welcome to M-Turbo Cache developed by Artio.
 
 
 
 
 
 
 
93
  To complete installation, we need to have entered the path to your directory where you want to store cached pages.
94
- This path is then entered into a .htaccess file, which is a function of the components necessary."
95
- "Yes","Yes"
96
- "Your base url match not with url in the licence key. This action is not available","Your base url match not with url in the licence key. This action is not available"
 
 
 
 
 
97
  "Your first options","Your first options"
98
- "Your licence code is not valid. This action is not available","Your licence code is not valid. This action is not available"
99
- "Zend loader is not configured to load encoded files.","Zend loader is not configured to load encoded files."
100
  "items selected","items selected"
101
- "DOMAIN DOES NOT MATCH","Domain does not match"
102
- "Download ID not set.","Download ID not set correctly."
103
- "ERROR_DOWNLOAD_ID_NOT_FOUND","The inserted Download ID has not been found. Please, make sure you have entered it correctly. If you are sure it is correct and valid, contact <a href=""mailto:support@artio.net"">support@artio.net</a>."
104
- "ERROR_REG_CHECK_FAIL","Check licence fail. Please, contact <a href=""mailto:support@artio.net"">support@artio.net</a>."
105
- "INFO_UPGRADE_LICENSE_EXPIRED","Your license has already expired. Please, visit <a href="http://www.artio.net/magento-extensions/m-turbo-accelerator">artio.net</a> to prolong
106
- it."
107
- "INFO_UPGRADE_NOT_ACTIVE","The license has not been activated yet. Please, retry later or contact
108
- support@artio.net."
109
- "INFO_YOU_GET_FREE_VERSION","INFO_YOU_GET_FREE_VERSION"
110
- "INFO_ENTER_DOWNLOAD_ID","INFO_ENTER_DOWNLOAD_ID"
111
- "Not activated yet","Not activated yet"
112
- "OK","OK"
1
+ " Generate a list of the URLs and store it on the disk. This action will be executed if Automatic cache management is enabled."," Generate a list of the URLs and store it on the disk. This action will be executed if Automatic cache management is enabled."
 
2
  "(hours : minutes)","(hours : minutes)"
3
  "Actions","Actions"
4
+ "Add newly created categories to select","Add newly created categories to select"
5
+ "Added newly cms to select","Added newly cms to select"
6
+ "All pages was succesfully removed","All pages were succesfully removed"
7
+ "Analyze used space","Analyze used space"
8
+ "Apply Mage Patch","Apply Mage Patch"
9
+ "Apply the patch only just in case you need to use Direct Access download method!","Apply the patch only just in case you need to use Direct Access download method!"
10
  "Are you sure?","Are you sure?"
11
  "Automatic cache management","Automatic cache management"
12
+ "Base directory","Base directory"
13
  "Block","Block"
14
+ "Blocked page can't refresh","Blocked page can't be refreshed"
15
  "Blocked","Blocked"
16
+ "CLOSE","CLOSE"
17
+ "CMS page","CMS page"
18
+ "CMS","CMS"
19
+ "CURL is not installed","CURL is not installed"
20
+ "Cache Path","Cache Path"
21
+ "Cache actions","Cache actions"
22
+ "Cache all pages","Cache all pages"
23
  "Cache selected pages","Cache selected pages"
24
  "Cache","Cache"
25
  "Cached","Cached"
26
+ "Cannot read Mage.php file","Can't read Mage.php file"
27
+ "Cannot read patch file","Can't read patch file"
28
+ "Cart Block (sidebar)","Cart Block (sidebar)"
29
  "Categories","Categories"
30
+ "Category view","Category view"
31
+ "Company","Company"
32
+ "Compare Block (sidebar)","Compare Block (sidebar)"
33
  "Configuration error","Configuration error"
34
  "Configuration was successfully saved","Configuration was successfully saved"
35
+ "Connection to server could not be established.","Connection to the server could not be established."
36
+ "Create cache for all pages (except blocked pages). Download progress can be monitored in a separate window. Please, do not close this window. Update of URLs from the Rewrite Table will be started automatically before caching is executed. Please, note that initial cache creation may take a long time (several hours). Time needed depends on the number of pages your site has.","Create cache for all pages (except blocked pages). Download progress can be monitored in a separate window. Please, do not close this window. Update of URLs from the Rewrite Table will be started automatically before caching is executed. Please, note that initial cache creation may take a long time (several hours). Time needed depends on the number of pages your site has."
37
+ "Create connection over sockets","Create connection over sockets"
38
+ "DOMAIN DOES NOT MATCH","Domain does not match"
39
+ "Date","Date"
40
  "Delete","Delete"
41
+ "Direct access (created new instance Magento)","Direct access (created new instance Magento)"
42
+ "Download ID not set.","Download ID not set."
43
+ "Download Test","Download Test"
44
+ "Download method","Download method"
45
  "Downloaded <strong>%s</strong> pages","Downloaded <strong>%s</strong> pages"
46
+ "Dynamic loaded blocks","Dynamic loaded blocks"
47
+ "ERROR_DOWNLOAD_ID_NOT_FOUND","The inserted Download ID has not been found. Please, make sure you have entered it correctly. If you are sure it is correct and valid, contact <a href=""mailto:support@artio.net"">support@artio.net</a>."
48
+ "ERROR_REG_CHECK_FAIL","Check licence fail. Please, contact <a href=""mailto:support@artio.net"">support@artio.net</a>."
49
+ "Edited by MTurbo","Edited by MTurbo"
50
  "Enable automatic cache refresh","Enable automatic cache refresh"
51
+ "Enable automatic refresh after save CMS pages","Enable automatic refresh after save CMS pages"
52
+ "Enable automatic refresh for preview of categories of saved product","Enable automatic refresh for preview of categories of saved product"
53
+ "Enable automatic refresh for preview of saved category","Enable automatic refresh for preview of saved category"
54
+ "Enable automatic refresh for previews of parents of categories of saved product","Enable automatic refresh for previews of parents of categories of saved product"
55
+ "Enable automatic refresh for previews of parents of saved category","Enable automatic refresh for previews of parents of saved category"
56
+ "Enable making htaccess backup","Enable do htaccess backup"
57
+ "Enable website","Enable website"
58
+ "Enable/Disable Storeview","Enable/Disable Storeview"
59
+ "Export to:","Export to:"
60
+ "Extension ZLIB is not loaded.","Extension ZLIB is not loaded."
61
+ "File .htaccess path","File .htaccess path"
62
+ "File .htaccess state","File .htaccess state"
63
+ "File Mage.php is not patched","File Mage.php is not patched"
64
  "Finished downloading.","Finished downloading."
65
+ "Generate URL list for all websites","Generate URL list for all websites"
66
+ "Generate URL list for this website","Generate URL list for this website"
67
  "Generate error","Generate error"
68
+ "Generating complete for website '%s'. Wrote %d urls","Generating complete for website '%s'. Wrote %d urls"
69
+ "Generating for website '%s' fail.","Generating for website '%s' fail."
70
+ "Htacces for website '%s' was rebuilded.","Htacces for website '%s' was rebuilded."
71
+ "Htaccess does not exist.","Htaccess does not exist."
72
+ "Htaccess is not writable.","Htaccess is not writable."
73
+ "Htaccess model has not assigned website","Htaccess model has not assigned website"
74
+ "Htaccess settings","Htaccess settings"
75
+ "I can't create '%s'. Please, check permission to create this directory.","I can't create '%s'. Please, check permission to create this directory."
76
+ "I can't open/create urllist file '%s'.","I can't open/create urllist file '%s'."
77
+ "I can't write to urllist file '%s'","I can't write to urllist file '%s'"
78
  "ID","ID"
79
+ "INFO_UPGRADE_LICENSE_EXPIRED","Your license has already expired. Please, visit <a href=http://www.artio.net/magento-extensions/m-turbo-accelerator"">artio.net</a> to prolong it."""
80
+ "INFO_UPGRADE_NOT_ACTIVE","The license has not been activated yet. Please, retry later or contact
81
+ support@artio.net."
82
+ "Inserting MTurbo directives fail. Htaccess template not found.","Inserting MTurbo directives fail. Htaccess template not found."
83
+ "Inserting MTurbo directives into htaccess fail.","Inserting MTurbo directives into htaccess fail."
84
  "Installation complete. Welcome!!!","Installation complete. Welcome!!!"
85
+ "Installation succesfull. Now will be your Magento faster than other.","Installation succesfull. Now will be your Magento faster than before."
 
86
  "Last refresh","Last refresh"
87
+ "Launchng this action will update cached URLs based on current values from the Rewrite Table. We recommend runing this action after major modifications to the products or categories.","Launchng this action will update cached URLs based on current values from the Rewrite Table. We recommend runing this action after major modifications to the products or categories."
88
+ "Layout names of dynamic loaded blocks","Layout names of dynamic loaded blocks"
89
+ "M-Turbo Cache Management","M-Turbo Cache Management"
90
+ "M-Turbo Management - Downloading pages","M-Turbo Management - Downloading pages"
91
+ "M-Turbo Management","M-Turbo Management"
92
+ "M-Turbo installation problem","M-Turbo installation problem"
93
+ "M-Turbo installation succesfull. Please see into System/M-Turbo Management","M-Turbo installation succesfull. Please see into System/M-Turbo Management"
94
+ "M-Turbo was uninstalled, but some directories were not deleted. These are the following files and directories: %s","M-Turbo was uninstalled, but some directories were not deleted. These are the following files and directories: %s"
95
+ "Magento MTurbo Your licence has expired. All cached pages was removed","Magento MTurbo Your licence has expired. All cached pages was removed"
96
+ "Magento MTurbo Your license has expired","Magento MTurbo Your license has expired"
97
  "Magento Turbo Cache Management","Magento Turbo Cache Management"
98
+ "Main Configuration","Main Configuration"
99
  "Menu","Menu"
100
+ "My Cart (%s item)","My Cart (%s item)"
101
+ "My Cart (%s items)","My Cart (%s items)"
102
+ "My Cart","My Cart"
103
+ "Name","Name"
104
+ "Next page","Next page"
105
  "No","No"
106
+ "Not activated yet","Not activated yet"
107
  "Not blocked","Not blocked"
108
  "Not cached","Not cached"
109
+ "OK","OK"
110
+ "Other","Other"
111
  "Page downloaded: ","Page downloaded: "
112
+ "Page was succesfull download. Now is cached.","Page was succesfull downloaded. It is cached now."
113
+ "Page was succesfull purge from disk.","Page was succesfull purged from disk."
114
+ "Page","Page"
115
+ "Patch already removed","Patch already removed"
116
+ "Patch already used","Patch already used"
117
+ "Patch was applied.","Patch was applied."
118
+ "Patch was removed.","Patch was removed."
119
+ "Path '%s' is not correct.","Path '%s' is not correct."
120
+ "Path '%s' is not usable. This path is used by system Magento, please enter other path.","Path '%s' is not usable. This path is used by system Magento, please enter other path."
121
+ "Permission denied. Cannot write to Mage.php","Permission denied. Cannot write to Mage.php"
122
  "Please select item(s)","Please select item(s)"
123
+ "Poll Block (sidebar)","Poll Block (sidebar)"
124
+ "Preview fail.","Preview fail."
125
+ "Preview","Preview"
126
+ "Previous page","Previous page"
127
  "Processed <strong>%s%% %s/%d</strong> pages","Processed <strong>%s%% %s/%d</strong> pages"
128
+ "Product detail","Product detail"
129
  "Products","Products"
 
 
130
  "Purge all cached pages and relevant directories located on the disk. No caching will be done until cache is recreated.","Purge all cached pages and relevant directories located on the disk. No caching will be done until cache is recreated."
131
+ "Purge from disk","Purge from disk"
132
+ "Purge","Purge"
133
+ "Purging page fail.","Purging page fail."
134
+ "Rebuild .htaccess for all websites","Rebuild .htaccess for all websites"
135
+ "Rebuild .htaccess for all websites.","Rebuild .htaccess for all websites."
136
+ "Rebuild .htaccess for this website","Rebuild .htaccess for this website"
137
+ "Rebuild htacces for website '%s' fail.","Rebuild htacces for website '%s' fail."
138
+ "Record was successfully updated.","Record was successfully updated."
139
+ "Registration","Registration"
140
+ "Relative path from webroot","Relative path from webroot"
141
+ "Remove Mage Patch","Remove Mage Patch"
142
  "Remove all cached pages","Remove all cached pages"
143
  "Remove error:","Remove error:"
144
+ "Removing MTurbo directives fail. Terminating MTurbo directive not found. The htaccess may be corrupted.","Removing MTurbo directives fail. Terminating MTurbo directive not found. The htaccess may be corrupted."
145
+ "Removing MTurbo directives from htaccess fail.","Removing MTurbo directives from htaccess fail."
146
  "Request path","Request path"
147
  "Save and Install","Save and Install"
148
  "Save configuration","Save configuration"
149
  "Select All","Select All"
150
  "Select Visible","Select Visible"
151
+ "Setting 'allow_url_fopen' is disabled.","Setting 'allow_url_fopen' is disabled."
152
+ "Size","Size"
153
  "Skip blocked page: ","Skip blocked page: "
154
  "Starting download pages, please wait...","Starting download pages, please wait..."
 
155
  "Status","Status"
156
  "Store View","Store View"
 
157
  "Synchronization complete","Synchronization complete"
158
  "Synchronization error","Synchronization error"
159
+ "Synchronize","Synchronize"
160
+ "The information in this tab has been changed.","The information in this tab has been changed."
161
+ "The maximum number of htaccess backups","The maximum number of htaccess backups"
162
+ "The minimum size to decision, the page is alright (bytes)","The minimum size to decision, the page is alright (bytes)"
163
+ "This action completely removes M-Turbo from your Magento","This action completely removes M-Turbo from your Magento"
164
+ "This tab contains invalid data. Please solve the problem before saving.","This tab contains invalid data. Please solve the problem before saving."
165
+ "Total %d records found","Total %d records found"
166
+ "Total of %d page(s) were successfully purged.","Total of %d page(s) were successfully purged."
167
+ "Total of %d record(s) were successfully deleted.","Total of %d record(s) were successfully deleted."
168
+ "Total of %d record(s) were successfully updated.","Total of %d record(s) were successfully updated."
169
+ "Turbopath directory","Turbopath directory"
170
+ "Two diferent websites can't have one base dir. Please check, that each website has unique base dir.","Two diferent websites can't have one base dir. Please check, that each website has unique base dir."
171
+ "Type","Type"
172
+ "Unable to retrieve the contents of htaccess.","Unable to retrieve the contents of htaccess."
173
+ "Unable to save installation file in temp directory.","Unable to save installation file in temp directory."
174
+ "Unable to unpack install package.","Unable to unpack install package."
175
  "Unblock","Unblock"
176
+ "Uninstall M-Turbo complete","Uninstall M-Turbo complete"
177
+ "Uninstall M-Turbo","Uninstall M-Turbo"
178
+ "Uninstall error","Uninstall error"
179
+ "Uninstall","Uninstall"
180
  "Unselect All","Unselect All"
181
  "Unselect Visible","Unselect Visible"
182
+ "Update URLs from Rewrite Table","Update URLs from Rewrite Table"
183
+ "Upgrade complete, please refresh Magento system cache","Upgrade complete, please refresh Magento system cache"
184
+ "Upgrade to Full Version","Upgrade to Full Version"
185
  "Url","Url"
186
+ "Using CURL PHP extensions","Using CURL PHP extensions"
187
+ "Using function 'file_get_contents'","Using function 'file_get_contents'"
188
+ "Values separated by (',').","Values separated by (',')."
189
+ "View","View"
190
  "Warning: Please don't close window during downloading pages","Warning: Please don't close window during downloading pages"
191
+ "Websites Configuration","Websites Configuration"
192
+ "Welcome text","<p>Welcome to M-Turbo Cache developed by Artio.
193
+ To complete installation, we need to have entered the path to your directory where you want to store cached pages.
194
+ This path is then entered into a .htaccess file, which is a function of the components necessary.</p><p>More, you can choose
195
+ which website you want to caches and which not. Each website you can also choose storeview.
196
+ In addition, please fill out the base directory of each website. In the default settings is set base dir for the administration,
197
+ which does must not correspond to the base dir for the frontend. (There must not exists two different websites with same base dir).</p>"
198
+ "Welcome text demo","<p>Welcome to M-Turbo Cache developed by Artio.
199
  To complete installation, we need to have entered the path to your directory where you want to store cached pages.
200
+ This path is then entered into a .htaccess file, which is a function of the components necessary.</p><p>More, you can choose
201
+ which website you want to caches and which not. Each website you can also choose storeview.
202
+ In addition, please fill out the base directory of each website. In the default settings is set base dir for the administration,
203
+ which does must not correspond to the base dir for the frontend. (There must not exists two different websites with same base dir).</p><p style="color:red">Note: In demo version you can enable only one website.</p>"
204
+ In addition, please fill out the base directory of each website. In the default settings is set base dir for the administration,
205
+ which does must not correspond to the base dir for the frontend.</p>"
206
+ "Your Download ID","Your Download ID"
207
+ "Your download ID is not valid. I can't upgrade your MTurbo.","Your download ID is not valid. I can't upgrade your MTurbo."
208
  "Your first options","Your first options"
209
+ "empty output","empty output"
 
210
  "items selected","items selected"
211
+ "of %s pages","of %s pages"
212
+ "per page","per page"
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,22 +1,26 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MTurbo</name>
4
- <version>1.1.1</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.artio.net/m-turbo/license">Copyright 2010, ARTIO s.r.o. All rights reserved.</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>MAGENTO E-COMMERCE ACCELERATOR</summary>
10
  <description>M-Turbo is a seamlessy working caching component for Magento e-store
 
11
  that provides fast response to shoppers, improves performance of the
 
12
  store and saves significant ammount of server resources. Integral part
 
13
  of Magento site optimization!</description>
14
  <notes>Visit product homepage at:
 
15
  http://www.artio.net/magento-extensions/m-turbo-accelerator</notes>
16
  <authors><author><name>Michal Unzeitig</name><user>auto-converted</user><email>michal.unzeitig@artio.net</email></author><author><name>Ji&#x159;&#xED; Chmiel</name><user>auto-converted</user><email>jiri.chmiel@artio.net</email></author></authors>
17
- <date>2010-11-05</date>
18
- <time>15:31:54</time>
19
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mturbo.xml" hash="e1e9a5dc117f392f9e2926526b9b1c56"/></dir><dir name="template"><dir name="mturbo"><dir name="preview"><file name="tree.phtml" hash="558e2da8b9c5584a94748116fd8249d0"/></dir><file name="demo.phtml" hash="509ced41c68e1ee7abca6636d24cac0f"/><file name="massaction.phtml" hash="c4ca58cbd05d564129d3c39d452c783e"/><file name="tabs.phtml" hash="1015f2e05a41bb7751b11036e48cbd9f"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Artio"><dir name="MTurbo"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><dir name="Tab"><file name="Abstract.php" hash="16a37f270112b175796bb5af02eea84d"/><file name="Actions.php" hash="8e60e7c2ef8996fc1486e5b6e0fcce16"/><file name="Category.php" hash="c3ead1f2e3c4456ae506bc412cb7a4d6"/><file name="License.php" hash="554adc83dd6d0c69f65a674c30c0e49f"/><file name="Main.php" hash="4219a12abbf78ee3015126792a84480d"/><file name="Product.php" hash="2458da4035912d8345f479583fd161bd"/><file name="Url.php" hash="81f49156c0f08b244235d715f2fe7b4f"/></dir><file name="Form.php" hash="e3694987ff374e400703f188e391e351"/><file name="Tabs.php" hash="282cb5ff643fa61480994e3f72856f36"/></dir><dir name="Welcome"><file name="Form.php" hash="47eaeb2094670dd783ff2027794c6bb6"/></dir><file name="Mturbo.php" hash="3abfef293f93f669cf38b0efc076721f"/><file name="Run.php" hash="a88befc34123fb04ebf74041ca763338"/><file name="Welcome.php" hash="30b0b1882eff25371e8d1bf4ee0bf880"/></dir><dir name="Data"><dir name="Form"><dir name="Element"><file name="Button.php" hash="0317d74c9856481c8e2ccfdff5f7ff20"/><file name="CategoryTree.php" hash="0294437ea2c2b7f92414b945061b12ee"/><file name="NoEscLabel.php" hash="d10b4e82853916eccba7989a3d272660"/><file name="SelectDownloadMethod.php" hash="f9a816189f98787120d8e7340b78e102"/><file name="Time.php" hash="5b7f93a35b2463a0215c8ae566cc5bd9"/></dir></dir><dir name="Grid"><dir name="Column"><file name="Blocked.php" hash="4941dcafb09b4eb502d3eabfd3f73dc4"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CheckController.php" hash="6b62cfd1cbb8d9713eb64abe553b10b8"/><file name="MturboController.php" hash="cce26b19b4779be3053b781a5466a5a0"/></dir><file name="AdminhtmlController.php" hash="3ec6e0b5eed5a3e93259b8d7a0eb4003"/></dir><dir name="etc"><file name="config.xml" hash="7f9b1b8a4133ba0d66543d6f0c6ff1f6"/></dir><dir name="Helper"><file name="Checker.php" hash="164bb3cb86eb68b3b1969dd92824735f"/><file name="Data.php" hash="f63bdc034ae79c5473ef66e0f5712c07"/><file name="Downloader.php" hash="1f5c4798e38b13e36452b45aeea124eb"/><file name="Info.php" hash="b2f804ce14c86097d57e3ce7b15e8187"/></dir><dir name="Model"><dir name="htaccess"><file name="htaccess.txt" hash="b37433b41cf37e325f2ade4e7839261a"/><file name="htaccessroot.txt" hash="7d55f4bb772128b1f8783b319344d17c"/></dir><dir name="Mysql4"><dir name="Mturbo"><file name="Collection.php" hash="905f9728ed7a8c9d901f3f55c3e9a7d7"/></dir><file name="Mturbo.php" hash="e81f8f1801eca956229a068d0bdea2ab"/></dir><dir name="patches"><file name="mage.txt" hash="0e2ef3ed32b7041f518f162745812023"/></dir><dir name="scripts"><file name="wgetlib.so" hash="f166fd66565116adadca8e558d1430b7"/><file name="wgettrans.so" hash="e4f414b0f796051518b6d951133c856b"/></dir><file name="Config.php" hash="112b173a6d13f37cb463ec0e48abcd3a"/><file name="File.php" hash="30c7703f65824523ed3c803cc6d57f5a"/><file name="File.php~" hash="98a04470cad3dcc993273f1824192e0e"/><file name="Mturbo.php" hash="4022660e4aec01a436c6d5bc498c088c"/><file name="Mturbo.php~" hash="6701ca232eca2087ce82a05e0a918066"/><file name="Observer.php" hash="1a53243dd2b292181a86c26736ad9004"/><file name="Observer2.php" hash="de554c2515d5cdefbaa2375a5389f7f8"/></dir><dir name="sql"><dir name="mturbo_setup"><file name="mysql4-install-1.0.0.php" hash="cdd6c7ca28d1e6471744b03ffbd8527e"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Artio_MTurbo.csv" hash="37ce492d01d06c14e5f0991a6d60b375"/></dir></target><target name="mageetc"><dir name="modules"><file name="Artio_MTurbo.xml" hash="4de5464bc12f3c0702d2c36931bda64d"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies/>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MTurbo</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.artio.net/m-turbo/license">Copyright 2010-2011, ARTIO s.r.o. All rights reserved.</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>MAGENTO E-COMMERCE ACCELERATOR</summary>
10
  <description>M-Turbo is a seamlessy working caching component for Magento e-store
11
+
12
  that provides fast response to shoppers, improves performance of the
13
+
14
  store and saves significant ammount of server resources. Integral part
15
+
16
  of Magento site optimization!</description>
17
  <notes>Visit product homepage at:
18
+
19
  http://www.artio.net/magento-extensions/m-turbo-accelerator</notes>
20
  <authors><author><name>Michal Unzeitig</name><user>auto-converted</user><email>michal.unzeitig@artio.net</email></author><author><name>Ji&#x159;&#xED; Chmiel</name><user>auto-converted</user><email>jiri.chmiel@artio.net</email></author></authors>
21
+ <date>2011-02-07</date>
22
+ <time>17:20:52</time>
23
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mturbo.xml" hash="6e20ef84ceeac5a82dc7c7ce6897f12d"/></dir><dir name="template"><dir name="mturbo"><dir name="preview"><file name="tree.phtml" hash="558e2da8b9c5584a94748116fd8249d0"/></dir><file name="demo.phtml" hash="da2b65990f1221d981b1c850f292dae6"/><file name="grid.phtml" hash="f11cea678bbc7230028cf5a870479ac8"/><file name="massaction.phtml" hash="c4ca58cbd05d564129d3c39d452c783e"/><file name="tabs.phtml" hash="1015f2e05a41bb7751b11036e48cbd9f"/><file name="version.phtml" hash="3f7c9b1d76d9f92050fde76c1f869fb4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="mturbo.xml" hash="679c071acb59fa8a28251acd25738a9b"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="Artio"><dir name="MTurbo"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><dir name="Tab"><file name="Abstract.php" hash="16a37f270112b175796bb5af02eea84d"/><file name="Actions.php" hash="913ea3d61f3d51ebce4a0a5952535a35"/><file name="Category.php" hash="3eb3d4924ab7d4e7978198d8caf31a30"/><file name="Cms.php" hash="cee56f9271b29ff645e84105c831fd6c"/><file name="Dynamic.php" hash="f4cbca97c122bf1a93b22bfdaa884c3f"/><file name="License.php" hash="3c405988f5bfc0581b5a7fe1b6204055"/><file name="Main.php" hash="db7d92e60c308a12ef772e9a0de7c7c7"/><file name="Product.php" hash="38d4025873e1e25c4d9289da20178096"/><file name="Uninstall.php" hash="fde35018cd407e8dd2cc7d91b4aafa3a"/><file name="Url.php" hash="f2366956b47613a036aefdb01494cb16"/><file name="Website.php" hash="e5e6b9b77d3b8bc7a5c42d4d10635351"/></dir><file name="Form.php" hash="9ba7b56533f6c7f8f8b3a6e1a71fe6ad"/><file name="Tabs.php" hash="a82341a6c981ba91b69774c81a7ad28e"/></dir><dir name="Welcome"><file name="Form.php" hash="3e9c5ccb67023327ea5c2d893cb82dd1"/></dir><file name="Mturbo.php" hash="4c6758e028e608ce93847a55a1ce27e1"/><file name="Run.php" hash="e6ff24da20d057de3b1e7147a209b395"/><file name="Welcome.php" hash="5acab4515cf35c30bf182eb0529855ad"/></dir><dir name="Data"><dir name="Form"><dir name="Element"><file name="Button.php" hash="c61ec7e27c62364c21e6d893f875ad93"/><file name="CategoryTree.php" hash="128d2bd67969552bb3f413975fc6313a"/><file name="CmsTree.php" hash="db33490dd6b51e596309ef4e96baf55e"/><file name="Html.php" hash="83a40987e47c142e6be58f311d29276d"/><file name="NoEscLabel.php" hash="1ce0fca5efc5e6afcbb96cf818ff7fef"/><file name="SelectDownloadMethod.php" hash="ca4b9117ecc129a08c08f810bed063d5"/><file name="Time.php" hash="c6617317308bd74c9714ccee2ac870bb"/></dir></dir><dir name="Grid"><dir name="Column"><file name="Blocked.php" hash="4e6c21fee2c3d8fc26198471ef79b041"/><file name="ColorOption.php" hash="9efec8edc0a724b1840acfee3333bcc1"/><file name="FileSize.php" hash="b01fca106ea04f0a32d5ead838dd7446"/><file name="SwitchAction.php" hash="35b90030144a8b42d9696f5be0694a20"/></dir></dir></dir><file name="Ajax.php" hash="3cf0bebbf933f7786f3e39c5e482c260"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CheckController.php" hash="78c05c96f294f009f35dc8b88537162c"/><file name="MturboController.php" hash="9f4fd9784444074a8fbadd7dcea9cdd3"/></dir><file name="AdminhtmlController.php" hash="cb9981505f756dd9658b44b93b07e57c"/><file name="IndexController.php" hash="01d2430a8a2d52764a67efb71058171d"/></dir><dir name="etc"><file name="config.xml" hash="9b59ace7a00664a11f4ecf5d02f8e981"/></dir><dir name="Helper"><file name="Data.php" hash="06a52dc94771ccc3a680ac220140d4f0"/><file name="Downloader.php" hash="16d34956e7b85f5e34ec18f02b8e13f4"/><file name="Functions.php" hash="6020d64b22824e2fca93eea6dd44c693"/><file name="Info.php" hash="24d92981d5c7adcc22f10761341c34d0"/><file name="Website.php" hash="933c17cff1253ef2084313c2a2d62fcc"/></dir><dir name="Model"><dir name="Config"><file name="CmsTransformer.php" hash="a5fca7b305322112e5bddd247ec20074"/><file name="DynamicTransformer.php" hash="c7a66182ebd4dfb3b0a123b3f3dbbddf"/><file name="Website.php" hash="c9207be6f07586f21a03f0da4632071b"/><file name="WebsiteTransformer.php" hash="0fad70e7e599158077d22cd04eab672f"/></dir><dir name="DownloadMethods"><file name="Abstract.php" hash="ddac44cb6f0548c0cd303bb1fa3e3e1b"/><file name="Curl.php" hash="cdcd9d20402af9e2a8f5e1a3f713404b"/><file name="Direct.php" hash="980a50b03c9f91e4e896d5757c80c555"/><file name="Filegetcontents.php" hash="9c6c97fc34ea57cd8479cc042a990990"/><file name="Socket.php" hash="7db1aeb2142f400847f4684e2a2b35a2"/></dir><dir name="htaccess"><file name="htaccess.txt" hash="15c1175c5f50f16c5952f4ab3284f760"/><file name="htaccessside.txt" hash="7d55f4bb772128b1f8783b319344d17c"/><file name="htaccessstore.txt" hash="e164a63253fb16c48ce62d2c43ba2568"/></dir><dir name="Mturbo"><file name="Event.php" hash="d131a0f0d34370619fe3114a94940819"/><file name="File.php" hash="d8669da2bf626caa24b793b6335cd406"/></dir><dir name="Mysql4"><dir name="Mturbo"><file name="Collection.php" hash="c8e06d986966455cd28b37a93b78a23d"/></dir><file name="Mturbo.php" hash="17a258f73ea138481a5727e7b9d383fc"/></dir><dir name="patches"><file name="layout.txt" hash="4d0055e6119d297fd78deb4c576ae9f0"/><file name="mage.txt" hash="0e2ef3ed32b7041f518f162745812023"/></dir><dir name="scripts"><file name="wgetlib.so" hash="53b4a2b9009c126d68bc446f4356919c"/><file name="wgettrans.so" hash="e4f414b0f796051518b6d951133c856b"/></dir><file name="Config.php" hash="1aa8e81b4c7289c561aa150426c29357"/><file name="DownloadMethodsFactory.php" hash="1bd5932612148116ee745c6bec68edaa"/><file name="Htaccess.php" hash="5991e3d4fc511272ffe26d4cfd470f27"/><file name="LayoutPatch.php" hash="51d2f43775f295d8c2e002a65415321f"/><file name="Mturbo.php" hash="08f738e50519a807f32b5cff15117acb"/><file name="Observer.php" hash="474a292f0fca5ee953bbefdbaa252266"/><file name="Patch.php" hash="213b25c08f2a8a02fd574abbb3f30826"/></dir><dir name="sql"><dir name="mturbo_setup"><file name="mysql4-install-1.2.0.php" hash="f0ac4560593928412d09a4ecdb02e238"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Artio_MTurbo.csv" hash="78978bfc2c13750439d770b994163d92"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="js"><file name="mturbo.js" hash="e68a8592fe57d400448c5cb9eab54bd6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Artio_MTurbo.xml" hash="4de5464bc12f3c0702d2c36931bda64d"/></dir></target></contents>
24
  <compatible/>
25
  <dependencies/>
26
  </package>
skin/frontend/default/default/js/mturbo.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var mturboloader = {
2
+
3
+ url: '',
4
+ blocks: '',
5
+ complete: false,
6
+ cartLink: false,
7
+ blocksContents: new Array(),
8
+
9
+ addBlockRequest: function(blockIdentifier) {
10
+ if (mturboloader.blocks=='') {
11
+ mturboloader.blocks = 'identifier[]=' + blockIdentifier;
12
+ } else {
13
+ mturboloader.blocks = mturboloader.blocks + '&identifier[]=' + blockIdentifier;
14
+ }
15
+ },
16
+
17
+ getBlock: function (blockIdentifier) {
18
+ return mturboloader.blocksContents[blockIdentifier].replace(/&amp;MTURBO!/g, "&");
19
+ },
20
+
21
+ loadBlocks: function(url) {
22
+ url = url+'?'+this.blocks;
23
+ new Ajax.Request(url, {
24
+ method: "get",
25
+ onSuccess:
26
+ function(transport) {
27
+
28
+ if (window.DOMParser) {
29
+ parser=new DOMParser();
30
+ xmlDoc=parser.parseFromString(transport.responseText, "text/xml");
31
+ }
32
+ else // Internet Explorer
33
+ {
34
+ xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
35
+ xmlDoc.async="false";
36
+ xmlDoc.loadXML(transport.responseText);
37
+ }
38
+
39
+ var i;
40
+ var blocks = xmlDoc.childNodes[0].childNodes;
41
+ for (i=0; i<blocks.length; i++) {
42
+
43
+ var name = blocks[i].getAttribute('name');
44
+ if (name!='') {
45
+ try {
46
+
47
+ // Gecko-based browsers, Safari, Opera.
48
+ mturboloader.blocksContents[name] = (new XMLSerializer()).serializeToString(blocks[i]);
49
+ }
50
+ catch (e) {
51
+ try {
52
+ // Internet Explorer
53
+ mturboloader.blocksContents[name] = blocks[i].xml;
54
+ }
55
+ catch (e)
56
+ {}
57
+ }
58
+ }
59
+ }
60
+
61
+ mturboloader.complete = true;
62
+ setTimeout('updateCartLink()', 100);
63
+ }
64
+ });
65
+ }
66
+
67
+ }
68
+ function updateCartLink() {
69
+ var re = new RegExp('checkout/cart/$');
70
+ var links = document.getElementsByTagName('a');
71
+ for (var i=0; i<links.length; i++) {
72
+ if (re.exec(links[i].href)) {
73
+ if (mturboloader.blocksContents['cartlink'])
74
+ links[i].innerHTML = mturboloader.blocksContents['cartlink'];
75
+ else {
76
+ setTimeout('updateCartLink()', 100);
77
+ return;
78
+ }
79
+ }
80
+ }
81
+ }