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


Version 1.0

Files changed (46) hide show
  1. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Form.php +51 -0
  2. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Abstract.php +102 -0
  3. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Actions.php +93 -0
  4. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Category.php +71 -0
  5. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/License.php +125 -0
  6. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Main.php +138 -0
  7. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Product.php +40 -0
  8. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Url.php +251 -0
  9. app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tabs.php +63 -0
  10. app/code/local/Artio/MTurbo/Block/Adminhtml/Mturbo.php +64 -0
  11. app/code/local/Artio/MTurbo/Block/Adminhtml/Run.php +296 -0
  12. app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome.php +57 -0
  13. app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php +105 -0
  14. app/code/local/Artio/MTurbo/Block/Data/Form/Element/Button.php +71 -0
  15. app/code/local/Artio/MTurbo/Block/Data/Form/Element/CategoryTree.php +89 -0
  16. app/code/local/Artio/MTurbo/Block/Data/Form/Element/NoEscLabel.php +51 -0
  17. app/code/local/Artio/MTurbo/Block/Data/Form/Element/Time.php +84 -0
  18. app/code/local/Artio/MTurbo/Block/Data/Grid/Column/Blocked.php +59 -0
  19. app/code/local/Artio/MTurbo/Helper/Checker.php +87 -0
  20. app/code/local/Artio/MTurbo/Helper/Data.php +163 -0
  21. app/code/local/Artio/MTurbo/Helper/Downloader.php +113 -0
  22. app/code/local/Artio/MTurbo/Helper/Info.php +121 -0
  23. app/code/local/Artio/MTurbo/Model/Config.php +595 -0
  24. app/code/local/Artio/MTurbo/Model/File.php +255 -0
  25. app/code/local/Artio/MTurbo/Model/Mturbo.php +357 -0
  26. app/code/local/Artio/MTurbo/Model/Mysql4/Mturbo.php +33 -0
  27. app/code/local/Artio/MTurbo/Model/Mysql4/Mturbo/Collection.php +33 -0
  28. app/code/local/Artio/MTurbo/Model/Observer.php +156 -0
  29. app/code/local/Artio/MTurbo/Model/Observer2.php +225 -0
  30. app/code/local/Artio/MTurbo/Model/htaccess/htaccess.txt +32 -0
  31. app/code/local/Artio/MTurbo/Model/htaccess/htaccessroot.txt +2 -0
  32. app/code/local/Artio/MTurbo/Model/scripts/wgetlib.so +1 -0
  33. app/code/local/Artio/MTurbo/Model/scripts/wgettrans.so +1 -0
  34. app/code/local/Artio/MTurbo/controllers/Adminhtml/CheckController.php +47 -0
  35. app/code/local/Artio/MTurbo/controllers/Adminhtml/MturboController.php +415 -0
  36. app/code/local/Artio/MTurbo/controllers/AdminhtmlController.php +64 -0
  37. app/code/local/Artio/MTurbo/etc/config.xml +181 -0
  38. app/code/local/Artio/MTurbo/sql/mturbo_setup/mysql4-install-0.1.0.php +76 -0
  39. app/design/adminhtml/default/default/layout/mturbo.xml +39 -0
  40. app/design/adminhtml/default/default/template/mturbo/demo.phtml +44 -0
  41. app/design/adminhtml/default/default/template/mturbo/massaction.phtml +80 -0
  42. app/design/adminhtml/default/default/template/mturbo/preview/tree.phtml +227 -0
  43. app/design/adminhtml/default/default/template/mturbo/tabs.phtml +45 -0
  44. app/etc/modules/Artio_MTurbo.xml +9 -0
  45. app/locale/en_US/Artio_MTurbo.csv +112 -0
  46. package.xml +22 -0
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Form.php ADDED
@@ -0,0 +1,51 @@
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
+ /**
29
+ * Adminhtml cms block edit form
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
+ {
37
+
38
+ protected function _prepareForm() {
39
+ $form = new Varien_Data_Form(array('name'=>'edit_form', 'id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
40
+ $form->setUseContainer(true);
41
+
42
+ $form->addField('activeTab', 'hidden', array(
43
+ 'name' => 'activeTab',
44
+ 'id' => 'activeTab',
45
+ 'value' => ''
46
+ ));
47
+
48
+ $this->setForm($form);
49
+ return parent::_prepareForm();
50
+ }
51
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Abstract.php ADDED
@@ -0,0 +1,102 @@
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
+ *
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Artio Magento Team <info@artio.net>
33
+ */
34
+
35
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
36
+ extends Mage_Adminhtml_Block_Widget_Form
37
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
38
+ {
39
+
40
+ /**
41
+ * @var Artio_MTurbo_Helper_Data
42
+ */
43
+ private static $helper = null;
44
+
45
+ /**
46
+ * @var string
47
+ */
48
+ protected $_title;
49
+
50
+ public function __construct() {
51
+ parent::__construct();
52
+ if (empty(self::$helper)) self::$helper = Mage::helper('mturbo');
53
+ }
54
+
55
+ /**
56
+ * @return Artio_MTurbo_Helper_Data
57
+ */
58
+ public static function getMyHelper() {
59
+ return self::$helper;
60
+ }
61
+
62
+ /**
63
+ * Prepare label for tab
64
+ *
65
+ * @return string
66
+ */
67
+ public function getTabLabel()
68
+ {
69
+ return $this->_title;
70
+ }
71
+
72
+ /**
73
+ * Prepare title for tab
74
+ *
75
+ * @return string
76
+ */
77
+ public function getTabTitle()
78
+ {
79
+ return $this->_title;
80
+ }
81
+
82
+ /**
83
+ * Returns status flag about this tab can be shown or not
84
+ *
85
+ * @return true
86
+ */
87
+ public function canShowTab()
88
+ {
89
+ return true;
90
+ }
91
+
92
+ /**
93
+ * Returns status flag about this tab hidden or not
94
+ *
95
+ * @return true
96
+ */
97
+ public function isHidden()
98
+ {
99
+ return false;
100
+ }
101
+
102
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Actions.php ADDED
@@ -0,0 +1,93 @@
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_Actions 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()->__('Actions');
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('action_fieldset', array(
57
+ 'legend' => $this->getMyHelper()->__('Cache actions'),
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()->__('Remove all cached pages'),
65
+ 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/clearpages') . "')",
66
+ 'comment' => $this->getMyHelper()->__('Purge all cached pages and relevant directories located on the disk. No caching will be done until cache is recreated.')
67
+ ));
68
+
69
+ $layoutFieldset->addField('syn_button', 'widget_button', array(
70
+ 'name' => 'syn_button',
71
+ 'label' => $this->getMyHelper()->__('Update URLs from Rewrite Table'),
72
+ 'onclick' => "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/synchronize') . "')",
73
+ 'comment' => $this->getMyHelper()->__('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.')
74
+ ));
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
+ ));
82
+
83
+ $layoutFieldset->addField('download_button', 'widget_button', array(
84
+ 'name' => 'download_button',
85
+ 'label' => $this->getMyHelper()->__('Cache all pages'),
86
+ 'onclick' => "window.open('" . Mage::helper('adminhtml')->getUrl('*/*/download') . "')",
87
+ 'comment' => $this->getMyHelper()->__('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.')
88
+
89
+ ));
90
+
91
+ }
92
+
93
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Category.php ADDED
@@ -0,0 +1,71 @@
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
+ *
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Artio Magento Team <info@artio.net>
33
+ */
34
+
35
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Category extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
36
+ {
37
+
38
+ public function __construct() {
39
+ parent::__construct();
40
+ $this->setId('category_section');
41
+ $this->_title = $this->getMyHelper()->__('Categories');
42
+ }
43
+
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();
69
+ }
70
+
71
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/License.php ADDED
@@ -0,0 +1,125 @@
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_License extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
27
+ {
28
+
29
+ /**
30
+ * @var Varien_Data_Form
31
+ */
32
+ private $form;
33
+ private $regInfo;
34
+
35
+ public function __construct() {
36
+ parent::__construct();
37
+ $this->setId('license_section');
38
+ $this->_title = $this->getMyHelper()->__('Registration');
39
+ $this->regInfo = Mage::helper('mturbo/info')->getRegInfo();
40
+ }
41
+
42
+ protected function _prepareForm() {
43
+
44
+ $config = Mage::getSingleton('mturbo/config');
45
+ if (!empty($this->regInfo)) {
46
+ $data = array_merge($config->getData(), get_object_vars($this->regInfo));
47
+ }
48
+
49
+ $this->form = new Varien_Data_Form();
50
+ $this->_addLicenseFieldset();
51
+
52
+ $this->form->setValues($data);
53
+ $this->setForm($this->form);
54
+
55
+ return parent::_prepareForm();
56
+
57
+ }
58
+
59
+ private function _addLicenseFieldset() {
60
+
61
+ $layoutFieldset = $this->form->addFieldset('license_fieldset', array(
62
+ 'legend' => $this->getMyHelper()->__('Registration'),
63
+ 'class' => 'fieldset'
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
+ ));
72
+
73
+
74
+ if ($this->regInfo != null) {
75
+
76
+ if (!empty($this->regInfo->name))
77
+ $layoutFieldset->addField('name', 'label', array(
78
+ 'name' => 'name',
79
+ 'label' => $this->getMyHelper()->__('Name').':',
80
+ 'style' => 'height:24em;',
81
+ 'disabled' => true,
82
+ ));
83
+
84
+ if (!empty($this->regInfo->company))
85
+ $layoutFieldset->addField('company', 'label', array(
86
+ 'name' => 'company',
87
+ 'label' => $this->getMyHelper()->__('Company').':',
88
+ 'style' => 'height:24em;',
89
+ 'disabled' => true,
90
+ ));
91
+
92
+ if (!empty($this->regInfo->date))
93
+ $layoutFieldset->addField('date', 'label', array(
94
+ 'name' => 'date',
95
+ 'label' => $this->getMyHelper()->__('Date').':',
96
+ 'style' => 'height:24em;',
97
+ 'disabled' => true,
98
+ 'value' => 'x'
99
+ ));
100
+
101
+ if (!empty($this->regInfo->message)) {
102
+ $layoutFieldset->addField('message', 'noesclabel', array(
103
+ 'name' => 'message',
104
+ 'label' => $this->getMyHelper()->__('Status').':',
105
+ 'bold' => true,
106
+ 'disabled' => true
107
+ ));
108
+ }
109
+
110
+ } else {
111
+
112
+ $layoutFieldset->addField('message', 'noesclabel', array(
113
+ 'name' => 'message',
114
+ 'label' => $this->getMyHelper()->__('Status').':',
115
+ 'style' => 'height:24em;',
116
+ 'bold' => true,
117
+ 'disabled' => true,
118
+ ));
119
+
120
+ }
121
+
122
+ }
123
+
124
+
125
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Main.php ADDED
@@ -0,0 +1,138 @@
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_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();
48
+
49
+ $this->form->setValues($config->getData());
50
+ $this->setForm($this->form);
51
+
52
+ return parent::_prepareForm();
53
+
54
+ }
55
+
56
+ private function _addGeneralFieldset() {
57
+
58
+ $layoutFieldset = $this->form->addFieldset('general_fieldset', array(
59
+ 'legend' => $this->getMyHelper()->__('General Options'),
60
+ 'class' => 'fieldset'
61
+ ));
62
+
63
+ $layoutFieldset->addField('turbopath', 'text', array(
64
+ 'name' => 'turbopath',
65
+ 'label' => $this->getMyHelper()->__('Cache Path').':',
66
+ 'value' => 'var/turbocache'
67
+ ));
68
+
69
+ $layoutFieldset->addField('multistoreview', 'select', array(
70
+ 'name' => 'multistoreview',
71
+ 'label' => $this->getMyHelper()->__('Enable multi-storeview').':',
72
+ 'options' => array(
73
+ 0 => $this->getMyHelper()->__('No'),
74
+ 1 => $this->getMyHelper()->__('Yes'))
75
+ ));
76
+
77
+ $layoutFieldset->addField('refreshsave', 'select', array(
78
+ 'name' => 'refreshsave',
79
+ 'label' => $this->getMyHelper()->__('Refresh cache after product or category save').':',
80
+ 'options' => array(
81
+ 0 => $this->getMyHelper()->__('No'),
82
+ 1 => $this->getMyHelper()->__('Yes'))
83
+ ));
84
+
85
+ }
86
+
87
+ private function _addAutomaticDownloadFieldset() {
88
+
89
+ $layoutFieldset = $this->form->addFieldset('download_fieldset', array(
90
+ 'legend' => $this->getMyHelper()->__('Automatic cache management'),
91
+ 'class' => 'fieldset'
92
+ ));
93
+
94
+ $layoutFieldset->addField('automaticdownload', 'select', array(
95
+ 'name' => 'automaticdownload',
96
+ 'label' => $this->getMyHelper()->__('Enable automatic cache refresh').':',
97
+ 'options' => array(
98
+ 0 => $this->getMyHelper()->__('No'),
99
+ 1 => $this->getMyHelper()->__('Yes'))
100
+ ));
101
+
102
+ $layoutFieldset->addType('crontime', Artio_MTurbo_Helper_Data::FORM_CRON_HOUR_TIME);
103
+ $layoutFieldset->addField('downloadtime', 'crontime', array(
104
+ 'name' => 'downloadtime',
105
+ 'label' => $this->getMyHelper()->__('Download time').':',
106
+ 'style' => 'display:inline;width:40px;'
107
+ ));
108
+
109
+ $layoutFieldset->addField('lastdownload', 'label', array(
110
+ 'name' => 'lastdownload',
111
+ 'label' => $this->getMyHelper()->__('Last downlaod').':',
112
+ 'style' => 'height:24em;',
113
+ 'disabled' => true
114
+ ));
115
+
116
+
117
+
118
+ }
119
+
120
+
121
+ private function _addHomepageFieldset() {
122
+
123
+ $layoutFieldset = $this->form->addFieldset('homepage_fieldset', array(
124
+ 'legend' => $this->getMyHelper()->__('Homepage Cache Options'),
125
+ 'class' => 'fieldset'
126
+ ));
127
+
128
+ $layoutFieldset->addField('homepage', 'select', array(
129
+ 'name' => 'homepage',
130
+ 'label' => $this->getMyHelper()->__('Cache homepage').':',
131
+ 'options' => array(
132
+ 0 => $this->getMyHelper()->__('No'),
133
+ 1 => $this->getMyHelper()->__('Yes'))
134
+ ));
135
+
136
+ }
137
+
138
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Product.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
+ * 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_Product
36
+ extends Artio_MTurbo_Block_Adminhtml_Edit_Tab_Abstract
37
+ {
38
+
39
+
40
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Url.php ADDED
@@ -0,0 +1,251 @@
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_Url
36
+ extends Mage_Adminhtml_Block_Widget_Grid
37
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
38
+ {
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setId('url_section');
43
+ $this->setDefaultSort('mturbo_id');
44
+ $this->setDefaultDir('ASC');
45
+ $this->setSaveParametersInSession(true);
46
+ }
47
+
48
+ protected function _prepareCollection() {
49
+
50
+ $collection = Mage::getModel('mturbo/mturbo')->getCollection();
51
+ $this->setCollection($collection);
52
+
53
+ return parent::_prepareCollection();
54
+
55
+ }
56
+
57
+ protected function _afterLoadCollection() {
58
+
59
+ foreach ($this->getCollection() as $model) {
60
+ $model->checkExist();
61
+ }
62
+
63
+ }
64
+
65
+ protected function _prepareColumns() {
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'),
86
+ 'align' =>'left',
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
+
104
+ $this->addColumn('last_refresh', array(
105
+ 'header' => Mage::helper('mturbo')->__('Last refresh'),
106
+ 'align' =>'left',
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(),
120
+ 'options' => array(
121
+ 0 => Mage::helper('mturbo')->__('Not blocked'),
122
+ 1 => Mage::helper('mturbo')->__('Blocked')
123
+ ),
124
+ ));
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
+ ),
141
+ 'filter' => false,
142
+ 'sortable' => false,
143
+ ));
144
+
145
+ return parent::_prepareColumns();
146
+ }
147
+
148
+ protected function _prepareMassaction() {
149
+
150
+ $this->setMassactionIdField('mturbo_id');
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'),
161
+ 'url' => $this->getUrl('*/*/massBlock')
162
+ ));
163
+
164
+ $this->getMassactionBlock()->addItem('unblock', array(
165
+ 'label' => Mage::helper('mturbo')->__('Unblock'),
166
+ 'url' => $this->getUrl('*/*/massUnblock')
167
+ ));
168
+
169
+ $this->getMassactionBlock()->addItem('delete', array(
170
+ 'label' => Mage::helper('mturbo')->__('Delete'),
171
+ 'url' => $this->getUrl('*/*/massDelete'),
172
+ 'confirm' => Mage::helper('mturbo')->__('Are you sure?')
173
+ ));
174
+
175
+ return $this;
176
+ }
177
+
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')."';
200
+ this.form.submit();
201
+ this.form.target='_self';
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
213
+ *
214
+ * @return string
215
+ */
216
+ public function getTabLabel()
217
+ {
218
+ return Mage::helper('mturbo')->__('Url');
219
+ }
220
+
221
+ /**
222
+ * Prepare title for tab
223
+ *
224
+ * @return string
225
+ */
226
+ public function getTabTitle()
227
+ {
228
+ return Mage::helper('mturbo')->__('Url');
229
+ }
230
+
231
+ /**
232
+ * Returns status flag about this tab can be shown or not
233
+ *
234
+ * @return true
235
+ */
236
+ public function canShowTab()
237
+ {
238
+ return true;
239
+ }
240
+
241
+ /**
242
+ * Returns status flag about this tab hidden or not
243
+ *
244
+ * @return true
245
+ */
246
+ public function isHidden()
247
+ {
248
+ return false;
249
+ }
250
+
251
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tabs.php ADDED
@@ -0,0 +1,63 @@
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
+ * Admin page left menu
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Artio Magento Team <info@artio.net>
33
+ */
34
+ class Artio_MTurbo_Block_Adminhtml_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+
37
+ private $activeTab = '';
38
+
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setId('page_tabs');
43
+ $this->setDestElementId('edit_form');
44
+ $this->setTitle(Mage::helper('mturbo')->__('Menu'));
45
+
46
+ $request = Mage::getModel('core/url')->getRequest();
47
+ $this->activeTab = $request->getParam('activeTab');
48
+
49
+ $formKey = $request->getParam('form_key');
50
+ if (!empty($formKey)) $this->activeTab = '';
51
+
52
+ }
53
+
54
+ public function addTab($tabId, $tab) {
55
+ parent::addTab($tabId, $tab);
56
+
57
+ if ($this->getId().'_'.$tabId == $this->activeTab) {
58
+ $this->setActiveTab($tabId);
59
+ }
60
+
61
+ }
62
+
63
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Mturbo.php ADDED
@@ -0,0 +1,64 @@
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_MTurbo extends Mage_Adminhtml_Block_Widget_Form_Container
27
+ {
28
+
29
+ public function __construct()
30
+ {
31
+ $this->_objectId = 'page_id';
32
+ $this->_blockGroup = 'mturbo';
33
+ $this->_controller = 'adminhtml';
34
+
35
+ parent::__construct();
36
+
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
+ /**
47
+ * Retrieve text for header element depending on loaded page
48
+ *
49
+ * @return string
50
+ */
51
+ public function getHeaderText() {
52
+ return Mage::helper('mturbo')->__('M-Turbo Cache Management');
53
+ }
54
+
55
+ /**
56
+ * Check permission for passed action
57
+ *
58
+ * @param string $action
59
+ * @return bool
60
+ */
61
+ protected function _isAllowedAction($action) {
62
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
63
+ }
64
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Run.php ADDED
@@ -0,0 +1,296 @@
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_Run extends Mage_Adminhtml_Block_Abstract
27
+ {
28
+
29
+ private $_importIds;
30
+
31
+ public function setImportIds($importIds) {
32
+ $this->_importIds = (is_array($importIds)) ? $importIds : explode(",", $importIds);
33
+ return $this;
34
+ }
35
+
36
+ public function isSetImportIds() {
37
+ return (!empty($this->_importIds));
38
+ }
39
+
40
+ public function getImportIds() {
41
+ return $this->_importIds;
42
+ }
43
+
44
+ protected function _toHtml() {
45
+
46
+ //$profile = $this->getProfile();
47
+
48
+ echo '<html>';
49
+
50
+ echo '<head>';
51
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
52
+ echo '<script type="text/javascript">var FORM_KEY = "'.Mage::getSingleton('core/session')->getFormKey().'";</script>';
53
+ echo $this->_getCssJsHtml();
54
+ echo '<title>'.Mage::helper('mturbo')->__('Turbo Cache Management - Downloading pages').'</title>';
55
+ echo '</head>';
56
+
57
+ echo '<body>';
58
+
59
+
60
+
61
+ echo '<ul>';
62
+ echo '<li>';
63
+ echo '<img src="'.Mage::getDesign()->getSkinUrl('images/note_msg_icon.gif').'" class="v-middle" style="margin-right:5px"/>';
64
+ echo $this->__("Starting download pages, please wait...");
65
+ echo '</li>';
66
+ echo '<li style="background-color:#FFD;">';
67
+ echo '<img src="'.Mage::getDesign()->getSkinUrl('images/fam_bullet_error.gif').'" class="v-middle" style="margin-right:5px"/>';
68
+ echo $this->__("Warning: Please don't close window during downloading pages");
69
+ echo '</li>';
70
+ echo '</ul>';
71
+
72
+ echo '<ul>';
73
+ echo '<li id="liFinished" style="display:none;">';
74
+ echo '<img src="'.Mage::getDesign()->getSkinUrl('images/note_msg_icon.gif').'" class="v-middle" style="margin-right:5px"/>';
75
+ echo $this->__("Finished downloading.");
76
+ echo '</li>';
77
+
78
+ echo '</ul>';
79
+
80
+ $showFinished = true;
81
+
82
+ $importIds = ($this->isSetImportIds()) ?
83
+ $this->getImportIds() :
84
+ Mage::getModel('mturbo/mturbo')->getCollection()->getAllIds();
85
+
86
+ if (count($importIds)>0) {
87
+
88
+ $showFinished = false;
89
+ $countItems = count($importIds);
90
+
91
+ $batchConfig = array(
92
+ 'styles' => array(
93
+ 'error' => array(
94
+ 'icon' => Mage::getDesign()->getSkinUrl('images/error_msg_icon.gif'),
95
+ 'bg' => '#FDD'),
96
+ 'message' => array(
97
+ 'icon' => Mage::getDesign()->getSkinUrl('images/fam_bullet_success.gif'),
98
+ 'bg' => '#DDF'),
99
+ 'loader' => Mage::getDesign()->getSkinUrl('images/ajax-loader.gif')),
100
+ 'template' => '<li style="#{style}" id="#{id}">'
101
+ . '<img id="#{id}_img" src="#{image}" class="v-middle" style="margin-right:5px"/>'
102
+ . '<span id="#{id}_status" class="text">#{text}</span>'
103
+ . '</li>',
104
+ 'text' => $this->__('Processed <strong>%s%% %s/%d</strong> pages', '#{percent}', '#{updated}', $countItems),
105
+ 'successText' => $this->__('Downloaded <strong>%s</strong> pages', '#{updated}')
106
+ );
107
+
108
+
109
+ echo $this->_getAjaxScript($batchConfig, $countItems);
110
+
111
+
112
+ foreach ($importIds as $id) {
113
+ $data = array( 'batch_id' => $id, 'rows[]' => $id );
114
+ echo '<script type="text/javascript">addImportData('.Zend_Json::encode($data).')</script>';
115
+ }
116
+
117
+ echo '<script type="text/javascript">execImportData()</script>';
118
+
119
+ }
120
+
121
+ if ($showFinished) {
122
+ echo "<script type=\"text/javascript\">$('liFinished').show();</script>";
123
+ }
124
+
125
+ echo '</body>';
126
+ echo '<html>';
127
+
128
+ }
129
+
130
+ private function _getCssJsHtml() {
131
+
132
+ $headBlock = $this->getLayout()->createBlock('page/html_head');
133
+ $headBlock->addJs('prototype/prototype.js');
134
+ $headBlock->addJs('mage/adminhtml/loader.js');
135
+ echo $headBlock->getCssJsHtml() . $this->_getMyCssHtml();
136
+
137
+ }
138
+
139
+ private function _getMyCssHtml() {
140
+ return '<style type="text/css">
141
+ ul { list-style-type:none; padding:0; margin:0; }
142
+ li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
143
+ img { margin-right:5px; }
144
+ </style>';
145
+ }
146
+
147
+ private function _getAjaxScript($batchConfig, $countItems) {
148
+ return '
149
+
150
+ <script type="text/javascript">
151
+ var countOfStartedProfiles = 0;
152
+ var countOfUpdated = 0;
153
+ var countOfError = 0;
154
+ var importData = [];
155
+ var totalRecords = ' . $countItems . ';
156
+ var config= '.Zend_Json::encode($batchConfig).';
157
+ </script>
158
+
159
+ <script type="text/javascript">
160
+
161
+ function addImportData(data) {
162
+ importData.push(data);
163
+ }
164
+
165
+ function execImportData() {
166
+
167
+ if (importData.length == 0) {
168
+ $("updatedRows_img").src = config.styles.message.icon;
169
+ $("updatedRows").style.backgroundColor = config.styles.message.bg;
170
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
171
+ style: "background-color:"+config.styles.message.bg,
172
+ image: config.styles.message.icon,
173
+ text: config.tplSccTxt.evaluate({updated:(countOfUpdated-countOfError)}),
174
+ id: "updatedFinish"
175
+ })});
176
+
177
+ if ($("liBeforeFinish")) {
178
+ Element.insert($("liFinished"), {before: $("liBeforeFinish")});
179
+ $("liBeforeFinish").show();
180
+ }
181
+
182
+ new Ajax.Request("' .$this->_getBatchFinishUrl().'", {
183
+ method: "post",
184
+ parameters: {form_key: FORM_KEY},
185
+
186
+ onComplete: function(transport) {
187
+ if (transport.responseText.isJSON()) {
188
+ var response = transport.responseText.evalJSON();
189
+ if (response.error) {
190
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
191
+ style: "background-color:"+config.styles.error.bg,
192
+ image: config.styles.error.icon,
193
+ text: response.error.escapeHTML(),
194
+ id: "error-finish"
195
+ })});
196
+ }
197
+ }
198
+
199
+ if ($("before-finish-wait-img")) {
200
+ $("before-finish-wait-img").hide();
201
+ }
202
+
203
+ $(\'liFinished\').show();
204
+ }
205
+ });
206
+
207
+ } else {
208
+ sendImportData(importData.shift());
209
+ }
210
+ }
211
+
212
+ function sendImportData(data) {
213
+
214
+ if (!config.tpl) {
215
+ config.tpl = new Template(config.template);
216
+ config.tplTxt = new Template(config.text);
217
+ config.tplSccTxt = new Template(config.successText);
218
+ }
219
+
220
+ if (!$("updatedRows")) {
221
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
222
+ style: "background-color: #FFD;",
223
+ image: config.styles.loader,
224
+ text: config.tplTxt.evaluate({updated:countOfUpdated, percent:getPercent()}),
225
+ id: "updatedRows"
226
+ })});
227
+ }
228
+
229
+ countOfStartedProfiles++;
230
+ if (!data.form_key) {
231
+ data.form_key = FORM_KEY;
232
+ }
233
+
234
+ new Ajax.Request("'.$this->_getBatchRunUrl().'", {
235
+ method: "post",
236
+ parameters: data,
237
+ onSuccess: function(transport) {
238
+ countOfStartedProfiles --;
239
+ countOfUpdated ++;
240
+ if (transport.responseText.isJSON()) {
241
+ addProfileRow(transport.responseText.evalJSON());
242
+ } else {
243
+ Element.insert($("updatedRows"), {before: config.tpl.evaluate({
244
+ style: "background-color:"+config.styles.error.bg,
245
+ image: config.styles.error.icon,
246
+ text: transport.responseText.escapeHTML(),
247
+ id: "error-" + countOfStartedProfiles
248
+ })});
249
+ countOfError ++;
250
+ }
251
+ execImportData();
252
+ }
253
+ });
254
+ }
255
+
256
+ function getPercent() {
257
+ return Math.ceil((countOfUpdated/totalRecords)*1000)/10;
258
+ }
259
+
260
+ function addProfileRow(data) {
261
+ if (data.errors.length > 0) {
262
+ for (var i=0, length=data.errors.length; i<length; i++) {
263
+ Element.insert($("updatedRows"), {before: config.tpl.evaluate({
264
+ style: "background-color:"+config.styles.error.bg,
265
+ image: config.styles.error.icon,
266
+ text: data.errors[i],
267
+ id: "id-" + (countOfUpdated + i + 1)
268
+ })});
269
+ countOfError ++;
270
+ }
271
+ }
272
+ if (data.messages.length > 0) {
273
+ for (var i=0, length=data.messages.length; i<length; i++) {
274
+ Element.insert($("updatedRows"), {before: config.tpl.evaluate({
275
+ style: "background-color:"+config.styles.message.bg,
276
+ image: config.styles.message.icon,
277
+ text: data.messages[i],
278
+ id: "id-" + (countOfUpdated + i + 1)
279
+ })});
280
+ }
281
+ }
282
+ $("updatedRows_status").update(config.tplTxt.evaluate({updated:countOfUpdated, percent:getPercent()}));
283
+ }
284
+ </script>';
285
+
286
+ }
287
+
288
+ private function _getBatchFinishUrl() {
289
+ return $this->getUrl('*/*/downloadFinish'/*, array('id' => $batchModel->getId())*/);
290
+ }
291
+
292
+ private function _getBatchRunUrl() {
293
+ return $this->getUrl('*/*/downloadRun');
294
+ }
295
+
296
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome.php ADDED
@@ -0,0 +1,57 @@
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_Welcome extends Mage_Adminhtml_Block_Widget_Form_Container
27
+ {
28
+
29
+ public function __construct() {
30
+
31
+ $this->_objectId = 'page_id';
32
+ $this->_blockGroup = 'mturbo';
33
+ $this->_controller = 'adminhtml';
34
+ $this->_mode = 'welcome';
35
+
36
+ parent::__construct();
37
+
38
+ $this->_removeButton('reset');
39
+ $this->_removeButton('back');
40
+ $this->_removeButton('save');
41
+
42
+ }
43
+
44
+ /**
45
+ * Retrieve text for header element depending on loaded page
46
+ *
47
+ * @return string
48
+ */
49
+ public function getHeaderText() {
50
+ return Mage::helper('mturbo')->__('Magento Turbo Cache Management');
51
+ }
52
+
53
+ protected function _afterToHtml($html) {
54
+ return '<div style="width:50%;margin:0 auto;font-weight:bold;">'.$html.'</div>';
55
+ }
56
+
57
+ }
app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php ADDED
@@ -0,0 +1,105 @@
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
+ /**
29
+ * Adminhtml cms block edit form
30
+ *
31
+ * @category Artio
32
+ * @package Artio_MTurbo
33
+ * @author Artio <info@artio.net>
34
+ */
35
+ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+
38
+ protected function _prepareForm() {
39
+
40
+ $form = new Varien_Data_Form(array(
41
+ 'name'=>'welcome_form',
42
+ 'id' => 'welcome_form',
43
+ 'action' => Mage::helper('adminhtml')->getUrl('*/*/install'),
44
+ 'method' => 'post'));
45
+
46
+ $form->setUseContainer(true);
47
+
48
+ $layoutFieldset = $form->addFieldset('general_fieldset', array(
49
+ 'legend' => Mage::helper('mturbo')->__('Your first options'),
50
+ 'class' => 'fieldset',
51
+ ));
52
+
53
+ $layoutFieldset->addField('turbopath', 'text', array(
54
+ 'name' => 'turbopath',
55
+ 'label' => Mage::helper('mturbo')->__('Cache Path').':',
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',
62
+ 'label' => Mage::helper('mturbo')->__('Save and Install'),
63
+ 'onclick' => "welcome_form.submit()",
64
+ 'style' => "text-align:right;"
65
+ ));
66
+
67
+ $this->setForm($form);
68
+
69
+ return parent::_prepareForm();
70
+ }
71
+
72
+ protected function _afterToHtml($html) {
73
+
74
+ if (Mage::helper('mturbo/info')->getRegName()) {
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
+
96
+ private function _wrapErrorDiv($error) {
97
+ return '<div style="margin-bottom:10px;padding:10px;background:#E06060;border:1px solid #802020">'.$error.'</div>';
98
+ }
99
+
100
+ private function _wrapInfoDiv($text) {
101
+ return '<div style="margin-bottom:10px;padding:10px;">'.$text.'</div>';
102
+ }
103
+
104
+
105
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/Button.php ADDED
@@ -0,0 +1,71 @@
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_Form_Element_Button extends Varien_Data_Form_Element_Abstract
35
+ {
36
+
37
+ private $label;
38
+ private $onclick;
39
+ private $comment;
40
+ private $style;
41
+
42
+ public function __construct($attributes=array())
43
+ {
44
+ parent::__construct($attributes);
45
+ if (array_key_exists('label', $attributes)) $this->label = $attributes['label'];
46
+ if (array_key_exists('onclick', $attributes)) $this->onclick = $attributes['onclick'];
47
+ if (array_key_exists('comment', $attributes)) $this->comment = $attributes['comment'];
48
+ if (array_key_exists('style', $attributes)) $this->style = $attributes['style'];
49
+ }
50
+
51
+ /**
52
+ * @see Varien_Data_Form_Element_Abstract::getHtml()
53
+ *
54
+ * @return unknown
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,
62
+ 'type' => 'button',
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
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/CategoryTree.php ADDED
@@ -0,0 +1,89 @@
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
+ * Form button element
29
+ * ABY TOTO FUNGOVALO MUSI BYT NAHRANE JAVASCRIPTY A AKCE OBSLUHUJICI AJAX viz. Adminhtml/CatalogController.php
30
+ * funkce
31
+ * categoriesJsonAction()
32
+ * _initCategory()
33
+ * a vlozeni javascriptu
34
+ * $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
35
+ ->setContainerCssClass('catalog-categories');
36
+ *
37
+ * @category Artio
38
+ * @package Artio_MTurbo
39
+ * @author Artio Magento Team <info@artio.net>
40
+ */
41
+ class Artio_MTurbo_Block_Data_Form_Element_CategoryTree extends Varien_Data_Form_Element_Abstract
42
+ {
43
+
44
+ private $treeId='category_ids';
45
+ private $categoryIds = array(0);
46
+ private $updateElementId='update_element';
47
+ private $formName='form_name';
48
+
49
+ public function __construct($attributes=array()) {
50
+ parent::__construct($attributes);
51
+ $this->loadAttributesToData($attributes);
52
+ }
53
+
54
+ private function loadAttributesToData($attributes=array()) {
55
+ foreach ($attributes as $key=>$value) {
56
+ if (!empty($this->$key)) $this->$key = $value;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @see Varien_Data_Form_Element_Abstract::getHtml()
62
+ *
63
+ * @return unknown
64
+ */
65
+ public function getHtml() {
66
+
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;
81
+ return $html;
82
+ }
83
+
84
+ private function getFormNameAsElement() {
85
+ return "$('" . $this->formName . "')";
86
+ }
87
+
88
+
89
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/NoEscLabel.php ADDED
@@ -0,0 +1,51 @@
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
+ * Data form abstract class
29
+ *
30
+ * @category Artio
31
+ * @package Artio
32
+ * @author Artio Magento Team <info@artio.cz>
33
+ */
34
+ class Artio_MTurbo_Block_Data_Form_Element_NoEscLabel extends Varien_Data_Form_Element_Abstract
35
+ {
36
+ public function __construct($attributes=array())
37
+ {
38
+ parent::__construct($attributes);
39
+ $this->setType('label');
40
+ }
41
+
42
+ public function getElementHtml()
43
+ {
44
+ $html = $this->getBold() ? '<strong>' : '';
45
+ $html.= $this->getValue();
46
+ $html.= $this->getBold() ? '</strong>' : '';
47
+ $html.= $this->getAfterElementHtml();
48
+ return $html;
49
+ }
50
+
51
+ }
app/code/local/Artio/MTurbo/Block/Data/Form/Element/Time.php ADDED
@@ -0,0 +1,84 @@
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
+ * Form time element
29
+ *
30
+ * @category Artio
31
+ * @package Artio_MTurbo
32
+ * @author Artio Magento Team <info@artio.net>
33
+ */
34
+ class Artio_MTurbo_Block_Data_Form_Element_Time extends Varien_Data_Form_Element_Abstract
35
+ {
36
+ public function __construct($attributes=array())
37
+ {
38
+ parent::__construct($attributes);
39
+ $this->setType('hmtime');
40
+ }
41
+
42
+ public function getName()
43
+ {
44
+ $name = parent::getName();
45
+ if (strpos($name, '[]') === false) {
46
+ $name.= '[]';
47
+ }
48
+ return $name;
49
+ }
50
+
51
+ public function getElementHtml()
52
+ {
53
+ $this->addClass('select');
54
+
55
+ $value_hrs = 0;
56
+ $value_min = 0;
57
+
58
+ if( $value = $this->getValue() ) {
59
+ $values = split(" ", $value);
60
+ if( is_array($values) && count($values) == 5 ) {
61
+ $value_hrs = $values[1];
62
+ $value_min = $values[0];
63
+ }
64
+ }
65
+
66
+ $html = '<select name="'. $this->getName() . '" '.$this->serialize($this->getHtmlAttributes()).' style="width:40px">'."\n";
67
+ for( $i=0;$i<24;$i++ ) {
68
+ $hour = str_pad($i, 2, '0', STR_PAD_LEFT);
69
+ $html.= '<option value="'.$hour.'" '. ( ($value_hrs == $i) ? 'selected="selected"' : '' ) .'>' . $hour . '</option>';
70
+ }
71
+ $html.= '</select>'."\n";
72
+
73
+ $html.= '&nbsp;:&nbsp;<select name="'. $this->getName() . '" '.$this->serialize($this->getHtmlAttributes()).' style="width:40px">'."\n";
74
+ for( $i=0;$i<60;$i++ ) {
75
+ $hour = str_pad($i, 2, '0', STR_PAD_LEFT);
76
+ $html.= '<option value="'.$hour.'" '. ( ($value_min == $i) ? 'selected="selected"' : '' ) .'>' . $hour . '</option>';
77
+ }
78
+ $html.= '</select>'."\n";
79
+ $html.= '&nbsp;&nbsp;<span>'. Mage::helper('mturbo')->__('(hours : minutes)') .'</span>';
80
+
81
+ $html.= $this->getAfterElementHtml();
82
+ return $html;
83
+ }
84
+ }
app/code/local/Artio/MTurbo/Block/Data/Grid/Column/Blocked.php ADDED
@@ -0,0 +1,59 @@
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_Blocked
35
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
36
+ implements Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Interface {
37
+
38
+ public function render(Varien_Object $row) {
39
+
40
+ $value = $row->getData($this->getColumn()->getIndex());
41
+ $color = ($value==0) ? 'green' : 'red';
42
+ $action = ($value==0) ? 'block' : 'unblock';
43
+ $label = '';
44
+ $onclick = "setLocation('" . Mage::helper('adminhtml')->getUrl('*/*/'.$action, array('id' => $row->id)) . "')";
45
+
46
+ foreach ($this->getColumn()->getOptions() as $val => $lab) {
47
+ if (($val == $value) && (!is_null($value))) {
48
+ $label = $lab;
49
+ break;
50
+ }
51
+ }
52
+
53
+ $html = '<span style="cursor:pointer;color:'.$color./*'" onclick="'.$onclick.'"*/'">'.$label.'</span>';
54
+
55
+ return $html;
56
+
57
+ }
58
+
59
+ }
app/code/local/Artio/MTurbo/Helper/Checker.php ADDED
@@ -0,0 +1,87 @@
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
+ $permission = fileperms($htaccess);
56
+ return self::canWrite($permission);
57
+ }
58
+
59
+ public static function checkPermissionLayout() {
60
+ $perm = fileperms(Mage::getBaseDir().DS.self::UPGRADE_XML);
61
+ return self::canWrite($perm);
62
+ }
63
+
64
+ public static function checkPermissionCode() {
65
+ $perm = fileperms(Mage::getBaseDir().DS.self::UPGRADE_CODE);
66
+ return self::canWrite($perm);
67
+ }
68
+
69
+ public static function canWrite($perm) {
70
+ return ($perm) ? (($perm & 0x0080) && ($perm & 0x0010)) : false;
71
+ }
72
+
73
+ /**
74
+ * Check all prerequisites.
75
+ *
76
+ */
77
+ public static function checkAll() {
78
+
79
+ if (!self::checkPermission())
80
+ return Mage::helper('mturbo')->__("I can't write to .htaccess, please change permission.");
81
+
82
+