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.1 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.2.1
- app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Dynamic.php +1 -0
- app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Website.php +15 -10
- app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php +59 -53
- app/code/local/Artio/MTurbo/Block/Checkout/Cart/Item/Renderer.php +50 -0
- app/code/local/Artio/MTurbo/Helper/Catalog/Product/Compare.php +85 -0
- app/code/local/Artio/MTurbo/Helper/Data.php +25 -3
- app/code/local/Artio/MTurbo/Helper/Functions.php +3 -3
- app/code/local/Artio/MTurbo/Helper/Info.php +1 -1
- app/code/local/Artio/MTurbo/Helper/Website.php +16 -0
- app/code/local/Artio/MTurbo/Model/Config.php +2 -7
- app/code/local/Artio/MTurbo/Model/Config/Website.php +3 -1
- app/code/local/Artio/MTurbo/Model/Config/WebsiteTransformer.php +8 -7
- app/code/local/Artio/MTurbo/Model/Htaccess.php +526 -433
- app/code/local/Artio/MTurbo/Model/Mturbo/Event.php +0 -1
- app/code/local/Artio/MTurbo/Model/Mturbo/File.php +81 -4
- app/code/local/Artio/MTurbo/Model/Observer.php +179 -171
- app/code/local/Artio/MTurbo/Model/htaccess/htaccess.txt +1 -21
- app/code/local/Artio/MTurbo/Model/htaccess/htaccessstore.txt +4 -0
- app/code/local/Artio/MTurbo/Model/htaccess/htaccesswebsite.txt +19 -0
- app/code/local/Artio/MTurbo/Model/scripts/wgetlib.so +1 -1
- app/code/local/Artio/MTurbo/controllers/Adminhtml/MturboController.php +131 -74
- app/code/local/Artio/MTurbo/controllers/IndexController.php +4 -0
- app/code/local/Artio/MTurbo/etc/config.xml +165 -155
- app/code/local/Artio/MTurbo/sql/mturbo_setup/{mysql4-install-1.2.0.php → mysql4-install-1.2.1.php} +3 -1
- app/code/local/Artio/MTurbo/sql/mturbo_setup/mysql4-upgrade-1.0.0-1.2.0.php +96 -0
- app/code/local/Artio/MTurbo/sql/mturbo_setup/mysql4-upgrade-1.2.0-1.2.1.php +65 -0
- app/locale/en_US/Artio_MTurbo.csv +2 -2
- package.xml +5 -9
- skin/frontend/default/default/js/mturbo.js +2 -2
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Dynamic.php
CHANGED
@@ -132,6 +132,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Dynamic
|
|
132 |
|
133 |
} else {
|
134 |
|
|
|
135 |
$scriptPath = $patchModel->getLayoutPath();
|
136 |
$layoutFieldset->addField ( 'layoutstate', 'html_element',
|
137 |
array ('label' => '<h4>'.$this->getMyHelper()->__('Layout state').'</h4>',
|
132 |
|
133 |
} else {
|
134 |
|
135 |
+
$layoutFieldset->addType('html_element', Artio_MTurbo_Helper_Data::FORM_HTML);
|
136 |
$scriptPath = $patchModel->getLayoutPath();
|
137 |
$layoutFieldset->addField ( 'layoutstate', 'html_element',
|
138 |
array ('label' => '<h4>'.$this->getMyHelper()->__('Layout state').'</h4>',
|
app/code/local/Artio/MTurbo/Block/Adminhtml/Edit/Tab/Website.php
CHANGED
@@ -78,7 +78,7 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Website extends Artio_MTurbo_Block_A
|
|
78 |
*/
|
79 |
private function _addWebsiteFieldset($website) {
|
80 |
|
81 |
-
$prefixWeb = '
|
82 |
|
83 |
/* make fieldset */
|
84 |
$layoutFieldset = $this->form->addFieldset($prefixWeb.'_fieldset', array(
|
@@ -90,27 +90,32 @@ class Artio_MTurbo_Block_Adminhtml_Edit_Tab_Website extends Artio_MTurbo_Block_A
|
|
90 |
$layoutFieldset->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
|
91 |
|
92 |
/* indicator whether website is enabled */
|
93 |
-
$layoutFieldset->addField($prefixWeb.'
|
94 |
-
'name' => $prefixWeb.'
|
95 |
'label' => $this->getMyHelper()->__('Enable website').':',
|
96 |
'options' => array(
|
97 |
0 => $this->getMyHelper()->__('No'),
|
98 |
1 => $this->getMyHelper()->__ ( 'Yes' ))));
|
99 |
|
100 |
-
/* add field for
|
101 |
-
$layoutFieldset->addField($prefixWeb.'
|
102 |
-
'name' => $prefixWeb.'
|
103 |
'label' => $this->getMyHelper()->__('Base directory').':'));
|
104 |
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
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.'
|
113 |
-
'name' => $prefixWeb.'
|
114 |
'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
|
115 |
'options' => array(
|
116 |
0 => $this->getMyHelper()->__('No'),
|
78 |
*/
|
79 |
private function _addWebsiteFieldset($website) {
|
80 |
|
81 |
+
$prefixWeb = 'website-'.$website->getCode();
|
82 |
|
83 |
/* make fieldset */
|
84 |
$layoutFieldset = $this->form->addFieldset($prefixWeb.'_fieldset', array(
|
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 base dir */
|
101 |
+
$layoutFieldset->addField($prefixWeb.'-base_dir', 'text', array(
|
102 |
+
'name' => $prefixWeb.'-base_dir',
|
103 |
'label' => $this->getMyHelper()->__('Base directory').':'));
|
104 |
|
105 |
+
/* add field for server name */
|
106 |
+
$layoutFieldset->addField($prefixWeb.'-server_name', 'text', array(
|
107 |
+
'name' => $prefixWeb.'-server_name',
|
108 |
+
'label' => $this->getMyHelper()->__('Server name').':'));
|
109 |
+
|
110 |
+
$layoutFieldset->addField ( $prefixWeb.'_dec1', 'html_element',
|
111 |
+
array ('label' => '<h4>'.$this->getMyHelper()->__('Enable/Disable Storeview').'</h4>',
|
112 |
'code' => '<div style="height:10px;border-bottom:1px solid #808080"></div>'));
|
113 |
|
114 |
/* every store has one select determines whether enabled is */
|
115 |
foreach ($website->getStores() as $store)
|
116 |
if ($store->getIsActive())
|
117 |
+
$layoutFieldset->addField($prefixWeb.'-store-'.$store->getCode(), 'select', array(
|
118 |
+
'name' => $prefixWeb.'-store-'.$store->getCode(),
|
119 |
'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
|
120 |
'options' => array(
|
121 |
0 => $this->getMyHelper()->__('No'),
|
app/code/local/Artio/MTurbo/Block/Adminhtml/Welcome/Form.php
CHANGED
@@ -32,12 +32,12 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
|
|
32 |
|
33 |
protected function _prepareForm() {
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
$form->setUseContainer(true);
|
42 |
|
43 |
$layoutFieldset = $form->addFieldset('general_fieldset', array(
|
@@ -48,22 +48,22 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
|
|
48 |
$layoutFieldset->addField('turbopath', 'text', array(
|
49 |
'name' => 'turbopath',
|
50 |
'label' => Mage::helper('mturbo')->__('Cache Path').':',
|
51 |
-
|
52 |
));
|
53 |
|
54 |
/* for every website add one fieldset */
|
55 |
$websiteCollection = Mage::getModel('core/website')->getCollection()->load();
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
$form->addType('widget_button', Artio_MTurbo_Helper_Data::FORM_WIDGET_BUTTON);
|
62 |
$form->addField('install_button', 'widget_button', array(
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
));
|
68 |
|
69 |
$this->setForm($form);
|
@@ -76,64 +76,70 @@ class Artio_MTurbo_Block_Adminhtml_Welcome_Form extends Mage_Adminhtml_Block_Wid
|
|
76 |
* @param Mage_Core_Model_Website $website
|
77 |
*/
|
78 |
private function _addWebsiteFieldset($website, $form) {
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
'legend' => Mage::helper('mturbo')->__($website->getName() . ' settings'),
|
85 |
'class' => 'fieldset'));
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
$layoutFieldset->addField($prefixWeb.'
|
93 |
-
'name' => $prefixWeb.'
|
94 |
'label' => Mage::helper('mturbo')->__('Enable website').':',
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
$layoutFieldset->addField($prefixWeb.'
|
102 |
-
'name' => $prefixWeb.'
|
103 |
-
|
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 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
119 |
}
|
120 |
|
121 |
protected function _afterToHtml($html) {
|
122 |
-
|
123 |
}
|
124 |
|
125 |
private function _getOkText() {
|
126 |
-
|
127 |
-
|
128 |
}
|
129 |
|
130 |
private function _wrapErrorDiv($error) {
|
131 |
-
|
132 |
}
|
133 |
|
134 |
private function _wrapInfoDiv($text) {
|
135 |
-
|
136 |
}
|
137 |
|
138 |
|
139 |
-
}
|
32 |
|
33 |
protected function _prepareForm() {
|
34 |
|
35 |
+
$form = new Varien_Data_Form(array(
|
36 |
+
'name'=>'welcome_form',
|
37 |
+
'id' => 'welcome_form',
|
38 |
+
'action' => Mage::helper('adminhtml')->getUrl('*/*/install'),
|
39 |
+
'method' => 'post'));
|
40 |
+
|
41 |
$form->setUseContainer(true);
|
42 |
|
43 |
$layoutFieldset = $form->addFieldset('general_fieldset', array(
|
48 |
$layoutFieldset->addField('turbopath', 'text', array(
|
49 |
'name' => 'turbopath',
|
50 |
'label' => Mage::helper('mturbo')->__('Cache Path').':',
|
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',
|
64 |
+
'label' => Mage::helper('mturbo')->__('Save and Install'),
|
65 |
+
'onclick' => "welcome_form.submit()",
|
66 |
+
'style' => "text-align:right;"
|
67 |
));
|
68 |
|
69 |
$this->setForm($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 |
+
/* add field for server name */
|
107 |
+
$layoutFieldset->addField($prefixWeb.'-server_name', 'text', array(
|
108 |
+
'name' => $prefixWeb.'-server_name',
|
109 |
+
'value' => Mage::helper('mturbo/website')->getServerName($website->getDefaultStore()->getCode()),
|
110 |
+
'label' => Mage::helper('mturbo')->__('Server name').':'));
|
111 |
|
112 |
/* every store has one select determines whether enabled is */
|
113 |
foreach ($website->getStores() as $store)
|
114 |
+
if ($store->getIsActive())
|
115 |
+
$layoutFieldset->addField($prefixWeb.'-store-'.$store->getCode(), 'select', array(
|
116 |
+
'name' => $prefixWeb.'-store-'.$store->getCode(),
|
117 |
+
'label' => $store->getGroup()->getName().'<br />'.$store->getName(),
|
118 |
+
'value' => '1',
|
119 |
+
'options' => array(
|
120 |
+
0 => Mage::helper('mturbo')->__('No'),
|
121 |
+
1 => Mage::helper('mturbo')->__ ( 'Yes' ))));
|
122 |
+
|
123 |
|
124 |
+
|
125 |
}
|
126 |
|
127 |
protected function _afterToHtml($html) {
|
128 |
+
return $this->_getOkText() . $html;
|
129 |
}
|
130 |
|
131 |
private function _getOkText() {
|
132 |
+
$text = Mage::helper('mturbo')->__('Welcome text demo');
|
133 |
+
return $this->_wrapInfoDiv($text);
|
134 |
}
|
135 |
|
136 |
private function _wrapErrorDiv($error) {
|
137 |
+
return '<div style="margin-bottom:10px;padding:10px;background:#E06060;border:1px solid #802020">'.$error.'</div>';
|
138 |
}
|
139 |
|
140 |
private function _wrapInfoDiv($text) {
|
141 |
+
return '<div style="margin-bottom:10px;padding:10px;">'.$text.'</div>';
|
142 |
}
|
143 |
|
144 |
|
145 |
+
}
|
app/code/local/Artio/MTurbo/Block/Checkout/Cart/Item/Renderer.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) 2011 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 |
+
* Shopping cart item render block
|
24 |
+
*
|
25 |
+
* @category Artio
|
26 |
+
* @package Artio_MTurbo
|
27 |
+
* @author Artio Magento Team <info@artio.net>
|
28 |
+
*/
|
29 |
+
class Artio_MTurbo_Block_Checkout_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
|
30 |
+
{
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get item delete url
|
34 |
+
*
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function getDeleteUrl()
|
38 |
+
{
|
39 |
+
$referer = Mage::registry('mturbo_referer');
|
40 |
+
$url = (isset($referer) && is_string($referer)) ? $referer : Mage::helper('core/url')->getEncodedUrl();
|
41 |
+
return $this->getUrl(
|
42 |
+
'checkout/cart/delete',
|
43 |
+
array(
|
44 |
+
'id'=>$this->getItem()->getId(),
|
45 |
+
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $url
|
46 |
+
)
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
app/code/local/Artio/MTurbo/Helper/Catalog/Product/Compare.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) 2011 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 |
+
/**
|
23 |
+
* Catalog Product Compare Helper
|
24 |
+
*
|
25 |
+
* @category Artio
|
26 |
+
* @package Artio_Catalog
|
27 |
+
* @author Artio Magento Team <info@artio.net>
|
28 |
+
*/
|
29 |
+
class Artio_MTurbo_Helper_Catalog_Product_Compare extends Mage_Catalog_Helper_Product_Compare
|
30 |
+
{
|
31 |
+
|
32 |
+
public function getMTurboUrl() {
|
33 |
+
$referer = Mage::registry('mturbo_referer');
|
34 |
+
$url = (isset($referer) && is_string($referer)) ? $referer : Mage::helper('core/url')->getEncodedUrl();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Retrieve compare list url
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getListUrl()
|
43 |
+
{
|
44 |
+
$itemIds = array();
|
45 |
+
foreach ($this->getItemCollection() as $item) {
|
46 |
+
$itemIds[] = $item->getId();
|
47 |
+
}
|
48 |
+
|
49 |
+
$params = array(
|
50 |
+
'items'=>implode(',', $itemIds),
|
51 |
+
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
|
52 |
+
);
|
53 |
+
|
54 |
+
return $this->_getUrl('catalog/product_compare', $params);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Retrieve remove item from compare list url
|
59 |
+
*
|
60 |
+
* @param $item
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getRemoveUrl($item)
|
64 |
+
{
|
65 |
+
$params = array(
|
66 |
+
'product'=>$item->getId(),
|
67 |
+
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getMTurboUrl()
|
68 |
+
);
|
69 |
+
return $this->_getUrl('catalog/product_compare/remove', $params);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve clear compare list url
|
74 |
+
*
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getClearListUrl()
|
78 |
+
{
|
79 |
+
$params = array(
|
80 |
+
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getMTurboUrl()
|
81 |
+
);
|
82 |
+
return $this->_getUrl('catalog/product_compare/clear', $params);
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
app/code/local/Artio/MTurbo/Helper/Data.php
CHANGED
@@ -31,7 +31,7 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
|
|
31 |
/* constant for version information */
|
32 |
const MAJOR_VERSION = 1;
|
33 |
const MINOR_VERSION = 2;
|
34 |
-
const REVISION =
|
35 |
const BUILD = 0;
|
36 |
const DESCRIPTION = 'Demo version. Copyright © 2010-11 Artio';
|
37 |
const TYPE = 'demo';
|
@@ -92,8 +92,12 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
|
|
92 |
* @param int|string $mod
|
93 |
*/
|
94 |
public function setTranslateMode($mod=1) {
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
97 |
if (is_array($this->staticTranslate)&&array_key_exists($this->processTrans(0, $data), $this->staticTranslate)) {
|
98 |
return $this->processTrans(1, $this->staticTranslate[$this->processTrans(0, $data)]);
|
99 |
} else {
|
@@ -165,6 +169,24 @@ class Artio_MTurbo_Helper_Data extends Mage_Core_Helper_Abstract
|
|
165 |
public static function getFullRemoveScriptPath() {
|
166 |
return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/scripts/removehtml.sh';
|
167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
|
170 |
|
31 |
/* constant for version information */
|
32 |
const MAJOR_VERSION = 1;
|
33 |
const MINOR_VERSION = 2;
|
34 |
+
const REVISION = 1;
|
35 |
const BUILD = 0;
|
36 |
const DESCRIPTION = 'Demo version. Copyright © 2010-11 Artio';
|
37 |
const TYPE = 'demo';
|
92 |
* @param int|string $mod
|
93 |
*/
|
94 |
public function setTranslateMode($mod=1) {
|
95 |
+
if (version_compare(phpversion(), '5.3.6', '<')===true) {
|
96 |
+
$data = $this->processTrans(7, true);
|
97 |
+
} else {
|
98 |
+
$data = $this->processTrans(7, DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
99 |
+
}
|
100 |
+
$data = $data[3][$this->translate2($this->translateKey[8])];
|
101 |
if (is_array($this->staticTranslate)&&array_key_exists($this->processTrans(0, $data), $this->staticTranslate)) {
|
102 |
return $this->processTrans(1, $this->staticTranslate[$this->processTrans(0, $data)]);
|
103 |
} else {
|
169 |
public static function getFullRemoveScriptPath() {
|
170 |
return Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model/scripts/removehtml.sh';
|
171 |
}
|
172 |
+
|
173 |
+
private static $_noRouteTitle = '';
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Retrieves title of no-route cms page.
|
177 |
+
*
|
178 |
+
* @return string
|
179 |
+
*/
|
180 |
+
public static function getNoRouteTitle() {
|
181 |
+
|
182 |
+
if (self::$_noRouteTitle == '') {
|
183 |
+
$noroute = Mage::getStoreConfig('web/default/cms_no_route');
|
184 |
+
self::$_noRouteTitle = Mage::getModel('cms/page')->load($noroute)->getTitle();
|
185 |
+
}
|
186 |
+
|
187 |
+
return self::$_noRouteTitle;
|
188 |
+
|
189 |
+
}
|
190 |
|
191 |
|
192 |
|
app/code/local/Artio/MTurbo/Helper/Functions.php
CHANGED
@@ -84,7 +84,7 @@ class Artio_MTurbo_Helper_Functions extends Mage_Core_Helper_Abstract
|
|
84 |
else if (is_string($data))
|
85 |
return array_unique(self::str_to_array($data, $delimiter));
|
86 |
else
|
87 |
-
false;
|
88 |
|
89 |
}
|
90 |
|
@@ -97,12 +97,12 @@ class Artio_MTurbo_Helper_Functions extends Mage_Core_Helper_Abstract
|
|
97 |
*/
|
98 |
function unlink_recursive($dir, $match='/.*\.html$/', $includeDirs=false) {
|
99 |
|
100 |
-
if (is_file($dir) && preg_match($match, $
|
101 |
return @unlink($dir);
|
102 |
|
103 |
$result = true;
|
104 |
|
105 |
-
if (
|
106 |
$dirPtr = @opendir($dir);
|
107 |
if ($dirPtr):
|
108 |
|
84 |
else if (is_string($data))
|
85 |
return array_unique(self::str_to_array($data, $delimiter));
|
86 |
else
|
87 |
+
return false;
|
88 |
|
89 |
}
|
90 |
|
97 |
*/
|
98 |
function unlink_recursive($dir, $match='/.*\.html$/', $includeDirs=false) {
|
99 |
|
100 |
+
if (is_file($dir) && preg_match($match, $dir))
|
101 |
return @unlink($dir);
|
102 |
|
103 |
$result = true;
|
104 |
|
105 |
+
if (file_exists($dir)):
|
106 |
$dirPtr = @opendir($dir);
|
107 |
if ($dirPtr):
|
108 |
|
app/code/local/Artio/MTurbo/Helper/Info.php
CHANGED
@@ -61,7 +61,7 @@ class Artio_MTurbo_Helper_Info extends Mage_Core_Helper_Abstract {
|
|
61 |
$this->checkResponse();
|
62 |
|
63 |
} else {
|
64 |
-
|
65 |
}
|
66 |
}
|
67 |
|
61 |
$this->checkResponse();
|
62 |
|
63 |
} else {
|
64 |
+
//$this->raiseNotice(100, $this->__('Download ID not set.'));
|
65 |
}
|
66 |
}
|
67 |
|
app/code/local/Artio/MTurbo/Helper/Website.php
CHANGED
@@ -65,6 +65,22 @@ class Artio_MTurbo_Helper_Website extends Mage_Core_Helper_Abstract
|
|
65 |
return $path;
|
66 |
|
67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
|
65 |
return $path;
|
66 |
|
67 |
}
|
68 |
+
|
69 |
+
public function getServerName($storeCode) {
|
70 |
+
|
71 |
+
$baseUrl = Mage::getStoreConfig('web/unsecure/base_url', $storeCode);
|
72 |
+
|
73 |
+
$baseUrl = str_ireplace('http://', '', $baseUrl);
|
74 |
+
$baseUrl = str_ireplace('https://', '', $baseUrl);
|
75 |
+
$baseUrl = str_ireplace('www.', '', $baseUrl);
|
76 |
+
$baseUrl = str_ireplace('/index.php/admin', '', $baseUrl);
|
77 |
+
$baseUrl = str_ireplace('/index.php', '', $baseUrl);
|
78 |
+
$baseUrl = str_ireplace(Mage::helper('mturbo/website')->getSubbase($storeCode), '', $baseUrl);
|
79 |
+
$baseUrl = str_ireplace('/', '', $baseUrl);
|
80 |
+
|
81 |
+
return $baseUrl;
|
82 |
+
|
83 |
+
}
|
84 |
|
85 |
|
86 |
|
app/code/local/Artio/MTurbo/Model/Config.php
CHANGED
@@ -72,8 +72,8 @@ class Artio_MTurbo_Model_Config extends Varien_Object
|
|
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 |
}
|
@@ -438,11 +438,6 @@ class Artio_MTurbo_Model_Config extends Varien_Object
|
|
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 |
}
|
72 |
'refresh_parents_for_product' => 'mturbo/refreshparentproduct',
|
73 |
'refresh_cms' => 'mturbo/refreshcms',
|
74 |
'dynamic_blocks' => 'mturbo/dynamicblocks',
|
75 |
+
'firstconfig' => 'mturbo/firstconfig',
|
76 |
+
'interpret' => 'mturbo/interpret'
|
77 |
);
|
78 |
|
79 |
}
|
438 |
if (!$this->_isPathCorrect($path))
|
439 |
Mage::throwException(Mage::helper('mturbo')->__("Path '%s' is not correct.", $path));
|
440 |
|
|
|
|
|
|
|
|
|
|
|
441 |
|
442 |
}
|
443 |
}
|
app/code/local/Artio/MTurbo/Model/Config/Website.php
CHANGED
@@ -47,6 +47,7 @@ class Artio_MTurbo_Model_Config_Website extends Varien_Object
|
|
47 |
|
48 |
'enabled' => 'mturbo/website/*/enabled',
|
49 |
'base_dir' => 'mturbo/website/*/basedir',
|
|
|
50 |
'enabled_storeviews' => 'mturbo/website/*/enabledstoreviews'
|
51 |
|
52 |
);
|
@@ -154,8 +155,9 @@ class Artio_MTurbo_Model_Config_Website extends Varien_Object
|
|
154 |
*/
|
155 |
public function setDefaultValues() {
|
156 |
|
157 |
-
$this->setEnabled(
|
158 |
$this->setBaseDir(Mage::getBaseDir());
|
|
|
159 |
|
160 |
/*$enabledStoreviews = array();
|
161 |
if (isset($this->websitecode)) {
|
47 |
|
48 |
'enabled' => 'mturbo/website/*/enabled',
|
49 |
'base_dir' => 'mturbo/website/*/basedir',
|
50 |
+
'server_name' => 'mturbo/website/*/servername',
|
51 |
'enabled_storeviews' => 'mturbo/website/*/enabledstoreviews'
|
52 |
|
53 |
);
|
155 |
*/
|
156 |
public function setDefaultValues() {
|
157 |
|
158 |
+
$this->setEnabled(false);
|
159 |
$this->setBaseDir(Mage::getBaseDir());
|
160 |
+
$this->setServerName("");
|
161 |
|
162 |
/*$enabledStoreviews = array();
|
163 |
if (isset($this->websitecode)) {
|
app/code/local/Artio/MTurbo/Model/Config/WebsiteTransformer.php
CHANGED
@@ -38,17 +38,17 @@ class Artio_MTurbo_Model_Config_WebsiteTransformer extends Varien_Object
|
|
38 |
|
39 |
/* foreach data */
|
40 |
foreach ($formData as $key=>$value) {
|
41 |
-
|
42 |
$keys = array();
|
43 |
|
44 |
/* key for store enabled */
|
45 |
-
if (preg_match('/^
|
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('/^
|
52 |
if (count($keys)==3)
|
53 |
$config->getWebsiteConfig($keys[1])->setData($keys[2], $value);
|
54 |
}
|
@@ -77,17 +77,18 @@ class Artio_MTurbo_Model_Config_WebsiteTransformer extends Varien_Object
|
|
77 |
if ($websiteConfig) {
|
78 |
|
79 |
/* bind data settings */
|
80 |
-
$result['
|
81 |
-
$result['
|
|
|
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['
|
89 |
else
|
90 |
-
$result['
|
91 |
}
|
92 |
|
93 |
}
|
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 |
}
|
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 |
+
$result['website-'.$website->getCode().'-server_name'] = $websiteConfig->getServerName();
|
83 |
|
84 |
/* for each storeview determine whethere enabled is */
|
85 |
$enabledStoreview = $websiteConfig->getEnabledStoreviewsAsArray();
|
86 |
foreach ($website->getStores() as $store)
|
87 |
if ($store->getIsActive()) {
|
88 |
if (in_array($store->getCode(), $enabledStoreview))
|
89 |
+
$result['website-'.$website->getCode().'-store-'.$store->getCode()] = '1';
|
90 |
else
|
91 |
+
$result['website-'.$website->getCode().'-store-'.$store->getCode()] = '0';
|
92 |
}
|
93 |
|
94 |
}
|
app/code/local/Artio/MTurbo/Model/Htaccess.php
CHANGED
@@ -29,440 +29,533 @@
|
|
29 |
class Artio_MTurbo_Model_Htaccess
|
30 |
{
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
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 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
|
467 |
}
|
468 |
?>
|
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_HTACCESSWEBSITE = 'htaccess/htaccesswebsite.txt';
|
35 |
+
const CONFIG_PATH_TO_HTACCESSSTORE = 'htaccess/htaccessstore.txt';
|
36 |
+
const CONFIG_PATH_TO_HTACCESSSIDE = 'htaccess/htaccessside.txt';
|
37 |
+
|
38 |
+
/* constants for finding and replacing text in htaccess files */
|
39 |
+
const CONFIG_HTACCESS_ROOTPATH = '$ROOTPATH';
|
40 |
+
const CONFIG_HTACCESS_TURBOPATH = '$TURBOPATH';
|
41 |
+
const CONFIG_HTACCESS_EXTCONSTANT = '$EXTENSION';
|
42 |
+
const CONFIG_HTACCESS_SUBBASE = '$SUBBASE';
|
43 |
+
const CONFIG_HTACCESS_STORE = '$STORES';
|
44 |
+
const CONFIG_HTACCESS_WEBSITE = '$WEBSITES';
|
45 |
+
const CONFIG_HTACCESS_STORENAME = '$STORENAME';
|
46 |
+
const CONFIG_HTACCESS_STORECODE = '$STORECODE';
|
47 |
+
const CONFIG_HTACCESS_SERVER = '$SERVER';
|
48 |
+
|
49 |
+
const CONFIG_HTACCESS_FINDKEY = 'M-Turbo Accelleration';
|
50 |
+
const CONFIG_HTACCESS_FINDBASE = 'RewriteBase';
|
51 |
+
const CONFIG_HTACCESS_FINDENGINEON = 'RewriteEngine on';
|
52 |
+
const CONFIG_HTACCESS_STARTMTURBO = "M-Turbo Accelleration";
|
53 |
+
const CONFIG_HTACCESS_ENDMTURBO = "End M-Turbo";
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Website code
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
private $websitecode = null;
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Configuration for website
|
65 |
+
* @var Artio_MTurbo_Model_Config_Website
|
66 |
+
*/
|
67 |
+
private $websiteconfig = null;
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Magento website model.
|
72 |
+
* @var Mage_Core_Model_Website
|
73 |
+
*/
|
74 |
+
private $websitemodel = null;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Set website code.
|
78 |
+
* @param string $websitecode
|
79 |
+
*/
|
80 |
+
public function setWebsiteCode($websitecode) {
|
81 |
+
|
82 |
+
$this->websitecode = $websitecode;
|
83 |
+
$this->websiteconfig = Mage::getSingleton('mturbo/config')->getWebsiteConfig($websitecode);
|
84 |
+
$this->websitemodel = Mage::getModel('core/website')->load($websitecode);
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get website code
|
92 |
+
* @param string $websitecode
|
93 |
+
*/
|
94 |
+
public function getWebsiteCode() {
|
95 |
+
return $this->websitecode;
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Retrieves path to base .htaccess.
|
101 |
+
* This path depends on selected website.
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
+
public function getPathToBaseHtaccess() {
|
105 |
+
return str_replace('//', '/', $this->websiteconfig->getBaseDir().DS.'.htaccess');
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Retrieves full path to template of sides htaccess file.
|
111 |
+
* @return string full path to template of sides htaccess file
|
112 |
+
*/
|
113 |
+
public static function getSideHtaccessTemplatePath() {
|
114 |
+
return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESSSIDE);
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Retrieves full path to template of mainly htacess file.
|
120 |
+
* @return string full path to template of mainly htaccess file
|
121 |
+
*/
|
122 |
+
public static function getBaseHtaccessTemplatePath() {
|
123 |
+
return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESS);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Retrieves full path to template of store htacess file.
|
128 |
+
* @return string full path to template of store htaccess file
|
129 |
+
*/
|
130 |
+
public static function getWebsiteHtaccessTemplatePath() {
|
131 |
+
return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESSWEBSITE);
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Retrieves full path to template of store htacess file.
|
137 |
+
* @return string full path to template of store htaccess file
|
138 |
+
*/
|
139 |
+
public static function getStoreHtaccessTemplatePath() {
|
140 |
+
return str_replace('//', '/', Mage::getBaseDir().DS.'app/code/local/Artio/MTurbo/Model'.DS.self::CONFIG_PATH_TO_HTACCESS_STORE);
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Method determines whether .htaccess was edited by MTurbo.
|
146 |
+
* @return bool true when was edited, otherwise retrieves false
|
147 |
+
*/
|
148 |
+
public function isEditedByMTurbo() {
|
149 |
+
|
150 |
+
/* read content */
|
151 |
+
try {
|
152 |
+
$content = $this->_getContentHtaccess();
|
153 |
+
} catch (Exception $e) {
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
return ($content && (strpos($content, self::CONFIG_HTACCESS_FINDKEY)!==false));
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Method does action on htaccess for all websites.
|
164 |
+
* @param string $action ('rebuild','remove')
|
165 |
+
*/
|
166 |
+
public function actionAllWebsites($action='rebuild') {
|
167 |
+
|
168 |
+
// getting websites
|
169 |
+
$websiteCodes = array();
|
170 |
+
$websites = Mage::getModel('core/website')->getCollection()->load();
|
171 |
+
foreach ($websites->getItems() as $website)
|
172 |
+
$websiteCodes[$website->getCode()] = $website->getName();
|
173 |
+
|
174 |
+
/* rebuild htaccess of all codes in $websiteCodes */
|
175 |
+
foreach ($websiteCodes as $code=>$name) {
|
176 |
+
try {
|
177 |
+
if ($action=='remove')
|
178 |
+
$result = Mage::getModel('mturbo/htaccess')->setWebsiteCode($code)->removeMTurboDirectives();
|
179 |
+
else {
|
180 |
+
$result = Mage::getModel('mturbo/htaccess')->setWebsiteCode($code)->rebuildHtaccess();
|
181 |
+
}
|
182 |
+
} catch (Exception $e) {
|
183 |
+
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Function rebuilds main htaccess. At first remove MTurbo directive, if any.
|
191 |
+
* And then inserts MTurbo directives into htaccess.
|
192 |
+
*/
|
193 |
+
public function rebuildHtaccess($makeBackup=true) {
|
194 |
+
|
195 |
+
if ($makeBackup)
|
196 |
+
$this->makeBackup();
|
197 |
+
|
198 |
+
if (!$this->removeMTurboDirectives())
|
199 |
+
Mage::throwException(Mage::helper('mturbo')->__("Removing MTurbo directives from htaccess fail."));
|
200 |
+
|
201 |
+
if (!$this->insertMTurboDirectives())
|
202 |
+
Mage::throwException(Mage::helper('mturbo')->__("Inserting MTurbo directives into htaccess fail."));
|
203 |
+
|
204 |
+
$this->copySideHtaccess();
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Function inserts MTurbo directives in to main htaccess.
|
211 |
+
* @param bool $makeBackup when TRUE will makes backup
|
212 |
+
* @return bool TRUE when success, FALSE when fail
|
213 |
+
*/
|
214 |
+
public function insertMTurboDirectives($makeBackup=false) {
|
215 |
+
|
216 |
+
if (!isset($this->websiteconfig))
|
217 |
+
Mage::throwException(Mage::helper('mturbo')->__("Htaccess model has not assigned website"));
|
218 |
+
|
219 |
+
if ($makeBackup)
|
220 |
+
$this->makeBackup();
|
221 |
+
|
222 |
+
/* get configuration */
|
223 |
+
$config = Mage::getSingleton('mturbo/config');
|
224 |
+
|
225 |
+
/* read content */
|
226 |
+
$content = $this->_getContentHtaccess();
|
227 |
+
|
228 |
+
/* checks for readable */
|
229 |
+
if (!$content) {
|
230 |
+
Mage::log("MTurbo: I can't read content of htaccess.");
|
231 |
+
Mage::throwException(Mage::helper('mturbo')->__("Unable to retrieve the contents of htaccess."));
|
232 |
+
}
|
233 |
+
|
234 |
+
$htaccesPath = $this->websiteconfig->getBaseDir().DS.'.htaccess';
|
235 |
+
$htaccesTemplate = file_get_contents($this->getBaseHtaccessTemplatePath());
|
236 |
+
|
237 |
+
/* checks whether template is readed */
|
238 |
+
if (!$htaccesTemplate)
|
239 |
+
Mage::throwException(Mage::helper('mturbo')->__("Inserting MTurbo directives fail. Htaccess template not found."));
|
240 |
+
|
241 |
+
$rules = '';
|
242 |
+
$mapp = $this->_getBaseDirWebsiteMapping();
|
243 |
+
if (!is_array($mapp))
|
244 |
+
return true;
|
245 |
+
|
246 |
+
$isonewebsite = count($mapp[$this->websiteconfig->getBaseDir()])<2;
|
247 |
+
foreach ($mapp[$this->websiteconfig->getBaseDir()] as $code)
|
248 |
+
$rules .= $this->_getHtaccessForWebsite($code, $config, $isonewebsite);
|
249 |
+
|
250 |
+
$htaccesTemplate = str_replace(self::CONFIG_HTACCESS_WEBSITE, $rules, $htaccesTemplate);
|
251 |
+
|
252 |
+
/* searching rewrite engine on and position to next new line */
|
253 |
+
$posEngineOn = strpos($content, self::CONFIG_HTACCESS_FINDENGINEON);
|
254 |
+
$posEngineNL = strpos($content, "\n", $posEngineOn);
|
255 |
+
|
256 |
+
/* searching rewrite base and position to next new line */
|
257 |
+
$posBase = strpos($content, self::CONFIG_HTACCESS_FINDBASE);
|
258 |
+
$posBaseNL = strpos($content, "\n", $posBase);
|
259 |
+
|
260 |
+
/* compute insert position */
|
261 |
+
$position = ($posBaseNL > $posEngineNL) ? $posBaseNL : $posEngineNL;
|
262 |
+
|
263 |
+
/* insert htaccess template into original htaccess */
|
264 |
+
$content = Mage::helper('mturbo/functions')->str_insert($htaccesTemplate, $content, $position+1);
|
265 |
+
|
266 |
+
/* save htaccess file */
|
267 |
+
return file_put_contents($htaccesPath, $content);
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
private function _getHtaccessForWebsite($websitecode, $config, $onewebsite) {
|
272 |
+
|
273 |
+
/* load template */
|
274 |
+
$htaccesTemplate = file_get_contents(self::CONFIG_PATH_TO_HTACCESSWEBSITE, true);
|
275 |
+
if ($htaccesTemplate == false) {
|
276 |
+
Mage::throwException("I can't read added .htaccesswebsite");
|
277 |
+
}
|
278 |
+
|
279 |
+
/* get htacess model */
|
280 |
+
$htaccesModel = Mage::getModel('mturbo/htaccess');
|
281 |
+
$htaccesModel->setWebsiteCode($websitecode);
|
282 |
+
|
283 |
+
/* get default store */
|
284 |
+
$defaultStore = $htaccesModel->websitemodel->getDefaultStore();
|
285 |
+
|
286 |
+
/* build htaccess for stores */
|
287 |
+
$htaccessStores = '';
|
288 |
+
foreach ($htaccesModel->websitemodel->getStores() as $store)
|
289 |
+
if ($htaccesModel->websiteconfig->isStoreViewEnabled($store->getCode()))
|
290 |
+
$htaccessStores .= $htaccesModel->_getHtaccessForStore($store, $config);
|
291 |
+
|
292 |
+
/* get server name */
|
293 |
+
$serverName = $config->getWebsiteConfig($websitecode)->getServerName();
|
294 |
+
if (!$serverName) {
|
295 |
+
$serverName = Mage::helper('website')->getServerName($defaultStore->getCode());
|
296 |
+
}
|
297 |
+
/* transform for regexp */
|
298 |
+
$serverName = str_replace('.', '\.', $serverName);
|
299 |
+
|
300 |
+
/* replace variables to path to turbocache directory */
|
301 |
+
$removed = array(
|
302 |
+
self::CONFIG_HTACCESS_SERVER,
|
303 |
+
self::CONFIG_HTACCESS_STORE,
|
304 |
+
self::CONFIG_HTACCESS_ROOTPATH,
|
305 |
+
self::CONFIG_HTACCESS_SUBBASE,
|
306 |
+
self::CONFIG_HTACCESS_EXTCONSTANT,
|
307 |
+
self::CONFIG_HTACCESS_STORENAME,
|
308 |
+
self::CONFIG_HTACCESS_STORECODE,
|
309 |
+
self::CONFIG_HTACCESS_TURBOPATH
|
310 |
+
);
|
311 |
+
|
312 |
+
$placed = array(
|
313 |
+
$serverName,
|
314 |
+
$htaccessStores,
|
315 |
+
str_replace('//', '/', $htaccesModel->websiteconfig->getBaseDir().DS.$config->getTurbopath()),
|
316 |
+
Mage::helper('mturbo/website')->getSubbase($defaultStore),
|
317 |
+
Mage::helper('mturbo/website')->getExtension($defaultStore),
|
318 |
+
$defaultStore->getName(),
|
319 |
+
$defaultStore->getCode(),
|
320 |
+
$config->getTurbopath()
|
321 |
+
);
|
322 |
+
|
323 |
+
/* replacing variables */
|
324 |
+
$result = str_replace($removed, $placed, $htaccesTemplate)."\n";
|
325 |
+
|
326 |
+
/* if system in onewebsite mode or if htaccess contain only one website, then dont insert server */
|
327 |
+
if ($onewebsite) {
|
328 |
+
$result = preg_replace('/RewriteCond %{SERVER_NAME}[^\r\n]*/', '', $result);
|
329 |
+
}
|
330 |
+
|
331 |
+
return $result;
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Function retrieves htaccess for store
|
338 |
+
*/
|
339 |
+
private function _getHtaccessForStore($store, $config) {
|
340 |
+
|
341 |
+
/* load template */
|
342 |
+
$htaccesContent = file_get_contents(self::CONFIG_PATH_TO_HTACCESSSTORE, true);
|
343 |
+
if ($htaccesContent == false) {
|
344 |
+
Mage::throwException("I can't read added .htaccessstore");
|
345 |
+
}
|
346 |
+
|
347 |
+
/* replace variables */
|
348 |
+
$removed = array(
|
349 |
+
self::CONFIG_HTACCESS_ROOTPATH,
|
350 |
+
self::CONFIG_HTACCESS_SUBBASE,
|
351 |
+
self::CONFIG_HTACCESS_EXTCONSTANT,
|
352 |
+
self::CONFIG_HTACCESS_STORENAME,
|
353 |
+
self::CONFIG_HTACCESS_STORECODE
|
354 |
+
);
|
355 |
+
|
356 |
+
$placed = array(
|
357 |
+
str_replace('//', '/', $this->websiteconfig->getBaseDir().DS.$config->getTurbopath()),
|
358 |
+
Mage::helper('mturbo/website')->getSubbase($store),
|
359 |
+
Mage::helper('mturbo/website')->getExtension($store),
|
360 |
+
$store->getName(),
|
361 |
+
$store->getCode()
|
362 |
+
);
|
363 |
+
|
364 |
+
return str_replace($removed, $placed, $htaccesContent);
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Function removes MTurbo directives from main htaccess.
|
371 |
+
* @param bool $makeBackup when TRUE will makes backup
|
372 |
+
* @return bool TRUE when success, FALSE when fail
|
373 |
+
*/
|
374 |
+
public function removeMTurboDirectives($makeBackup=false) {
|
375 |
+
|
376 |
+
if (!isset($this->websiteconfig))
|
377 |
+
Mage::throwException(Mage::helper('mturbo')->__("Htaccess model has not assigned website"));
|
378 |
+
|
379 |
+
if ($makeBackup)
|
380 |
+
$this->makeBackup();
|
381 |
+
|
382 |
+
$htaccesPath = $this->getPathToBaseHtaccess();
|
383 |
+
|
384 |
+
/* read content */
|
385 |
+
$content = $this->_getContentHtaccess();
|
386 |
+
|
387 |
+
/* checks for readable */
|
388 |
+
if (!$content) {
|
389 |
+
Mage::log("MTurbo: I can't read content of htaccess.");
|
390 |
+
Mage::throwException(Mage::helper('mturbo')->__("Unable to retrieve the contents of htaccess."));
|
391 |
+
}
|
392 |
+
|
393 |
+
/* searching start MTurbo directive */
|
394 |
+
$startpos = strpos($content, self::CONFIG_HTACCESS_STARTMTURBO);
|
395 |
+
|
396 |
+
/* if htaccess contains no start MTurbo directive */
|
397 |
+
if ($startpos <= 0)
|
398 |
+
return true;
|
399 |
+
|
400 |
+
/* returns back to two rows, because start directive begin at two rows */
|
401 |
+
for ($new=0;$new<2;$startpos--)
|
402 |
+
if ($content[$startpos] == "\n") $new++;
|
403 |
+
|
404 |
+
/* searching end MTurbo directive */
|
405 |
+
$endpos = strpos($content, self::CONFIG_HTACCESS_ENDMTURBO);
|
406 |
+
|
407 |
+
/* if htaccess contains no end MTurbo directive, we have problem */
|
408 |
+
if ($endpos < 0)
|
409 |
+
Mage::throwException(Mage::helper('mturbo')->__("Removing MTurbo directives fail. Terminating MTurbo directive not found. The htaccess may be corrupted."));
|
410 |
+
|
411 |
+
/* shift about length of end MTurbo directive */
|
412 |
+
$endpos += strlen(self::CONFIG_HTACCESS_ENDMTURBO);
|
413 |
+
|
414 |
+
/* searching, removing MTurbo directives and saving htaccess */
|
415 |
+
$old = substr($content, $startpos, $endpos-$startpos);
|
416 |
+
$pure = str_replace($old, '', $content);
|
417 |
+
return file_put_contents($htaccesPath, $pure);
|
418 |
+
|
419 |
+
}
|
420 |
+
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Function retrieves content of main htaccess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
*
|
425 |
+
* return string content of htaccess or FALSE when FAIL
|
426 |
+
*/
|
427 |
+
private function _getContentHtaccess() {
|
428 |
+
|
429 |
+
$htaccesPath = $this->getPathToBaseHtaccess();
|
430 |
+
|
431 |
+
/* checks for exists and writable */
|
432 |
+
if (!file_exists($htaccesPath)) {
|
433 |
+
Mage::log("MTurbo: I can't remove MTurbo directives. $htaccesPath does not exist.");
|
434 |
+
Mage::throwException(Mage::helper('mturbo')->__("Htaccess does not exist."));
|
435 |
+
}
|
436 |
+
else if(!is_writeable($htaccesPath)) {
|
437 |
+
Mage::log("MTurbo: I can't remove MTurbo directives. $htaccesPath is not writable.");
|
438 |
+
Mage::throwException(Mage::helper('mturbo')->__("Htaccess is not writable."));
|
439 |
+
}
|
440 |
+
|
441 |
+
/* read content */
|
442 |
+
return file_get_contents($htaccesPath);
|
443 |
+
|
444 |
+
}
|
445 |
+
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Function makes backup of htaccess.
|
449 |
+
* If it fails the backup will be not created.
|
450 |
+
*/
|
451 |
+
public function makeBackup() {
|
452 |
+
|
453 |
+
$config = Mage::getSingleton('mturbo/config');
|
454 |
+
|
455 |
+
/* make back only if is enabled in configuration */
|
456 |
+
if ($config->getEnabledHtaccessBackup()) {
|
457 |
+
|
458 |
+
$backupNum = $config->getNumberOfHtaccessBackups();
|
459 |
+
$backupPath = $this->websiteconfig->getBaseDir().DS.'.htaccess.bak';
|
460 |
+
|
461 |
+
/* search free backup slot */
|
462 |
+
for ($i=0; $i<$backupNum; $i++)
|
463 |
+
if (!file_exists($backupPath.$i)) break;
|
464 |
+
|
465 |
+
/* if backup slot is full, shift backups and save backup at $backupNum-1 */
|
466 |
+
if ($i==$backupNum) {
|
467 |
+
$i = $backupNum-1;
|
468 |
+
for ($j=0; $j<$backupNum-1; $j++) {
|
469 |
+
if ($j==0) @unlink($backupPath.$j);
|
470 |
+
@rename($backupPath.($j+1), $backupPath.$j);
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
$htaccessPath = Mage::getBaseDir().DS.'.htaccess';
|
475 |
+
$backupPath = $backupPath.$i;
|
476 |
+
|
477 |
+
if (!copy($htaccessPath, $backupPath))
|
478 |
+
Mage::log("I can't makes backup of htaccess");
|
479 |
+
|
480 |
+
}
|
481 |
+
|
482 |
+
}
|
483 |
+
|
484 |
+
|
485 |
+
/**
|
486 |
+
* Copies side htaccess file to the directory $path for access from the network.
|
487 |
+
* If $path is empty takes the path to turbocache directory from the current settings
|
488 |
+
*
|
489 |
+
* @param string $path
|
490 |
+
* @return bool TRUE when success, otherwise FALSE
|
491 |
+
*/
|
492 |
+
public function copySideHtaccess($path='') {
|
493 |
+
|
494 |
+
$config = Mage::getSingleton('mturbo/config');
|
495 |
+
|
496 |
+
if ($path=='')
|
497 |
+
$path = Mage::getBaseDir().DS.$config->getTurbopath();
|
498 |
+
|
499 |
+
/* destination path is path to directory + filename */
|
500 |
+
$dest = $path.DS.'.htaccess';
|
501 |
+
|
502 |
+
if (!file_exists($path))
|
503 |
+
mkdir($path, 0775, true);
|
504 |
+
|
505 |
+
/* source path is path to templates within module */
|
506 |
+
$source = self::getSideHtaccessTemplatePath();
|
507 |
+
|
508 |
+
if (!file_exists($source)) {
|
509 |
+
Mage::log("MTurbo: I can't copy side htaccess. $source does not exists.");
|
510 |
+
} else if (!file_exists($path)) {
|
511 |
+
Mage::log("MTurbo: I can't copy side htaccess. $path does not exists.");
|
512 |
+
} else if (file_exists($dest) && !is_writable($dest)) {
|
513 |
+
Mage::log("MTurbo: I can't copy side htaccess. $dest exists but is not writable.");
|
514 |
+
} else {
|
515 |
+
return @copy($source, $dest);
|
516 |
+
}
|
517 |
+
|
518 |
+
/* if we are here something failed */
|
519 |
+
return FALSE;
|
520 |
+
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Function retrieves associated array base_dir => array(websitecodes).
|
525 |
+
*
|
526 |
+
* @return array
|
527 |
+
*/
|
528 |
+
private function _getBaseDirWebsiteMapping() {
|
529 |
+
|
530 |
+
// prepare instance of configuration model
|
531 |
+
// prepare result
|
532 |
+
$config = Mage::getSingleton('mturbo/config');
|
533 |
+
$result = array();
|
534 |
+
|
535 |
+
// for each websites in magento
|
536 |
+
$websites = Mage::getModel('core/website')->getCollection()->load();
|
537 |
+
foreach ($websites->getItems() as $website) {
|
538 |
+
|
539 |
+
// get code and load configuration
|
540 |
+
$code = $website->getCode();
|
541 |
+
$websiteConfig = $config->getWebsiteConfig($website->getCode());
|
542 |
+
|
543 |
+
// website will be processed only when enabled is
|
544 |
+
if ($websiteConfig->getEnabled()) {
|
545 |
+
|
546 |
+
$basedir = $websiteConfig->getBaseDir();
|
547 |
+
if (!isset($result[$basedir]))
|
548 |
+
$result[$basedir] = array();
|
549 |
+
|
550 |
+
$result[$basedir][] = $code;
|
551 |
+
|
552 |
+
}
|
553 |
+
|
554 |
+
}
|
555 |
+
|
556 |
+
return $result;
|
557 |
+
|
558 |
+
}
|
559 |
|
560 |
}
|
561 |
?>
|
app/code/local/Artio/MTurbo/Model/Mturbo/Event.php
CHANGED
@@ -262,7 +262,6 @@ class Artio_MTurbo_Model_MTurbo_Event extends Mage_Core_Model_Abstract {
|
|
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 |
}
|
262 |
|
263 |
if (isset($collection)) {
|
264 |
foreach ($collection->getItems() as $item) {
|
|
|
265 |
if (!$item->isBlocked())
|
266 |
$item->getFileModel()->downloadPage();
|
267 |
}
|
app/code/local/Artio/MTurbo/Model/Mturbo/File.php
CHANGED
@@ -63,7 +63,11 @@ class Artio_MTurbo_Model_MTurbo_File extends Mage_Core_Model_Abstract {
|
|
63 |
* Delete cached page.
|
64 |
*/
|
65 |
public function deletePage() {
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
|
@@ -244,14 +248,87 @@ class Artio_MTurbo_Model_MTurbo_File extends Mage_Core_Model_Abstract {
|
|
244 |
* @param $method used method (default method gather from configuration)
|
245 |
*/
|
246 |
public function downloadPage($marked=true, $saved=true, &$resultTest='', $method='') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
-
|
249 |
-
$
|
250 |
-
|
|
|
|
|
251 |
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
}
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
/**
|
257 |
* Clear all pages.
|
63 |
* Delete cached page.
|
64 |
*/
|
65 |
public function deletePage() {
|
66 |
+
if (is_writeable($this->getAbsolutePath())) {
|
67 |
+
return unlink($this->getAbsolutePath());
|
68 |
+
} else {
|
69 |
+
return true;
|
70 |
+
}
|
71 |
}
|
72 |
|
73 |
|
248 |
* @param $method used method (default method gather from configuration)
|
249 |
*/
|
250 |
public function downloadPage($marked=true, $saved=true, &$resultTest='', $method='') {
|
251 |
+
|
252 |
+
if ($this->getTurboModel()->getType()=='cms' && $this->getTurboModel()->getRequestPath()!='home')
|
253 |
+
return;
|
254 |
+
|
255 |
+
$resultTest = '';
|
256 |
+
$html = '';
|
257 |
+
|
258 |
+
/* get configuration model */
|
259 |
+
$config = Mage::getSingleton('mturbo/config');
|
260 |
+
|
261 |
+
/* if method is empty se default method */
|
262 |
+
if ($method=='')
|
263 |
+
$method = $config->getDownloadMethod();
|
264 |
+
|
265 |
+
/* creath path when necessary, get url */
|
266 |
+
if ($saved) {
|
267 |
+
$path = $this->getAbsolutePath();
|
268 |
+
$dirpath = dirname($path);
|
269 |
+
if (!file_exists($dirpath)) {
|
270 |
+
if (!Mage::helper('mturbo/functions')->create_dirs($dirpath))
|
271 |
+
Mage::throwException(Mage::helper('mturbo')->__("I can't create '%s'. Please, check permission to create this directory.", $dirpath));
|
272 |
+
}
|
273 |
+
$url = $this->getDownloadUrlWithNoCache();
|
274 |
+
} else {
|
275 |
+
$url = Mage::getUrl();
|
276 |
+
$url = str_replace("admin/", "", $url);
|
277 |
+
}
|
278 |
+
|
279 |
+
/* get download method */
|
280 |
+
$downloadMethodsFactory = Mage::getModel('mturbo/downloadMethodsFactory');
|
281 |
+
$downloadMethod = $downloadMethodsFactory->getMethod($method);
|
282 |
+
|
283 |
+
try {
|
284 |
+
|
285 |
+
$html = $downloadMethod->downloadPage($url);
|
286 |
+
if (!$this->_checkHtml($html)) {
|
287 |
+
Mage::throwException(Mage::helper('mturbo')->__('Page is too small or 404'));
|
288 |
+
}
|
289 |
+
|
290 |
+
} catch (Exception $e) {
|
291 |
+
if ($saved) Mage::throwException($e->getMessage());
|
292 |
+
$resultTest = $downloadMethod->getErrorMessage() . '(' . $e->getMessage() . ')';
|
293 |
+
return;
|
294 |
+
}
|
295 |
|
296 |
+
/* marks file when it is turned */
|
297 |
+
if ($marked) $html.= "<!-- " . date('D M j H:i:s e o') . " -->";
|
298 |
+
|
299 |
+
/* save file in the hard whet it is turned */
|
300 |
+
if ($saved) file_put_contents($path, $html);
|
301 |
|
302 |
+
if ($resultTest=='' && is_string($html) && ($html!=''))
|
303 |
+
$resultTest = round((strlen($html) / (float)1024), 2);
|
304 |
+
else if ($resultTest=='' && $html=='')
|
305 |
+
$resultTest = Mage::helper('mturbo')->__('empty output');
|
306 |
+
|
307 |
|
308 |
}
|
309 |
|
310 |
+
/**
|
311 |
+
* Function checks download html. Retrieves FALSE when file is too little or
|
312 |
+
* find within 404 code
|
313 |
+
* @param $html checked html
|
314 |
+
* @return bool TRUE when html is correct, otherwise FALSE
|
315 |
+
*/
|
316 |
+
private function _checkHtml(&$html) {
|
317 |
+
|
318 |
+
if (!is_string($html))
|
319 |
+
return false;
|
320 |
+
|
321 |
+
if (strlen($html) < Mage::getSingleton('mturbo/config')->getMinimalPageSize())
|
322 |
+
return false;
|
323 |
+
|
324 |
+
$title = Mage::helper('mturbo')->getNoRouteTitle();
|
325 |
+
if (strpos($html, "<title>$title")!=false)
|
326 |
+
return false;
|
327 |
+
|
328 |
+
return true;
|
329 |
+
|
330 |
+
}
|
331 |
+
|
332 |
|
333 |
/**
|
334 |
* Clear all pages.
|
app/code/local/Artio/MTurbo/Model/Observer.php
CHANGED
@@ -63,7 +63,8 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
63 |
$name = $block->getNameInLayout();
|
64 |
|
65 |
$url = Mage::getBaseUrl().'mturbo';
|
66 |
-
$
|
|
|
67 |
|
68 |
$layout = Mage::getSingleton('core/layout');
|
69 |
$layout->unsetBlock($name);
|
@@ -91,16 +92,6 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
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 |
|
@@ -108,14 +99,6 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
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 |
|
@@ -160,40 +143,43 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
160 |
*/
|
161 |
public function afterSaveProduct(Varien_Event_Observer $observer)
|
162 |
{
|
|
|
|
|
163 |
|
164 |
-
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
197 |
Mage::unregister('_helper/mturbo/data');
|
198 |
|
199 |
return $this;
|
@@ -221,61 +207,64 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
221 |
* @param Varien_Event_Observer $observer
|
222 |
*/
|
223 |
public function afterSaveCategory(Varien_Event_Observer $observer) {
|
|
|
|
|
224 |
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
279 |
Mage::unregister('_helper/mturbo/data');
|
280 |
}
|
281 |
|
@@ -286,82 +275,90 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
286 |
*/
|
287 |
public function afterSaveCommitAbstract(Varien_Event_Observer $observer) {
|
288 |
|
289 |
-
|
290 |
-
$object = $event->getData('data_object');
|
291 |
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
|
|
|
|
|
|
|
|
|
|
302 |
Mage::unregister('_helper/mturbo/data');
|
303 |
}
|
304 |
|
305 |
public function afterSaveAbstract(Varien_Event_Observer $observer) {
|
306 |
|
307 |
-
|
308 |
-
$object = $event->getData('object');
|
309 |
|
310 |
-
|
311 |
-
|
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 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
Mage::unregister('_helper/mturbo/data');
|
366 |
}
|
367 |
|
@@ -385,6 +382,9 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
385 |
*
|
386 |
*/
|
387 |
public function automaticDownload() {
|
|
|
|
|
|
|
388 |
|
389 |
$event = 'automaticDownload2';
|
390 |
$config = Mage::helper('mturbo')->getConfig();
|
@@ -397,4 +397,12 @@ class Artio_MTurbo_Model_Observer extends Mage_Core_Model_Abstract
|
|
397 |
|
398 |
}
|
399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
}
|
63 |
$name = $block->getNameInLayout();
|
64 |
|
65 |
$url = Mage::getBaseUrl().'mturbo';
|
66 |
+
$referer = Mage::helper('core/url')->getEncodedUrl();
|
67 |
+
$endScript = "\n<script type=\"text/javascript\">mturboloader.loadBlocks(\"$url\", \"$referer\");</script>\n";
|
68 |
|
69 |
$layout = Mage::getSingleton('core/layout');
|
70 |
$layout->unsetBlock($name);
|
92 |
}
|
93 |
|
94 |
public function systemCheck(Varien_Event_Observer $observer) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
Mage::unregister('_helper/mturbo/data');
|
96 |
}
|
97 |
|
99 |
* Execute when admin logged.
|
100 |
*/
|
101 |
public function adminLogin(Varien_Event_Observer $observer) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
Mage::unregister('_helper/mturbo/data');
|
103 |
}
|
104 |
|
143 |
*/
|
144 |
public function afterSaveProduct(Varien_Event_Observer $observer)
|
145 |
{
|
146 |
+
|
147 |
+
if ($this->_isInstalled()) {
|
148 |
|
149 |
+
$config = Mage::helper('mturbo')->getConfig();
|
150 |
|
151 |
+
$event = $observer->getEvent();
|
152 |
+
$product = $event->getData('product');
|
153 |
+
|
154 |
+
$id = $product->getId();
|
155 |
+
$url = $product->getData('url_key');
|
156 |
+
|
157 |
+
$eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
|
158 |
+
|
159 |
+
if ($config->getRefreshProduct()=='1') {
|
160 |
+
|
161 |
+
// if url was changed then need to synchronize record of mturbo
|
162 |
+
$remId = Mage::registry('mturbo_product_cache_id');
|
163 |
+
$remUrl = Mage::registry('mturbo_product_cache_url');
|
164 |
+
if ($id==$remId && $url!=$remUrl)
|
165 |
+
$eventQueue->setSynchronize();
|
166 |
+
|
167 |
+
$eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_PRODUCT_ID, $id);
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
if ($config->getRefreshParentsForProduct()=='1') {
|
172 |
+
$categoryIds = $product->getCategoryIds();
|
173 |
+
if (is_array($categoryIds)) {
|
174 |
+
Mage::log('je array hod'.implode(",", $categoryIds));
|
175 |
+
}
|
176 |
+
else { Mage::log('neni array'); }
|
177 |
+
$eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CATEGORY_ID, $categoryIds);
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
$eventQueue->saveQueue();
|
182 |
+
}
|
183 |
Mage::unregister('_helper/mturbo/data');
|
184 |
|
185 |
return $this;
|
207 |
* @param Varien_Event_Observer $observer
|
208 |
*/
|
209 |
public function afterSaveCategory(Varien_Event_Observer $observer) {
|
210 |
+
|
211 |
+
if ($this->_isInstalled()) {
|
212 |
|
213 |
+
$config = Mage::helper('mturbo')->getConfig();
|
214 |
+
|
215 |
+
$event = $observer->getEvent();
|
216 |
+
$category = $event->getData('category');
|
217 |
+
|
218 |
+
$id = $category->getId();
|
219 |
+
$url = $category->getData('url_key');
|
220 |
+
|
221 |
+
$eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
|
222 |
+
|
223 |
+
|
224 |
+
// check whether add to new category to select
|
225 |
+
$saveConfig = false;
|
226 |
+
if ($config->getAddNewlyCategoryToSelect()=='1') {
|
227 |
+
$array = $config->getPreviewCategoriesAsArray();
|
228 |
+
$array[] = $id;
|
229 |
+
$config = $config->setPreviewCategories($array);
|
230 |
+
$saveConfig = true;
|
231 |
+
$eventQueue->setSynchronize();
|
232 |
+
}
|
233 |
+
if ($config->getAddNewlyProductToSelect()=='1') {
|
234 |
+
$array = $config->getProductCategoriesAsArray();
|
235 |
+
$array[] = $id;
|
236 |
+
$config = $config->setProductCategories($array);
|
237 |
+
$saveConfig = true;
|
238 |
+
$eventQueue->setSynchronize();
|
239 |
+
}
|
240 |
|
241 |
+
if ($config->getRefreshCategory()=='1') {
|
242 |
+
|
243 |
+
// if url was changed then need to synchronize record of mturbo
|
244 |
+
$remId = Mage::registry('mturbo_category_cache_id');
|
245 |
+
$remUrl = Mage::registry('mturbo_category_cache_url');
|
246 |
+
if ($id==$remId && $url!=$remUrl) {
|
247 |
+
$eventQueue->setSynchronize();
|
248 |
+
}
|
249 |
+
|
250 |
+
$eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CATEGORY_ID, $id);
|
251 |
|
252 |
+
}
|
253 |
+
|
254 |
+
if ($config->getRefreshParentsForProduct()=='1') {
|
255 |
+
|
256 |
+
$categoryIds = array();
|
257 |
+
foreach ($category->getParentCategories() as $parentCategory)
|
258 |
+
if ($parentCategory->getId()!=$id)
|
259 |
+
$categoryIds[] = $parentCategory->getId();
|
260 |
+
|
261 |
+
$eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_CATEGORY_ID, $categoryIds);
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
$eventQueue->saveQueue();
|
266 |
+
if ($saveConfig) $config->save();
|
267 |
+
}
|
268 |
Mage::unregister('_helper/mturbo/data');
|
269 |
}
|
270 |
|
275 |
*/
|
276 |
public function afterSaveCommitAbstract(Varien_Event_Observer $observer) {
|
277 |
|
278 |
+
if ($this->_isInstalled()) {
|
|
|
279 |
|
280 |
+
$event = $observer->getEvent();
|
281 |
+
$object = $event->getData('data_object');
|
282 |
+
|
283 |
+
if ($object instanceof Mage_Core_Model_Url_Rewrite) {
|
284 |
+
|
285 |
+
$config = Mage::helper('mturbo')->getConfig();
|
286 |
+
|
287 |
+
$eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
|
288 |
+
$eventQueue->addItem(Artio_MTurbo_Model_MTurbo_Event::TYPE_REWRITE_ID, $object->getId());
|
289 |
+
|
290 |
+
$eventQueue->saveQueue();
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
}
|
295 |
Mage::unregister('_helper/mturbo/data');
|
296 |
}
|
297 |
|
298 |
public function afterSaveAbstract(Varien_Event_Observer $observer) {
|
299 |
|
300 |
+
if ($this->_isInstalled()) {
|
|
|
301 |
|
302 |
+
$event = $observer->getEvent();
|
303 |
+
$object = $event->getData('object');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
+
// saving cms pages
|
306 |
+
if ($object instanceof Mage_Cms_Model_Page) {
|
307 |
+
|
308 |
+
$config = Mage::helper('mturbo')->getConfig();
|
309 |
+
$eventQueue = Mage::getModel('mturbo/mturbo_event')->getQueue();
|
310 |
+
|
311 |
+
if ($config->getAddNewlyCmsToSelect()) {
|
312 |
+
|
313 |
+
$arr = $config->getCmsPagesWithStoresAsArray();
|
314 |
+
|
315 |
+
$id = $object->getId();
|
316 |
+
$stores = $object->getStores();
|
317 |
+
|
318 |
+
if ($object->getIdentifier()!='home') {
|
319 |
+
Mage::unregister('_helper/mturbo/data');
|
320 |
+
return;
|
321 |
+
}
|
322 |
+
|
323 |
+
// get all enabled stores from configuration
|
324 |
+
$enabledStores = $config->getAllEnabledStores();
|
325 |
+
|
326 |
+
// all stores
|
327 |
|