Version Notes
License changed from LiteSpeed proprietary to GPLv3.
Download this release
Release Info
Developer | LiteSpeed Technologies |
Extension | LiteSpeed_LiteMage |
Version | 1.0.18 |
Comparing to | |
See all releases |
Code changes from version 1.0.17 to 1.0.18
- app/code/community/Litespeed/Litemage/Block/Adminhtml/Cache/Management.php +74 -34
- app/code/community/Litespeed/Litemage/Block/Core/Esi.php +74 -47
- app/code/community/Litespeed/Litemage/Block/Core/Messages.php +344 -164
- app/code/community/Litespeed/Litemage/Block/Inject/Jsvar.php +23 -5
- app/code/community/Litespeed/Litemage/Block/Inject/Nickname.php +22 -4
- app/code/community/Litespeed/Litemage/Helper/Data.php +516 -317
- app/code/community/Litespeed/Litemage/Helper/Esi.php +596 -322
- app/code/community/Litespeed/Litemage/Helper/Viewvary.php +109 -48
- app/code/community/Litespeed/Litemage/Model/Config/Source/CustomerGroup.php +22 -4
- app/code/community/Litespeed/Litemage/Model/Config/Source/EnableWarmUp.php +22 -4
- app/code/community/Litespeed/Litemage/Model/Layout.php +121 -57
- app/code/community/Litespeed/Litemage/Model/Layout/Update.php +215 -113
- app/code/community/Litespeed/Litemage/Model/Observer/Cron.php +786 -436
- app/code/community/Litespeed/Litemage/Model/Observer/Esi.php +670 -360
- app/code/community/Litespeed/Litemage/Model/Observer/Purge.php +290 -170
- app/code/community/Litespeed/Litemage/Model/Session.php +66 -33
- app/code/community/Litespeed/Litemage/Model/Translate.php +20 -4
- app/code/community/Litespeed/Litemage/controllers/AdminController.php +108 -55
- app/code/community/Litespeed/Litemage/controllers/Adminhtml/LitemageCacheController.php +66 -38
- app/code/community/Litespeed/Litemage/controllers/EsiController.php +763 -411
- app/code/community/Litespeed/Litemage/etc/config.xml +25 -1
- app/code/community/Litespeed/Litemage/etc/config.xml.dev +506 -0
- app/code/community/Litespeed/Litemage/etc/config.xml.package +505 -0
- app/code/community/Litespeed/Litemage/etc/system.xml +22 -5
- app/design/adminhtml/default/default/layout/litemage.xml +25 -0
- app/design/adminhtml/default/default/template/litemage/cache_management.phtml +144 -88
- app/design/frontend/base/default/layout/litemage.xml +22 -2
- app/design/frontend/base/default/template/litemage/inject/jsvar.phtml +22 -3
- app/etc/modules/Litespeed_Litemage.xml +22 -2
- package.xml +7 -10
app/code/community/Litespeed/Litemage/Block/Adminhtml/Cache/Management.php
CHANGED
@@ -1,34 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
|
26 |
+
|
27 |
+
class Litespeed_Litemage_Block_Adminhtml_Cache_Management extends Mage_Adminhtml_Block_Template
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* Get clean cache url
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getPurgeUrl($type)
|
35 |
+
{
|
36 |
+
if ($type == 'Refresh') {
|
37 |
+
return $this->getUrl('*/cache/index');
|
38 |
+
}
|
39 |
+
else {
|
40 |
+
$types = array('All', 'Tag', 'Url');
|
41 |
+
|
42 |
+
if (in_array($type, $types)) {
|
43 |
+
return $this->getUrl('*/litemageCache/purge' . $type);
|
44 |
+
}
|
45 |
+
else {
|
46 |
+
return $this->getUrl('*/litemageCache/purgeAll');
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getCrawlerStatus()
|
52 |
+
{
|
53 |
+
$status = Mage::getModel( 'litemage/observer_cron' )->getCrawlerStatus();
|
54 |
+
$status['url_reset'] = $this->getUrl('*/litemageCache/resetCrawlerList');
|
55 |
+
$status['url_details'] = $this->getUrl('*/litemageCache/getCrawlerList');
|
56 |
+
return $status;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Check if block can be displayed
|
61 |
+
*
|
62 |
+
* @return bool
|
63 |
+
*/
|
64 |
+
public function canShowButton()
|
65 |
+
{
|
66 |
+
return Mage::helper('litemage/data')->moduleEnabled();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function isCacheAvailable()
|
70 |
+
{
|
71 |
+
return Mage::app()->useCache('layout') && Mage::app()->useCache('config');
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/community/Litespeed/Litemage/Block/Core/Esi.php
CHANGED
@@ -1,47 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Block_Core_Esi extends Mage_Core_Block_Abstract
|
27 |
+
{
|
28 |
+
public function initByPeer( $peer, $esiHtml )
|
29 |
+
{
|
30 |
+
$this->setData('esiHtml', $esiHtml) ;
|
31 |
+
$peer->setData('litemageInjected', 1);
|
32 |
+
|
33 |
+
$this->_layout = $peer->_layout;
|
34 |
+
$this->_nameInLayout = $peer->_nameInLayout ;
|
35 |
+
$this->_alias = $peer->_alias;
|
36 |
+
$parent = $peer->getParentBlock();
|
37 |
+
if ($parent != null) {
|
38 |
+
$parent->setChild($peer->_alias, $this) ;
|
39 |
+
}
|
40 |
+
$this->_layout->setBlock($this->_nameInLayout, $this) ;
|
41 |
+
|
42 |
+
if (!$this->hasData('valueonly') && Mage::registry('LITEMAGE_SHOWHOLES')) {
|
43 |
+
$tip = 'LiteMage ESI block ' . $this->_nameInLayout;
|
44 |
+
$wrapperBegin = '<div style="position:relative;border:1px dotted red;background-color:rgba(198,245,174,0.3);margin:2px;padding:18px 2px 2px 2px;zoom:1;" title="' . $tip
|
45 |
+
. '"><div style="position: absolute; left: 0px; top: 0px; padding: 2px 5px; color: white; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-family: Arial; z-index: 998; text-align: left !important; background: rgba(0,100,0,0.5);">' . $tip . '</div>';
|
46 |
+
$this->setData('lmwrapperBegin', $wrapperBegin);
|
47 |
+
$this->setData('lmwrapperEnd', '</div>');
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _loadCache()
|
53 |
+
{
|
54 |
+
if ($this->hasData('esiHtml')) {
|
55 |
+
$esiHtml = $this->getData('esiHtml');
|
56 |
+
Mage::helper('litemage/data')->debugMesg('Injected ESI block ' . $this->_nameInLayout . ' ' . $esiHtml) ;
|
57 |
+
|
58 |
+
if (!$this->hasData('valueonly') && Mage::registry('LITEMAGE_SHOWHOLES'))
|
59 |
+
return $this->getData('lmwrapperBegin') . $esiHtml . $this->getData('lmwrapperEnd') ;
|
60 |
+
else {
|
61 |
+
return $esiHtml;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
else {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function _saveCache($data)
|
70 |
+
{
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/community/Litespeed/Litemage/Block/Core/Messages.php
CHANGED
@@ -1,164 +1,344 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Block_Core_Messages extends Mage_Core_Block_Messages
|
27 |
+
{
|
28 |
+
|
29 |
+
protected $_isEsiInject = false ;
|
30 |
+
protected $_hasSaved = false ;
|
31 |
+
protected $_outputCall ;
|
32 |
+
|
33 |
+
/*Override Mage_Core_Block_Abstract:getMessagesBlock */
|
34 |
+
public function getMessagesBlock()
|
35 |
+
{
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function initByPeer( $peer, $esiHtml )
|
40 |
+
{
|
41 |
+
$this->_isEsiInject = true ;
|
42 |
+
$this->setData('esiHtml', $esiHtml) ;
|
43 |
+
$peer->setData('litemageInjected', 1);
|
44 |
+
$this->_layout = $peer->_layout;
|
45 |
+
if ( $peer instanceof Mage_Core_Block_Messages ) {
|
46 |
+
$this->_messagesBlock = $peer ;
|
47 |
+
}
|
48 |
+
else {
|
49 |
+
$this->_messagesBlock = $this->_layout->getMessagesBlock();
|
50 |
+
}
|
51 |
+
$this->_nameInLayout = $peer->_nameInLayout ;
|
52 |
+
$this->_alias = $peer->_alias;
|
53 |
+
$parent = $peer->getParentBlock();
|
54 |
+
if ($parent != null) {
|
55 |
+
$parent->setChild($peer->_alias, $this) ;
|
56 |
+
}
|
57 |
+
$this->_layout->setBlock($this->_nameInLayout, $this) ;
|
58 |
+
|
59 |
+
if (Mage::registry('LITEMAGE_SHOWHOLES')) {
|
60 |
+
$tip = 'LiteMage ESI message block ' . $this->_nameInLayout;
|
61 |
+
$wrapperBegin = '<div style="position:relative;border:1px dotted red;background-color:rgba(255,255,0,0.3);margin:2px;padding:18px 2px 2px 2px;zoom:1;" title="' . $tip
|
62 |
+
. '"><div style="position: absolute; left: 0px; top: 0px; padding: 2px 5px; color: green; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-family: Arial; z-index: 998; text-align: left !important;">' . $tip . '</div>';
|
63 |
+
|
64 |
+
$this->setData('lmwrapperBegin', $wrapperBegin);
|
65 |
+
$this->setData('lmwrapperEnd', '</div>');
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
public function initByEsi( $storageNames, $outputCall, $peer )
|
70 |
+
{
|
71 |
+
$this->_layout = $peer->_layout;
|
72 |
+
if ( $peer instanceof Mage_Core_Block_Messages ) {
|
73 |
+
$this->_messagesBlock = $peer ;
|
74 |
+
}
|
75 |
+
else {
|
76 |
+
$this->_messagesBlock = $this->_layout->getMessagesBlock();
|
77 |
+
if ($tmpl = $peer->getTemplate()) {
|
78 |
+
$this->setTemplate($tmpl);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
$this->_usedStorageTypes = $storageNames ;
|
83 |
+
$this->_nameInLayout = $peer->getNameInLayout() ;
|
84 |
+
$this->_outputCall = $outputCall ;
|
85 |
+
$this->_alias = $peer->_alias;
|
86 |
+
$parent = $peer->getParentBlock();
|
87 |
+
if ($parent != null) {
|
88 |
+
$parent->setChild($peer->_alias, $this) ;
|
89 |
+
}
|
90 |
+
$this->_layout->setBlock($this->_nameInLayout, $this) ;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function renderView()
|
94 |
+
{
|
95 |
+
if ( ! $this->_hasSaved ) {
|
96 |
+
$messages = $this->getMessages() ;
|
97 |
+
if ( count($messages) > 0 ) {
|
98 |
+
// maybe multiple places point to same mesg block if use getMessageBlock(), use the name of the this->_messagesBlock, not itself
|
99 |
+
Mage::getSingleton('litemage/session')->saveMessages($this->_messagesBlock->_nameInLayout, $messages) ;
|
100 |
+
$this->getMessageCollection()->clear();
|
101 |
+
}
|
102 |
+
|
103 |
+
$this->_hasSaved = true ;
|
104 |
+
}
|
105 |
+
if ($this->_isEsiInject) {
|
106 |
+
$esiHtml = $this->getData('esiHtml');
|
107 |
+
Mage::helper('litemage/data')->debugMesg('Injected ESI Message block ' . $this->_nameInLayout . ' ' . $esiHtml) ;
|
108 |
+
|
109 |
+
if (Mage::registry('LITEMAGE_SHOWHOLES'))
|
110 |
+
return $this->getData('lmwrapperBegin') . $esiHtml . $this->getData('lmwrapperEnd') ;
|
111 |
+
else
|
112 |
+
return $esiHtml;
|
113 |
+
}
|
114 |
+
else
|
115 |
+
return parent::renderView() ;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function getGroupedHtml()
|
119 |
+
{
|
120 |
+
if ( $this->_isEsiInject ) {
|
121 |
+
$this->_adjustEsiUrl('getGroupedHtml') ;
|
122 |
+
return $this->renderView() ;
|
123 |
+
}
|
124 |
+
else {
|
125 |
+
$this->_loadMessages() ;
|
126 |
+
return $this->_messagesBlock->getGroupedHtml() ;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
public function getHtml( $type = null )
|
131 |
+
{
|
132 |
+
if ( $this->_isEsiInject ) {
|
133 |
+
$this->_adjustEsiUrl('getHtml', $type) ;
|
134 |
+
return $this->renderView() ;
|
135 |
+
}
|
136 |
+
else {
|
137 |
+
$this->_loadMessages($type) ;
|
138 |
+
return $this->_messagesBlock->getHtml($type) ;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
public function _prepareLayout()
|
143 |
+
{
|
144 |
+
// do nothing, as data already carried over
|
145 |
+
return $this ;
|
146 |
+
}
|
147 |
+
|
148 |
+
protected function _loadCache()
|
149 |
+
{
|
150 |
+
if ( $this->_isEsiInject && $this->hasData('esiHtml') ) {
|
151 |
+
$html = $this->getData('esiHtml') ;
|
152 |
+
if ( strpos($html, '/getMessage/') ) {
|
153 |
+
Mage::helper('litemage/data')->debugMesg('Injected ESI Message block ' . $this->_nameInLayout . ' ' . $html) ;
|
154 |
+
|
155 |
+
if (Mage::registry('LITEMAGE_SHOWHOLES'))
|
156 |
+
return $this->getData('lmwrapperBegin') . $html . $this->getData('lmwrapperEnd') ;
|
157 |
+
else
|
158 |
+
return $html ;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
return false ;
|
162 |
+
}
|
163 |
+
|
164 |
+
protected function _toHtml()
|
165 |
+
{
|
166 |
+
if ( $this->_isEsiInject ) {
|
167 |
+
$this->_adjustEsiUrl('_toHtml') ;
|
168 |
+
return $this->renderView() ;
|
169 |
+
}
|
170 |
+
else {
|
171 |
+
|
172 |
+
if ($this->getTemplate()) {
|
173 |
+
$this->_loadMessages();
|
174 |
+
$this->setScriptPath(Mage::getBaseDir('design'));
|
175 |
+
$html = $this->fetchView($this->getTemplateFile());
|
176 |
+
return $html;
|
177 |
+
}
|
178 |
+
|
179 |
+
// default is getGroupedHtml
|
180 |
+
if ( strncmp($this->_outputCall, 'getHtml', 7) == 0 ) {
|
181 |
+
$type = ($this->_outputCall == 'getHtml') ? null : substr($this->_outputCall, 7) ;
|
182 |
+
return $this->getHtml($type) ;
|
183 |
+
}
|
184 |
+
else {
|
185 |
+
return $this->getGroupedHtml() ;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
protected function _adjustEsiUrl( $caller, $type = null )
|
192 |
+
{
|
193 |
+
$esiHtml = $this->getData('esiHtml') ;
|
194 |
+
|
195 |
+
if ( strpos($esiHtml, '/getBlock/') ) {
|
196 |
+
$types = join(',', $this->_getStorageTypes());
|
197 |
+
$param = array( $types, $caller . $type ) ;
|
198 |
+
$param1 = str_replace('/session', '--', $param) ;
|
199 |
+
$param1 = str_replace('/', '-', $param1) ;
|
200 |
+
$replaced = '/getMessage/st/' . $param1[0] . '/call/' . $param1[1] . '/' ;
|
201 |
+
|
202 |
+
$esiHtml = str_replace('/getBlock/', $replaced, $esiHtml) ;
|
203 |
+
$this->setData('esiHtml', $esiHtml) ;
|
204 |
+
Mage::helper('litemage/esi')->setEsiBlockHtml($this->_nameInLayout, $esiHtml);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
protected function _loadMessages( $type = null )
|
209 |
+
{
|
210 |
+
$session = Mage::getSingleton('litemage/session') ;
|
211 |
+
if ( ($savedMessages = $session->loadMessages($this->_messagesBlock->_nameInLayout)) != null ) {
|
212 |
+
foreach ( $savedMessages as $savedMessage ) {
|
213 |
+
$this->addMessage($savedMessage) ;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
$types = ($type == null) ? $this->_usedStorageTypes : (is_array($type) ? $type : array( $type )) ;
|
218 |
+
|
219 |
+
foreach ( $types as $storageName ) {
|
220 |
+
if ( ($storage = Mage::getSingleton($storageName)) != null ) {
|
221 |
+
$this->addMessages($storage->getMessages(true)) ;
|
222 |
+
$this->setEscapeMessageFlag($storage->getEscapeMessages(true)) ;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
public function setEscapeMessageFlag( $flag )
|
228 |
+
{
|
229 |
+
$this->_messagesBlock->setEscapeMessageFlag($flag) ;
|
230 |
+
return $this ;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Set messages collection
|
235 |
+
*
|
236 |
+
* @param Mage_Core_Model_Message_Collection $messages
|
237 |
+
* @return Mage_Core_Block_Messages
|
238 |
+
*/
|
239 |
+
public function setMessages( Mage_Core_Model_Message_Collection $messages )
|
240 |
+
{
|
241 |
+
$this->_messagesBlock->setMessages($messages) ;
|
242 |
+
return $this ;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Add messages to display
|
247 |
+
*
|
248 |
+
* @param Mage_Core_Model_Message_Collection $messages
|
249 |
+
* @return Mage_Core_Block_Messages
|
250 |
+
*/
|
251 |
+
public function addMessages( Mage_Core_Model_Message_Collection $messages )
|
252 |
+
{
|
253 |
+
if ( $messages->count() > 0 ) {
|
254 |
+
$this->_messagesBlock->addMessages($messages) ;
|
255 |
+
}
|
256 |
+
return $this ;
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Retrieve messages collection
|
261 |
+
*
|
262 |
+
* @return Mage_Core_Model_Message_Collection
|
263 |
+
*/
|
264 |
+
public function getMessageCollection()
|
265 |
+
{
|
266 |
+
return $this->_messagesBlock->getMessageCollection() ;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Adding new message to message collection
|
271 |
+
*
|
272 |
+
* @param Mage_Core_Model_Message_Abstract $message
|
273 |
+
* @return Mage_Core_Block_Messages
|
274 |
+
*/
|
275 |
+
public function addMessage( Mage_Core_Model_Message_Abstract $message )
|
276 |
+
{
|
277 |
+
$this->_messagesBlock->addMessage($message) ;
|
278 |
+
return $this ;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Retrieve messages array by message type
|
283 |
+
*
|
284 |
+
* @param string $type
|
285 |
+
* @return array
|
286 |
+
*/
|
287 |
+
public function getMessages( $type = null )
|
288 |
+
{
|
289 |
+
return $this->_messagesBlock->getMessages($type) ;
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Set messages first level html tag name for output messages as html
|
294 |
+
*
|
295 |
+
* @param string $tagName
|
296 |
+
*/
|
297 |
+
public function setMessagesFirstLevelTagName( $tagName )
|
298 |
+
{
|
299 |
+
$this->_messagesBlock->setMessagesFirstLevelTagName($tagName) ;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Set messages first level html tag name for output messages as html
|
304 |
+
*
|
305 |
+
* @param string $tagName
|
306 |
+
*/
|
307 |
+
public function setMessagesSecondLevelTagName( $tagName )
|
308 |
+
{
|
309 |
+
$this->_messagesBlock->setMessagesSecondLevelTagName($tagName) ;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Get cache key informative items
|
314 |
+
*
|
315 |
+
* @return array
|
316 |
+
*/
|
317 |
+
public function getCacheKeyInfo()
|
318 |
+
{
|
319 |
+
return $this->_messagesBlock->getCacheKeyInfo() ;
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Add used storage type
|
324 |
+
*
|
325 |
+
* @param string $type
|
326 |
+
*/
|
327 |
+
public function addStorageType( $type )
|
328 |
+
{
|
329 |
+
$this->_messagesBlock->addStorageType($type) ;
|
330 |
+
if ( ! in_array($type, $this->_usedStorageTypes) )
|
331 |
+
$this->_usedStorageTypes[] = $type ;
|
332 |
+
}
|
333 |
+
|
334 |
+
protected function _getStorageTypes()
|
335 |
+
{
|
336 |
+
// it's possible, messageblock already replaced with esi one, when using layout->getMessageBlock
|
337 |
+
$types = array_merge($this->_usedStorageTypes, $this->_messagesBlock->_usedStorageTypes);
|
338 |
+
if ( ($this->_messagesBlock instanceof Litespeed_Litemage_Block_Core_Messages) && ($this->_messagesBlock->_messagesBlock != null)) {
|
339 |
+
$types = array_merge($types, $this->_messagesBlock->_messagesBlock->_usedStorageTypes);
|
340 |
+
}
|
341 |
+
return array_unique($types);
|
342 |
+
}
|
343 |
+
|
344 |
+
}
|
app/code/community/Litespeed/Litemage/Block/Inject/Jsvar.php
CHANGED
@@ -1,10 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
|
|
8 |
/* This is place holder block to adjust javascript variables. This is a private block, so javascript variable can be adjusted to correct value.
|
9 |
*
|
10 |
* The template file is jsvar.phtml
|
@@ -24,6 +42,6 @@ class Litespeed_Litemage_Block_Inject_Jsvar extends Mage_Core_Block_Template
|
|
24 |
return false;
|
25 |
}
|
26 |
}
|
27 |
-
|
28 |
// you can add your own function here to handle customized javascript variable
|
29 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
*/
|
24 |
|
25 |
+
|
26 |
/* This is place holder block to adjust javascript variables. This is a private block, so javascript variable can be adjusted to correct value.
|
27 |
*
|
28 |
* The template file is jsvar.phtml
|
42 |
return false;
|
43 |
}
|
44 |
}
|
45 |
+
|
46 |
// you can add your own function here to handle customized javascript variable
|
47 |
}
|
app/code/community/Litespeed/Litemage/Block/Inject/Nickname.php
CHANGED
@@ -1,10 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
|
|
8 |
/* This is sample code to inject a private block which shows customer name only.
|
9 |
* In litemage config.xml, this block needs to have <valueonly>1</valueonly>. It will output pure value, no added html tags.
|
10 |
*
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
*/
|
24 |
|
25 |
+
|
26 |
/* This is sample code to inject a private block which shows customer name only.
|
27 |
* In litemage config.xml, this block needs to have <valueonly>1</valueonly>. It will output pure value, no added html tags.
|
28 |
*
|
app/code/community/Litespeed/Litemage/Helper/Data.php
CHANGED
@@ -1,317 +1,516 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
26 |
+
{
|
27 |
+
|
28 |
+
const CFGXML_DEFAULTLM = 'default/litemage' ;
|
29 |
+
const CFGXML_ESIBLOCK = 'frontend/litemage/esiblock' ;
|
30 |
+
|
31 |
+
const STOREXML_PUBLICTTL = 'litemage/general/public_ttl' ;
|
32 |
+
const STOREXML_PRIVATETTL = 'litemage/general/private_ttl' ;
|
33 |
+
const STOREXML_TRACKLASTVIEWED = 'litemage/general/track_viewed' ;
|
34 |
+
const STOREXML_DIFFCUSTGRP = 'litemage/general/diff_customergroup' ;
|
35 |
+
const STOREXML_WARMUP_EANBLED = 'litemage/warmup/enable_warmup' ;
|
36 |
+
const STOREXML_WARMUP_MULTICURR = 'litemage/warmup/multi_currency' ;
|
37 |
+
const STOREXML_WARMUP_INTERVAL = 'litemage/warmup/interval' ;
|
38 |
+
const STOREXML_WARMUP_PRIORITY = 'litemage/warmup/priority' ;
|
39 |
+
const STOREXML_WARMUP_CUSTLIST = 'litemage/warmup/custlist' ;
|
40 |
+
const STOREXML_WARMUP_CUSTLIST_PRIORITY = 'litemage/warmup/custlist_priority' ;
|
41 |
+
const STOREXML_WARMUP_CUSTLIST_INTERVAL = 'litemage/warmup/custlist_interval' ;
|
42 |
+
|
43 |
+
const CFG_ENABLED = 'enabled' ;
|
44 |
+
const CFG_DEBUGON = 'debug' ;
|
45 |
+
const CFG_WARMUP = 'warmup' ;
|
46 |
+
const CFG_WARMUP_ALLOW = 'allow_warmup' ;
|
47 |
+
const CFG_WARMUP_EANBLED = 'enable_warmup' ;
|
48 |
+
const CFG_WARMUP_LOAD_LIMIT = 'load_limit' ;
|
49 |
+
const CFG_WARMUP_MAXTIME = 'max_time' ;
|
50 |
+
const CFG_WARMUP_THREAD_LIMIT = 'thread_limit' ;
|
51 |
+
const CFG_WARMUP_MULTICURR = 'multi_currency';
|
52 |
+
const CFG_TRACKLASTVIEWED = 'track_viewed' ;
|
53 |
+
const CFG_DIFFCUSTGRP = 'diff_customergroup' ;
|
54 |
+
const CFG_PUBLICTTL = 'public_ttl' ;
|
55 |
+
const CFG_PRIVATETTL = 'private_ttl' ;
|
56 |
+
const CFG_ESIBLOCK = 'esiblock' ;
|
57 |
+
const CFG_NOCACHE = 'nocache' ;
|
58 |
+
const CFG_CACHE_ROUTE = 'cache_routes' ;
|
59 |
+
const CFG_NOCACHE_ROUTE = 'nocache_routes' ;
|
60 |
+
const CFG_FULLCACHE_ROUTE = 'fullcache_routes' ;
|
61 |
+
const CFG_NOCACHE_VAR = 'nocache_vars' ;
|
62 |
+
const CFG_NOCACHE_URL = 'nocache_urls' ;
|
63 |
+
const CFG_ALLOWEDIPS = 'allow_ips' ;
|
64 |
+
const CFG_ADMINIPS = 'admin_ips';
|
65 |
+
const LITEMAGE_GENERAL_CACHE_TAG = 'LITESPEED_LITEMAGE' ;
|
66 |
+
|
67 |
+
// config items
|
68 |
+
protected $_conf = array() ;
|
69 |
+
protected $_userModuleEnabled = -2 ; // -2: not set, true, false
|
70 |
+
protected $_esiTag;
|
71 |
+
protected $_isDebug ;
|
72 |
+
protected $_debugTag = 'LiteMage' ;
|
73 |
+
|
74 |
+
public function moduleEnabled()
|
75 |
+
{
|
76 |
+
if ( isset($_SERVER['X-LITEMAGE']) && $_SERVER['X-LITEMAGE'] ) {
|
77 |
+
return $this->getConf(self::CFG_ENABLED) ;
|
78 |
+
}
|
79 |
+
else {
|
80 |
+
return false ;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
public function moduleEnabledForUser()
|
85 |
+
{
|
86 |
+
if ( $this->_userModuleEnabled === -2 ) {
|
87 |
+
$allowed = $this->moduleEnabled() ;
|
88 |
+
if ( $allowed ) {
|
89 |
+
$tag = '';
|
90 |
+
$httphelper = Mage::helper('core/http') ;
|
91 |
+
$remoteAddr = $httphelper->getRemoteAddr() ;
|
92 |
+
if ( $httphelper->getHttpUserAgent() == 'litemage_walker' ) {
|
93 |
+
$tag = 'litemage_walker:';
|
94 |
+
}
|
95 |
+
else if ( $ips = $this->getConf(self::CFG_ALLOWEDIPS) ) {
|
96 |
+
if ( ! in_array($remoteAddr, $ips) ) {
|
97 |
+
$allowed = false ;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
if ($this->_isDebug && $allowed) {
|
102 |
+
$tag .= $remoteAddr ;
|
103 |
+
$msec = microtime();
|
104 |
+
$msec1 = substr($msec, 2, strpos($msec, ' ') -2);
|
105 |
+
$this->_debugTag .= ' [' . $tag . ':'. $_SERVER['REMOTE_PORT'] . ':' . $msec1 . ']' ;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
$this->_userModuleEnabled = $allowed ;
|
109 |
+
}
|
110 |
+
return $this->_userModuleEnabled ;
|
111 |
+
}
|
112 |
+
|
113 |
+
public function isAdminIP()
|
114 |
+
{
|
115 |
+
if ($adminIps = $this->getConf(self::CFG_ADMINIPS) ) {
|
116 |
+
$remoteAddr = Mage::helper('core/http')->getRemoteAddr() ;
|
117 |
+
if (in_array($remoteAddr, $adminIps)) {
|
118 |
+
return true;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
public function isRestrainedIP()
|
125 |
+
{
|
126 |
+
return ($this->getConf(self::CFG_ALLOWEDIPS) != '') ;
|
127 |
+
}
|
128 |
+
|
129 |
+
public function isDebug()
|
130 |
+
{
|
131 |
+
return $this->getConf(self::CFG_DEBUGON) ;
|
132 |
+
}
|
133 |
+
|
134 |
+
public function esiTag($type)
|
135 |
+
{
|
136 |
+
if (isset($this->_esiTag[$type])) {
|
137 |
+
return $this->_esiTag[$type];
|
138 |
+
}
|
139 |
+
|
140 |
+
if ( $this->_isDebug ) {
|
141 |
+
$this->debugMesg('Invalid type for esiTag ' . $type);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
public function trackLastViewed()
|
146 |
+
{
|
147 |
+
return Mage::getStoreConfig(self::STOREXML_TRACKLASTVIEWED);
|
148 |
+
}
|
149 |
+
|
150 |
+
public function getEsiConf( $type = '', $name = '' ) //type = tag, block, event
|
151 |
+
{
|
152 |
+
$conf = $this->getConf('', self::CFG_ESIBLOCK) ;
|
153 |
+
if ( $type == 'event' && ! isset($conf['event']) ) {
|
154 |
+
$events = array() ;
|
155 |
+
foreach ( $conf['tag'] as $tag => $d ) {
|
156 |
+
if ( isset($d['purge_events']) ) {
|
157 |
+
$pes = array_keys($d['purge_events']) ;
|
158 |
+
foreach ( $pes as $e ) {
|
159 |
+
if ( ! isset($events[$e]) )
|
160 |
+
$events[$e] = array() ;
|
161 |
+
$events[$e][] = $d['cache-tag'];
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
$this->_conf[self::CFG_ESIBLOCK]['event'] = $events ;
|
166 |
+
return $events ;
|
167 |
+
}
|
168 |
+
if ( $type == '' )
|
169 |
+
return $conf ;
|
170 |
+
elseif ( $name == '' )
|
171 |
+
return $conf[$type] ;
|
172 |
+
else
|
173 |
+
return $conf[$type][$name] ;
|
174 |
+
}
|
175 |
+
|
176 |
+
public function getWarmUpConf()
|
177 |
+
{
|
178 |
+
if (!isset($this->_conf[self::CFG_WARMUP])) {
|
179 |
+
|
180 |
+
$storeInfo = array();
|
181 |
+
if ( $this->getConf(self::CFG_ENABLED) ) {
|
182 |
+
$this->getConf('', self::CFG_WARMUP);
|
183 |
+
$app = Mage::app();
|
184 |
+
$storeIds = array_keys($app->getStores());
|
185 |
+
$vary_dev = $this->isRestrainedIP() ? '/vary_dev/1' : '';
|
186 |
+
|
187 |
+
foreach ($storeIds as $storeId) {
|
188 |
+
$isEnabled = Mage::getStoreConfig(self::STOREXML_WARMUP_EANBLED, $storeId);
|
189 |
+
if ($isEnabled) {
|
190 |
+
$store = $app->getStore($storeId);
|
191 |
+
if (!$store->getIsActive()) {
|
192 |
+
continue;
|
193 |
+
}
|
194 |
+
$site = $store->getWebsite();
|
195 |
+
$is_default_store = ($site->getDefaultStore()->getId() == $storeId); // cannot use $app->getDefaultStoreView()->getId();
|
196 |
+
$is_default_site = $site->getIsDefault();
|
197 |
+
$orderAdjust = 0.0;
|
198 |
+
if ($is_default_site)
|
199 |
+
$orderAdjust -= 0.25;
|
200 |
+
if ($is_default_store)
|
201 |
+
$orderAdjust -= 0.25;
|
202 |
+
|
203 |
+
$vary_curr = '';
|
204 |
+
$curr = trim(Mage::getStoreConfig(self::STOREXML_WARMUP_MULTICURR, $storeId));
|
205 |
+
if ($curr) {
|
206 |
+
// get currency vary
|
207 |
+
$availCurrCodes = $store->getAvailableCurrencyCodes() ;
|
208 |
+
$default_currency = $store->getDefaultCurrencyCode() ;
|
209 |
+
|
210 |
+
$currs = preg_split("/[\s,]+/", strtoupper($curr), null, PREG_SPLIT_NO_EMPTY) ;
|
211 |
+
if (in_array('ALL', $currs)) {
|
212 |
+
$currs = $availCurrCodes;
|
213 |
+
}
|
214 |
+
else {
|
215 |
+
$currs = array_unique($currs);
|
216 |
+
}
|
217 |
+
|
218 |
+
foreach ($currs as $cur) {
|
219 |
+
if ( $cur != $default_currency && in_array($cur, $availCurrCodes) ) {
|
220 |
+
$vary_curr .= ',' . $cur ;
|
221 |
+
}
|
222 |
+
}
|
223 |
+
if ($vary_curr) {
|
224 |
+
$vary_curr = '/vary_curr/-' . $vary_curr; // "-" means default
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
$vary_cgrp = '' ;
|
229 |
+
/*if ( $diffGrp = Mage::getStoreConfig(self::STOREXML_DIFFCUSTGRP, $storeId)) ) {
|
230 |
+
// $crawlgrp = 'out' ;
|
231 |
+
$crawlUsers = array(138, 137);
|
232 |
+
if ($crawlUsers) {
|
233 |
+
if ($diffGrp == 2) {
|
234 |
+
// for in & out
|
235 |
+
$crawlgrp .= ',in_138';
|
236 |
+
}
|
237 |
+
* '/vary_cgrp/' . $vary_customergroup ;
|
238 |
+
}
|
239 |
+
//}*/
|
240 |
+
|
241 |
+
$env = '';
|
242 |
+
|
243 |
+
$priority = Mage::getStoreConfig(self::STOREXML_WARMUP_PRIORITY, $storeId) + $orderAdjust;
|
244 |
+
if (!$is_default_store) {
|
245 |
+
$env .= '/store/' . $store->getCode() . '/storeId/' . $storeId ;
|
246 |
+
}
|
247 |
+
$env .= $vary_curr . $vary_cgrp . $vary_dev;
|
248 |
+
$baseurl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
249 |
+
$ttl = Mage::getStoreConfig(self::STOREXML_PUBLICTTL, $storeId);
|
250 |
+
$interval = Mage::getStoreConfig(self::STOREXML_WARMUP_INTERVAL, $storeId);
|
251 |
+
if ($interval == '' || $interval < 600) { // for upgrade users, not refreshed conf
|
252 |
+
$interval = $ttl;
|
253 |
+
}
|
254 |
+
|
255 |
+
if ($isEnabled == 1) {
|
256 |
+
$listId = 'store' . $storeId;
|
257 |
+
$storeInfo[$listId] = array(
|
258 |
+
'id' => $listId,
|
259 |
+
'storeid' => $storeId,
|
260 |
+
'default_store' => $is_default_store,
|
261 |
+
'default_site' => $is_default_site,
|
262 |
+
'env' => $env,
|
263 |
+
'interval' => $interval,
|
264 |
+
'ttl' => $ttl,
|
265 |
+
'priority' => $priority,
|
266 |
+
'baseurl' => $baseurl );
|
267 |
+
}
|
268 |
+
|
269 |
+
// check custom list
|
270 |
+
$custlist = Mage::getStoreConfig(self::STOREXML_WARMUP_CUSTLIST, $storeId);
|
271 |
+
if (is_readable($custlist)) {
|
272 |
+
$priority = Mage::getStoreConfig(self::STOREXML_WARMUP_CUSTLIST_PRIORITY, $storeId) + $orderAdjust;
|
273 |
+
$custInterval = Mage::getStoreConfig(self::STOREXML_WARMUP_CUSTLIST_INTERVAL, $storeId);
|
274 |
+
$listId = 'cust' . $storeId;
|
275 |
+
$storeInfo[$listId] = array(
|
276 |
+
'id' => $listId,
|
277 |
+
'storeid' => $storeId,
|
278 |
+
'env' => $env,
|
279 |
+
'interval' => $custInterval,
|
280 |
+
'ttl' => $ttl,
|
281 |
+
'priority' => $priority,
|
282 |
+
'baseurl' => $baseurl,
|
283 |
+
'file' => $custlist );
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
287 |
+
}
|
288 |
+
else {
|
289 |
+
$this->_conf[self::CFG_WARMUP] = array();
|
290 |
+
}
|
291 |
+
|
292 |
+
if (empty($storeInfo)) {
|
293 |
+
if ( $this->_isDebug ) {
|
294 |
+
$this->debugMesg('Cron warm up skipped due to configuration not enabled.') ;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
else {
|
298 |
+
$load = sys_getloadavg() ;
|
299 |
+
$limit = $this->_conf[self::CFG_WARMUP][self::CFG_WARMUP_LOAD_LIMIT] ;
|
300 |
+
if ( $load[0] > $limit ) {
|
301 |
+
if ( $this->_isDebug ) {
|
302 |
+
$this->debugMesg('Cron warm up skipped due to load. Limit is ' . $limit . ', current load is ' . $load[0]) ;
|
303 |
+
}
|
304 |
+
}
|
305 |
+
else {
|
306 |
+
$this->_conf[self::CFG_WARMUP]['store'] = $storeInfo;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
return $this->_conf[self::CFG_WARMUP];
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
public function isEsiBlock( $block )
|
316 |
+
{
|
317 |
+
$blockName = $block->getNameInLayout();
|
318 |
+
$tag = null;
|
319 |
+
$valueonly = 0;
|
320 |
+
$blockType = null;
|
321 |
+
|
322 |
+
$ref = $this->_conf[self::CFG_ESIBLOCK]['block'];
|
323 |
+
if (isset($ref['bn'][$blockName])) {
|
324 |
+
$tag = $ref['bn'][$blockName]['tag'];
|
325 |
+
$valueonly = $ref['bn'][$blockName]['valueonly'];
|
326 |
+
}
|
327 |
+
else {
|
328 |
+
foreach ($ref['bt'] as $bt => $bv) {
|
329 |
+
if ($block instanceof $bt) {
|
330 |
+
$tag = $bv['tag'];
|
331 |
+
$valueonly = $bv['valueonly'];
|
332 |
+
$blockType = $bt;
|
333 |
+
break;
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
if ($tag == null) {
|
338 |
+
return null;
|
339 |
+
}
|
340 |
+
else {
|
341 |
+
$tagdata = $this->_conf[self::CFG_ESIBLOCK]['tag'][$tag];
|
342 |
+
$bconf = array(
|
343 |
+
'tag' => $tag,
|
344 |
+
'cache-tag' => $tagdata['cache-tag'],
|
345 |
+
'access' => $tagdata['access'],
|
346 |
+
'valueonly' => $valueonly,
|
347 |
+
'bn' => $blockName,
|
348 |
+
'bt' => $blockType
|
349 |
+
);
|
350 |
+
return $bconf;
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
public function getNoCacheConf( $name = '' )
|
355 |
+
{
|
356 |
+
return $this->getConf($name, self::CFG_NOCACHE) ;
|
357 |
+
}
|
358 |
+
|
359 |
+
public function getConf( $name, $type = '' )
|
360 |
+
{
|
361 |
+
if ( ($type == '' && ! isset($this->_conf[$name])) || ($type != '' && ! isset($this->_conf[$type])) ) {
|
362 |
+
$this->_initConf($type) ;
|
363 |
+
}
|
364 |
+
|
365 |
+
// get store override, because store id may change after init
|
366 |
+
if ($name == self::CFG_DIFFCUSTGRP) {
|
367 |
+
$this->_conf[self::CFG_DIFFCUSTGRP] = Mage::getStoreConfig(self::STOREXML_DIFFCUSTGRP);
|
368 |
+
}
|
369 |
+
elseif ($name == self::CFG_PUBLICTTL) {
|
370 |
+
$this->_conf[self::CFG_PUBLICTTL] = Mage::getStoreConfig(self::STOREXML_PUBLICTTL);
|
371 |
+
}
|
372 |
+
elseif ($name == self::CFG_PRIVATETTL) {
|
373 |
+
$this->_conf[self::CFG_PRIVATETTL] = Mage::getStoreConfig(self::STOREXML_PRIVATETTL);
|
374 |
+
}
|
375 |
+
elseif ($name == self::CFG_TRACKLASTVIEWED) {
|
376 |
+
$this->_conf[self::CFG_TRACKLASTVIEWED] = Mage::getStoreConfig(self::STOREXML_TRACKLASTVIEWED);
|
377 |
+
}
|
378 |
+
|
379 |
+
if ( $type == '' )
|
380 |
+
return $this->_conf[$name] ;
|
381 |
+
else if ( $name == '' )
|
382 |
+
return $this->_conf[$type] ;
|
383 |
+
else
|
384 |
+
return $this->_conf[$type][$name] ;
|
385 |
+
}
|
386 |
+
|
387 |
+
protected function _initConf( $type = '' )
|
388 |
+
{
|
389 |
+
$storeId = Mage::app()->getStore()->getId();
|
390 |
+
if ( ! isset($this->_conf['defaultlm']) ) {
|
391 |
+
$this->_conf['defaultlm'] = $this->_getConfigByPath(self::CFGXML_DEFAULTLM) ;
|
392 |
+
}
|
393 |
+
$pattern = "/[\s,]+/" ;
|
394 |
+
|
395 |
+
switch ( $type ) {
|
396 |
+
case self::CFG_ESIBLOCK:
|
397 |
+
$this->_conf[self::CFG_ESIBLOCK] = array() ;
|
398 |
+
$this->_conf[self::CFG_ESIBLOCK]['tag'] = $this->_getConfigByPath(self::CFGXML_ESIBLOCK) ;
|
399 |
+
|
400 |
+
$custblocks = array();
|
401 |
+
$custblocks['welcome'] = preg_split($pattern, $this->_conf['defaultlm']['donotcache']['welcome'], null, PREG_SPLIT_NO_EMPTY) ;
|
402 |
+
$custblocks['toplinks'] = preg_split($pattern, $this->_conf['defaultlm']['donotcache']['toplinks'], null, PREG_SPLIT_NO_EMPTY) ;
|
403 |
+
$custblocks['messages'] = preg_split($pattern, $this->_conf['defaultlm']['donotcache']['messages'], null, PREG_SPLIT_NO_EMPTY) ;
|
404 |
+
|
405 |
+
$allblocks = array('bn' => array(), 'bt' => array());
|
406 |
+
foreach ( $this->_conf[self::CFG_ESIBLOCK]['tag'] as $tag => $d ) {
|
407 |
+
$this->_conf[self::CFG_ESIBLOCK]['tag'][$tag]['cache-tag'] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_ESIBLOCK . $tag ;
|
408 |
+
$blocks = preg_split($pattern, $d['blocks'], null, PREG_SPLIT_NO_EMPTY) ;
|
409 |
+
if (!empty($custblocks[$tag])) {
|
410 |
+
$blocks = array_merge($blocks, $custblocks[$tag]);
|
411 |
+
}
|
412 |
+
|
413 |
+
foreach ( $blocks as $b ) {
|
414 |
+
$valueonly = 0;
|
415 |
+
if (substr($b, -2) == '$v') {
|
416 |
+
$valueonly = 1;
|
417 |
+
$b = substr($b, 0, -2);
|
418 |
+
}
|
419 |
+
$bc = array('tag' => $tag, 'valueonly' => $valueonly);
|
420 |
+
if (substr($b,0,2) == 'T:') {
|
421 |
+
$b = substr($b,2);
|
422 |
+
$allblocks['bt'][$b] = $bc;
|
423 |
+
}
|
424 |
+
else {
|
425 |
+
$allblocks['bn'][$b] = $bc;
|
426 |
+
}
|
427 |
+
}
|
428 |
+
if ( isset($d['purge_tags']) ) {
|
429 |
+
$pts = preg_split($pattern, $d['purge_tags'], null, PREG_SPLIT_NO_EMPTY) ;
|
430 |
+
if (!isset($d['purge_events']))
|
431 |
+
$this->_conf[self::CFG_ESIBLOCK]['tag'][$tag]['purge_events'] = array();
|
432 |
+
foreach ( $pts as $t ) {
|
433 |
+
if (isset($this->_conf[self::CFG_ESIBLOCK]['tag'][$t]['purge_events'])) {
|
434 |
+
$this->_conf[self::CFG_ESIBLOCK]['tag'][$tag]['purge_events'] =
|
435 |
+
array_merge($this->_conf[self::CFG_ESIBLOCK]['tag'][$tag]['purge_events'],
|
436 |
+
$this->_conf[self::CFG_ESIBLOCK]['tag'][$t]['purge_events']);
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
}
|
441 |
+
|
442 |
+
}
|
443 |
+
$this->_conf[self::CFG_ESIBLOCK]['block'] = $allblocks ;
|
444 |
+
break ;
|
445 |
+
|
446 |
+
case self::CFG_NOCACHE:
|
447 |
+
$this->_conf[self::CFG_NOCACHE] = array() ;
|
448 |
+
$default = $this->_conf['defaultlm']['default'] ;
|
449 |
+
$cust = $this->_conf['defaultlm']['donotcache'] ;
|
450 |
+
|
451 |
+
$this->_conf[self::CFG_NOCACHE][self::CFG_CACHE_ROUTE] = array_merge(preg_split($pattern, $default['cache_routes'], null, PREG_SPLIT_NO_EMPTY),
|
452 |
+
preg_split($pattern, $cust['cache_routes'], null, PREG_SPLIT_NO_EMPTY));
|
453 |
+
$this->_conf[self::CFG_NOCACHE][self::CFG_NOCACHE_ROUTE] = array_merge(preg_split($pattern, $default['nocache_subroutes'], null, PREG_SPLIT_NO_EMPTY),
|
454 |
+
preg_split($pattern, $default['nocache_subroutes'], null, PREG_SPLIT_NO_EMPTY));
|
455 |
+
$this->_conf[self::CFG_NOCACHE][self::CFG_FULLCACHE_ROUTE] = preg_split($pattern, $default['fullcache_routes'], null, PREG_SPLIT_NO_EMPTY) ;
|
456 |
+
$this->_conf[self::CFG_NOCACHE][self::CFG_NOCACHE_VAR] = preg_split($pattern, $cust['vars'], null, PREG_SPLIT_NO_EMPTY) ;
|
457 |
+
$this->_conf[self::CFG_NOCACHE][self::CFG_NOCACHE_URL] = preg_split($pattern, $cust['urls'], null, PREG_SPLIT_NO_EMPTY) ;
|
458 |
+
break ;
|
459 |
+
|
460 |
+
case self::CFG_WARMUP:
|
461 |
+
$warmup = $this->_conf['defaultlm']['warmup'] ;
|
462 |
+
$this->_conf[self::CFG_WARMUP] = array(
|
463 |
+
self::CFG_WARMUP_EANBLED => $warmup[self::CFG_WARMUP_EANBLED],
|
464 |
+
self::CFG_WARMUP_LOAD_LIMIT => $warmup[self::CFG_WARMUP_LOAD_LIMIT],
|
465 |
+
self::CFG_WARMUP_THREAD_LIMIT => $warmup[self::CFG_WARMUP_THREAD_LIMIT],
|
466 |
+
self::CFG_WARMUP_MAXTIME => $warmup[self::CFG_WARMUP_MAXTIME],
|
467 |
+
self::CFG_WARMUP_MULTICURR => $warmup[self::CFG_WARMUP_MULTICURR]);
|
468 |
+
break ;
|
469 |
+
|
470 |
+
default:
|
471 |
+
$general = $this->_conf['defaultlm']['general'] ;
|
472 |
+
$this->_conf[self::CFG_ENABLED] = $general[self::CFG_ENABLED] ;
|
473 |
+
|
474 |
+
$test = $this->_conf['defaultlm']['test'] ;
|
475 |
+
$this->_conf[self::CFG_DEBUGON] = $test[self::CFG_DEBUGON] ;
|
476 |
+
$this->_isDebug = $test[self::CFG_DEBUGON] ; // required by cron, needs to be set even when module disabled.
|
477 |
+
|
478 |
+
if ( ! $general[self::CFG_ENABLED] )
|
479 |
+
break ;
|
480 |
+
|
481 |
+
// get store override
|
482 |
+
$this->_conf[self::CFG_TRACKLASTVIEWED] = Mage::getStoreConfig(self::STOREXML_TRACKLASTVIEWED, $storeId);
|
483 |
+
$this->_conf[self::CFG_DIFFCUSTGRP] = Mage::getStoreConfig(self::STOREXML_DIFFCUSTGRP, $storeId);
|
484 |
+
$this->_conf[self::CFG_PUBLICTTL] = Mage::getStoreConfig(self::STOREXML_PUBLICTTL, $storeId);
|
485 |
+
$this->_conf[self::CFG_PRIVATETTL] = Mage::getStoreConfig(self::STOREXML_PRIVATETTL, $storeId);
|
486 |
+
|
487 |
+
$adminIps = trim($general[self::CFG_ADMINIPS]);
|
488 |
+
$this->_conf[self::CFG_ADMINIPS] = $adminIps ? preg_split($pattern, $adminIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
|
489 |
+
if ($general['alt_esi_syntax']) {
|
490 |
+
$this->_esiTag = array('include' => 'esi_include', 'inline' => 'esi_inline', 'remove' => 'esi_remove');
|
491 |
+
}
|
492 |
+
else {
|
493 |
+
$this->_esiTag = array('include' => 'esi:include', 'inline' => 'esi:inline', 'remove' => 'esi:remove');
|
494 |
+
}
|
495 |
+
$allowedIps = trim($test[self::CFG_ALLOWEDIPS]) ;
|
496 |
+
$this->_conf[self::CFG_ALLOWEDIPS] = $allowedIps ? preg_split($pattern, $allowedIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
protected function _getConfigByPath( $xmlPath )
|
501 |
+
{
|
502 |
+
$node = Mage::getConfig()->getNode($xmlPath) ;
|
503 |
+
if ( ! $node )
|
504 |
+
Mage::throwException('Litemage missing config in xml path ' . $xmlPath) ;
|
505 |
+
return $node->asCanonicalArray() ;
|
506 |
+
}
|
507 |
+
|
508 |
+
public function debugMesg( $mesg )
|
509 |
+
{
|
510 |
+
if ( $this->_isDebug ) {
|
511 |
+
$mesg = str_replace("\n", ("\n" . $this->_debugTag . ' '), $mesg);
|
512 |
+
Mage::log($this->_debugTag . ' '. $mesg ) ;
|
513 |
+
}
|
514 |
+
}
|
515 |
+
|
516 |
+
}
|
app/code/community/Litespeed/Litemage/Helper/Esi.php
CHANGED
@@ -1,322 +1,596 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Helper_Esi
|
27 |
+
{
|
28 |
+
|
29 |
+
const LSHEADER_PURGE = 'X-LiteSpeed-Purge' ;
|
30 |
+
const LSHEADER_CACHE_CONTROL = 'X-LiteSpeed-Cache-Control' ;
|
31 |
+
const LSHEADER_CACHE_TAG = 'X-LiteSpeed-Tag' ;
|
32 |
+
const LSHEADER_CACHE_VARY = 'X-LiteSpeed-Vary';
|
33 |
+
const TAG_PREFIX_CMS = 'G.' ;
|
34 |
+
const TAG_PREFIX_CATEGORY = 'C.' ;
|
35 |
+
const TAG_PREFIX_PRODUCT = 'P.' ;
|
36 |
+
const TAG_PREFIX_ESIBLOCK = 'E.' ;
|
37 |
+
//BITMASK for Cache Header Flag
|
38 |
+
const CHBM_CACHEABLE = 1 ;
|
39 |
+
const CHBM_PRIVATE = 2 ;
|
40 |
+
const CHBM_ONLY_CACHE_EMPTY = 4 ;
|
41 |
+
const CHBM_ESI_ON = 16 ;
|
42 |
+
const CHBM_ESI_REQ = 32 ;
|
43 |
+
const CHBM_FORMKEY_REPLACED = 64 ;
|
44 |
+
const FORMKEY_REAL = '_litemage_realformkey' ;
|
45 |
+
const FORMKEY_REPLACE = 'litemagefmkeylmg' ; //do not use special characters, maybe changed by urlencode
|
46 |
+
const FORMKEY_NAME = '_form_key' ;
|
47 |
+
const ENV_COOKIE_NAME = '_lscache_vary' ;
|
48 |
+
|
49 |
+
// config items
|
50 |
+
protected $_viewedTracker ;
|
51 |
+
protected $_cacheVars = array( 'tag' => array(), 'flag' => 0, 'ttl' => -1, 'env' => array(), 'cookie' => array(), 'baseUrl' => '', 'baseUrlESI' => '' ) ;
|
52 |
+
protected $_esiBlocks = array();
|
53 |
+
protected $_esiPurgeEvents = array() ;
|
54 |
+
protected $_isDebug;
|
55 |
+
protected $_config;
|
56 |
+
|
57 |
+
|
58 |
+
public function __construct()
|
59 |
+
{
|
60 |
+
$this->_config = Mage::helper('litemage/data');
|
61 |
+
$this->_isDebug = $this->_config->isDebug();
|
62 |
+
}
|
63 |
+
|
64 |
+
public function isDebug()
|
65 |
+
{
|
66 |
+
return $this->_isDebug;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function setCacheControlFlag( $flag, $ttl = -1, $tag = '' )
|
70 |
+
{
|
71 |
+
$this->_cacheVars['flag'] = $flag ;
|
72 |
+
if ( $tag )
|
73 |
+
$this->_cacheVars['tag'][] = $tag ;
|
74 |
+
if ( $ttl != -1 )
|
75 |
+
$this->_cacheVars['ttl'] = $ttl ;
|
76 |
+
// init esiconf
|
77 |
+
$this->_config->getEsiConf('tag');
|
78 |
+
}
|
79 |
+
|
80 |
+
public function setEsiOn()
|
81 |
+
{
|
82 |
+
if ( ($this->_cacheVars['flag'] & self::CHBM_ESI_ON) == 0 ) {
|
83 |
+
$this->_cacheVars['flag'] |= self::CHBM_ESI_ON ;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
public function setEsiBlockHtml($blockIndex, $html)
|
88 |
+
{
|
89 |
+
if (isset($this->_esiBlocks[$blockIndex])) {
|
90 |
+
$this->_esiBlocks['adjusted'] = 1;
|
91 |
+
}
|
92 |
+
$this->_esiBlocks[$blockIndex] = $html ;
|
93 |
+
}
|
94 |
+
|
95 |
+
public function isEsiBlockAdjusted()
|
96 |
+
{
|
97 |
+
return isset($this->_esiBlocks['adjusted']);
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getEsiBlockHtml()
|
101 |
+
{
|
102 |
+
return serialize($this->_esiBlocks);
|
103 |
+
}
|
104 |
+
|
105 |
+
public function getBaseUrl()
|
106 |
+
{
|
107 |
+
if ($this->_cacheVars['baseUrl'] == '') {
|
108 |
+
/*$base2 = Mage::app()->getRequest()->getBaseUrl();
|
109 |
+
if (($base2 == '') || (substr($base2, -1) != '/'))
|
110 |
+
$base2 .= '/';
|
111 |
+
|
112 |
+
if (strpos($base2, 'index.php/') === false)
|
113 |
+
$base2 .= 'index.php/';
|
114 |
+
*/
|
115 |
+
|
116 |
+
$base = Mage::getBaseUrl(); // cannot use request->getBaseUrl, as store ID maybe in url
|
117 |
+
$this->_cacheVars['baseUrl'] = $base;
|
118 |
+
$esibase = $base;
|
119 |
+
if ((stripos($base, 'http') !== false) && ($pos = strpos($base, '://'))) {
|
120 |
+
// remove domain, some configuration will use multiple domain/vhosts map to different one.
|
121 |
+
$pos2 = strpos($base, '/', $pos+ 4);
|
122 |
+
$esibase = ($pos2 === false) ? '/' : substr($base, $pos2);
|
123 |
+
}
|
124 |
+
$this->_cacheVars['baseUrlESI'] = $esibase;
|
125 |
+
}
|
126 |
+
|
127 |
+
return $this->_cacheVars['baseUrl'];
|
128 |
+
}
|
129 |
+
|
130 |
+
public function getEsiBaseUrl()
|
131 |
+
{
|
132 |
+
if ($this->_cacheVars['baseUrlESI'] == '') {
|
133 |
+
$this->getBaseUrl();
|
134 |
+
}
|
135 |
+
return $this->_cacheVars['baseUrlESI'];
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getSubReqUrl($route, $params)
|
139 |
+
{
|
140 |
+
$baseurl = $this->getEsiBaseUrl();
|
141 |
+
$url = $baseurl . $route . '/';
|
142 |
+
foreach ( $params as $key => $value ) {
|
143 |
+
$url .= $key . '/' . $value . '/';
|
144 |
+
}
|
145 |
+
return $url;
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
public function canInjectEsi()
|
150 |
+
{
|
151 |
+
$flag = $this->_cacheVars['flag'] ;
|
152 |
+
return ((($flag & self::CHBM_CACHEABLE) != 0) && (($flag & self::CHBM_ESI_REQ) == 0)) ;
|
153 |
+
}
|
154 |
+
|
155 |
+
public function isEsiRequest()
|
156 |
+
{
|
157 |
+
$flag = $this->_cacheVars['flag'] ;
|
158 |
+
return (($flag & self::CHBM_ESI_REQ) != 0) ;
|
159 |
+
}
|
160 |
+
|
161 |
+
public function initFormKey()
|
162 |
+
{
|
163 |
+
$session = Mage::getSingleton('core/session') ;
|
164 |
+
if ( method_exists($session, 'getFormKey') ) {
|
165 |
+
$cur_formkey = $session->getFormKey() ;
|
166 |
+
if ( $cur_formkey != self::FORMKEY_REPLACE ) {
|
167 |
+
$session->setData(self::FORMKEY_REAL, $cur_formkey) ;
|
168 |
+
$session->setData(self::FORMKEY_NAME, self::FORMKEY_REPLACE) ;
|
169 |
+
}
|
170 |
+
$this->_cacheVars['flag'] |= self::CHBM_FORMKEY_REPLACED ;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
public function restoreFormKey()
|
175 |
+
{
|
176 |
+
if ( ($this->_cacheVars['flag'] & self::CHBM_FORMKEY_REPLACED) != 0 ) {
|
177 |
+
$session = Mage::getSingleton('core/session') ;
|
178 |
+
if ( ($realFormKey = $session->getData(self::FORMKEY_REAL)) != null ) {
|
179 |
+
$session->unsetData(self::FORMKEY_REAL) ;
|
180 |
+
$session->setData(self::FORMKEY_NAME, $realFormKey) ;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
public function addPurgeEvent( $eventName )
|
186 |
+
{
|
187 |
+
// always set purge header, due to ajax call, before_reponse_send will not be triggered, also it may die out in the middle, so must set raw header using php directly
|
188 |
+
if (!isset($this->_esiPurgeEvents[$eventName])) {
|
189 |
+
|
190 |
+
$this->_esiPurgeEvents[$eventName] = $eventName ;
|
191 |
+
|
192 |
+
if ( $cachePurgeHeader = $this->_getEsiPurgeHeader() ) {
|
193 |
+
$purgeHeader = $this->_getPurgeHeaderValue($cachePurgeHeader, true);
|
194 |
+
header(self::LSHEADER_PURGE . ': ' . $purgeHeader, true);
|
195 |
+
if ($this->_isDebug)
|
196 |
+
$this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by event ' . $eventName . ')') ;
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
protected function _getEsiPurgeHeader()
|
202 |
+
{
|
203 |
+
if ( count($this->_esiPurgeEvents) == 0 )
|
204 |
+
return null ;
|
205 |
+
|
206 |
+
$events = $this->_config->getEsiConf('event');
|
207 |
+
$tags = array() ;
|
208 |
+
foreach ( $this->_esiPurgeEvents as $e ) {
|
209 |
+
if (isset($events[$e])) {
|
210 |
+
foreach($events[$e] as $t) {
|
211 |
+
if (!in_array($t, $tags)) {
|
212 |
+
$tags[] = $t;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
if ($this->_isDebug) {
|
219 |
+
$this->_config->debugMesg('Purge events ' . implode(', ', $this->_esiPurgeEvents) . ' tags: ' . implode(', ', $tags));
|
220 |
+
}
|
221 |
+
|
222 |
+
return (count($tags) ? $tags : null) ;
|
223 |
+
}
|
224 |
+
|
225 |
+
protected function _getPurgeHeaderValue($tags, $private)
|
226 |
+
{
|
227 |
+
$purgeHeader = $private ? 'private,' : '' ;
|
228 |
+
$t = '';
|
229 |
+
foreach ($tags as $tag) {
|
230 |
+
$t .= ( $tag == '*' ) ? '*' : 'tag=' . $tag . ',' ;
|
231 |
+
}
|
232 |
+
$purgeHeader .= trim($t, ',');
|
233 |
+
return $purgeHeader;
|
234 |
+
}
|
235 |
+
|
236 |
+
public function setPurgeHeader( $tags, $by, $response = null, $private = false )
|
237 |
+
{
|
238 |
+
$purgeHeader = $this->_getPurgeHeaderValue($tags, $private);
|
239 |
+
|
240 |
+
if ( $response == null ) {
|
241 |
+
$response = Mage::app()->getResponse() ;
|
242 |
+
}
|
243 |
+
|
244 |
+
if ($this->_isDebug)
|
245 |
+
$this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by ' . $by . ')') ;
|
246 |
+
$response->setHeader(self::LSHEADER_PURGE, $purgeHeader, true) ;
|
247 |
+
}
|
248 |
+
|
249 |
+
public function setPurgeURLHeader( $url, $by )
|
250 |
+
{
|
251 |
+
$response = Mage::app()->getResponse() ;
|
252 |
+
|
253 |
+
if ($this->_isDebug)
|
254 |
+
$this->_config->debugMesg("SetPurgeHeader: " . $url . ' (triggered by ' . $by . ')') ;
|
255 |
+
$response->setHeader(self::LSHEADER_PURGE, $url, true) ;
|
256 |
+
}
|
257 |
+
|
258 |
+
/*public function refreshPrivateSessionOnce($by)
|
259 |
+
{
|
260 |
+
header(self::LSHEADER_PURGE . ': once, private, *', false);
|
261 |
+
}*/
|
262 |
+
|
263 |
+
public function addCacheEntryTag( $tag )
|
264 |
+
{
|
265 |
+
$this->_cacheVars['tag'][] = $tag ;
|
266 |
+
}
|
267 |
+
|
268 |
+
public function trackProduct( $productId )
|
269 |
+
{
|
270 |
+
if ( $this->_viewedTracker == null )
|
271 |
+
$this->_viewedTracker = array( 'product' => $productId ) ;
|
272 |
+
else
|
273 |
+
$this->_viewedTracker['product'] = $productId ;
|
274 |
+
}
|
275 |
+
|
276 |
+
public function beforeResponseSend( $response )
|
277 |
+
{
|
278 |
+
$extraHeaders = array();
|
279 |
+
$envChanged = $this->setEnvCookie();
|
280 |
+
|
281 |
+
$cacheControlHeader = '' ;
|
282 |
+
$flag = $this->_cacheVars['flag'] ;
|
283 |
+
$cacheable = true;
|
284 |
+
|
285 |
+
if ( (($flag & self::CHBM_CACHEABLE) == 0)
|
286 |
+
|| $envChanged
|
287 |
+
|| Mage::registry('LITEMAGE_SHOWHOLES')
|
288 |
+
|| Mage::registry('LITEMAGE_PURGE')
|
289 |
+
|| !in_array($response->getHttpResponseCode(), array( 200, 301, 404 ))) {
|
290 |
+
$cacheable = false;
|
291 |
+
}
|
292 |
+
|
293 |
+
if ( $cacheable ) {
|
294 |
+
if ( ($flag & self::CHBM_PRIVATE) != 0 )
|
295 |
+
$cacheControlHeader = 'private,max-age=' . (($this->_cacheVars['ttl'] > 0) ? $this->_cacheVars['ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PRIVATETTL)) ;
|
296 |
+
else
|
297 |
+
$cacheControlHeader = 'public,max-age=' . (($this->_cacheVars['ttl'] > 0) ? $this->_cacheVars['ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PUBLICTTL)) ;
|
298 |
+
|
299 |
+
$notEsiReq = (($flag & self::CHBM_ESI_REQ) == 0);
|
300 |
+
if ($notEsiReq) {
|
301 |
+
// for cacheable, non-esi page
|
302 |
+
if ($vary_on = $this->_getCacheVaryOn()) {
|
303 |
+
$extraHeaders[self::LSHEADER_CACHE_VARY] = $vary_on;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
else {
|
307 |
+
$cacheControlHeader .= ',no-vary';
|
308 |
+
if ( ($this->_cacheVars['flag'] & self::CHBM_ONLY_CACHE_EMPTY) != 0)
|
309 |
+
$cacheControlHeader .= ',set-blank';
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( ($cacheTagHeader = $this->_getCacheTagHeader($notEsiReq)) ) {
|
313 |
+
$extraHeaders[self::LSHEADER_CACHE_TAG] = $cacheTagHeader;
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
if ((($flag & self::CHBM_ESI_REQ) == 0) // for non-esi request
|
318 |
+
&& ((($flag & self::CHBM_ESI_ON) != 0) // esi on
|
319 |
+
|| (($flag & self::CHBM_FORMKEY_REPLACED) != 0) // formkey replaced
|
320 |
+
|| ($this->_viewedTracker != null))) { // has view tracker
|
321 |
+
$this->_updateResponseBody($response) ;
|
322 |
+
}
|
323 |
+
|
324 |
+
if ( ($flag & self::CHBM_ESI_ON) != 0 ) {
|
325 |
+
if ($cacheControlHeader != '')
|
326 |
+
$cacheControlHeader .= ',';
|
327 |
+
$cacheControlHeader .= 'esi=on' ;
|
328 |
+
}
|
329 |
+
|
330 |
+
if ($cacheControlHeader != '') { // if only no-cache, no need to set header
|
331 |
+
$extraHeaders[self::LSHEADER_CACHE_CONTROL] = $cacheControlHeader;
|
332 |
+
}
|
333 |
+
|
334 |
+
// due to ajax, move purge header when event happens, so already purged
|
335 |
+
if (Mage::registry('LITEMAGE_PURGE')) {
|
336 |
+
$extraHeaders[self::LSHEADER_PURGE] = $this->_getPurgeCacheTags();
|
337 |
+
}
|
338 |
+
|
339 |
+
$this->restoreFormKey() ;
|
340 |
+
|
341 |
+
foreach($extraHeaders as $key => $val) {
|
342 |
+
$response->setHeader($key, $val);
|
343 |
+
if ($this->_isDebug) {
|
344 |
+
$this->_config->debugMesg("Header $key: $val");
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
return $extraHeaders;
|
349 |
+
}
|
350 |
+
|
351 |
+
protected function _updateResponseBody( $response )
|
352 |
+
{
|
353 |
+
// only for non-esi request and injected
|
354 |
+
$responseBody = $response->getBody() ;
|
355 |
+
$updated = false ;
|
356 |
+
$combined = '' ;
|
357 |
+
$tracker = '' ;
|
358 |
+
$sharedParams = $this->getEsiSharedParams();
|
359 |
+
$esiIncludeTag = $this->_config->esiTag('include');
|
360 |
+
|
361 |
+
if ( (($this->_cacheVars['flag'] & self::CHBM_FORMKEY_REPLACED) != 0) && strpos($responseBody, self::FORMKEY_REPLACE) ) {
|
362 |
+
$replace = '<' . $esiIncludeTag . ' src="' . $this->getEsiBaseUrl() . 'litemage/esi/getFormKey" as-var="1" combine="sub" cache-control="no-vary,private" cache-tag="E.formkey"/>' ;
|
363 |
+
$responseBody = str_replace(self::FORMKEY_REPLACE, $replace, $responseBody) ;
|
364 |
+
if ($this->_isDebug) {
|
365 |
+
$this->_config->debugMesg('Form key replaced as ' . $replace);
|
366 |
+
}
|
367 |
+
$updated = true ;
|
368 |
+
}
|
369 |
+
|
370 |
+
if ( $this->_viewedTracker != null ) {
|
371 |
+
$logOptions = $this->_viewedTracker;
|
372 |
+
$logOptions['s'] = $sharedParams['s'];
|
373 |
+
//$tracker = '<!--esi<esi:include src="' . $this->getSubReqUrl('litemage/esi/log', $logOptions)
|
374 |
+
// . '" test="$(RESP_HEADER{X-LITESPEED-CACHE})!=\'\'" cache-control="no-cache" combine="sub"/>-->' ;
|
375 |
+
// remove comments for html minify
|
376 |
+
// if response coming from backend, no need to send separate log request
|
377 |
+
$tracker = '<' . $esiIncludeTag . ' src="' . $this->getSubReqUrl('litemage/esi/log', $logOptions)
|
378 |
+
. '" test="$(RESP_HEADER{X-LITESPEED-CACHE})!=\'\'" cache-control="no-cache" combine="sub"/>' ;
|
379 |
+
$updated = true ;
|
380 |
+
}
|
381 |
+
|
382 |
+
if ( $updated )
|
383 |
+
$this->setEsiOn() ;
|
384 |
+
|
385 |
+
if ( ($this->_cacheVars['flag'] & self::CHBM_ESI_ON) != 0 ) {
|
386 |
+
// no need to use comment, will be removed by minify extensions
|
387 |
+
$combined = '<' . $esiIncludeTag . ' src="' . $this->getSubReqUrl('litemage/esi/getCombined', $sharedParams) . '" combine="main" cache-control="no-cache"/>' ;
|
388 |
+
$updated = true;
|
389 |
+
}
|
390 |
+
|
391 |
+
if ( $updated ) {
|
392 |
+
$response->setBody($combined . $tracker . $responseBody) ;
|
393 |
+
if ($this->_isDebug) {
|
394 |
+
$this->_config->debugMesg('_updateResponseBody combined is ' . $combined);
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
}
|
399 |
+
|
400 |
+
protected function _getCacheTagHeader($notEsiReq)
|
401 |
+
{
|
402 |
+
$tags = $this->_cacheVars['tag'] ;
|
403 |
+
if ($notEsiReq) {
|
404 |
+
if ( count($tags) == 0 ) {
|
405 |
+
// set tag for product id, cid, and pageid
|
406 |
+
if ( ($curProduct = Mage::registry('current_product')) != null ) {
|
407 |
+
$tags[] = self::TAG_PREFIX_PRODUCT . $curProduct->getId() ;
|
408 |
+
}
|
409 |
+
elseif ( ($curCategory = Mage::registry('current_category')) != null ) {
|
410 |
+
$tags[] = self::TAG_PREFIX_CATEGORY . $curCategory->getId() ;
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
$currStore = Mage::app()->getStore() ;
|
415 |
+
if ($currStore->getCurrentCurrencyCode() != $currStore->getBaseCurrencyCode()) {
|
416 |
+
$tags[] = 'CURR'; // will be purged by currency rate update event
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
$tag = count($tags) ? implode(',', $tags) : '' ;
|
421 |
+
return $tag ;
|
422 |
+
}
|
423 |
+
|
424 |
+
protected function _getPurgeCacheTags()
|
425 |
+
{
|
426 |
+
$tags = $this->_cacheVars['tag'] ;
|
427 |
+
if (empty($tags)) {
|
428 |
+
// set tag for product id, cid, and pageid
|
429 |
+
if ( ($curProduct = Mage::registry('current_product')) != null ) {
|
430 |
+
$tags[] = self::TAG_PREFIX_PRODUCT . $curProduct->getId() ;
|
431 |
+
}
|
432 |
+
elseif ( ($curCategory = Mage::registry('current_category')) != null ) {
|
433 |
+
$tags[] = self::TAG_PREFIX_CATEGORY . $curCategory->getId() ;
|
434 |
+
}
|
435 |
+
else {
|
436 |
+
// go by url
|
437 |
+
$uri = str_replace('LITEMAGE_CTRL=PURGE', '', $_SERVER['REQUEST_URI']);
|
438 |
+
if (substr($uri, -1) == '?') {
|
439 |
+
$uri = rtrim($uri, '?');
|
440 |
+
}
|
441 |
+
$tags[] = $uri;
|
442 |
+
}
|
443 |
+
}
|
444 |
+
$tag = count($tags) ? implode(',', $tags) : '' ;
|
445 |
+
return $tag ;
|
446 |
+
}
|
447 |
+
|
448 |
+
public function setEnvCookie()
|
449 |
+
{
|
450 |
+
$changed = false;
|
451 |
+
$this->getDefaultEnvCookie();
|
452 |
+
foreach ($this->_cacheVars['env'] as $name => $data) {
|
453 |
+
$newVal = '';
|
454 |
+
$oldVal = '';
|
455 |
+
if ($data != null) {
|
456 |
+
ksort($data); // data is array, key sorted
|
457 |
+
foreach ($data as $k => $v) {
|
458 |
+
$newVal .= $k . '~' . $v . '~';
|
459 |
+
}
|
460 |
+
}
|
461 |
+
if ($cookievar = $this->getCookieEnvVars($name)) {
|
462 |
+
$oldVal = $cookievar['_ORG_'];
|
463 |
+
}
|
464 |
+
|
465 |
+
if ($oldVal != $newVal) {
|
466 |
+
Mage::getSingleton('core/cookie')->set($name, $newVal);
|
467 |
+
$changed = true;
|
468 |
+
if ($this->_isDebug)
|
469 |
+
$this->_config->debugMesg('Env ' . $name . ' changed, old=' . $oldVal . ' new=' . $newVal) ;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
return $changed;
|
473 |
+
|
474 |
+
}
|
475 |
+
|
476 |
+
protected function _getCacheVaryOn()
|
477 |
+
{
|
478 |
+
$vary_on = array();
|
479 |
+
|
480 |
+
foreach ($this->_cacheVars['env'] as $name => $data) {
|
481 |
+
if ($name != self::ENV_COOKIE_NAME) {
|
482 |
+
$vary_on[] = 'cookie=' . $name;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
switch (count($vary_on)) {
|
487 |
+
case 0: return '';
|
488 |
+
case 1: return $vary_on[0];
|
489 |
+
default: return implode(',', $vary_on);
|
490 |
+
}
|
491 |
+
|
492 |
+
}
|
493 |
+
|
494 |
+
public function setDefaultEnvCookie()
|
495 |
+
{
|
496 |
+
// when calling set, always reset, as value may change during processing
|
497 |
+
$default = array() ;
|
498 |
+
$app = Mage::app() ;
|
499 |
+
$currStore = $app->getStore() ;
|
500 |
+
$currStoreId = $currStore->getId() ;
|
501 |
+
$currStoreCurrency = $currStore->getCurrentCurrencyCode() ;
|
502 |
+
$currStoreDefaultCurrency = $currStore->getDefaultCurrencyCode() ;
|
503 |
+
|
504 |
+
if ($currStoreCurrency != $currStoreDefaultCurrency) {
|
505 |
+
$default['curr'] = $currStoreCurrency ;
|
506 |
+
}
|
507 |
+
|
508 |
+
if ( $currStore->getWebsite()->getDefaultStore()->getId() != $currStoreId ) {
|
509 |
+
$default['st'] = intval($currStoreId) ;
|
510 |
+
}
|
511 |
+
if ($diffGrp = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_DIFFCUSTGRP)) {
|
512 |
+
// diff cache copy peer customer group
|
513 |
+
$currCustomerGroup = Mage::getSingleton('customer/session')->getCustomerGroupId() ;
|
514 |
+
if ( Mage_Customer_Model_Group::NOT_LOGGED_IN_ID != $currCustomerGroup ) {
|
515 |
+
if ($diffGrp == 1) // diff copy per group
|
516 |
+
$default['cgrp'] = $currCustomerGroup ;
|
517 |
+
else // diff copy for logged in user
|
518 |
+
$default['cgrp'] = 'in' ;
|
519 |
+
}
|
520 |
+
}
|
521 |
+
if ($this->_config->isRestrainedIP()) {
|
522 |
+
$default['dev'] = 1; //developer mode for restrained IP
|
523 |
+
}
|
524 |
+
|
525 |
+
$this->_cacheVars['env'][self::ENV_COOKIE_NAME] = count($default) > 0 ? $default : null ;
|
526 |
+
}
|
527 |
+
|
528 |
+
|
529 |
+
public function getDefaultEnvCookie()
|
530 |
+
{
|
531 |
+
if ( ! isset($this->_cacheVars['env'][self::ENV_COOKIE_NAME]) ) {
|
532 |
+
$this->setDefaultEnvCookie();
|
533 |
+
}
|
534 |
+
return $this->_cacheVars['env'][self::ENV_COOKIE_NAME];
|
535 |
+
}
|
536 |
+
|
537 |
+
public function getEsiSharedParams()
|
538 |
+
{
|
539 |
+
if (!isset($this->_cacheVars['esiUrlSharedParams'])) {
|
540 |
+
$design = Mage::getDesign() ;
|
541 |
+
$currStore = Mage::app()->getStore() ;
|
542 |
+
$urlParams = array(
|
543 |
+
's' => $currStore->getId(), // current store id
|
544 |
+
'dp' => $design->getPackageName(),
|
545 |
+
'dt' => $design->getTheme('layout') ) ;
|
546 |
+
|
547 |
+
$currency = $currStore->getCurrentCurrencyCode();
|
548 |
+
if ($currency != $currStore->getDefaultCurrencyCode()) {
|
549 |
+
$urlParams['cur'] = $currency;
|
550 |
+
}
|
551 |
+
|
552 |
+
if ($diffGrp = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_DIFFCUSTGRP)) {
|
553 |
+
// diff cache copy peer customer group
|
554 |
+
$currCustomerGroup = Mage::getSingleton('customer/session')->getCustomerGroupId() ;
|
555 |
+
if ( Mage_Customer_Model_Group::NOT_LOGGED_IN_ID != $currCustomerGroup ) {
|
556 |
+
if ($diffGrp == 1) // diff copy per group
|
557 |
+
$urlParams['cg'] = $currCustomerGroup ;
|
558 |
+
else // diff copy for logged in user
|
559 |
+
$urlParams['cg'] = 'in' ;
|
560 |
+
}
|
561 |
+
}
|
562 |
+
// for public block, should consider vary on
|
563 |
+
$this->_cacheVars['esiUrlSharedParams'] = $urlParams;
|
564 |
+
|
565 |
+
}
|
566 |
+
return $this->_cacheVars['esiUrlSharedParams'];
|
567 |
+
}
|
568 |
+
|
569 |
+
public function getCookieEnvVars( $cookieName )
|
570 |
+
{
|
571 |
+
if ( ! isset($this->_cacheVars['cookie'][$cookieName]) ) {
|
572 |
+
$this->_cacheVars['cookie'][$cookieName] = null ;
|
573 |
+
$cookieVal = Mage::getSingleton('core/cookie')->get($cookieName) ;
|
574 |
+
if ( $cookieVal != null ) {
|
575 |
+
$cv = explode('~', trim($cookieVal, '~')); // restore cookie value
|
576 |
+
for ($i = 0 ; $i < count($cv) ; $i += 2) {
|
577 |
+
$this->_cacheVars['cookie'][$cookieName][$cv[$i]] = $cv[$i+1];
|
578 |
+
}
|
579 |
+
|
580 |
+
$this->_cacheVars['cookie'][$cookieName]['_ORG_'] = $cookieVal ;
|
581 |
+
}
|
582 |
+
}
|
583 |
+
return $this->_cacheVars['cookie'][$cookieName] ;
|
584 |
+
}
|
585 |
+
|
586 |
+
public function addEnvVars($cookieName, $key='', $val='' )
|
587 |
+
{
|
588 |
+
if ( ! isset($this->_cacheVars['env'][$cookieName]) || ($this->_cacheVars['env'][$cookieName] == null) ) {
|
589 |
+
$this->_cacheVars['env'][$cookieName] = array() ;
|
590 |
+
}
|
591 |
+
if ($key != '') {
|
592 |
+
$this->_cacheVars['env'][$cookieName][$key] = $val ;
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
}
|
app/code/community/Litespeed/Litemage/Helper/Viewvary.php
CHANGED
@@ -1,48 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Helper_Viewvary
|
27 |
+
{
|
28 |
+
|
29 |
+
protected $_vary = array( 'toolbar' => '_adjustToolbar', 'env' => '_setEnv' ) ;
|
30 |
+
|
31 |
+
public function persistViewVary( $tags )
|
32 |
+
{
|
33 |
+
foreach ( $tags as $tag ) {
|
34 |
+
$func = $this->_vary[$tag] ;
|
35 |
+
$this->$func(true) ;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
public function restoreViewVary( $tags )
|
40 |
+
{
|
41 |
+
foreach ( $tags as $tag ) {
|
42 |
+
$func = $this->_vary[$tag] ;
|
43 |
+
$this->$func(false) ;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _setEnv( $isSave )
|
48 |
+
{
|
49 |
+
if ($isSave) {
|
50 |
+
// run before exit, as value maybe changed during process.
|
51 |
+
Mage::helper('litemage/esi')->setDefaultEnvCookie();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function _adjustToolbar( $isSave )
|
56 |
+
{
|
57 |
+
// for Mage_Catalog_Block_Product_List
|
58 |
+
$helper = Mage::helper('litemage/esi') ;
|
59 |
+
$isDebug = $helper->isDebug() ;
|
60 |
+
$session = Mage::getSingleton('catalog/session') ;
|
61 |
+
$cookieName = '_lscache_vary_toolbar' ;
|
62 |
+
$keys = array( 'sort_order', 'sort_direction', 'display_mode', 'limit_page' ) ;
|
63 |
+
// limit_page is linked to display_mode, sort_direction is linked to sort_order
|
64 |
+
$cookieVars = $helper->getCookieEnvVars($cookieName) ;
|
65 |
+
|
66 |
+
if ( $isSave ) {
|
67 |
+
$saved = false ;
|
68 |
+
$mesg = 'addEnv ' . $cookieName;
|
69 |
+
foreach ( $keys as $key ) {
|
70 |
+
if ( $value = $session->getData($key) ) {
|
71 |
+
// only save limit_page if mode is same
|
72 |
+
if ( $key == 'limit_page' ) {
|
73 |
+
$old_mode = ( $cookieVars != null && isset($cookieVars['display_mode']) ) ? $cookieVars['display_mode'] : '' ;
|
74 |
+
$cur_mode = $session->getData('display_mode') ;
|
75 |
+
if ( $old_mode != $cur_mode )
|
76 |
+
continue ;
|
77 |
+
}
|
78 |
+
|
79 |
+
$helper->addEnvVars($cookieName, $key, $value) ;
|
80 |
+
if ($isDebug) {
|
81 |
+
$mesg .= ' ' . $key . '=' . $value ;
|
82 |
+
}
|
83 |
+
$saved = true ;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
if ( ! $saved ) {
|
88 |
+
$helper->addEnvVars($cookieName) ;
|
89 |
+
}
|
90 |
+
|
91 |
+
if ( $isDebug ) {
|
92 |
+
Mage::helper('litemage/data')->debugMesg($mesg) ;
|
93 |
+
}
|
94 |
+
|
95 |
+
}
|
96 |
+
else {
|
97 |
+
// restore
|
98 |
+
if ( $cookieVars != null ) {
|
99 |
+
foreach ( $keys as $key ) {
|
100 |
+
if ( isset($cookieVars[$key]) )
|
101 |
+
$session->setData($key, $cookieVars[$key]) ;
|
102 |
+
else
|
103 |
+
$session->unsetData($key) ;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
app/code/community/Litespeed/Litemage/Model/Config/Source/CustomerGroup.php
CHANGED
@@ -1,10 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
|
|
8 |
class Litespeed_Litemage_Model_Config_Source_CustomerGroup {
|
9 |
public function toOptionArray() {
|
10 |
$helper = Mage::helper('litemage/data');
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
*/
|
24 |
|
25 |
+
|
26 |
class Litespeed_Litemage_Model_Config_Source_CustomerGroup {
|
27 |
public function toOptionArray() {
|
28 |
$helper = Mage::helper('litemage/data');
|
app/code/community/Litespeed/Litemage/Model/Config/Source/EnableWarmUp.php
CHANGED
@@ -1,10 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
|
|
8 |
class Litespeed_Litemage_Model_Config_Source_EnableWarmUp {
|
9 |
public function toOptionArray() {
|
10 |
$helper = Mage::helper('litemage/data');
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
*/
|
24 |
|
25 |
+
|
26 |
class Litespeed_Litemage_Model_Config_Source_EnableWarmUp {
|
27 |
public function toOptionArray() {
|
28 |
$helper = Mage::helper('litemage/data');
|
app/code/community/Litespeed/Litemage/Model/Layout.php
CHANGED
@@ -1,57 +1,121 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Model_Layout extends Mage_Core_Model_Layout
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Class constructor
|
30 |
+
*
|
31 |
+
* @param array $data
|
32 |
+
*/
|
33 |
+
|
34 |
+
//protected $_isDebug;
|
35 |
+
|
36 |
+
public function __construct()
|
37 |
+
{
|
38 |
+
$this->_elementClass = Mage::getConfig()->getModelClassName('core/layout_element');
|
39 |
+
$this->setXml(simplexml_load_string('<layout/>', $this->_elementClass));
|
40 |
+
$this->_update = Mage::getModel('litemage/layout_update');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getBlock($name)
|
44 |
+
{
|
45 |
+
if (!isset($this->_blocks[$name])) {
|
46 |
+
$dummyblocks = array('root', 'head');
|
47 |
+
if (in_array($name, $dummyblocks)) {
|
48 |
+
$dummy = new Varien_Object();
|
49 |
+
return $dummy;
|
50 |
+
}
|
51 |
+
return null;
|
52 |
+
}
|
53 |
+
return $this->_blocks[$name];
|
54 |
+
}
|
55 |
+
|
56 |
+
public function resetBlocks()
|
57 |
+
{
|
58 |
+
$this->_output = array();
|
59 |
+
$this->_blocks = array();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Create layout blocks hierarchy from layout xml configuration
|
64 |
+
*
|
65 |
+
* @param Mage_Core_Layout_Element|null $parent
|
66 |
+
*/
|
67 |
+
public function generateBlocks($parent=null)
|
68 |
+
{
|
69 |
+
if (empty($parent)) {
|
70 |
+
$root = $this->addBlock('page/html', 'esiroot');// dummy root
|
71 |
+
$parent = $this->getNode();
|
72 |
+
foreach ($parent as $node) {
|
73 |
+
$node['parent'] = 'esiroot';
|
74 |
+
}
|
75 |
+
}
|
76 |
+
parent::generateBlocks($parent);
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getOutputBlock($name_alias)
|
80 |
+
{
|
81 |
+
$block = null;
|
82 |
+
$mesg = '';
|
83 |
+
|
84 |
+
if (isset($this->_blocks['esiroot']) && ($block = $this->_blocks['esiroot']->getChild($name_alias))) {
|
85 |
+
// as alias
|
86 |
+
if ( ($name = $block->getNameInLayout()) != $name_alias ) {
|
87 |
+
if ($this->_blocks[$name] != $block) {
|
88 |
+
$mesg = 'block name in layout is not unique, please check layout xml for block name ' . $name;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
elseif (isset($this->_blocks[$name_alias])) {
|
94 |
+
$block = $this->_blocks[$name_alias]; // dynamic block
|
95 |
+
}
|
96 |
+
else {
|
97 |
+
$mesg = 'failed to find the block by alias or name';
|
98 |
+
}
|
99 |
+
if ($mesg != '') {
|
100 |
+
Mage::helper('litemage/data')->debugMesg('getOutputBlock ' . $name_alias . ' ALERT: ' . $mesg);
|
101 |
+
}
|
102 |
+
return $block;
|
103 |
+
}
|
104 |
+
|
105 |
+
// override getOutput, as the output block maybe go by alias
|
106 |
+
public function getOutput()
|
107 |
+
{
|
108 |
+
$out = '';
|
109 |
+
if (!empty($this->_output)) {
|
110 |
+
foreach ($this->_output as $callback) {
|
111 |
+
if ($block = $this->getOutputBlock($callback[0])) {
|
112 |
+
$out .= $block->$callback[1]();
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
return $out;
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
app/code/community/Litespeed/Litemage/Model/Layout/Update.php
CHANGED
@@ -1,113 +1,215 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Update
|
27 |
+
{
|
28 |
+
protected $_esiBlockName;
|
29 |
+
protected $_storeId;
|
30 |
+
protected $_filtered = false;
|
31 |
+
protected $_blockNames = array();
|
32 |
+
protected $_peerFullXml;
|
33 |
+
protected $_isDebug;
|
34 |
+
|
35 |
+
public function getPackageLayout()
|
36 |
+
{
|
37 |
+
if (empty($this->_packageLayout)) {
|
38 |
+
$this->fetchFileLayoutUpdates();
|
39 |
+
}
|
40 |
+
return $this->_packageLayout;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setStoreId($storeId)
|
44 |
+
{
|
45 |
+
$this->_storeId = $storeId;
|
46 |
+
$this->_isDebug = Mage::helper('litemage/data')->isDebug() ;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getEsiBlockName()
|
50 |
+
{
|
51 |
+
return $this->_esiBlockName;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function setBlockNames($blockNames)
|
55 |
+
{
|
56 |
+
$this->_blockNames = $blockNames;
|
57 |
+
$this->_esiBlockName = $blockNames[0];
|
58 |
+
$this->_cacheId = null;
|
59 |
+
$this->_filtered = false;
|
60 |
+
$this->resetHandles();
|
61 |
+
$this->resetUpdates();
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getBlockNames()
|
65 |
+
{
|
66 |
+
return $this->_blockNames;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function importLayoutUpdate($blockNames, $blockHandles, $layout )
|
70 |
+
{
|
71 |
+
$this->setBlockNames($blockNames);
|
72 |
+
if ($this->_peerFullXml == null)
|
73 |
+
$this->_peerFullXml = $layout->getUpdate()->asSimplexml() ;
|
74 |
+
|
75 |
+
$this->_filterUpdates($this->_peerFullXml);
|
76 |
+
$this->addHandle($blockHandles);
|
77 |
+
$this->saveCache();
|
78 |
+
return $this->_blockNames;
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _filterUpdates($layoutUpdateXml)
|
82 |
+
{
|
83 |
+
$this->resetUpdates();
|
84 |
+
$blockUsed = array();
|
85 |
+
|
86 |
+
foreach ($this->_blockNames as $blockName) {
|
87 |
+
$xpath = '//*[@name="' . $blockName . '"]';
|
88 |
+
$nameUsed = false;
|
89 |
+
if ($els = $layoutUpdateXml->xpath($xpath)) {
|
90 |
+
foreach ($els as $el) {
|
91 |
+
if (!$el->getAttribute('litemage_used')) {
|
92 |
+
$this->addUpdate($el->asNiceXml());
|
93 |
+
$nameUsed = true;
|
94 |
+
$this->_markNodeUsed($el);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
if ($nameUsed)
|
99 |
+
$blockUsed[] = $blockName;
|
100 |
+
}
|
101 |
+
|
102 |
+
// check if children blocks being removed
|
103 |
+
$removeNodes = $layoutUpdateXml->xpath("//remove");
|
104 |
+
|
105 |
+
if (is_array($removeNodes)) {
|
106 |
+
$xml = $this->asSimplexml();
|
107 |
+
|
108 |
+
foreach ($removeNodes as $removeNode) {
|
109 |
+
$attributes = $removeNode->attributes();
|
110 |
+
$blockName = (string)$attributes->name;
|
111 |
+
if ($blockName) {
|
112 |
+
$ignoreNodes = $xml->xpath("//block[@name='".$blockName."']");
|
113 |
+
if (is_array($ignoreNodes) && count($ignoreNodes) > 0) {
|
114 |
+
$this->addUpdate($removeNode->asNiceXml());
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->_blockNames = $blockUsed;
|
121 |
+
$this->_filtered = true;
|
122 |
+
}
|
123 |
+
|
124 |
+
protected function _markNodeUsed($node)
|
125 |
+
{
|
126 |
+
$node->addAttribute('litemage_used', 'esi');
|
127 |
+
$children = $node->children();
|
128 |
+
foreach ($children as $child) {
|
129 |
+
$this->_markNodeUsed($child);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Get cache id
|
135 |
+
*
|
136 |
+
* @return string
|
137 |
+
*/
|
138 |
+
public function getCacheId()
|
139 |
+
{
|
140 |
+
if (!$this->_cacheId) {
|
141 |
+
$tags = $this->getHandles();
|
142 |
+
if (count($tags) > 1) {
|
143 |
+
sort($tags);
|
144 |
+
}
|
145 |
+
$tags[] = 'LITEMAGE_ESI_' . $this->_esiBlockName;
|
146 |
+
|
147 |
+
$this->_cacheId = 'LAYOUT_' . $this->_storeId . md5(join('__', $tags));
|
148 |
+
}
|
149 |
+
return $this->_cacheId;
|
150 |
+
}
|
151 |
+
|
152 |
+
/*
|
153 |
+
* @return -1: no layout cache allowed, 0: nocache, 1: has cache
|
154 |
+
*/
|
155 |
+
|
156 |
+
public function loadEsiBlockCache($blockName, $handles)
|
157 |
+
{
|
158 |
+
if (!Mage::app()->useCache('layout')) {
|
159 |
+
return -1;
|
160 |
+
}
|
161 |
+
//reset internals
|
162 |
+
$this->setBlockNames(array($blockName));
|
163 |
+
$this->addHandle($handles);
|
164 |
+
|
165 |
+
if ($this->loadCache())
|
166 |
+
return 1;
|
167 |
+
else
|
168 |
+
return 0;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function loadCache()
|
172 |
+
{
|
173 |
+
if (!Mage::app()->useCache('layout')) {
|
174 |
+
return false;
|
175 |
+
}
|
176 |
+
|
177 |
+
if (!$result = Mage::app()->loadCache($this->getCacheId())) {
|
178 |
+
return false;
|
179 |
+
}
|
180 |
+
|
181 |
+
$pos = strpos($result, "\n");
|
182 |
+
$filteredBlocks = substr($result, 0, $pos);
|
183 |
+
$this->_filtered = true;
|
184 |
+
if ($this->_isDebug) {
|
185 |
+
Mage::helper('litemage/data')->debugMesg('LU_Load B=' . $filteredBlocks . ' H=' . join(',',$this->getHandles()) . ' ID=' . substr($this->getCacheId(), 8, 10));
|
186 |
+
}
|
187 |
+
$this->_blockNames = explode(',', $filteredBlocks);
|
188 |
+
$this->addUpdate(substr($result, $pos+1));
|
189 |
+
|
190 |
+
return true;
|
191 |
+
}
|
192 |
+
|
193 |
+
public function saveCache()
|
194 |
+
{
|
195 |
+
if (!$this->_filtered) {
|
196 |
+
$this->_filterUpdates($this->asSimplexml());
|
197 |
+
}
|
198 |
+
|
199 |
+
if (!Mage::app()->useCache('layout')) {
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
|
203 |
+
$tags = $this->getHandles();
|
204 |
+
$tags[] = Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG;
|
205 |
+
$tags[] = Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG;
|
206 |
+
$firstLine = join(',', $this->_blockNames);
|
207 |
+
if ($this->_isDebug) {
|
208 |
+
Mage::helper('litemage/data')->debugMesg('LU_Save B=' . $firstLine . ' H=' . join(',',$this->getHandles()) . ' ID=' . substr($this->getCacheId(), 8, 10));
|
209 |
+
}
|
210 |
+
|
211 |
+
$content = $firstLine . "\n" . $this->asString();
|
212 |
+
return Mage::app()->saveCache($content, $this->getCacheId(), $tags, null);
|
213 |
+
}
|
214 |
+
|
215 |
+
}
|
app/code/community/Litespeed/Litemage/Model/Observer/Cron.php
CHANGED
@@ -1,436 +1,786 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
/
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
|
26 |
+
{
|
27 |
+
|
28 |
+
const WARMUP_MAP_FILE = 'litemage_warmup_urlmap' ;
|
29 |
+
const WARMUP_META_CACHE_ID = 'litemage_warmup_meta' ;
|
30 |
+
const USER_AGENT = 'litemage_walker' ;
|
31 |
+
const ENV_COOKIE_NAME = '_lscache_vary' ;
|
32 |
+
|
33 |
+
protected $_meta ; // time, curfileline
|
34 |
+
protected $_metaUpdated = false;
|
35 |
+
protected $_conf;
|
36 |
+
protected $_isDebug ;
|
37 |
+
protected $_debugTag;
|
38 |
+
protected $_maxRunTime;
|
39 |
+
protected $_curThreads = -1;
|
40 |
+
protected $_curThreadTime ;
|
41 |
+
protected $_curList ;
|
42 |
+
protected $_listDir;
|
43 |
+
protected $_priority;
|
44 |
+
|
45 |
+
|
46 |
+
protected function _construct()
|
47 |
+
{
|
48 |
+
$helper = Mage::helper('litemage/data') ;
|
49 |
+
$this->_isDebug = $helper->isDebug() ;
|
50 |
+
if ($this->_isDebug) {
|
51 |
+
$this->_debugTag = 'LiteMage [' . self::USER_AGENT . ':';
|
52 |
+
if (isset($_SERVER['USER']))
|
53 |
+
$this->_debugTag .= $_SERVER['USER'];
|
54 |
+
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
55 |
+
$this->_debugTag .= $_SERVER['HTTP_X_FORWARDED_FOR'];
|
56 |
+
$this->_debugTag .= ':'. $_SERVER['REQUEST_TIME'] . '] ' ;
|
57 |
+
}
|
58 |
+
$this->_listDir = Mage::getBaseDir('var') . DS . 'litemage';
|
59 |
+
|
60 |
+
if (!is_dir($this->_listDir)) {
|
61 |
+
mkdir($this->_listDir);
|
62 |
+
chmod($this->_listDir, 0777);
|
63 |
+
}
|
64 |
+
|
65 |
+
$this->_conf = $helper->getWarmUpConf();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function resetCrawlerList($listId)
|
69 |
+
{
|
70 |
+
$adminSession = Mage::getSingleton('adminhtml/session') ;
|
71 |
+
$meta = Mage::app()->loadCache(self::WARMUP_META_CACHE_ID);
|
72 |
+
$updated = false;
|
73 |
+
|
74 |
+
if ($listId) {
|
75 |
+
$id = strtolower($listId);
|
76 |
+
if ( $meta ) {
|
77 |
+
$meta = unserialize($meta) ;
|
78 |
+
if (isset($meta[$id])) {
|
79 |
+
unset($meta[$id]);
|
80 |
+
$updated = true;
|
81 |
+
$adminSession->addSuccess($listId . ' ' . Mage::helper('litemage/data')->__('List has been reset and will be regenerated in next run.')) ;
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
$adminSession->addError($listId . ' ' . Mage::helper('litemage/data')->__('List has been reset already. It will be regenerated in next run.')) ;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
else {
|
89 |
+
if ($meta) {
|
90 |
+
Mage::app()->removeCache(self::WARMUP_META_CACHE_ID);
|
91 |
+
$updated = true;
|
92 |
+
$adminSession->addSuccess(Mage::helper('litemage/data')->__('All lists have been reset and will be regenerated in next run.')) ;
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
$adminSession->addError(Mage::helper('litemage/data')->__('All lists have been reset already. It will be regenerated in next run.')) ;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
if ($updated) {
|
100 |
+
$this->_saveMeta($meta);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getCrawlerList($listId)
|
105 |
+
{
|
106 |
+
$output = '<h3>Generated URL List ' . $listId . '</h3>';
|
107 |
+
if ( ($urls = $this->_getCrawlListFileData($listId)) != null ) {
|
108 |
+
$output .= '<pre>' . $urls . '</pre>';
|
109 |
+
}
|
110 |
+
else {
|
111 |
+
$output .= '<p>Cannot find generated URL list. It will be regenerated in next run.</p>';
|
112 |
+
}
|
113 |
+
return $output;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function getCrawlerStatus()
|
117 |
+
{
|
118 |
+
$priority = $this->_initMeta();
|
119 |
+
$saved = $this->_meta;
|
120 |
+
$timefmt = 'Y-m-d H:i:s';
|
121 |
+
$status = array('lastupdate' => '', 'endreason' => '',
|
122 |
+
'stores' => array());
|
123 |
+
|
124 |
+
if (isset($saved['lastupdate'])) {
|
125 |
+
$status['lastupdate'] = date($timefmt, $saved['lastupdate']);
|
126 |
+
}
|
127 |
+
|
128 |
+
if (isset($saved['endreason'])) {
|
129 |
+
$status['endreason'] = $saved['endreason'];
|
130 |
+
}
|
131 |
+
|
132 |
+
foreach ($priority as $listId => $pri ) {
|
133 |
+
$store_stat = $saved[$listId];
|
134 |
+
$disp = array();
|
135 |
+
$disp['priority'] = intval($pri + 0.5);
|
136 |
+
$disp['id'] = strtoupper($listId);
|
137 |
+
$disp['baseurl'] = $store_stat['baseurl'];
|
138 |
+
$disp['file'] = (isset($store_stat['file']) ? $store_stat['file'] : '');
|
139 |
+
$disp['ttl'] = $store_stat['ttl'];
|
140 |
+
$disp['interval'] = $store_stat['interval'];
|
141 |
+
if ($store_stat['gentime'] > 0) {
|
142 |
+
$disp['gentime'] = date($timefmt, $store_stat['gentime']);
|
143 |
+
}
|
144 |
+
else {
|
145 |
+
$disp['gentime'] = isset($store_stat['tmpmsg']) ? $store_stat['tmpmsg'] : '';
|
146 |
+
}
|
147 |
+
$disp['lastquerytime'] = ($store_stat['lastquerytime'] > 0) ? date($timefmt, $store_stat['lastquerytime']) : '';
|
148 |
+
$disp['endtime'] = ($store_stat['endtime'] > 0) ? date($timefmt, $store_stat['endtime']) : '';
|
149 |
+
$disp['listsize'] = ($store_stat['listsize'] > 0) ? $store_stat['listsize'] : '';
|
150 |
+
$disp['curpos'] = $store_stat['curpos'];
|
151 |
+
$disp['env'] = $store_stat['env'];
|
152 |
+
$disp['curvary'] = preg_replace("/_lscache_vary=.+;/", '', $store_stat['curvary']);
|
153 |
+
$disp['queried'] = $store_stat['queried'];
|
154 |
+
$status['stores'][] = $disp;
|
155 |
+
}
|
156 |
+
|
157 |
+
return $status;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* called by cron job
|
162 |
+
*/
|
163 |
+
|
164 |
+
public function warmCache()
|
165 |
+
{
|
166 |
+
if ( $this->_isDebug ) {
|
167 |
+
$this->_debugLog("cron warmCache envoked") ;
|
168 |
+
}
|
169 |
+
|
170 |
+
$curRunTime = time() ;
|
171 |
+
|
172 |
+
if (!$this->_init()) {
|
173 |
+
$this->_debugLog('skip this round');
|
174 |
+
return;
|
175 |
+
}
|
176 |
+
|
177 |
+
$options = array(
|
178 |
+
CURLOPT_USERAGENT => self::USER_AGENT,
|
179 |
+
CURLOPT_SSL_VERIFYPEER => 0,
|
180 |
+
CURLOPT_TIMEOUT => 180
|
181 |
+
);
|
182 |
+
|
183 |
+
$client = new Varien_Http_Adapter_Curl();
|
184 |
+
$curCookie = '';
|
185 |
+
$endReason = '';
|
186 |
+
|
187 |
+
while ($urls = $this->_getNextUrls($curCookie)) {
|
188 |
+
$curlOptions = $options;
|
189 |
+
if ($curCookie) {
|
190 |
+
$curlOptions[CURLOPT_COOKIE] = $curCookie;
|
191 |
+
}
|
192 |
+
|
193 |
+
if ($this->_isDebug) {
|
194 |
+
$id = $this->_curList['id'];
|
195 |
+
$this->_debugLog('crawling ' . $id . ' urls (cur_pos:' . $this->_meta[$id]['curpos'] . ') with cookie ' . $curCookie . ' ' . print_r($urls, true));
|
196 |
+
}
|
197 |
+
|
198 |
+
try {
|
199 |
+
$client->multiRequest($urls, $curlOptions);
|
200 |
+
} catch ( Exception $e ) {
|
201 |
+
$endReason = 'Error when crawling url ' . implode(' ', $urls) . ' : ' . $e->getMessage();
|
202 |
+
break ;
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
$this->_finishCurPosition() ;
|
207 |
+
|
208 |
+
if ($this->_meta['lastupdate'] > $this->_maxRunTime) {
|
209 |
+
$endReason = Mage::helper('litemage/data')->__('Stopped due to exceeding defined Maximum Run Time.');
|
210 |
+
break;
|
211 |
+
}
|
212 |
+
|
213 |
+
if ($this->_meta['lastupdate'] - 60 > $this->_curThreadTime) {
|
214 |
+
$this->_adjustCurThreads();
|
215 |
+
if ($this->_curThreads == 0) {
|
216 |
+
$endReason = Mage::helper('litemage/data')->__('Stopped due to current system load exceeding defined load limit.');
|
217 |
+
break;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
}
|
221 |
+
$this->_meta['endreason'] = $endReason;
|
222 |
+
|
223 |
+
$this->_saveMeta() ;
|
224 |
+
if ( $this->_isDebug ) {
|
225 |
+
$this->_debugLog($endReason . ' cron meta end = ' . print_r($this->_meta, true)) ;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
protected function _getCrawlListFileData($listId)
|
230 |
+
{
|
231 |
+
$filename = $this->_listDir . DS . self::WARMUP_MAP_FILE . '_' . strtolower($listId);
|
232 |
+
if (!file_exists($filename))
|
233 |
+
return null;
|
234 |
+
else
|
235 |
+
return file_get_contents($filename);
|
236 |
+
}
|
237 |
+
|
238 |
+
protected function _saveCrawlListFileData($listId, $data)
|
239 |
+
{
|
240 |
+
$filename = $this->_listDir . DS . self::WARMUP_MAP_FILE . '_' . strtolower($listId);
|
241 |
+
if (!file_put_contents($filename, $data)) {
|
242 |
+
$this->_debugLog('Failed to save url map file ' . $filename);
|
243 |
+
}
|
244 |
+
else {
|
245 |
+
chmod($filename, 0644);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
protected function _prepareCurList()
|
250 |
+
{
|
251 |
+
$id = array_shift($this->_priority);
|
252 |
+
if ($id == null) {
|
253 |
+
return false;
|
254 |
+
}
|
255 |
+
|
256 |
+
$m = $this->_meta[$id];
|
257 |
+
// parse env & get all possible varies
|
258 |
+
$vary = array();
|
259 |
+
$fixed = $this->_parseEnvCookies($m['env'], $vary);
|
260 |
+
if (!in_array($m['curvary'], $vary) || $m['curpos'] > $m['listsize']) {
|
261 |
+
// reset current pointer
|
262 |
+
$this->_meta[$id]['curvary'] = $vary[0];
|
263 |
+
$this->_meta[$id]['curpos'] = 0;
|
264 |
+
if ( $this->_isDebug ) {
|
265 |
+
$this->_debugLog('Reset current position pointer to 0. curvary is ' . $m['curvary']);
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
while ($this->_meta[$id]['curvary'] != $vary[0]) {
|
270 |
+
array_shift($vary);
|
271 |
+
}
|
272 |
+
|
273 |
+
$this->_curList = array(
|
274 |
+
'id' => $id,
|
275 |
+
'fixed' => $fixed,
|
276 |
+
'vary' => $vary,
|
277 |
+
'working' => 0);
|
278 |
+
if ( ($urls = $this->_getCrawlListFileData($id)) != null ) {
|
279 |
+
$allurls = explode("\n", $urls) ;
|
280 |
+
// verify data
|
281 |
+
$header = explode("\t", array_shift($allurls));
|
282 |
+
if (($m['gentime'] == $header[0])
|
283 |
+
&& ($m['listsize'] == $header[1])
|
284 |
+
&& ($m['env'] == $header[2])
|
285 |
+
&& count($allurls) == $m['listsize']) {
|
286 |
+
$this->_curList['urls'] = $allurls;
|
287 |
+
}
|
288 |
+
else if ( $this->_isDebug ) {
|
289 |
+
$this->_debugLog('load saved url list, header does not match, will regenerate') ;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
else if ($this->_isDebug) {
|
293 |
+
$this->_debugLog('load saved url list failed, will regenerate');
|
294 |
+
}
|
295 |
+
|
296 |
+
if (!isset($this->_curList['urls'])) {
|
297 |
+
// regenerate
|
298 |
+
$this->_curList['urls'] = $this->_generateUrlList($id);
|
299 |
+
}
|
300 |
+
|
301 |
+
if ($this->_meta[$id]['listsize'] > 0) {
|
302 |
+
return true;
|
303 |
+
}
|
304 |
+
else {
|
305 |
+
// get next list
|
306 |
+
return $this->_prepareCurList();
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
protected function _parseEnvCookies( $env, &$vary )
|
311 |
+
{
|
312 |
+
$fixed = 'litemage_cron=' . self::USER_AGENT .';';
|
313 |
+
if ( $env ) {
|
314 |
+
$lsvary = array();
|
315 |
+
$multiCurr = array('-') ; // default currency
|
316 |
+
$multiCgrp = array('-') ; // default user group
|
317 |
+
|
318 |
+
$env = trim($env, '/');
|
319 |
+
$envs = explode('/', $env) ;
|
320 |
+
$envVars = array() ;
|
321 |
+
$cnt = count($envs) ;
|
322 |
+
for ( $i = 0 ; ($i + 1) < $cnt ; $i+=2 ) {
|
323 |
+
$envVars[$envs[$i]] = $envs[$i + 1] ;
|
324 |
+
}
|
325 |
+
if ( isset($envVars['vary_dev']) ) {
|
326 |
+
$lsvary['dev'] = 1 ;
|
327 |
+
}
|
328 |
+
|
329 |
+
if ( isset($envVars['store']) ) {
|
330 |
+
$fixed .= Mage_Core_Model_Store::COOKIE_NAME . '=' . $envVars['store'] . ';';
|
331 |
+
$lsvary['st'] = $envVars['storeId'] ;
|
332 |
+
}
|
333 |
+
|
334 |
+
if ( isset($envVars['vary_cgrp']) ) {
|
335 |
+
$multiCgrp = explode(',', $envVars['vary_cgrp']) ;
|
336 |
+
}
|
337 |
+
|
338 |
+
if ( isset($envVars['vary_curr']) ) {
|
339 |
+
$multiCurr = explode(',', $envVars['vary_curr']) ;
|
340 |
+
}
|
341 |
+
|
342 |
+
foreach ( $multiCurr as $currency ) {
|
343 |
+
$cookie_vary = '';
|
344 |
+
$lsvary1 = $lsvary;
|
345 |
+
|
346 |
+
if ( $currency != '-' ) {
|
347 |
+
$lsvary1['curr'] = $currency ;
|
348 |
+
$cookie_vary .= Mage_Core_Model_Store::COOKIE_CURRENCY . '=' . $currency . ';' ;
|
349 |
+
}
|
350 |
+
|
351 |
+
foreach ( $multiCgrp as $cgrp ) {
|
352 |
+
if ( $cgrp != '-' ) {
|
353 |
+
// need to set user id
|
354 |
+
$lsvary1['cgrp'] = $cgrp ;
|
355 |
+
}
|
356 |
+
|
357 |
+
if (!empty($lsvary1)) {
|
358 |
+
ksort($lsvary1) ;
|
359 |
+
$lsvary1_val = '';
|
360 |
+
foreach ($lsvary1 as $k => $v) {
|
361 |
+
$lsvary1_val .= $k . '%7E' . urlencode($v) . '%7E'; // %7E is "~"
|
362 |
+
}
|
363 |
+
$cookie_vary .= self::ENV_COOKIE_NAME . '=' . $lsvary1_val . ';';
|
364 |
+
}
|
365 |
+
$vary[] = $cookie_vary; // can be empty string for default no vary
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
}
|
370 |
+
else {
|
371 |
+
$vary[] = ''; // no vary
|
372 |
+
}
|
373 |
+
|
374 |
+
return $fixed;
|
375 |
+
}
|
376 |
+
|
377 |
+
protected function _getNextUrls(&$curCookie)
|
378 |
+
{
|
379 |
+
$id = $this->_curList['id'];
|
380 |
+
if ($this->_meta[$id]['endtime'] > 0) {
|
381 |
+
if ($this->_prepareCurList()) {
|
382 |
+
return $this->_getNextUrls($curCookie);
|
383 |
+
}
|
384 |
+
else {
|
385 |
+
return null;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
$curpos = $this->_meta[$id]['curpos'];
|
390 |
+
$curCookie = $this->_curList['fixed'] . $this->_meta[$id]['curvary'];
|
391 |
+
$urls = array_slice($this->_curList['urls'],
|
392 |
+
$this->_meta[$id]['curpos'],
|
393 |
+
$this->_curThreads);
|
394 |
+
$this->_curList['working'] = count($urls);
|
395 |
+
|
396 |
+
if (empty($urls)) {
|
397 |
+
return null;
|
398 |
+
}
|
399 |
+
else {
|
400 |
+
$baseurl = $this->_meta[$id]['baseurl'];
|
401 |
+
foreach ($urls as $key => $val) {
|
402 |
+
$urls[$key] = $baseurl . $val;
|
403 |
+
}
|
404 |
+
return $urls ;
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
protected function _finishCurPosition()
|
409 |
+
{
|
410 |
+
$now = time();
|
411 |
+
$id = $this->_curList['id'];
|
412 |
+
if (($this->_meta[$id]['curpos'] + $this->_curList['working']) < $this->_meta[$id]['listsize']) {
|
413 |
+
$this->_meta[$id]['curpos'] += $this->_curList['working'];
|
414 |
+
}
|
415 |
+
else {
|
416 |
+
if (count($this->_curList['vary']) > 1) {
|
417 |
+
array_shift($this->_curList['vary']);
|
418 |
+
$this->_meta[$id]['curvary'] = $this->_curList['vary'][0];
|
419 |
+
$this->_meta[$id]['curpos'] = 0;
|
420 |
+
}
|
421 |
+
else {
|
422 |
+
$this->_meta[$id]['endtime'] = $now;
|
423 |
+
$this->_meta[$id]['curpos'] = $this->_meta[$id]['listsize'];
|
424 |
+
}
|
425 |
+
}
|
426 |
+
$this->_meta[$id]['queried'] += $this->_curList['working'];
|
427 |
+
$this->_meta[$id]['lastquerytime'] = $now;
|
428 |
+
$this->_meta['lastupdate'] = $now;
|
429 |
+
$this->_metaUpdated = true;
|
430 |
+
$this->_curList['working'] = 0;
|
431 |
+
}
|
432 |
+
|
433 |
+
protected function _newStoreMeta($storeInfo, $tmpmsg)
|
434 |
+
{
|
435 |
+
$meta = array(
|
436 |
+
'id' => $storeInfo['id'], // store1, custom1, delta
|
437 |
+
'storeid' => $storeInfo['storeid'],
|
438 |
+
'baseurl' => $storeInfo['baseurl'],
|
439 |
+
'ttl' => $storeInfo['ttl'],
|
440 |
+
'interval' => $storeInfo['interval'],
|
441 |
+
'priority' => $storeInfo['priority'],
|
442 |
+
'gentime' => 0,
|
443 |
+
'listsize' => 0,
|
444 |
+
'env' => $storeInfo['env'],
|
445 |
+
'curpos' => 0,
|
446 |
+
'curvary' => '',
|
447 |
+
'queried' => 0,
|
448 |
+
'lastquerytime' => 0,
|
449 |
+
'endtime' => 0);
|
450 |
+
if (isset($storeInfo['file'])) {
|
451 |
+
$meta['file'] = $storeInfo['file'];
|
452 |
+
}
|
453 |
+
if ($tmpmsg) {
|
454 |
+
$meta['tmpmsg'] = $tmpmsg;
|
455 |
+
if ( $this->_isDebug ) {
|
456 |
+
$this->_debugLog($tmpmsg) ;
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
return $meta;
|
461 |
+
}
|
462 |
+
|
463 |
+
protected function _saveMeta($meta=null)
|
464 |
+
{
|
465 |
+
if ($meta == null) {
|
466 |
+
$meta = $this->_meta ;
|
467 |
+
}
|
468 |
+
$tags = array( Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG, self::WARMUP_META_CACHE_ID ) ;
|
469 |
+
Mage::app()->saveCache(serialize($meta), self::WARMUP_META_CACHE_ID, $tags) ;
|
470 |
+
}
|
471 |
+
|
472 |
+
protected function _initMeta()
|
473 |
+
{
|
474 |
+
$priority = array();
|
475 |
+
$curtime = time();
|
476 |
+
$this->_meta = array();
|
477 |
+
|
478 |
+
$saved = array();
|
479 |
+
if ( $meta = Mage::app()->loadCache(self::WARMUP_META_CACHE_ID) ) {
|
480 |
+
$saved = unserialize($meta) ;
|
481 |
+
if (isset($saved['lastupdate'])) {
|
482 |
+
$this->_meta['lastupdate'] = $saved['lastupdate'];
|
483 |
+
}
|
484 |
+
if (isset($saved['endreason'])) {
|
485 |
+
$this->_meta['endreason'] = $saved['endreason'];
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
if (empty($this->_conf['store'])) {
|
490 |
+
return $priority;
|
491 |
+
}
|
492 |
+
|
493 |
+
foreach( $this->_conf['store'] as $listId => $info) {
|
494 |
+
$tmpmsg = '';
|
495 |
+
if (isset($saved[$listId])) {
|
496 |
+
// validate saved
|
497 |
+
$m = $saved[$listId];
|
498 |
+
if (isset($m['storeid']) && ($m['storeid'] == $info['storeid'])
|
499 |
+
&& isset($m['env']) && ($m['env'] == $info['env'])
|
500 |
+
&& isset($m['interval']) && ($m['interval'] == $info['interval'])
|
501 |
+
&& isset($m['priority']) && ($m['priority'] == $info['priority'])
|
502 |
+
&& isset($m['baseurl']) && ($m['baseurl'] == $info['baseurl'])) {
|
503 |
+
|
504 |
+
if (($m['endtime'] == 0) // not finished
|
505 |
+
|| ($m['endtime'] + $m['interval'] > $curtime)) { // not timedout
|
506 |
+
$this->_meta[$listId] = $m;
|
507 |
+
}
|
508 |
+
else {
|
509 |
+
$tmpmsg = strtoupper($listId) . ' - ' . Mage::helper('litemage/data')->__('Maximum Run Time exceeded. List will be regenerated.');
|
510 |
+
}
|
511 |
+
}
|
512 |
+
else {
|
513 |
+
$tmpmsg = strtoupper($listId) . ' - ' . Mage::helper('litemage/data')->__('Saved configuration does not match current configuration. List will be regenerated.');
|
514 |
+
}
|
515 |
+
}
|
516 |
+
if (!isset($this->_meta[$listId])) {
|
517 |
+
$this->_meta[$listId] = $this->_newStoreMeta($info, $tmpmsg);
|
518 |
+
}
|
519 |
+
$priority[$listId] = $this->_meta[$listId]['priority'];
|
520 |
+
}
|
521 |
+
|
522 |
+
asort($priority, SORT_NUMERIC);
|
523 |
+
|
524 |
+
return $priority;
|
525 |
+
}
|
526 |
+
|
527 |
+
protected function _init()
|
528 |
+
{
|
529 |
+
if (empty($this->_conf['store'])) {
|
530 |
+
return false;
|
531 |
+
}
|
532 |
+
if ( $this->_isDebug ) {
|
533 |
+
$this->_debugLog('cron config is = ' . print_r($this->_conf, true)) ;
|
534 |
+
}
|
535 |
+
|
536 |
+
$priority = $this->_initMeta();
|
537 |
+
$this->_priority = array();
|
538 |
+
foreach ($priority as $listId => $pri ) {
|
539 |
+
|
540 |
+
if ($this->_meta[$listId]['gentime'] == 0) {
|
541 |
+
$this->_generateUrlList($listId);
|
542 |
+
}
|
543 |
+
if ($this->_meta[$listId]['listsize'] > 0 && $this->_meta[$listId]['endtime'] == 0) {
|
544 |
+
// need crawl
|
545 |
+
$this->_priority[] = $listId;
|
546 |
+
}
|
547 |
+
}
|
548 |
+
|
549 |
+
if ($this->_metaUpdated) {
|
550 |
+
$this->_saveMeta();
|
551 |
+
}
|
552 |
+
|
553 |
+
if ( $this->_isDebug ) {
|
554 |
+
$this->_debugLog('cron meta starting = ' . print_r($this->_meta, true)) ;
|
555 |
+
}
|
556 |
+
|
557 |
+
if ( empty($this->_priority) ) {
|
558 |
+
if ( $this->_isDebug )
|
559 |
+
$this->_debugLog("no url list available for warm up") ;
|
560 |
+
return false;
|
561 |
+
}
|
562 |
+
else {
|
563 |
+
|
564 |
+
$maxTime = (int) ini_get('max_execution_time') ;
|
565 |
+
if ( $maxTime == 0 )
|
566 |
+
$maxTime = 300 ; // hardlimit
|
567 |
+
else
|
568 |
+
$maxTime -= 5 ;
|
569 |
+
|
570 |
+
$configed = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_MAXTIME];
|
571 |
+
if ( $maxTime > $configed )
|
572 |
+
$maxTime = $configed ;
|
573 |
+
$this->_maxRunTime = $maxTime + time();
|
574 |
+
|
575 |
+
$this->_adjustCurThreads();
|
576 |
+
|
577 |
+
return $this->_prepareCurList();
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
protected function _adjustCurThreads()
|
582 |
+
{
|
583 |
+
$max = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_THREAD_LIMIT];
|
584 |
+
$limit = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_LOAD_LIMIT] ;
|
585 |
+
|
586 |
+
$load = sys_getloadavg() ;
|
587 |
+
$curload = $load[0];
|
588 |
+
$curthreads = $this->_curThreads;
|
589 |
+
|
590 |
+
if ($this->_curThreads == -1) {
|
591 |
+
// init
|
592 |
+
if ($curload >= ($limit - 1)) {
|
593 |
+
$curthreads = 1;
|
594 |
+
}
|
595 |
+
else {
|
596 |
+
$curthreads = intval($limit - $curload);
|
597 |
+
if ($curthreads > $max) {
|
598 |
+
$curthreads = $max;
|
599 |
+
}
|
600 |
+
}
|
601 |
+
}
|
602 |
+
else {
|
603 |
+
// adjust
|
604 |
+
if ($curload >= $limit + 1 ) {
|
605 |
+
sleep(5); // sleep 5 secs
|
606 |
+
$curthreads --;
|
607 |
+
}
|
608 |
+
elseif ($curload >= $limit) {
|
609 |
+
if ($curthreads > 1) // if already 1, keep
|
610 |
+
$curthreads --;
|
611 |
+
}
|
612 |
+
elseif ( ($curload + 1) < $limit ) {
|
613 |
+
if ($curthreads < $max)
|
614 |
+
$curthreads ++;
|
615 |
+
}
|
616 |
+
}
|
617 |
+
|
618 |
+
if ($curthreads <= 0)
|
619 |
+
$curthreads = 0;
|
620 |
+
|
621 |
+
if ($this->_isDebug) {
|
622 |
+
$this->_debugLog('set current threads = ' . $curthreads . ' previous=' . $this->_curThreads
|
623 |
+
. ' max_allowed=' . $max . ' load_limit=' . $limit . ' current_load=' . $curload);
|
624 |
+
}
|
625 |
+
|
626 |
+
$this->_curThreads = $curthreads;
|
627 |
+
$this->_curThreadTime = time();
|
628 |
+
|
629 |
+
}
|
630 |
+
|
631 |
+
protected function _generateUrlList($listId)
|
632 |
+
{
|
633 |
+
if ($listId{0} == 's') {
|
634 |
+
// store
|
635 |
+
return $this->_generateStoreUrlList($listId);
|
636 |
+
}
|
637 |
+
else {
|
638 |
+
return $this->_generateCustUrlList($listId);
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
protected function _generateStoreUrlList($listId)
|
643 |
+
{
|
644 |
+
$app = Mage::app() ;
|
645 |
+
$storeId = $this->_meta[$listId]['storeid'];
|
646 |
+
$store = $app->getStore($storeId);
|
647 |
+
$app->setCurrentStore($store) ;
|
648 |
+
|
649 |
+
$baseUrl = $this->_meta[$listId]['baseurl'];
|
650 |
+
$basen = strlen($baseUrl);
|
651 |
+
|
652 |
+
$urls = array(''); // first line is empty for base url
|
653 |
+
|
654 |
+
$visibility = array(
|
655 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
656 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
|
657 |
+
) ;
|
658 |
+
$catModel = Mage::getModel('catalog/category') ;
|
659 |
+
|
660 |
+
$activeCat = $catModel->getCollection($storeId)->addIsActiveFilter() ;
|
661 |
+
|
662 |
+
$produrls = array();
|
663 |
+
|
664 |
+
// url with cat in path
|
665 |
+
foreach ( $activeCat as $cat ) {
|
666 |
+
$caturl = $cat->getUrl() ;
|
667 |
+
if (strncasecmp($baseUrl, $caturl, $basen) == 0) {
|
668 |
+
$urls[] = substr($caturl, $basen);
|
669 |
+
}
|
670 |
+
foreach ( $cat->getProductCollection($storeId)
|
671 |
+
->addUrlRewrite($cat->getId())
|
672 |
+
->addAttributeToFilter('visibility', $visibility)
|
673 |
+
as $prod ) {
|
674 |
+
$produrl = $prod->getProductUrl() ;
|
675 |
+
if (strncasecmp($baseUrl, $produrl, $basen) == 0) {
|
676 |
+
$produrls[] = substr($produrl, $basen);
|
677 |
+
}
|
678 |
+
}
|
679 |
+
}
|
680 |
+
|
681 |
+
// url with no cat info
|
682 |
+
foreach ( $activeCat as $cat ) {
|
683 |
+
foreach ( $cat->getProductCollection($storeId)
|
684 |
+
->addAttributeToFilter('visibility', $visibility)
|
685 |
+
as $prod ) {
|
686 |
+
$produrl = $prod->getProductUrl() ;
|
687 |
+
if (strncasecmp($baseUrl, $produrl, $basen) == 0) {
|
688 |
+
$produrls[] = substr($produrl, $basen);
|
689 |
+
}
|
690 |
+
}
|
691 |
+
}
|
692 |
+
|
693 |
+
$sitemap = 'sitemap/cms_page' ;
|
694 |
+
$sitemap = (Mage::getConfig()->getNode('modules/MageWorx_XSitemap') !== false) ?
|
695 |
+
'xsitemap/cms_page' : 'sitemap/cms_page' ;
|
696 |
+
|
697 |
+
$sitemodel = Mage::getResourceModel($sitemap);
|
698 |
+
if ($sitemodel != null) {
|
699 |
+
foreach ( $sitemodel->getCollection($storeId) as $item ) {
|
700 |
+
$sitemapurl = $item->getUrl();
|
701 |
+
$urls[] = $sitemapurl;
|
702 |
+
}
|
703 |
+
}
|
704 |
+
|
705 |
+
$produrls = array_unique($produrls);
|
706 |
+
$urls = array_merge($urls, $produrls);
|
707 |
+
|
708 |
+
$this->_meta[$listId]['listsize'] = count($urls);
|
709 |
+
$this->_meta[$listId]['gentime'] = time();
|
710 |
+
$this->_meta[$listId]['curpos'] = 0;
|
711 |
+
//$this->_meta[$listId]['queried'] = 0;
|
712 |
+
$this->_meta['lastupdate'] = $this->_meta[$listId]['gentime'];
|
713 |
+
$this->_metaUpdated = true;
|
714 |
+
$header = $this->_meta[$listId]['gentime'] . "\t"
|
715 |
+
. $this->_meta[$listId]['listsize'] . "\t"
|
716 |
+
. $this->_meta[$listId]['env'] . "\n";
|
717 |
+
|
718 |
+
if ( $this->_isDebug ) {
|
719 |
+
$this->_debugLog('Generate url map for ' . $listId . ' url count =' . $this->_meta[$listId]['listsize']);
|
720 |
+
}
|
721 |
+
|
722 |
+
$buf = $header . implode("\n", $urls);
|
723 |
+
|
724 |
+
$this->_saveCrawlListFileData($listId, $buf);
|
725 |
+
|
726 |
+
return $urls;
|
727 |
+
}
|
728 |
+
|
729 |
+
protected function _generateCustUrlList($listId)
|
730 |
+
{
|
731 |
+
$baseUrl = $this->_meta[$listId]['baseurl'];
|
732 |
+
$basen = strlen($baseUrl);
|
733 |
+
$custlist = $this->_meta[$listId]['file'];
|
734 |
+
$lines = file($custlist, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
735 |
+
$urls = array();
|
736 |
+
if ($lines === false) {
|
737 |
+
if ( $this->_isDebug ) {
|
738 |
+
$this->_debugLog('Fail to read custom URL list file ' . $custlist);
|
739 |
+
}
|
740 |
+
}
|
741 |
+
else if (!empty($lines)) {
|
742 |
+
$urls[] = ''; // always add home page
|
743 |
+
foreach ($lines as $line) {
|
744 |
+
$line = ltrim(trim($line), '/');
|
745 |
+
if ($line != '') {
|
746 |
+
if (strpos($line, 'http') !== false) {
|
747 |
+
if (strncasecmp($baseUrl, $line, $basen) == 0) {
|
748 |
+
$urls[] = substr($line, $basen);
|
749 |
+
}
|
750 |
+
}
|
751 |
+
else {
|
752 |
+
$urls[] = $line;
|
753 |
+
}
|
754 |
+
}
|
755 |
+
}
|
756 |
+
$urls = array_unique($urls);
|
757 |
+
}
|
758 |
+
|
759 |
+
$this->_meta[$listId]['listsize'] = count($urls);
|
760 |
+
$this->_meta[$listId]['gentime'] = time();
|
761 |
+
$this->_meta['lastupdate'] = $this->_meta[$listId]['gentime'];
|
762 |
+
$this->_metaUpdated = true;
|
763 |
+
$header = $this->_meta[$listId]['gentime'] . "\t"
|
764 |
+
. $this->_meta[$listId]['listsize'] . "\t"
|
765 |
+
. $this->_meta[$listId]['env'] . "\n";
|
766 |
+
|
767 |
+
if ( $this->_isDebug ) {
|
768 |
+
$this->_debugLog('Generate url map for ' . $listId . ' url count =' . $this->_meta[$listId]['listsize']);
|
769 |
+
}
|
770 |
+
|
771 |
+
$buf = $header . implode("\n", $urls);
|
772 |
+
$this->_saveCrawlListFileData($listId, $buf);
|
773 |
+
|
774 |
+
return $urls;
|
775 |
+
}
|
776 |
+
|
777 |
+
protected function _debugLog( $message, $level = 0 )
|
778 |
+
{
|
779 |
+
if ( $this->_isDebug ) {
|
780 |
+
$message = str_replace("\n", ("\n" . $this->_debugTag . ' '), $message);
|
781 |
+
Mage::log($this->_debugTag . ' '. $message ) ;
|
782 |
+
}
|
783 |
+
|
784 |
+
}
|
785 |
+
|
786 |
+
}
|
app/code/community/Litespeed/Litemage/Model/Observer/Esi.php
CHANGED
@@ -1,360 +1,670 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
27 |
+
{
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Add the core/messages block rewrite if the flash message fix is enabled
|
31 |
+
*
|
32 |
+
* The core/messages block is rewritten because it doesn't use a template
|
33 |
+
* we can replace with an ESI include tag, just dumps out a block of
|
34 |
+
* hard-coded HTML and also frequently skips the toHtml method
|
35 |
+
*
|
36 |
+
* @param Varien_Object $eventObj
|
37 |
+
* @return null
|
38 |
+
*/
|
39 |
+
protected $_esi ;
|
40 |
+
protected $_isDebug ;
|
41 |
+
protected $_moduleEnabledForUser ;
|
42 |
+
protected $_canInjectEsi = -1;
|
43 |
+
protected $_helper ;
|
44 |
+
protected $_config ;
|
45 |
+
protected $_viewVary = array();
|
46 |
+
protected $_routeCache;
|
47 |
+
protected $_injectedBlocks = array();
|
48 |
+
|
49 |
+
protected function _construct()
|
50 |
+
{
|
51 |
+
$this->_helper = Mage::helper('litemage/esi') ;
|
52 |
+
$this->_config = Mage::helper('litemage/data') ;
|
53 |
+
$this->_isDebug = $this->_config->isDebug() ;
|
54 |
+
$this->_moduleEnabledForUser = $this->_config->moduleEnabledForUser();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function purgeEsiCache( $eventObj )
|
58 |
+
{
|
59 |
+
if ( $this->_moduleEnabledForUser ) {
|
60 |
+
$this->_helper->addPurgeEvent($eventObj->getEvent()->getName()) ;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
//customer_login, customer_logout
|
65 |
+
public function purgePrivateCache( $eventObj )
|
66 |
+
{
|
67 |
+
if ( $this->_moduleEnabledForUser ) {
|
68 |
+
$this->_helper->setPurgeHeader(array('*'), $eventObj->getEvent()->getName(), null, true) ;
|
69 |
+
$this->_viewVary[] = 'env';
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
//customer_login
|
74 |
+
//other are captured when pre-dispatch by action name
|
75 |
+
public function changeEnvCookie( $eventObj )
|
76 |
+
{
|
77 |
+
if ( $this->_moduleEnabledForUser ) {
|
78 |
+
$this->_viewVary[] = 'env';
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
//controller_action_predispatch
|
83 |
+
public function checkControllerNoCache( $eventObj )
|
84 |
+
{
|
85 |
+
// no need to check admin, this is frontend event only
|
86 |
+
if ( ! $this->_moduleEnabledForUser ) {
|
87 |
+
$this->_canInjectEsi = 0;
|
88 |
+
return ;
|
89 |
+
}
|
90 |
+
$req = Mage::app()->getRequest() ;
|
91 |
+
$controller = $eventObj->getControllerAction();
|
92 |
+
$reason = '';
|
93 |
+
|
94 |
+
if (($lmdebug = $req->getParam('LITEMAGE_DEBUG')) !== null) {
|
95 |
+
// either isDebug or IP match
|
96 |
+
if ($this->_isDebug || $this->_config->isRestrainedIP() || $this->_config->isAdminIP()) {
|
97 |
+
if ($lmdebug == 'SHOWHOLES') {
|
98 |
+
// for redirect, maybe already set, need to check, otherwise exception
|
99 |
+
if ( ! Mage::registry('LITEMAGE_SHOWHOLES') ) {
|
100 |
+
Mage::register('LITEMAGE_SHOWHOLES', 1) ;
|
101 |
+
}
|
102 |
+
// set to nocache later at beforeResponseSend
|
103 |
+
}
|
104 |
+
elseif ($lmdebug == 'NOCACHE') {
|
105 |
+
$reason = 'contains var LITEMAGE_DEBUG=NOCACHE';
|
106 |
+
}
|
107 |
+
}
|
108 |
+
else {
|
109 |
+
$controller->norouteAction();
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
$curActionName = $controller->getFullActionName() ;
|
115 |
+
if ($reason == '') {
|
116 |
+
$reason = $this->_cannotCache($req, $curActionName);
|
117 |
+
}
|
118 |
+
|
119 |
+
if ($reason != '') {
|
120 |
+
$this->_canInjectEsi = 0;
|
121 |
+
$reason = ' NO_CACHE=' . $reason;
|
122 |
+
|
123 |
+
// special checks
|
124 |
+
$envChanged = array('customer_account_logoutSuccess', 'directory_currency_switch');
|
125 |
+
if (in_array($curActionName, $envChanged)) {
|
126 |
+
$this->_viewVary[] = 'env';
|
127 |
+
}
|
128 |
+
}
|
129 |
+
else {
|
130 |
+
|
131 |
+
// hardcode for now
|
132 |
+
if ( strncmp('catalog_category_', $curActionName, strlen('catalog_category_')) == 0 ) {
|
133 |
+
$this->_viewVary[] = 'toolbar' ;
|
134 |
+
Mage::Helper('litemage/viewvary')->restoreViewVary($this->_viewVary) ;
|
135 |
+
}
|
136 |
+
elseif (in_array($curActionName, $this->_config->getNoCacheConf(Litespeed_Litemage_Helper_Data::CFG_FULLCACHE_ROUTE))) {
|
137 |
+
$this->_setWholeRouteCache($curActionName, $controller);
|
138 |
+
}
|
139 |
+
|
140 |
+
if (($lmctrl = $req->getParam('LITEMAGE_CTRL')) !== null) {
|
141 |
+
// either isDebug or IP match
|
142 |
+
if ($this->_config->isAdminIP()) {
|
143 |
+
if ($lmctrl == 'PURGE') {
|
144 |
+
// for redirect, maybe already set, need to check, otherwise exception
|
145 |
+
if (!Mage::registry('LITEMAGE_PURGE')) {
|
146 |
+
Mage::register('LITEMAGE_PURGE', 1);
|
147 |
+
}
|
148 |
+
// set to nocache later at beforeResponseSend
|
149 |
+
}
|
150 |
+
}
|
151 |
+
else {
|
152 |
+
$controller->norouteAction();
|
153 |
+
return;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
$this->_helper->setCacheControlFlag(Litespeed_Litemage_Helper_Esi::CHBM_CACHEABLE) ;
|
158 |
+
|
159 |
+
if (Mage::getSingleton('core/cookie')->get('litemage_cron') == Litespeed_Litemage_Model_Observer_Cron::USER_AGENT) {
|
160 |
+
$currency = Mage::getSingleton('core/cookie')->get('currency');
|
161 |
+
if ($currency != '')
|
162 |
+
Mage::app()->getStore()->setCurrentCurrencyCode($currency);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( $this->_isDebug ) {
|
167 |
+
$this->_config->debugMesg('****** PRECHECK route_action [' . $curActionName . '] url=' . $req->getRequestString() . $reason) ;
|
168 |
+
}
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
+
// return reason string. if can be cached, return false;
|
173 |
+
protected function _cannotCache( $req, $curActionName )
|
174 |
+
{
|
175 |
+
$requrl = $req->getRequestString() ;
|
176 |
+
|
177 |
+
if ( $req->isPost() ) {
|
178 |
+
return 'POST';
|
179 |
+
}
|
180 |
+
|
181 |
+
$nocache = $this->_config->getNoCacheConf() ;
|
182 |
+
foreach ( $nocache[Litespeed_Litemage_Helper_Data::CFG_NOCACHE_VAR] as $param ) {
|
183 |
+
if ( $req->getParam($param) ) {
|
184 |
+
return 'contains param ' . $param;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
// check controller level
|
189 |
+
$cacheable = false;
|
190 |
+
foreach ( $nocache[Litespeed_Litemage_Helper_Data::CFG_CACHE_ROUTE] as $route ) {
|
191 |
+
if ( strncmp($route, $curActionName, strlen($route)) == 0 ) {
|
192 |
+
$cacheable = true;
|
193 |
+
break;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
if ( !$cacheable ) {
|
197 |
+
return 'route not cacheable';
|
198 |
+
}
|
199 |
+
|
200 |
+
foreach ( $nocache[Litespeed_Litemage_Helper_Data::CFG_NOCACHE_ROUTE] as $route ) {
|
201 |
+
if ( strncmp($route, $curActionName, strlen($route)) == 0 ) {
|
202 |
+
return 'subroute disabled';
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
foreach ( $nocache[Litespeed_Litemage_Helper_Data::CFG_NOCACHE_URL] as $url ) {
|
207 |
+
if ( strpos($requrl, $url) !== false ) {
|
208 |
+
return 'disabled url ' . $url;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
return ''; // can be cached
|
213 |
+
}
|
214 |
+
|
215 |
+
|
216 |
+
// event core_layout_block_create_after
|
217 |
+
public function checkEsiBlock($eventObj)
|
218 |
+
{
|
219 |
+
if ( ! $this->_moduleEnabledForUser )
|
220 |
+
return;
|
221 |
+
|
222 |
+
if ($this->_canInjectEsi === -1) {
|
223 |
+
$this->_canInjectEsi = $this->_helper->canInjectEsi();
|
224 |
+
}
|
225 |
+
|
226 |
+
if ( ! $this->_canInjectEsi )
|
227 |
+
return ;
|
228 |
+
|
229 |
+
// this is to deal with duplicated block names, caused by bad extensions, those blocks are lost in layout->_blocks[name], since name not unique
|
230 |
+
$block = $eventObj->getData('block') ;
|
231 |
+
|
232 |
+
$bconf = $this->_config->isEsiBlock($block);
|
233 |
+
if ($bconf != null) {
|
234 |
+
$blockName = $bconf['bn'];
|
235 |
+
|
236 |
+
if (!isset($this->_injectedBlocks[$blockName])) {
|
237 |
+
$bconf['blocks'] = array();
|
238 |
+
$this->_injectedBlocks[$blockName] = $bconf;
|
239 |
+
}
|
240 |
+
$this->_injectedBlocks[$blockName]['blocks'][] = $block;
|
241 |
+
}
|
242 |
+
// needs to be in its own section, not in else
|
243 |
+
if ($block->hasData('litemage_dynamic')) {
|
244 |
+
// dynamic injection right now
|
245 |
+
$this->_injectDynamicBlock($block);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
protected function _injectDynamicBlock($block)
|
250 |
+
{
|
251 |
+
$bd = $block->getData('litemage_dynamic');
|
252 |
+
if (!isset($bd['type']))
|
253 |
+
return;
|
254 |
+
|
255 |
+
if (!isset($bd['tag'])) { // todo: need to validate tag
|
256 |
+
/*$conf = $this->_config->getEsiConf('tag', $tag) ;
|
257 |
+
if ($conf == null) {
|
258 |
+
if ( $this->_isDebug ) {
|
259 |
+
$this->_config->debugMesg('Missing config for tag '. $tag) ;
|
260 |
+
}
|
261 |
+
return false ;
|
262 |
+
} */
|
263 |
+
$bd['tag'] = 'welcome';
|
264 |
+
}
|
265 |
+
$bd['cache-tag'] = 'E.' . $bd['tag'];
|
266 |
+
if (!isset($bd['access']) || !in_array($bd['access'], array('private', 'public'))) {
|
267 |
+
$bd['access'] = 'private';
|
268 |
+
}
|
269 |
+
if (!isset($bd['valueonly'])) {
|
270 |
+
$bd['valueonly'] = false;
|
271 |
+
}
|
272 |
+
|
273 |
+
/*
|
274 |
+
* $litemage_attr = array('litemage_dynamic' =>
|
275 |
+
array('tag' => 'welcome', 'access' => 'private', 'type' => 'customer/form_login', 'template' => 'customer/form/mini.login.phtml'));
|
276 |
+
*/
|
277 |
+
|
278 |
+
$blockName = $block->getNameInLayout();
|
279 |
+
$layout = $block->getLayout();
|
280 |
+
|
281 |
+
//re-init just in case
|
282 |
+
$conf = $this->_config->getEsiConf() ;
|
283 |
+
$preload = $this->_initInjectionCache($layout) ; // -1: donot use cache, 0 : no cahce, 1: cache loaded, 2: require update
|
284 |
+
|
285 |
+
|
286 |
+
$esiHtml = '' ;
|
287 |
+
if ( $preload && isset($this->_esi['layout']['blocks'][$blockName]) ) {
|
288 |
+
$esiHtml = $this->_esi['layout']['blocks'][$blockName] ;
|
289 |
+
unset($this->_esi['layout']['blocks'][$blockName]) ;
|
290 |
+
}
|
291 |
+
else {
|
292 |
+
if ( $preload == 1 ) {
|
293 |
+
$preload = 2 ; // found a new blockName not preloaded
|
294 |
+
}
|
295 |
+
|
296 |
+
$urlOptions = array('b' => $blockName, 't' => $bd['tag']);
|
297 |
+
$urlOptions['p'] = str_replace('/', '--', $bd['type']);
|
298 |
+
if (isset($bd['template'])) {
|
299 |
+
$urlOptions['l'] = str_replace('/', '--', $bd['template']);
|
300 |
+
}
|
301 |
+
$urlOptions = array_merge($urlOptions, $this->_esi['urlParams']);
|
302 |
+
|
303 |
+
$esiUrl = $this->_helper->getSubReqUrl('litemage/esi/getBlock', $urlOptions) ;
|
304 |
+
$esiHtml = '<' . $this->_config->esiTag('include') . ' src="' . $esiUrl . '" combine="sub" cache-tag="' . $bd['cache-tag'] . '" cache-control="no-vary,' . $bd['access'] . '"/>' ;
|
305 |
+
if (!$bd['valueonly'] && $this->_isDebug) {
|
306 |
+
$esiHtml = '<!--Litemage esi started ' . $blockName . '-->' . $esiHtml . '<!--Litemage esi ended ' . $blockName . '-->' ;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
$this->_helper->setEsiBlockHtml($blockName, $esiHtml) ;
|
311 |
+
|
312 |
+
$esiBlock = new Litespeed_Litemage_Block_Core_Esi() ;
|
313 |
+
if ($bd['valueonly']) {
|
314 |
+
$esiBlock->setData('valueonly', 1); // needs to set before initbypeer
|
315 |
+
}
|
316 |
+
$esiBlock->setData('dynamic', 1);
|
317 |
+
$esiBlock->initByPeer($block, $esiHtml) ;
|
318 |
+
$this->_esi['layout']['preload'] = $preload ;
|
319 |
+
|
320 |
+
}
|
321 |
+
|
322 |
+
//controller_action_layout_generate_blocks_after
|
323 |
+
public function prepareInjection( $eventObj )
|
324 |
+
{
|
325 |
+
if ($this->_canInjectEsi === -1) {
|
326 |
+
$this->_canInjectEsi = $this->_helper->canInjectEsi();
|
327 |
+
}
|
328 |
+
|
329 |
+
if ( ! $this->_canInjectEsi )
|
330 |
+
return ;
|
331 |
+
|
332 |
+
$this->_helper->initFormKey() ;
|
333 |
+
|
334 |
+
if (count($this->_injectedBlocks) == 0)
|
335 |
+
return;
|
336 |
+
|
337 |
+
$layout = $eventObj->getData('layout') ;
|
338 |
+
$conf = $this->_config->getEsiConf() ;
|
339 |
+
$preload = $this->_initInjectionCache($layout) ; // -1: donot use cache, 0 : no cahce, 1: cache loaded, 2: require update
|
340 |
+
$esiLayoutUpdate = null ;
|
341 |
+
$conflict = array();
|
342 |
+
|
343 |
+
foreach ( $this->_injectedBlocks as $blockName => $bd ) {
|
344 |
+
|
345 |
+
foreach ($bd['blocks'] as $block) {
|
346 |
+
|
347 |
+
$esiHtml = '' ;
|
348 |
+
|
349 |
+
$blockAlias = $block->getBlockAlias();
|
350 |
+
$blockIndex = $blockName;
|
351 |
+
if ($blockAlias != '' && $blockAlias != $blockName) {
|
352 |
+
$blockIndex .= '!' . $blockAlias;
|
353 |
+
}
|
354 |
+
|
355 |
+
// check confliction
|
356 |
+
if (!isset($conflict[$blockIndex])) {
|
357 |
+
$conflict[$blockIndex] = array($block);
|
358 |
+
}
|
359 |
+
else {
|
360 |
+
$conflict[$blockIndex][] = $block;
|
361 |
+
if ( $this->_isDebug )
|
362 |
+
$this->_config->debugMesg('ALERT not unique block name plus alias ' . $blockIndex);
|
363 |
+
}
|
364 |
+
|
365 |
+
if ( $preload && isset($this->_esi['layout']['blocks'][$blockIndex]) ) {
|
366 |
+
$esiHtml = $this->_esi['layout']['blocks'][$blockIndex] ;
|
367 |
+
unset($this->_esi['layout']['blocks'][$blockIndex]) ;
|
368 |
+
}
|
369 |
+
else {
|
370 |
+
if ( $preload == 1 ) {
|
371 |
+
$preload = 2 ; // found a new blockIndex not preloaded
|
372 |
+
}
|
373 |
+
|
374 |
+
// check if it is a child block of an injected block, bypassed one also need to save esihtml
|
375 |
+
if ( $this->_checkIsInjectedChild($block) ) {
|
376 |
+
$esiHtml = 'BYPASS';
|
377 |
+
}
|
378 |
+
else {
|
379 |
+
|
380 |
+
if ( $esiLayoutUpdate == null ) {
|
381 |
+
$esiLayoutUpdate = Mage::getSingleton('litemage/layout_update') ;
|
382 |
+
$esiLayoutUpdate->setStoreId($this->_esi['urlParams']['s']) ;
|
383 |
+
}
|
384 |
+
|
385 |
+
$urlOptions = $this->_getEsiUrlBHOptions($blockName, $block, $layout, $esiLayoutUpdate) ;
|
386 |
+
$urlOptions['t'] = $bd['tag'];
|
387 |
+
if ($blockAlias != '' && $blockName != $blockAlias) {
|
388 |
+
$urlOptions['a'] = $blockAlias;
|
389 |
+
}
|
390 |
+
$urlOptions = array_merge($urlOptions, $this->_esi['urlParams']);
|
391 |
+
|
392 |
+
$esiUrl = $this->_helper->getSubReqUrl('litemage/esi/getBlock', $urlOptions) ;
|
393 |
+
|
394 |
+
$esiHtml = '<' . $this->_config->esiTag('include') . ' src="' . $esiUrl . '" combine="sub" cache-tag="' . $bd['cache-tag'] . '" cache-control="no-vary,' . $bd['access'] . '"/>' ;
|
395 |
+
if (!$bd['valueonly'] && $this->_isDebug) {
|
396 |
+
//$esiHtml = '<esi:remove>ESI processing not enabled</esi:remove><!--esi' . $esiInclude . '-->' ; // remove comment, for html minify
|
397 |
+
$esiHtml = '<!--Litemage esi started ' . $blockName . '-->' . $esiHtml . '<!--Litemage esi ended ' . $blockName . '-->' ;
|
398 |
+
}
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
$this->_helper->setEsiBlockHtml($blockIndex, $esiHtml) ;
|
403 |
+
|
404 |
+
if ($esiHtml == 'BYPASS') {
|
405 |
+
// can be a child block of an injected block
|
406 |
+
continue;
|
407 |
+
}
|
408 |
+
|
409 |
+
if ( $bd['tag'] == 'messages' ) {
|
410 |
+
$esiBlock = new Litespeed_Litemage_Block_Core_Messages() ;
|
411 |
+
}
|
412 |
+
else {
|
413 |
+
$esiBlock = new Litespeed_Litemage_Block_Core_Esi() ;
|
414 |
+
}
|
415 |
+
if ($bd['valueonly']) {
|
416 |
+
$esiBlock->setData('valueonly', 1); // needs to be before initbypeer
|
417 |
+
}
|
418 |
+
$esiBlock->initByPeer($block, $esiHtml) ;
|
419 |
+
|
420 |
+
}
|
421 |
+
|
422 |
+
}
|
423 |
+
|
424 |
+
$this->_esi['layout']['preload'] = $preload ;
|
425 |
+
}
|
426 |
+
|
427 |
+
protected function _checkIsInjectedChild($block)
|
428 |
+
{
|
429 |
+
$layer = 20;
|
430 |
+
$blk = $block;
|
431 |
+
while (($blk = $blk->getParentBlock()) && $layer > 0 ) {
|
432 |
+
if ($blk->getData('litemageInjected')) {
|
433 |
+
return true;
|
434 |
+
}
|
435 |
+
$layer --;
|
436 |
+
}
|
437 |
+
return false;
|
438 |
+
}
|
439 |
+
|
440 |
+
protected function _setWholeRouteCache($actionName, $controller)
|
441 |
+
{
|
442 |
+
$app = Mage::app();
|
443 |
+
$design = Mage::getDesign() ;
|
444 |
+
$tags = array($actionName);
|
445 |
+
$tags[] = $app->getStore()->getId() ;
|
446 |
+
$tags[] = $design->getPackageName();
|
447 |
+
$tags[] = $design->getTheme('layout');
|
448 |
+
$cacheId = 'LITEMAGE_ROUTE_' . md5(join('__', $tags));
|
449 |
+
|
450 |
+
$this->_routeCache = array('actionName' => $actionName, 'cacheId' => $cacheId);
|
451 |
+
if ($result = $app->loadCache($cacheId)) {
|
452 |
+
$this->_routeCache['content'] = unserialize($result);
|
453 |
+
$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, 1);
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
protected function _initInjectionCache( $layout )
|
458 |
+
{
|
459 |
+
if (isset($this->_esi['layout']['cacheId'])) {
|
460 |
+
// already initialized
|
461 |
+
return isset($this->_esi['layout']['preload']) ? $this->_esi['layout']['preload'] : 0;
|
462 |
+
}
|
463 |
+
|
464 |
+
$this->_esi = array(
|
465 |
+
'layout' => array(),
|
466 |
+
'urlParams' => $this->_helper->getEsiSharedParams()) ;
|
467 |
+
$rootHandles = $layout->getUpdate()->getHandles() ;
|
468 |
+
//should we deal with wrong theme input? THEME_frontend_neoshop_Designer Sarees, Salwar Kameez, Lehengas, Wedding Sherwanis, Mens Kurta Pyjama, Online Shopping
|
469 |
+
$tags = array() ;
|
470 |
+
foreach ( $rootHandles as $handle ) {
|
471 |
+
if ( (strpos($handle, 'CATEGORY_') === false) && ((strpos($handle, 'PRODUCT_') === false) || (strpos($handle, 'PRODUCT_TYPE_') !== false)) ) {
|
472 |
+
$this->_esi['layout']['handles'][] = $handle ;
|
473 |
+
if ( ($handle != 'customer_logged_out') && ($handle != 'customer_logged_in') )
|
474 |
+
$tags[] = $handle ;
|
475 |
+
}
|
476 |
+
}
|
477 |
+
sort($tags) ;
|
478 |
+
$tags[] = 'LITEMAGE_INJECT_ESI' ;
|
479 |
+
$tags[] = join('-', $this->_esi['urlParams']); // for env vary
|
480 |
+
$cacheId = 'LITEMAGE_BLOCK_' . md5(join('__', $tags)) ;
|
481 |
+
$this->_esi['layout']['cacheId'] = $cacheId ;
|
482 |
+
$this->_helper->setEsiOn() ;
|
483 |
+
|
484 |
+
$preload = 0 ;
|
485 |
+
|
486 |
+
if ( $result = Mage::app()->loadCache($cacheId) ) {
|
487 |
+
$preload = 1 ;
|
488 |
+
$this->_esi['layout']['blocks'] = unserialize($result) ;
|
489 |
+
}
|
490 |
+
|
491 |
+
if ( $this->_isDebug )
|
492 |
+
$this->_config->debugMesg('INJECTING_' . $preload . ' ' . $_SERVER['REQUEST_URI']) ;
|
493 |
+
|
494 |
+
return $preload ;
|
495 |
+
}
|
496 |
+
|
497 |
+
protected function _getEsiUrlBHOptions( $blockName, $block, $layout, $esiLayoutUpdate )
|
498 |
+
{
|
499 |
+
// for blocks and handles
|
500 |
+
$hParam = array() ;
|
501 |
+
$handles = array() ;
|
502 |
+
$packageLayout = $esiLayoutUpdate->getPackageLayout() ;
|
503 |
+
|
504 |
+
$blockNames = $this->_getChildrenNames($block, $layout) ;
|
505 |
+
if ( ($alias = $block->getBlockAlias()) && ($alias != $blockName) ) {
|
506 |
+
array_unshift($blockNames, $blockName, $alias) ;
|
507 |
+
}
|
508 |
+
else {
|
509 |
+
array_unshift($blockNames, $blockName) ;
|
510 |
+
}
|
511 |
+
foreach ( $this->_esi['layout']['handles'] as $h ) {
|
512 |
+
if ( $h == 'customer_logged_out' || $h == 'customer_logged_in' ) {
|
513 |
+
$handles[] = $h ;
|
514 |
+
}
|
515 |
+
else {
|
516 |
+
|
517 |
+
foreach ( $blockNames as $name ) {
|
518 |
+
$xpath = '//' . $h . '//*[@name="' . $name . '"]' ;
|
519 |
+
if ( $node = $packageLayout->xpath($xpath) ) {
|
520 |
+
$handles[] = $h ;
|
521 |
+
$hParam[] = $h ;
|
522 |
+
break ;
|
523 |
+
}
|
524 |
+
}
|
525 |
+
}
|
526 |
+
}
|
527 |
+
|
528 |
+
$hasCache = $esiLayoutUpdate->loadEsiBlockCache($blockName, $handles) ;
|
529 |
+
if ( $hasCache === 0 ) {
|
530 |
+
//save layout cache right now, most economic way, blockNames will be filtered
|
531 |
+
$blockNames = $esiLayoutUpdate->importLayoutUpdate($blockNames, $handles, $layout) ;
|
532 |
+
}
|
533 |
+
elseif ( $hasCache == 1 ) {
|
534 |
+
// blockNames will be filtered
|
535 |
+
$blockNames = $esiLayoutUpdate->getBlockNames() ;
|
536 |
+
}
|
537 |
+
|
538 |
+
$urlOptions = array(
|
539 |
+
'b' => implode(',', $blockNames) ) ;
|
540 |
+
|
541 |
+
if ( count($hParam) > 0 )
|
542 |
+
$urlOptions['h'] = implode(',', $hParam) ;
|
543 |
+
|
544 |
+
return $urlOptions ;
|
545 |
+
}
|
546 |
+
|
547 |
+
protected function _getChildrenNames( $block, $layout )
|
548 |
+
{
|
549 |
+
if ($block == null) {
|
550 |
+
return array();
|
551 |
+
}
|
552 |
+
|
553 |
+
$children = $block->getSortedChildren() ;
|
554 |
+
foreach ( $children as $childName ) {
|
555 |
+
if ( $childBlock = $layout->getBlock($childName) ) {
|
556 |
+
$alias = $childBlock->getBlockAlias() ;
|
557 |
+
if ( $alias != $childName ) {
|
558 |
+
$children[] = $alias ;
|
559 |
+
}
|
560 |
+
$grandChildren = $this->_getChildrenNames($childBlock, $layout) ;
|
561 |
+
if ( count($grandChildren) > 0 ) {
|
562 |
+
$children = array_merge($children, $grandChildren) ;
|
563 |
+
}
|
564 |
+
}
|
565 |
+
}
|
566 |
+
return $children ;
|
567 |
+
}
|
568 |
+
|
569 |
+
//event: http_response_send_before
|
570 |
+
public function beforeResponseSend( $eventObj )
|
571 |
+
{
|
572 |
+
if ( !$this->_moduleEnabledForUser )
|
573 |
+
return;
|
574 |
+
|
575 |
+
$resp = $eventObj->getResponse();
|
576 |
+
|
577 |
+
if (isset($this->_routeCache['content'])) {
|
578 |
+
// serve cached whole page
|
579 |
+
$resp->setBody($this->_routeCache['content']['body']);
|
580 |
+
foreach($this->_routeCache['content']['header'] as $key => $val) {
|
581 |
+
$resp->setHeader($key, $val);
|
582 |
+
}
|
583 |
+
if (isset($this->_routeCache['content']['respcode'])) {
|
584 |
+
$resp->setHttpResponseCode($this->_routeCache['content']['respcode']);
|
585 |
+
}
|
586 |
+
if ($this->_isDebug) {
|
587 |
+
// last debug mesg
|
588 |
+
$this->_config->debugMesg('###### Served whole route from cache') ;
|
589 |
+
}
|
590 |
+
return;
|
591 |
+
}
|
592 |
+
|
593 |
+
if ( $this->_esi != null && ($this->_esi['layout']['preload'] != 1 || ! empty($this->_esi['layout']['blocks']) || $this->_helper->isEsiBlockAdjusted()) ) {
|
594 |
+
$tags = array(Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG, Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG);
|
595 |
+
|
596 |
+
if (Mage::app()->useCache('layout')) {
|
597 |
+
Mage::app()->saveCache($this->_helper->getEsiBlockHtml(), $this->_esi['layout']['cacheId'], $tags) ;
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
if ( count($this->_viewVary) ) {
|
602 |
+
// this needs to run before helper's beforeResponseSend
|
603 |
+
Mage::Helper('litemage/viewvary')->persistViewVary($this->_viewVary) ;
|
604 |
+
}
|
605 |
+
|
606 |
+
$extraHeaders = $this->_helper->beforeResponseSend($resp) ;
|
607 |
+
|
608 |
+
if (isset($this->_routeCache['cacheId']) && Mage::app()->useCache('layout')) {
|
609 |
+
$tags = array(Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG);
|
610 |
+
$content = array();
|
611 |
+
$content['body'] = $resp->getBody();
|
612 |
+
$cheaders = array();
|
613 |
+
$headers = $resp->getHeaders();
|
614 |
+
foreach ($headers as $header) {
|
615 |
+
$cheaders[$header['name']] = $header['value'];
|
616 |
+
}
|
617 |
+
foreach($extraHeaders as $key => $val) {
|
618 |
+
$cheaders[$key] = $val;
|
619 |
+
}
|
620 |
+
$content['header'] = $cheaders;
|
621 |
+
$curRespCode = $resp->getHttpResponseCode();
|
622 |
+
if ($curRespCode != 200) {
|
623 |
+
$content['respcode'] = $curRespCode;
|
624 |
+
}
|
625 |
+
|
626 |
+
Mage::app()->saveCache(serialize($content), $this->_routeCache['cacheId'], $tags);
|
627 |
+
}
|
628 |
+
|
629 |
+
if ($this->_isDebug) {
|
630 |
+
$this->_config->debugMesg('###### end of process, body length ' . strlen($resp->getBody()));
|
631 |
+
}
|
632 |
+
|
633 |
+
}
|
634 |
+
|
635 |
+
//catalog_controller_product_view
|
636 |
+
public function onCatalogProductView( $eventObj )
|
637 |
+
{
|
638 |
+
if ( $this->_moduleEnabledForUser && ! $this->_helper->isEsiRequest() ) {
|
639 |
+
$productId = $eventObj->getProduct()->getId() ;
|
640 |
+
$this->_helper->addCacheEntryTag(Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $productId) ;
|
641 |
+
|
642 |
+
if ( $this->_config->trackLastViewed() ) {
|
643 |
+
$this->_helper->addPurgeEvent($eventObj->getEvent()->getName()) ;
|
644 |
+
$this->_helper->trackProduct($productId) ;
|
645 |
+
}
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
// cms_page_render
|
650 |
+
public function onCmsPageRender( $eventObj )
|
651 |
+
{
|
652 |
+
if ( $this->_moduleEnabledForUser ) {
|
653 |
+
$pageId = $eventObj->getPage()->getId() ;
|
654 |
+
$this->_helper->addCacheEntryTag(Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CMS . $pageId) ;
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
public function initNewVisitor($eventObj)
|
659 |
+
{
|
660 |
+
if ( $this->_moduleEnabledForUser ) {
|
661 |
+
if (Mage::registry('LITEMAGE_NEWVISITOR')) {
|
662 |
+
Mage::unregister('LITEMAGE_NEWVISITOR'); // to be safe
|
663 |
+
}
|
664 |
+
else {
|
665 |
+
Mage::register('LITEMAGE_NEWVISITOR', 1);
|
666 |
+
}
|
667 |
+
}
|
668 |
+
}
|
669 |
+
|
670 |
+
}
|
app/code/community/Litespeed/Litemage/Model/Observer/Purge.php
CHANGED
@@ -1,170 +1,290 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
|
27 |
+
{
|
28 |
+
|
29 |
+
const WARMUP_DELTA_CACHE_ID = 'litemage_warmup_delta' ;
|
30 |
+
|
31 |
+
protected $_curProductId ;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Clear LiteSpeed Cache cache by admin actions
|
35 |
+
*
|
36 |
+
* Events:
|
37 |
+
* controller_action_postdispatch_adminhtml_cache_flushAll
|
38 |
+
* controller_action_postdispatch_adminhtml_cache_flushSystem
|
39 |
+
*
|
40 |
+
* @param Varien_Object $eventObj
|
41 |
+
* @return null
|
42 |
+
*/
|
43 |
+
public function adminPurgeCache( $eventObj )
|
44 |
+
{
|
45 |
+
$config = Mage::helper('litemage/data') ;
|
46 |
+
if ( $config->moduleEnabled() ) {
|
47 |
+
$this->_purgeAllByAdmin($this->_getAdminSession(), $config) ;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function adminPurgeCurrency($eventObj)
|
52 |
+
{
|
53 |
+
$config = Mage::helper('litemage/data') ;
|
54 |
+
if ( $config->moduleEnabled() ) {
|
55 |
+
Mage::helper('litemage/esi')->setPurgeHeader(array( 'CURR' ), 'adminPurgeCurrency') ;
|
56 |
+
$this->_getAdminSession()->addSuccess($config->__('Notified LiteSpeed web server to purge all cached pages which have currency rates.')) ;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
public function adminPurgeCacheBy($type, $ids )
|
61 |
+
{
|
62 |
+
$config = Mage::helper('litemage/data') ;
|
63 |
+
if ( $config->moduleEnabled() ) {
|
64 |
+
// validate
|
65 |
+
$adminSession = $this->_getAdminSession() ;
|
66 |
+
if ($ids == '') {
|
67 |
+
$adminSession->addError($config->__('Missing input value.'));
|
68 |
+
}
|
69 |
+
elseif (in_array($type, array('P','C','G'))) {
|
70 |
+
$tags = preg_split("/[\s,]+/", $ids, null, PREG_SPLIT_NO_EMPTY);
|
71 |
+
if (count($tags) == 0) {
|
72 |
+
$adminSession->addError($config->__('Missing ID values.'));
|
73 |
+
}
|
74 |
+
else {
|
75 |
+
$cacheTags = array();
|
76 |
+
foreach ($tags as $tag) {
|
77 |
+
if (strval(intval($tag)) != $tag) {
|
78 |
+
$adminSession->addError($config->__('Invalid ID values ' . $tag));
|
79 |
+
break;
|
80 |
+
}
|
81 |
+
$cacheTags[] = $type . '.' . $tag;
|
82 |
+
}
|
83 |
+
if (count($cacheTags)) {
|
84 |
+
$this->_purgeTagByAdmin($cacheTags, 'by ID ' . $ids . ' (from cache management)');
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
elseif ($type == 'U') {
|
89 |
+
if ($ids[0] != '/') {
|
90 |
+
$adminSession->addError($config->__('Invalid URL value, requires relative URL starting with /'));
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
$this->_purgeUrlByAdmin($ids);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
else {
|
97 |
+
$adminSession->addError($config->__('Invalid input type'));
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
public function adminConfigChangedSection( $eventObj )
|
103 |
+
{
|
104 |
+
$config = Mage::helper('litemage/data') ;
|
105 |
+
$moduleEnabled = $config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED) ;
|
106 |
+
$serverEnabled = isset($_SERVER['X-LITEMAGE']) && $_SERVER['X-LITEMAGE'] ;
|
107 |
+
$adminSession = $this->_getAdminSession() ;
|
108 |
+
if ( ! $serverEnabled ) {
|
109 |
+
$adminSession->addError($config->__('Your installation of LiteSpeed Web Server does not have LiteMage Cache enabled.')) ;
|
110 |
+
}
|
111 |
+
if ( $moduleEnabled ) {
|
112 |
+
if ( $serverEnabled ) {
|
113 |
+
$adminSession->addNotice($config->__('To make your changes take effect immediately, purge LiteSpeed Cache (System -> Cache Management).')) ;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
else {
|
117 |
+
$this->_purgeAllByAdmin($adminSession, $config) ;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
public function adminConfigEditSection( $eventObj )
|
122 |
+
{
|
123 |
+
$sectionCode = Mage::app()->getRequest()->getParam('section') ;
|
124 |
+
if ( $sectionCode == 'litemage' ) {
|
125 |
+
$serverEnabled = isset($_SERVER['X-LITEMAGE']) && $_SERVER['X-LITEMAGE'] ;
|
126 |
+
if ( ! $serverEnabled ) {
|
127 |
+
$config = Mage::helper('litemage/data') ;
|
128 |
+
$this->_getAdminSession()->addError($config->__('Your installation of LiteSpeed Web Server does not have LiteMage Cache enabled.')) ;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
protected function _purgeAllByAdmin( $adminSession, $config )
|
134 |
+
{
|
135 |
+
$tags = array( Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG ) ;
|
136 |
+
Mage::app()->cleanCache($tags) ;
|
137 |
+
$adminSession->addSuccess($config->__('Purged all LiteMage ESI block cache.')) ;
|
138 |
+
|
139 |
+
Mage::helper('litemage/esi')->setPurgeHeader(array( '*' ), 'purgeAllByAdmin') ;
|
140 |
+
$adminSession->addSuccess($config->__('Notified LiteSpeed web server to purge all cached items.')) ;
|
141 |
+
}
|
142 |
+
|
143 |
+
protected function _purgeTagByAdmin( $tags, $message = '' )
|
144 |
+
{
|
145 |
+
Mage::helper('litemage/esi')->setPurgeHeader($tags, 'purgeTagByAdmin') ;
|
146 |
+
if ( $message ) {
|
147 |
+
$this->_getAdminSession()->addSuccess(Mage::helper('litemage/data')->__('Notified LiteSpeed web server to purge ' . $message)) ;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
protected function _purgeUrlByAdmin($url)
|
152 |
+
{
|
153 |
+
Mage::helper('litemage/esi')->setPurgeURLHeader($url, 'purgeUrlByAdmin') ;
|
154 |
+
$this->_getAdminSession()->addSuccess(Mage::helper('litemage/data')->__('Notified LiteSpeed web server to purge URL ' . $url)) ;
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function _getAdminSession()
|
158 |
+
{
|
159 |
+
return Mage::getSingleton('adminhtml/session') ;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Event: admin catalog_category_save_commit_after
|
164 |
+
*/
|
165 |
+
public function adminPurgeCatalogCategory( $eventObj )
|
166 |
+
{
|
167 |
+
try {
|
168 |
+
if ( Mage::helper('litemage/data')->moduleEnabled() ) {
|
169 |
+
$category = $eventObj->getEvent()->getCategory() ;
|
170 |
+
if ( $category != null ) {
|
171 |
+
$tag = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CATEGORY . $category->getId() ;
|
172 |
+
$this->_purgeTagByAdmin(array( $tag ), $category->getName()) ;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
} catch ( Exception $e ) {
|
176 |
+
Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCatalogCategory: ' . $e->getMessage()) ;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
//admin catalog_product_save_commit_after
|
181 |
+
public function adminPurgeCatalogProduct( $eventObj )
|
182 |
+
{
|
183 |
+
try {
|
184 |
+
if ( Mage::helper('litemage/data')->moduleEnabled() ) {
|
185 |
+
$product = $eventObj->getEvent()->getProduct() ;
|
186 |
+
if ( $product != null ) {
|
187 |
+
$this->_purgeByProduct($product) ;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
} catch ( Exception $e ) {
|
191 |
+
Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCatalogProduct: ' . $e->getMessage()) ;
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
// global cataloginventory_stock_item_save_after
|
196 |
+
public function purgeCatalogProductByStock( $eventObj )
|
197 |
+
{
|
198 |
+
try {
|
199 |
+
if ( Mage::helper('litemage/data')->moduleEnabled() ) {
|
200 |
+
$item = $eventObj->getEvent()->getItem() ;
|
201 |
+
if ( $item->getStockStatusChangedAutomatically() || ($item->getOriginalInventoryQty() <= 0 && (($item->getQty() + $item->getQtyCorrection()) > 0)) ) {
|
202 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
203 |
+
$this->_purgeByProduct($product) ;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
} catch ( Exception $e ) {
|
207 |
+
Mage::helper('litemage/data')->debugMesg('Error on purgeCatalogProductByStock: ' . $e->getMessage()) ;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
// on admin cms_page_save_commit_after
|
212 |
+
public function adminPurgeCmsPage( $eventObj )
|
213 |
+
{
|
214 |
+
try {
|
215 |
+
if ( Mage::helper('litemage/data')->moduleEnabled() ) {
|
216 |
+
$page = $eventObj->getEvent()->getObject() ;
|
217 |
+
if ( $page != null ) {
|
218 |
+
$id = $page->getId() ;
|
219 |
+
if ( $id != null ) {
|
220 |
+
$tag = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CMS . $id ;
|
221 |
+
$this->_purgeTagByAdmin(array( $tag ), 'Page ' . $page->getTitle()) ;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
} catch ( Exception $e ) {
|
226 |
+
Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCmsPage: ' . $e->getMessage()) ;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
protected function _purgeByProduct( $product )
|
231 |
+
{
|
232 |
+
$productId = $product->getId() ;
|
233 |
+
if ( $this->_curProductId == $productId )
|
234 |
+
return ; // already purged
|
235 |
+
$this->_curProductId = $productId ;
|
236 |
+
|
237 |
+
$cids = $product->getCategoryIds() ;
|
238 |
+
|
239 |
+
if ( $cids == null )
|
240 |
+
$cids = array() ;
|
241 |
+
|
242 |
+
$tags = array() ;
|
243 |
+
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $productId ;
|
244 |
+
|
245 |
+
$pids = array_unique(array_merge(Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($productId), Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($productId))) ;
|
246 |
+
|
247 |
+
foreach ( $pids as $pid ) {
|
248 |
+
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_PRODUCT . $pid ;
|
249 |
+
$pp = Mage::getModel('catalog/product')->load($pid) ;
|
250 |
+
if ( $pp->isVisibleInCatalog() ) {
|
251 |
+
if ( ($pcids = $pp->getCategoryIds()) != null ) {
|
252 |
+
$cids = array_merge($cids, $pcids) ;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
$cids = array_unique($cids) ;
|
258 |
+
$pcids = array() ;
|
259 |
+
|
260 |
+
foreach ( $cids as $cid ) {
|
261 |
+
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CATEGORY . $cid ;
|
262 |
+
$cat = Mage::getModel('catalog/category')->load($cid) ;
|
263 |
+
$pcids = array_merge($pcids, $cat->getParentIds()) ;
|
264 |
+
}
|
265 |
+
|
266 |
+
$pcids = array_diff(array_unique($pcids), $cids) ;
|
267 |
+
foreach ( $pcids as $cid ) {
|
268 |
+
$cat = Mage::getModel('catalog/category')->load($cid) ;
|
269 |
+
$dispmode = $cat->getDisplayMode() ;
|
270 |
+
if ( $dispmode == Mage_Catalog_Model_Category::DM_PRODUCT || $dispmode == Mage_Catalog_Model_Category::DM_MIXED )
|
271 |
+
$tags[] = Litespeed_Litemage_Helper_Esi::TAG_PREFIX_CATEGORY . $cid ;
|
272 |
+
}
|
273 |
+
|
274 |
+
$this->_purgeTagByAdmin($tags, $product->getName()) ;
|
275 |
+
}
|
276 |
+
|
277 |
+
/* protected function _addDelta($urls)
|
278 |
+
{
|
279 |
+
$app = Mage::app();
|
280 |
+
if ($delta = $app->loadCache( self::WARMUP_DELTA_CACHE_ID )) {
|
281 |
+
$delta .= "\n" . implode("\n", $urls);
|
282 |
+
}
|
283 |
+
else {
|
284 |
+
$delta = time() . "\n" . implode("\n", $urls);
|
285 |
+
}
|
286 |
+
$tags = array(Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG);
|
287 |
+
$app->saveCache($delta, self::WARMUP_DELTA_CACHE_ID, $tags);
|
288 |
+
|
289 |
+
} */
|
290 |
+
}
|
app/code/community/Litespeed/Litemage/Model/Session.php
CHANGED
@@ -1,33 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Litespeed_Litemage_Model_Session extends Mage_Core_Model_Session_Abstract
|
26 |
+
{
|
27 |
+
protected $_isDebug;
|
28 |
+
|
29 |
+
public function __construct()
|
30 |
+
{
|
31 |
+
$this->init('litemage');
|
32 |
+
$this->_isDebug = Mage::helper('litemage/data')->isDebug();
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Save the messages for a given block to the session
|
37 |
+
*
|
38 |
+
* @param string $blockName
|
39 |
+
* @param array $messages
|
40 |
+
* @return null
|
41 |
+
*/
|
42 |
+
public function saveMessages( $blockName, $messages )
|
43 |
+
{
|
44 |
+
$stored = $this->getData($blockName);
|
45 |
+
if ($stored != null) {
|
46 |
+
$messages = array_merge($stored, $messages);
|
47 |
+
}
|
48 |
+
$this->setData($blockName, $messages);
|
49 |
+
if ($this->_isDebug)
|
50 |
+
Mage::helper('litemage/data')->debugMesg("saveMessages for $blockName " . print_r($messages, true));
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Retrieve the messages for a given messages block
|
55 |
+
*
|
56 |
+
* @param string $blockName
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
public function loadMessages( $blockName )
|
60 |
+
{
|
61 |
+
$messages = $this->getData($blockName);
|
62 |
+
$this->unsetData($blockName);
|
63 |
+
return $messages;
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
app/code/community/Litespeed/Litemage/Model/Translate.php
CHANGED
@@ -1,12 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* LiteMage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
*
|
6 |
-
*
|
7 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
|
|
10 |
class Litespeed_Litemage_Model_Translate extends Mage_Core_Model_Translate
|
11 |
{
|
12 |
/* this class rewrite just try to fix one issue with old class: cacheId does not regenerated, so will still point to different store.
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
*/
|
24 |
|
25 |
+
|
26 |
class Litespeed_Litemage_Model_Translate extends Mage_Core_Model_Translate
|
27 |
{
|
28 |
/* this class rewrite just try to fix one issue with old class: cacheId does not regenerated, so will still point to different store.
|
app/code/community/Litespeed/Litemage/controllers/AdminController.php
CHANGED
@@ -1,55 +1,108 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Action
|
27 |
+
{
|
28 |
+
|
29 |
+
protected $_helper ;
|
30 |
+
protected $_config ;
|
31 |
+
protected $_isDebug ;
|
32 |
+
protected $_data;
|
33 |
+
|
34 |
+
protected function _construct()
|
35 |
+
{
|
36 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION, 1) ; // Do not start standart session
|
37 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_PRE_DISPATCH, true) ;
|
38 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_POST_DISPATCH, true) ;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* It seems this has to exist so we just make it redirect to the base URL
|
43 |
+
* for lack of anything better to do.
|
44 |
+
*
|
45 |
+
* @return null
|
46 |
+
*/
|
47 |
+
public function indexAction()
|
48 |
+
{
|
49 |
+
Mage::log('Err: litemage/admin/ come to indexaction') ;
|
50 |
+
$this->getResponse()->setRedirect(Mage::getBaseUrl()) ;
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _errorExit($errorMesg)
|
54 |
+
{
|
55 |
+
if ( $this->_isDebug ) {
|
56 |
+
$this->_config->debugMesg('litemage/admin ErrorExit: ' . $errorMesg) ;
|
57 |
+
}
|
58 |
+
$resp = $this->getResponse() ;
|
59 |
+
$resp->setHttpResponseCode(500) ;
|
60 |
+
$resp->setBody($errorMesg) ;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
public function purgeAction()
|
65 |
+
{
|
66 |
+
if ( $this->_accessAllowed()) {
|
67 |
+
if ($error = $this->_validatePurgeTags()) {
|
68 |
+
$this->_errorExit($error);
|
69 |
+
}
|
70 |
+
else {
|
71 |
+
$this->_helper->setPurgeHeader($this->_data, 'litemage/admin/purgeAction');
|
72 |
+
}
|
73 |
+
}
|
74 |
+
else {
|
75 |
+
$this->_errorExit('Access denied') ;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
protected function _accessAllowed()
|
81 |
+
{
|
82 |
+
$this->_config = Mage::helper('litemage/data') ;
|
83 |
+
$this->_isDebug = $this->_config->isDebug() ;
|
84 |
+
if ( $this->_config->moduleEnabledForUser() && $this->_config->isAdminIP() ) {
|
85 |
+
$this->_helper = Mage::helper('litemage/esi') ;
|
86 |
+
return true ;
|
87 |
+
}
|
88 |
+
else
|
89 |
+
return false ;
|
90 |
+
}
|
91 |
+
|
92 |
+
protected function _validatePurgeTags()
|
93 |
+
{
|
94 |
+
$req = $this->getRequest() ;
|
95 |
+
$tags = $req->getParam('tags');
|
96 |
+
if ($tags == null) {
|
97 |
+
return 'Missing tags value';
|
98 |
+
}
|
99 |
+
$data = explode(',', $tags);
|
100 |
+
foreach ($data as $d) {
|
101 |
+
if ( !preg_match("/^[GCP]\.\d+$/", $d)) {
|
102 |
+
return 'Invalid Format';
|
103 |
+
}
|
104 |
+
}
|
105 |
+
$this->_data = $data;
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
app/code/community/Litespeed/Litemage/controllers/Adminhtml/LitemageCacheController.php
CHANGED
@@ -1,38 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
class Litespeed_Litemage_Adminhtml_LitemageCacheController extends Mage_Adminhtml_Controller_Action
|
28 |
+
{
|
29 |
+
public function purgeAllAction()
|
30 |
+
{
|
31 |
+
Mage::getModel( 'litemage/observer_purge' )->adminPurgeCache(null);
|
32 |
+
$this->_redirect('*/cache/index');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function purgeTagAction()
|
36 |
+
{
|
37 |
+
$req = $this->getRequest();
|
38 |
+
Mage::getModel( 'litemage/observer_purge' )->adminPurgeCacheBy($req->getParam('tag_types'), $req->getParam('purge_tag'));
|
39 |
+
$this->_redirect('*/cache/index');
|
40 |
+
}
|
41 |
+
|
42 |
+
public function purgeUrlAction()
|
43 |
+
{
|
44 |
+
Mage::getModel( 'litemage/observer_purge' )->adminPurgeCacheBy('U', $this->getRequest()->getParam('purge_url'));
|
45 |
+
$this->_redirect('*/cache/index');
|
46 |
+
}
|
47 |
+
|
48 |
+
public function resetCrawlerListAction()
|
49 |
+
{
|
50 |
+
$req = $this->getRequest();
|
51 |
+
Mage::getModel( 'litemage/observer_cron' )->resetCrawlerList($req->getParam('list'));
|
52 |
+
$this->_redirect('*/cache/index');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getCrawlerListAction()
|
56 |
+
{
|
57 |
+
$req = $this->getRequest();
|
58 |
+
$output = Mage::getModel( 'litemage/observer_cron' )->getCrawlerList($req->getParam('list'));
|
59 |
+
$this->getResponse()->setBody($output);
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function _isAllowed()
|
63 |
+
{
|
64 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/cache/litemage');
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Litespeed/Litemage/controllers/EsiController.php
CHANGED
@@ -1,411 +1,763 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
27 |
+
{
|
28 |
+
|
29 |
+
const ESIDATA_CACHE_ID = 'litemage_esi_data' ;
|
30 |
+
const ESIDATA_CACHE_NOTSET = '__NOTSET__' ;
|
31 |
+
|
32 |
+
protected $_esiData ;
|
33 |
+
protected $_curData ;
|
34 |
+
protected $_env = array() ;
|
35 |
+
protected $_helper ;
|
36 |
+
protected $_config ;
|
37 |
+
protected $_isDebug ;
|
38 |
+
protected $_layout ;
|
39 |
+
|
40 |
+
protected function _construct()
|
41 |
+
{
|
42 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_PRE_DISPATCH, true);
|
43 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_POST_DISPATCH, true);
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Retrieve current layout object
|
48 |
+
*
|
49 |
+
* @return Mage_Core_Model_Layout
|
50 |
+
*/
|
51 |
+
public function getLayout()
|
52 |
+
{
|
53 |
+
if ( $this->_layout == null ) {
|
54 |
+
$this->_layout = Mage::getSingleton('litemage/layout') ;
|
55 |
+
}
|
56 |
+
return $this->_layout ;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* It seems this has to exist so we just make it redirect to the base URL
|
61 |
+
* for lack of anything better to do.
|
62 |
+
*
|
63 |
+
* @return null
|
64 |
+
*/
|
65 |
+
public function indexAction()
|
66 |
+
{
|
67 |
+
Mage::log('Err: litemage come to indexaction') ;
|
68 |
+
$this->getResponse()->setRedirect(Mage::getBaseUrl()) ;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function noRouteAction( $coreRoute = null )
|
72 |
+
{
|
73 |
+
//set esi off
|
74 |
+
$origEsiUrl = $_SERVER['REQUEST_URI'] ;
|
75 |
+
if ( $param = $this->_parseUrlParams($origEsiUrl) ) {
|
76 |
+
switch ( $param['action'] ) {
|
77 |
+
case 'getCombined': $this->getCombinedAction() ;
|
78 |
+
break ;
|
79 |
+
case 'getFormKey': $this->getFormKeyAction() ;
|
80 |
+
break ;
|
81 |
+
case 'getBlock': $this->getBlockAction() ;
|
82 |
+
break ;
|
83 |
+
case 'getMessage': $this->getMessageAction() ;
|
84 |
+
break ;
|
85 |
+
case 'log': $this->logAction() ;
|
86 |
+
break ;
|
87 |
+
default: $this->_errorExit() ;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
else {
|
91 |
+
$this->_errorExit() ;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function _errorExit()
|
96 |
+
{
|
97 |
+
$resp = $this->getResponse() ;
|
98 |
+
$resp->setHttpResponseCode(500) ;
|
99 |
+
$resp->setBody('<!-- ESI data is not valid -->') ;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Spit out the form key for this session
|
104 |
+
*
|
105 |
+
* @return null
|
106 |
+
*/
|
107 |
+
public function getFormKeyAction()
|
108 |
+
{
|
109 |
+
$action = 'getFormKey' ;
|
110 |
+
if ( $this->_initUserParams($action) ) {
|
111 |
+
$this->_setEsiFlag($this->_esiData[$action]) ;
|
112 |
+
$data = $this->_esiData[$action]['raw_output'] ;
|
113 |
+
$this->getResponse()->setBody($data) ;
|
114 |
+
}
|
115 |
+
else {
|
116 |
+
$this->_errorExit() ;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function _setEsiFlag( $esiData )
|
121 |
+
{
|
122 |
+
$flag = Litespeed_Litemage_Helper_Esi::CHBM_ESI_REQ ;
|
123 |
+
$tag = '' ;
|
124 |
+
|
125 |
+
if ( $esiData['ttl'] > 0 ) {
|
126 |
+
$flag |= Litespeed_Litemage_Helper_Esi::CHBM_CACHEABLE ;
|
127 |
+
if ( $esiData['access'] == 'private' )
|
128 |
+
$flag |= Litespeed_Litemage_Helper_Esi::CHBM_PRIVATE ;
|
129 |
+
if ( isset($esiData['cacheIfEmpty']) && $esiData['cacheIfEmpty'] )
|
130 |
+
$flag |= Litespeed_Litemage_Helper_Esi::CHBM_ONLY_CACHE_EMPTY ;
|
131 |
+
$tag = $esiData['tag'] ;
|
132 |
+
}
|
133 |
+
$this->_helper->setCacheControlFlag($flag, $esiData['ttl'], $tag) ;
|
134 |
+
}
|
135 |
+
|
136 |
+
public function getBlockAction()
|
137 |
+
{
|
138 |
+
if ( ! $this->_initUserParams('getBlock') ) {
|
139 |
+
$this->_errorExit() ;
|
140 |
+
return ;
|
141 |
+
}
|
142 |
+
|
143 |
+
$esiDatas = array_values($this->_esiData) ;
|
144 |
+
$esiData = $esiDatas[0] ;
|
145 |
+
if ( count($this->_esiData) > 1 ) {
|
146 |
+
// not sure when this will happen
|
147 |
+
$includeEsi = '<' . $this->_config->esiTag('include') . ' src="' . $esiData['url'] . '" combine="sub" cache-control="no-vary,private"/>' ;
|
148 |
+
$this->_esiData['include'] = array( 'output' => $includeEsi ) ;
|
149 |
+
$this->_getCombinedData() ;
|
150 |
+
}
|
151 |
+
else {
|
152 |
+
$this->_setEsiFlag($esiData) ;
|
153 |
+
if ( isset($esiData['output']) && ($esiData['output'] != self::ESIDATA_CACHE_NOTSET) ) {
|
154 |
+
$this->getResponse()->setBody($esiData['output']) ;
|
155 |
+
}
|
156 |
+
else {
|
157 |
+
$this->_blockData($esiData) ;
|
158 |
+
if ( $this->_env['update_cache'] && Mage::app()->useCache('layout') ) {
|
159 |
+
if ( $this->_env['update_cache'] & 2 ) {
|
160 |
+
$this->_env['esiUrls'][$esiData['n']][$esiData['url']] = $this->getResponse()->getBody() ;
|
161 |
+
}
|
162 |
+
$tags = array( Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG ) ;
|
163 |
+
Mage::app()->saveCache(serialize($this->_env['esiUrls']), $this->_env['cache_id'], $tags) ;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
protected function _blockData( $esiData )
|
170 |
+
{
|
171 |
+
$this->_curData = $esiData ;
|
172 |
+
if (isset($esiData['type'])) {
|
173 |
+
// dynamic block
|
174 |
+
$this->_layout->resetBlocks() ;
|
175 |
+
if ($block = $this->_layout->createBlock($esiData['type'], $esiData['n'])) {
|
176 |
+
if (isset($esiData['template'])) {
|
177 |
+
$block->setTemplate($esiData['template']);
|
178 |
+
}
|
179 |
+
$this->renderLayout($esiData['n']) ;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
else {
|
183 |
+
$this->loadLayoutUpdates() ;
|
184 |
+
$this->generateLayoutXml() ;
|
185 |
+
$this->generateLayoutBlocks() ;
|
186 |
+
$name_alias = isset($esiData['alias']) ? $esiData['alias'] : $esiData['n'];
|
187 |
+
$this->renderLayout($name_alias) ;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
public function renderLayout( $output = '' )
|
192 |
+
{
|
193 |
+
// override, output can be block name or alias
|
194 |
+
if ( $output != '' && $this->_layout->getOutputBlock($output) != null ) {
|
195 |
+
try {
|
196 |
+
parent::renderLayout($output) ;
|
197 |
+
} catch ( Exception $e ) {
|
198 |
+
if ( $this->_isDebug ) {
|
199 |
+
$this->_config->debugMesg('renderLayout, exception for block ' . $output . ' : ' . $e->getMessage()) ;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
else {
|
204 |
+
if ( $this->_isDebug ) {
|
205 |
+
$this->_config->debugMesg('renderLayout, not output for ' . $output) ;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
return $this ;
|
209 |
+
}
|
210 |
+
|
211 |
+
public function getMessageAction()
|
212 |
+
{
|
213 |
+
if ( $this->_initUserParams('getMessage') ) {
|
214 |
+
$esiData = array_values($this->_esiData) ;
|
215 |
+
$this->_setEsiFlag($esiData[0]) ;
|
216 |
+
$this->_messageData($esiData[0]) ;
|
217 |
+
}
|
218 |
+
else {
|
219 |
+
$this->_errorExit() ;
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
protected function _messageData( $esiData )
|
224 |
+
{
|
225 |
+
$this->_curData = $esiData ;
|
226 |
+
$this->loadLayoutUpdates() ;
|
227 |
+
$this->generateLayoutXml() ;
|
228 |
+
$this->generateLayoutBlocks() ;
|
229 |
+
|
230 |
+
$name_alias = isset($esiData['alias']) ? $esiData['alias'] : $esiData['n'];
|
231 |
+
|
232 |
+
$block = $this->_layout->getOutputBlock($name_alias) ;
|
233 |
+
$newMessages = new Litespeed_Litemage_Block_Core_Messages() ;
|
234 |
+
$newMessages->initByEsi($esiData['st'], $esiData['call'], $block) ;
|
235 |
+
$this->renderLayout($name_alias) ;
|
236 |
+
}
|
237 |
+
|
238 |
+
public function getCombinedAction()
|
239 |
+
{
|
240 |
+
if ( ! $this->_initUserParams('getCombined') ) {
|
241 |
+
$this->_errorExit() ;
|
242 |
+
return ;
|
243 |
+
}
|
244 |
+
//add raw header here, to handle ajax exception
|
245 |
+
header(Litespeed_Litemage_Helper_Esi::LSHEADER_CACHE_CONTROL . ': esi=on', true) ;
|
246 |
+
$this->_getCombinedData() ;
|
247 |
+
}
|
248 |
+
|
249 |
+
protected function _getCombinedData()
|
250 |
+
{
|
251 |
+
$this->_helper->setCacheControlFlag(Litespeed_Litemage_Helper_Esi::CHBM_ESI_ON | Litespeed_Litemage_Helper_Esi::CHBM_ESI_REQ) ;
|
252 |
+
$response = $this->getResponse() ;
|
253 |
+
$response->clearBody() ;
|
254 |
+
$body = '' ;
|
255 |
+
|
256 |
+
foreach ( $this->_esiData as $key => $esiData ) {
|
257 |
+
|
258 |
+
if ( isset($esiData['output']) && ($esiData['output'] != self::ESIDATA_CACHE_NOTSET) ) {
|
259 |
+
$body .= $esiData['output'] ;
|
260 |
+
continue ;
|
261 |
+
}
|
262 |
+
|
263 |
+
if ( $esiData['action'] == 'log' ) {
|
264 |
+
$this->_logData($esiData) ;
|
265 |
+
$esiData['raw_output'] = '' ;
|
266 |
+
}
|
267 |
+
|
268 |
+
if ( isset($esiData['raw_output']) ) { //getFormKey & log
|
269 |
+
$inlineBody = $this->_getInlineBody($esiData, $esiData['raw_output'], 200) ;
|
270 |
+
}
|
271 |
+
else {
|
272 |
+
if ( $esiData['action'] == 'getMessage' ) {
|
273 |
+
$this->_messageData($esiData) ;
|
274 |
+
}
|
275 |
+
else {
|
276 |
+
// getBlock
|
277 |
+
$this->_blockData($esiData) ;
|
278 |
+
}
|
279 |
+
// env['update_cache'] can be changed by logged_in handle
|
280 |
+
$inlineBody = $this->_getInlineBody($esiData, $response->getBody(), $response->getHttpResponseCode(), ($this->_env['update_cache'] & 2)) ;
|
281 |
+
$response->clearBody() ;
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
$body .= $inlineBody ;
|
286 |
+
}
|
287 |
+
$response->setBody($body) ;
|
288 |
+
if ( $this->_env['update_cache'] && Mage::app()->useCache('layout')) {
|
289 |
+
$tags = array( Litespeed_Litemage_Helper_Data::LITEMAGE_GENERAL_CACHE_TAG ) ;
|
290 |
+
Mage::app()->saveCache(serialize($this->_env['esiUrls']), $this->_env['cache_id'], $tags) ;
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
protected function _getInlineBody( $esiData, $output, $responseCode, $updateShared = -1 )
|
295 |
+
{
|
296 |
+
$output = trim($output) ;
|
297 |
+
$esiInlineTag = $this->_config->esiTag('inline');
|
298 |
+
$initShared = false ;
|
299 |
+
|
300 |
+
if ( ($updateShared != -1) && ($esiData['access'] == 'private') && ($esiData['ttl'] > 0) ) {
|
301 |
+
if ( $updateShared == 0 ) { // check if same as shared
|
302 |
+
$out2 = '">' . $output . "</$esiInlineTag>" ;
|
303 |
+
if ( strpos($this->_env['esiUrls'][$esiData['n']][$esiData['url']], $out2) ) {
|
304 |
+
$buf = $this->_env['esiUrls'][$esiData['n']][$esiData['url']] ;
|
305 |
+
if ( $this->_isDebug ) {
|
306 |
+
$this->_config->debugMesg('Inline0m ' . substr($buf, 0, strpos($buf, "\n"))) ;
|
307 |
+
}
|
308 |
+
return $buf ;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
else if ( $updateShared == 2 ) {
|
312 |
+
$initShared = true ;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
|
317 |
+
$buf = '<' . $esiInlineTag . ' name="' . $esiData['url'] . '" cache-control="' ;
|
318 |
+
|
319 |
+
$ttl = $esiData['ttl'] ;
|
320 |
+
if ( $ttl > 0 && ! in_array($responseCode, array( 200, 301, 404 )) ) {
|
321 |
+
$ttl = 0 ;
|
322 |
+
}
|
323 |
+
|
324 |
+
if ( $ttl == 0 ) {
|
325 |
+
$buf .= 'no-cache' ;
|
326 |
+
}
|
327 |
+
else {
|
328 |
+
$buf .= $esiData['access'] . ',max-age=' . $esiData['ttl'] . ',no-vary' ;
|
329 |
+
if ( $esiData['cacheIfEmpty'] )
|
330 |
+
$buf .= ',set-blank' ;
|
331 |
+
elseif ( $initShared ) {
|
332 |
+
$buf .= ',shared' ;
|
333 |
+
}
|
334 |
+
|
335 |
+
$buf .= '" cache-tag="' . $esiData['tag'] ;
|
336 |
+
}
|
337 |
+
|
338 |
+
$buf .= '">' . $output . "</$esiInlineTag>\n" ;
|
339 |
+
if ( $initShared ) {
|
340 |
+
$this->_env['esiUrls'][$esiData['n']][$esiData['url']] = $buf ;
|
341 |
+
}
|
342 |
+
|
343 |
+
if ( $this->_isDebug ) {
|
344 |
+
$this->_config->debugMesg('Inline' . $updateShared . ' ' . substr($buf, 0, strpos($buf, "\n"))) ;
|
345 |
+
}
|
346 |
+
|
347 |
+
return $buf ;
|
348 |
+
}
|
349 |
+
|
350 |
+
public function logAction()
|
351 |
+
{
|
352 |
+
$action = 'log' ;
|
353 |
+
if ( $this->_initUserParams($action) ) {
|
354 |
+
$this->_setEsiFlag($this->_esiData[$action]) ;
|
355 |
+
$this->_logData($this->_esiData[$action]) ;
|
356 |
+
}
|
357 |
+
else
|
358 |
+
$this->_errorExit() ;
|
359 |
+
}
|
360 |
+
|
361 |
+
protected function _logData( $esiData )
|
362 |
+
{
|
363 |
+
if ( isset($esiData['product']) ) {
|
364 |
+
if ( isset($this->_env['s']) && ! isset($this->_env['dp']) ) {
|
365 |
+
Mage::app()->setCurrentStore(Mage::app()->getStore($this->_env['s'])) ;
|
366 |
+
}
|
367 |
+
|
368 |
+
$product = new Varien_Object() ;
|
369 |
+
$product->setId($esiData['product']) ;
|
370 |
+
try {
|
371 |
+
Mage::dispatchEvent('catalog_controller_product_view', array( 'product' => $product )) ;
|
372 |
+
} catch ( Exception $e ) {
|
373 |
+
if ( $this->_isDebug ) {
|
374 |
+
$this->_config->debugMesg('_logData, exception for product ' . $product->getId() . ' : ' . $e->getMessage()) ;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
protected function _initUserParams( $action )
|
381 |
+
{
|
382 |
+
$this->_config = Mage::helper('litemage/data') ;
|
383 |
+
$this->_isDebug = $this->_config->isDebug() ;
|
384 |
+
if ( ! $this->_config->moduleEnabledForUser() ) {
|
385 |
+
return false ;
|
386 |
+
}
|
387 |
+
|
388 |
+
$this->_helper = Mage::helper('litemage/esi') ;
|
389 |
+
|
390 |
+
|
391 |
+
$origEsiUrl = $_SERVER['REQUEST_URI'] ;
|
392 |
+
$req = $this->getRequest() ;
|
393 |
+
|
394 |
+
//set original host url
|
395 |
+
if ( $refererUrl = $req->getServer('ESI_REFERER') ) {
|
396 |
+
$_SERVER['REQUEST_URI'] = $refererUrl ;
|
397 |
+
$req->setRequestUri($refererUrl) ;
|
398 |
+
$req->setPathInfo() ;
|
399 |
+
}
|
400 |
+
else {
|
401 |
+
// illegal entrance, only allow from lsws
|
402 |
+
if ( $this->_isDebug ) {
|
403 |
+
$this->_config->debugMesg('Illegal Entrance') ;
|
404 |
+
}
|
405 |
+
|
406 |
+
return false ;
|
407 |
+
}
|
408 |
+
|
409 |
+
if ( $this->_isDebug )
|
410 |
+
$this->_config->debugMesg('****** EsiController init url ' . $origEsiUrl) ;
|
411 |
+
|
412 |
+
|
413 |
+
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION, true); // only set here for postdispatch, do not set last viewed url
|
414 |
+
|
415 |
+
$this->_env['update_cache'] = 0 ;
|
416 |
+
$this->_esiData = array() ;
|
417 |
+
|
418 |
+
if ( $action == 'getCombined' ) {
|
419 |
+
if ( ! isset($_REQUEST['esi_include']) ) {
|
420 |
+
if ( $this->_isDebug ) {
|
421 |
+
$this->_config->debugMesg('Missing param esi_include') ;
|
422 |
+
}
|
423 |
+
|
424 |
+
return false ;
|
425 |
+
}
|
426 |
+
|
427 |
+
$esiIncludes = $_REQUEST['esi_include'] ;
|
428 |
+
unset($_REQUEST['esi_include']) ;
|
429 |
+
|
430 |
+
if ( $this->_isDebug ) {
|
431 |
+
$this->_config->debugMesg('combined from ' . $refererUrl . ' includes = ' . print_r($esiIncludes, true)) ;
|
432 |
+
}
|
433 |
+
|
434 |
+
$this->_initEnv($req->getUserParams()) ;
|
435 |
+
$res = $this->_parseEsiUrlList($esiIncludes, false) ;
|
436 |
+
if ( ! $res )
|
437 |
+
return false ;
|
438 |
+
}
|
439 |
+
else {
|
440 |
+
if ( $param = $this->_parseUrlParams($origEsiUrl) ) {
|
441 |
+
if ( $esiData = $this->_parseEsiData($param) ) {
|
442 |
+
$this->_esiData[$esiData['id']] = $esiData ;
|
443 |
+
}
|
444 |
+
else {
|
445 |
+
return false ;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
else {
|
449 |
+
return false ;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
if ( isset($this->_env['fetch_all']) ) {
|
453 |
+
$this->_fetchAll() ;
|
454 |
+
}
|
455 |
+
return true ;
|
456 |
+
}
|
457 |
+
|
458 |
+
protected function _fetchAll()
|
459 |
+
{
|
460 |
+
$extra = array() ;
|
461 |
+
|
462 |
+
$session = Mage::getSingleton('core/session') ;
|
463 |
+
$is_new_user = (($session->getData('_litemage_user') == null) && Mage::registry('LITEMAGE_NEWVISITOR') && (Mage::registry('current_customer') == null)) ;
|
464 |
+
if ( $is_new_user ) {
|
465 |
+
// new, return all blocks as non-logged in user first visit
|
466 |
+
$session->setData('_litemage_user', 1) ;
|
467 |
+
if ( method_exists($session, 'getFormKey') && ! isset($this->_esiData['getFormKey']) ) {
|
468 |
+
$formkey_url = 'litemage/esi/getFormKey' ;
|
469 |
+
$this->_esiData['getFormKey'] = $this->_getFormKeyEsiData($formkey_url) ;
|
470 |
+
}
|
471 |
+
foreach ( $this->_env['esiUrls'] as $blockname => $urls ) {
|
472 |
+
foreach ( $urls as $url => $output ) {
|
473 |
+
if ( $output == self::ESIDATA_CACHE_NOTSET ) {
|
474 |
+
$this->_env['update_cache'] |= 2 ; // 2: full update, 1: update url only
|
475 |
+
if ( ! isset($this->_esiData[$url]) ) {
|
476 |
+
$extra[] = $url ;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
else {
|
480 |
+
if ( isset($this->_esiData[$url]) ) {
|
481 |
+
$this->_esiData[$url]['output'] = $output ;
|
482 |
+
}
|
483 |
+
else {
|
484 |
+
$this->_esiData[$url] = array( 'output' => $output ) ;
|
485 |
+
}
|
486 |
+
}
|
487 |
+
}
|
488 |
+
}
|
489 |
+
}
|
490 |
+
else {
|
491 |
+
// regenerate all blocks for that store
|
492 |
+
foreach ( $this->_env['esiUrls'] as $blockname => $urls ) {
|
493 |
+
foreach ( array_keys($urls) as $url ) {
|
494 |
+
if ( ! isset($this->_esiData[$url]) ) {
|
495 |
+
$extra[] = $url ;
|
496 |
+
}
|
497 |
+
}
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
if ( count($extra) ) {
|
502 |
+
$res = $this->_parseEsiUrlList($extra, true) ;
|
503 |
+
}
|
504 |
+
|
505 |
+
if ( $this->_isDebug ) {
|
506 |
+
$this->_config->debugMesg(($is_new_user ? 'New user' : 'Existing user') . ' fetch extra = ' . count($extra)) ;
|
507 |
+
|
508 |
+
//if ($this->_isDebug)
|
509 |
+
//Mage::log('extra = ' . print_r($extra, true)) ;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
protected function _parseUrlParams( $esiUrl )
|
514 |
+
{
|
515 |
+
$esiUrl = urldecode($esiUrl) ;
|
516 |
+
if ( ($pos = strpos($esiUrl, 'litemage/esi/')) !== false ) {
|
517 |
+
$buf = explode('/', substr($esiUrl, $pos + 13)) ;
|
518 |
+
$c = count($buf) ;
|
519 |
+
$param = array() ;
|
520 |
+
$param['action'] = $buf[0] ;
|
521 |
+
$param['url'] = $esiUrl ;
|
522 |
+
for ( $i = 1 ; ($i + 1) < $c ; $i+=2 ) {
|
523 |
+
$param[$buf[$i]] = $buf[$i + 1] ;
|
524 |
+
}
|
525 |
+
return $param ;
|
526 |
+
}
|
527 |
+
else
|
528 |
+
return null ;
|
529 |
+
}
|
530 |
+
|
531 |
+
protected function _parseEsiUrlList( $esiUrls, $ignoreErr = false )
|
532 |
+
{
|
533 |
+
$res = true ;
|
534 |
+
foreach ( $esiUrls as $esiUrl ) {
|
535 |
+
|
536 |
+
if ( $esiUrl == '*' ) {
|
537 |
+
$this->_env['fetch_all'] = 1 ;
|
538 |
+
continue ;
|
539 |
+
}
|
540 |
+
$param = $this->_parseUrlParams($esiUrl) ;
|
541 |
+
if ( $param == null ) {
|
542 |
+
$res = false ;
|
543 |
+
if ( $ignoreErr )
|
544 |
+
continue ;
|
545 |
+
else
|
546 |
+
break ;
|
547 |
+
}
|
548 |
+
if ( $esiData = $this->_parseEsiData($param) ) {
|
549 |
+
$this->_esiData[$esiData['id']] = $esiData ;
|
550 |
+
}
|
551 |
+
else {
|
552 |
+
$res = false ;
|
553 |
+
if ( $ignoreErr ) {
|
554 |
+
continue ;
|
555 |
+
}
|
556 |
+
else {
|
557 |
+
break ;
|
558 |
+
}
|
559 |
+
}
|
560 |
+
}
|
561 |
+
return $res ;
|
562 |
+
}
|
563 |
+
|
564 |
+
protected function _getFormKeyEsiData( $url )
|
565 |
+
{
|
566 |
+
$session = Mage::getSingleton('core/session') ;
|
567 |
+
$real_formkey = $session->getData(Litespeed_Litemage_Helper_Esi::FORMKEY_NAME) ;
|
568 |
+
if ( ! $real_formkey ) {
|
569 |
+
$real_formkey = $session->getFormKey() ;
|
570 |
+
}
|
571 |
+
|
572 |
+
$pri_ttl = isset($this->_env['pri_ttl']) ? $this->_env['pri_ttl'] : $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PRIVATETTL) ;
|
573 |
+
|
574 |
+
return array( 'action' => 'getFormKey',
|
575 |
+
'cacheIfEmpty' => false,
|
576 |
+
'url' => $url,
|
577 |
+
'ttl' => $pri_ttl,
|
578 |
+
'tag' => 'E.formkey',
|
579 |
+
'access' => 'private',
|
580 |
+
'id' => 'getFormKey',
|
581 |
+
'raw_output' => $real_formkey ) ;
|
582 |
+
}
|
583 |
+
|
584 |
+
protected function _parseEsiData( $params )
|
585 |
+
{
|
586 |
+
$action = $params['action'] ;
|
587 |
+
$url = $params['url'] ;
|
588 |
+
if ( $action == 'getFormKey' ) {
|
589 |
+
return $this->_getFormKeyEsiData($url) ;
|
590 |
+
}
|
591 |
+
|
592 |
+
$esiData = array( 'action' => $action, 'cacheIfEmpty' => false, 'url' => $url ) ;
|
593 |
+
|
594 |
+
if ( $action == 'log' ) {
|
595 |
+
if ( isset($params['product']) )
|
596 |
+
$esiData['product'] = $params['product'] ;
|
597 |
+
if ( isset($params['s']) && ! isset($this->_env['s']) )
|
598 |
+
$this->_env['s'] = $params['s'] ;
|
599 |
+
$esiData['ttl'] = 0 ; // no cache
|
600 |
+
$esiData['id'] = $action ;
|
601 |
+
}
|
602 |
+
else {
|
603 |
+
|
604 |
+
if ( ! isset($this->_env['dp']) ) {
|
605 |
+
if ( ! $params['s'] || ! $params['dp'] || ! $params['dt'] ) {
|
606 |
+
if ( $this->_isDebug ) {
|
607 |
+
$this->_config->debugMesg('Missing param s_dp_dt') ;
|
608 |
+
}
|
609 |
+
return false ;
|
610 |
+
}
|
611 |
+
|
612 |
+
$this->_initEnv($params) ;
|
613 |
+
}
|
614 |
+
|
615 |
+
$tag = $params['t'] ;
|
616 |
+
if ( $tag == null ) {
|
617 |
+
if ( $this->_isDebug ) {
|
618 |
+
$this->_config->debugMesg('Missing param t') ;
|
619 |
+
}
|
620 |
+
return false ;
|
621 |
+
}
|
622 |
+
else {
|
623 |
+
$conf = $this->_config->getEsiConf('tag', $tag) ;
|
624 |
+
if ($conf == null) {
|
625 |
+
if ( $this->_isDebug ) {
|
626 |
+
$this->_config->debugMesg('Missing config for tag '. $tag) ;
|
627 |
+
}
|
628 |
+
return false ;
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
$esiData['b'] = explode(',', $params['b']) ;
|
633 |
+
if (count($esiData['b']) == 0) {
|
634 |
+
if ( $this->_isDebug ) {
|
635 |
+
$this->_config->debugMesg('Missing param b') ;
|
636 |
+
}
|
637 |
+
return false ;
|
638 |
+
}
|
639 |
+
$blockName = $esiData['b'][0];
|
640 |
+
$esiData['n'] = $blockName ;
|
641 |
+
$esiData['h'] = isset($params['h']) ? explode(',', $params['h']) : array() ;
|
642 |
+
$esiData['access'] = $conf['access'] ;
|
643 |
+
$esiData['ttl'] = isset($conf['ttl']) ? $conf['ttl'] :
|
644 |
+
(($conf['access'] == 'private') ? $this->_env['pri_ttl'] : $this->_env['pub_ttl'] ) ;
|
645 |
+
$esiData['tag'] = $conf['cache-tag'] ;
|
646 |
+
if (isset($params['a'])) {
|
647 |
+
$esiData['alias'] = $params['a'];
|
648 |
+
}
|
649 |
+
if (isset($params['p'])) {
|
650 |
+
$esiData['type'] = str_replace('--', '/', $params['p']); // dynamic block type
|
651 |
+
if (isset($params['l']))
|
652 |
+
$esiData['template'] = str_replace('--', '/', $params['l']);
|
653 |
+
}
|
654 |
+
|
655 |
+
if ( isset($params['st']) ) {
|
656 |
+
$param1 = array( $params['st'], $params['call'] ) ; // session type and call func
|
657 |
+
$param1 = str_replace('--', '/session', $param1) ;
|
658 |
+
$param1 = str_replace('-', '/', $param1) ;
|
659 |
+
$esiData['st'] = explode(',', $param1[0]) ;
|
660 |
+
$esiData['call'] = $param1[1] ;
|
661 |
+
$esiData['cacheIfEmpty'] = true ;
|
662 |
+
}
|
663 |
+
$esiData['id'] = $url ;
|
664 |
+
if ( ($conf['access'] == 'private') && ($esiData['ttl'] > 0) ) {
|
665 |
+
if ( ! isset($this->_env['esiUrls'][$blockName]) ) {
|
666 |
+
$this->_env['esiUrls'][$blockName] = array( $url => self::ESIDATA_CACHE_NOTSET ) ;
|
667 |
+
$this->_env['update_cache'] |= 1 ; // 2: full update, 1: update url only
|
668 |
+
}
|
669 |
+
elseif ( ! isset($this->_env['esiUrls'][$blockName][$url]) ) {
|
670 |
+
$this->_env['esiUrls'][$blockName][$url] = self::ESIDATA_CACHE_NOTSET ;
|
671 |
+
$this->_env['update_cache'] |= 1 ; // 2: full update, 1: update url only
|
672 |
+
}
|
673 |
+
}
|
674 |
+
}
|
675 |
+
|
676 |
+
return $esiData ;
|
677 |
+
}
|
678 |
+
|
679 |
+
protected function _initLayout()
|
680 |
+
{
|
681 |
+
$layout = $this->getLayout() ;
|
682 |
+
$update = $layout->getUpdate() ;
|
683 |
+
|
684 |
+
$update->setStoreId($this->_env['s']) ;
|
685 |
+
// dispatch event for adding handles to layout update, this will auto add customer_logged_in or out
|
686 |
+
Mage::dispatchEvent(
|
687 |
+
'controller_action_layout_load_before', array( 'action' => $this, 'layout' => $layout )
|
688 |
+
) ;
|
689 |
+
$this->_env['defaultHandles'] = $update->getHandles() ;
|
690 |
+
if ( (($this->_env['update_cache'] & 2) == 2) && in_array('customer_logged_in', $this->_env['defaultHandles']) ) {
|
691 |
+
$this->_env['update_cache'] &= ~2 ; // 2: full update, 1: update url only
|
692 |
+
//Mage::log('customer logged in, unset update_cahce 2 to 1 = ' . $this->_env['update_cache']);
|
693 |
+
}
|
694 |
+
}
|
695 |
+
|
696 |
+
public function loadLayoutUpdates()
|
697 |
+
{
|
698 |
+
//$_profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName() . $this->_curData['n'] ;
|
699 |
+
|
700 |
+
if ( ! isset($this->_env['defaultHandles']) ) {
|
701 |
+
$this->_initLayout() ;
|
702 |
+
}
|
703 |
+
|
704 |
+
$this->_layout->resetBlocks() ;
|
705 |
+
$update = $this->_layout->getUpdate() ;
|
706 |
+
$update->setBlockNames($this->_curData['b']) ;
|
707 |
+
|
708 |
+
$update->addHandle($this->_curData['h']) ;
|
709 |
+
$update->addHandle($this->_env['defaultHandles']) ;
|
710 |
+
|
711 |
+
// load layout updates by specified handles
|
712 |
+
//Varien_Profiler::start("$_profilerKey::layout_load") ;
|
713 |
+
$update->load() ;
|
714 |
+
//Varien_Profiler::stop("$_profilerKey::layout_load") ;
|
715 |
+
|
716 |
+
return $this ;
|
717 |
+
}
|
718 |
+
|
719 |
+
protected function _initEnv( $params )
|
720 |
+
{
|
721 |
+
if (isset($this->_env['cache_id']))
|
722 |
+
return;
|
723 |
+
|
724 |
+
$this->_env['s'] = $params['s'] ;
|
725 |
+
$this->_env['dp'] = $params['dp'] ;
|
726 |
+
$this->_env['dt'] = $params['dt'] ;
|
727 |
+
|
728 |
+
$app = Mage::app() ;
|
729 |
+
$app->setCurrentStore($app->getStore($this->_env['s'])) ;
|
730 |
+
Mage::getSingleton('core/design_package')
|
731 |
+
->setPackageName($this->_env['dp'])
|
732 |
+
->setTheme($this->_env['dt']) ;
|
733 |
+
|
734 |
+
$curLocale = $app->getLocale() ;
|
735 |
+
$locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE) ;
|
736 |
+
if ( $curLocale->getLocaleCode() != $locale ) {
|
737 |
+
$curLocale->setLocale($locale) ;
|
738 |
+
$translator = $app->getTranslator() ;
|
739 |
+
$translator->setLocale($locale) ;
|
740 |
+
$translator->init('frontend') ;
|
741 |
+
}
|
742 |
+
|
743 |
+
$customer_session = Mage::getSingleton('customer/session') ;
|
744 |
+
$customer_session->setNoReferer(true);
|
745 |
+
if ( $customer_session->isLoggedIn() ) {
|
746 |
+
Mage::register('current_customer', $customer_session->getCustomer()) ;
|
747 |
+
}
|
748 |
+
|
749 |
+
$tags = $this->_helper->getEsiSharedParams();
|
750 |
+
$this->_env['cache_id'] = self::ESIDATA_CACHE_ID . '_' . md5(join('__', $tags)) ;
|
751 |
+
|
752 |
+
$this->_env['esiUrls'] = array() ;
|
753 |
+
if (Mage::app()->useCache('layout')) {
|
754 |
+
if ( $data = Mage::app()->loadCache($this->_env['cache_id']) ) {
|
755 |
+
$this->_env['esiUrls'] = unserialize($data) ;
|
756 |
+
}
|
757 |
+
}
|
758 |
+
|
759 |
+
$this->_env['pri_ttl'] = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PRIVATETTL) ;
|
760 |
+
$this->_env['pub_ttl'] = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_PUBLICTTL) ;
|
761 |
+
}
|
762 |
+
|
763 |
+
}
|
app/code/community/Litespeed/Litemage/etc/config.xml
CHANGED
@@ -1,8 +1,32 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Litespeed_Litemage>
|
5 |
-
<version>1.0.
|
6 |
</Litespeed_Litemage>
|
7 |
</modules>
|
8 |
<global>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
-->
|
26 |
<config>
|
27 |
<modules>
|
28 |
<Litespeed_Litemage>
|
29 |
+
<version>1.0.18</version>
|
30 |
</Litespeed_Litemage>
|
31 |
</modules>
|
32 |
<global>
|
app/code/community/Litespeed/Litemage/etc/config.xml.dev
ADDED
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
-->
|
26 |
+
<config>
|
27 |
+
<modules>
|
28 |
+
<Litespeed_Litemage>
|
29 |
+
<version>1.0.17</version>
|
30 |
+
</Litespeed_Litemage>
|
31 |
+
</modules>
|
32 |
+
<global>
|
33 |
+
<blocks>
|
34 |
+
<litemage>
|
35 |
+
<class>Litespeed_Litemage_Block</class>
|
36 |
+
</litemage>
|
37 |
+
</blocks>
|
38 |
+
<helpers>
|
39 |
+
<litemage>
|
40 |
+
<class>Litespeed_Litemage_Helper</class>
|
41 |
+
</litemage>
|
42 |
+
</helpers>
|
43 |
+
<models>
|
44 |
+
<litemage>
|
45 |
+
<class>Litespeed_Litemage_Model</class>
|
46 |
+
</litemage>
|
47 |
+
<core>
|
48 |
+
<rewrite>
|
49 |
+
<translate>Litespeed_Litemage_Model_Translate</translate>
|
50 |
+
</rewrite>
|
51 |
+
</core>
|
52 |
+
</models>
|
53 |
+
<events>
|
54 |
+
<!-- purge product cache after stock update -->
|
55 |
+
<cataloginventory_stock_item_save_after>
|
56 |
+
<observers>
|
57 |
+
<litemage_purge>
|
58 |
+
<class>litemage/observer_purge</class>
|
59 |
+
<method>purgeCatalogProductByStock</method>
|
60 |
+
</litemage_purge>
|
61 |
+
</observers>
|
62 |
+
</cataloginventory_stock_item_save_after>
|
63 |
+
</events>
|
64 |
+
</global>
|
65 |
+
<admin>
|
66 |
+
<routers>
|
67 |
+
<adminhtml>
|
68 |
+
<args>
|
69 |
+
<modules>
|
70 |
+
<litemage after="Mage_Adminhtml">Litespeed_Litemage_Adminhtml</litemage>
|
71 |
+
</modules>
|
72 |
+
</args>
|
73 |
+
</adminhtml>
|
74 |
+
</routers>
|
75 |
+
</admin>
|
76 |
+
<adminhtml>
|
77 |
+
<layout>
|
78 |
+
<updates>
|
79 |
+
<litemage>
|
80 |
+
<file>litemage.xml</file>
|
81 |
+
</litemage>
|
82 |
+
</updates>
|
83 |
+
</layout>
|
84 |
+
<acl>
|
85 |
+
<resources>
|
86 |
+
<admin>
|
87 |
+
<children>
|
88 |
+
<system>
|
89 |
+
<children>
|
90 |
+
<cache>
|
91 |
+
<children>
|
92 |
+
<litemage>
|
93 |
+
<title>LiteMage Cache Management</title>
|
94 |
+
</litemage>
|
95 |
+
</children>
|
96 |
+
</cache>
|
97 |
+
<config>
|
98 |
+
<children>
|
99 |
+
<litemage>
|
100 |
+
<title>LiteMage Cache Configuration</title>
|
101 |
+
</litemage>
|
102 |
+
</children>
|
103 |
+
</config>
|
104 |
+
</children>
|
105 |
+
</system>
|
106 |
+
</children>
|
107 |
+
</admin>
|
108 |
+
</resources>
|
109 |
+
</acl>
|
110 |
+
<events>
|
111 |
+
<controller_action_postdispatch_adminhtml_cache_flushAll>
|
112 |
+
<observers>
|
113 |
+
<litemage_purge>
|
114 |
+
<type>singleton</type>
|
115 |
+
<class>litemage/observer_purge</class>
|
116 |
+
<method>adminPurgeCache</method>
|
117 |
+
</litemage_purge>
|
118 |
+
</observers>
|
119 |
+
</controller_action_postdispatch_adminhtml_cache_flushAll>
|
120 |
+
<controller_action_postdispatch_adminhtml_cache_flushSystem>
|
121 |
+
<observers>
|
122 |
+
<litemage_purge>
|
123 |
+
<type>singleton</type>
|
124 |
+
<class>litemage/observer_purge</class>
|
125 |
+
<method>adminPurgeCache</method>
|
126 |
+
</litemage_purge>
|
127 |
+
</observers>
|
128 |
+
</controller_action_postdispatch_adminhtml_cache_flushSystem>
|
129 |
+
<controller_action_postdispatch_adminhtml_system_currency_saveRates>
|
130 |
+
<observers>
|
131 |
+
<litemage_purge>
|
132 |
+
<type>singleton</type>
|
133 |
+
<class>litemage/observer_purge</class>
|
134 |
+
<method>adminPurgeCurrency</method>
|
135 |
+
</litemage_purge>
|
136 |
+
</observers>
|
137 |
+
</controller_action_postdispatch_adminhtml_system_currency_saveRates>
|
138 |
+
<!-- purge category cache after save -->
|
139 |
+
<catalog_category_save_commit_after>
|
140 |
+
<observers>
|
141 |
+
<litemage_purge>
|
142 |
+
<class>litemage/observer_purge</class>
|
143 |
+
<method>adminPurgeCatalogCategory</method>
|
144 |
+
</litemage_purge>
|
145 |
+
</observers>
|
146 |
+
</catalog_category_save_commit_after>
|
147 |
+
<!-- purge product cache after save -->
|
148 |
+
<catalog_product_save_commit_after>
|
149 |
+
<observers>
|
150 |
+
<litemage_purge>
|
151 |
+
<class>litemage/observer_purge</class>
|
152 |
+
<method>adminPurgeCatalogProduct</method>
|
153 |
+
</litemage_purge>
|
154 |
+
</observers>
|
155 |
+
</catalog_product_save_commit_after>
|
156 |
+
<!-- purge cms page cache after save -->
|
157 |
+
<cms_page_save_commit_after>
|
158 |
+
<observers>
|
159 |
+
<litemage_purge>
|
160 |
+
<class>litemage/observer_purge</class>
|
161 |
+
<method>adminPurgeCmsPage</method>
|
162 |
+
</litemage_purge>
|
163 |
+
</observers>
|
164 |
+
</cms_page_save_commit_after>
|
165 |
+
<!-- purge all caches when module disabled -->
|
166 |
+
<admin_system_config_changed_section_litemage>
|
167 |
+
<observers>
|
168 |
+
<litemage_purge>
|
169 |
+
<class>litemage/observer_purge</class>
|
170 |
+
<method>adminConfigChangedSection</method>
|
171 |
+
</litemage_purge>
|
172 |
+
</observers>
|
173 |
+
</admin_system_config_changed_section_litemage>
|
174 |
+
<!-- displays warning if license not enabled -->
|
175 |
+
<controller_action_predispatch_adminhtml_system_config_edit>
|
176 |
+
<observers>
|
177 |
+
<litemage_purge>
|
178 |
+
<class>litemage/observer_purge</class>
|
179 |
+
<method>adminConfigEditSection</method>
|
180 |
+
</litemage_purge>
|
181 |
+
</observers>
|
182 |
+
</controller_action_predispatch_adminhtml_system_config_edit>
|
183 |
+
</events>
|
184 |
+
</adminhtml>
|
185 |
+
<frontend>
|
186 |
+
<routers>
|
187 |
+
<litemage>
|
188 |
+
<use>standard</use>
|
189 |
+
<args>
|
190 |
+
<module>Litespeed_Litemage</module>
|
191 |
+
<frontName>litemage</frontName>
|
192 |
+
</args>
|
193 |
+
</litemage>
|
194 |
+
</routers>
|
195 |
+
<layout>
|
196 |
+
<updates>
|
197 |
+
<litemage>
|
198 |
+
<file>litemage.xml</file>
|
199 |
+
</litemage>
|
200 |
+
</updates>
|
201 |
+
</layout>
|
202 |
+
<events>
|
203 |
+
<controller_action_predispatch>
|
204 |
+
<observers>
|
205 |
+
<litemage_esi>
|
206 |
+
<class>litemage/observer_esi</class>
|
207 |
+
<method>checkControllerNoCache</method>
|
208 |
+
</litemage_esi>
|
209 |
+
</observers>
|
210 |
+
</controller_action_predispatch>
|
211 |
+
<visitor_init>
|
212 |
+
<observers>
|
213 |
+
<litemage_esi>
|
214 |
+
<class>litemage/observer_esi</class>
|
215 |
+
<method>initNewVisitor</method>
|
216 |
+
</litemage_esi>
|
217 |
+
</observers>
|
218 |
+
</visitor_init>
|
219 |
+
<core_layout_block_create_after>
|
220 |
+
<observers>
|
221 |
+
<litemage_esi>
|
222 |
+
<class>litemage/observer_esi</class>
|
223 |
+
<method>checkEsiBlock</method>
|
224 |
+
</litemage_esi>
|
225 |
+
</observers>
|
226 |
+
</core_layout_block_create_after>
|
227 |
+
<controller_action_layout_generate_blocks_after>
|
228 |
+
<observers>
|
229 |
+
<litemage_esi>
|
230 |
+
<class>litemage/observer_esi</class>
|
231 |
+
<method>prepareInjection</method>
|
232 |
+
</litemage_esi>
|
233 |
+
</observers>
|
234 |
+
</controller_action_layout_generate_blocks_after>
|
235 |
+
<http_response_send_before>
|
236 |
+
<observers>
|
237 |
+
<litemage_esi>
|
238 |
+
<class>litemage/observer_esi</class>
|
239 |
+
<method>beforeResponseSend</method>
|
240 |
+
</litemage_esi>
|
241 |
+
</observers>
|
242 |
+
</http_response_send_before>
|
243 |
+
<customer_login>
|
244 |
+
<observers>
|
245 |
+
<litemage_esi>
|
246 |
+
<class>litemage/observer_esi</class>
|
247 |
+
<method>purgePrivateCache</method>
|
248 |
+
</litemage_esi>
|
249 |
+
</observers>
|
250 |
+
</customer_login>
|
251 |
+
<customer_logout>
|
252 |
+
<observers>
|
253 |
+
<litemage_esi>
|
254 |
+
<class>litemage/observer_esi</class>
|
255 |
+
<method>purgePrivateCache</method>
|
256 |
+
</litemage_esi>
|
257 |
+
</observers>
|
258 |
+
</customer_logout>
|
259 |
+
<sales_quote_save_after>
|
260 |
+
<observers>
|
261 |
+
<litemage_esi>
|
262 |
+
<class>litemage/observer_esi</class>
|
263 |
+
<method>purgeEsiCache</method>
|
264 |
+
</litemage_esi>
|
265 |
+
</observers>
|
266 |
+
</sales_quote_save_after>
|
267 |
+
<wishlist_item_save_after>
|
268 |
+
<observers>
|
269 |
+
<litemage_esi>
|
270 |
+
<class>litemage/observer_esi</class>
|
271 |
+
<method>purgeEsiCache</method>
|
272 |
+
</litemage_esi>
|
273 |
+
</observers>
|
274 |
+
</wishlist_item_save_after>
|
275 |
+
<wishlist_item_delete_after>
|
276 |
+
<observers>
|
277 |
+
<litemage_esi>
|
278 |
+
<class>litemage/observer_esi</class>
|
279 |
+
<method>purgeEsiCache</method>
|
280 |
+
</litemage_esi>
|
281 |
+
</observers>
|
282 |
+
</wishlist_item_delete_after>
|
283 |
+
<catalog_product_compare_add_product>
|
284 |
+
<observers>
|
285 |
+
<litemage_esi>
|
286 |
+
<class>litemage/observer_esi</class>
|
287 |
+
<method>purgeEsiCache</method>
|
288 |
+
</litemage_esi>
|
289 |
+
</observers>
|
290 |
+
</catalog_product_compare_add_product>
|
291 |
+
<catalog_product_compare_remove_product>
|
292 |
+
<observers>
|
293 |
+
<litemage_esi>
|
294 |
+
<class>litemage/observer_esi</class>
|
295 |
+
<method>purgeEsiCache</method>
|
296 |
+
</litemage_esi>
|
297 |
+
</observers>
|
298 |
+
</catalog_product_compare_remove_product>
|
299 |
+
<catalog_product_compare_item_collection_clear>
|
300 |
+
<observers>
|
301 |
+
<litemage_esi>
|
302 |
+
<class>litemage/observer_esi</class>
|
303 |
+
<method>purgeEsiCache</method>
|
304 |
+
</litemage_esi>
|
305 |
+
</observers>
|
306 |
+
</catalog_product_compare_item_collection_clear>
|
307 |
+
<catalog_controller_product_view>
|
308 |
+
<observers>
|
309 |
+
<litemage_esi>
|
310 |
+
<class>litemage/observer_esi</class>
|
311 |
+
<method>onCatalogProductView</method>
|
312 |
+
</litemage_esi>
|
313 |
+
</observers>
|
314 |
+
</catalog_controller_product_view>
|
315 |
+
<cms_page_render>
|
316 |
+
<observers>
|
317 |
+
<litemage_esi>
|
318 |
+
<class>litemage/observer_esi</class>
|
319 |
+
<method>onCmsPageRender</method>
|
320 |
+
</litemage_esi>
|
321 |
+
</observers>
|
322 |
+
</cms_page_render>
|
323 |
+
<poll_vote_add>
|
324 |
+
<observers>
|
325 |
+
<litemage_esi>
|
326 |
+
<class>litemage/observer_esi</class>
|
327 |
+
<method>purgeEsiCache</method>
|
328 |
+
</litemage_esi>
|
329 |
+
</observers>
|
330 |
+
</poll_vote_add>
|
331 |
+
<core_session_abstract_add_message>
|
332 |
+
<observers>
|
333 |
+
<litemage_esi>
|
334 |
+
<class>litemage/observer_esi</class>
|
335 |
+
<method>purgeEsiCache</method>
|
336 |
+
</litemage_esi>
|
337 |
+
</observers>
|
338 |
+
</core_session_abstract_add_message>
|
339 |
+
<checkout_onepage_controller_success_action>
|
340 |
+
<observers>
|
341 |
+
<litemage_esi>
|
342 |
+
<class>litemage/observer_esi</class>
|
343 |
+
<method>purgeEsiCache</method>
|
344 |
+
</litemage_esi>
|
345 |
+
</observers>
|
346 |
+
</checkout_onepage_controller_success_action>
|
347 |
+
</events>
|
348 |
+
<litemage>
|
349 |
+
<esiblock>
|
350 |
+
<!-- If you need to inject any other privately cached custom block groupings,
|
351 |
+
you can add them here. <blocks> contains the block names defined in your
|
352 |
+
layout files. All blocks that share the same purge events can be listed
|
353 |
+
together in a single grouping. If their purge events are not being watched
|
354 |
+
in the previous events section, you will also need to add a litemage esi
|
355 |
+
observer for those events.
|
356 |
+
|
357 |
+
This config file will be overwritten with upgrades to the LiteMage module.
|
358 |
+
If you have made any modifications, please make sure to keep a copy -->
|
359 |
+
<welcome>
|
360 |
+
<!-- blocks only purged by login/logout events, no purge_events configuration is required as login/logout will auto purge all private blocks -->
|
361 |
+
<access>private</access>
|
362 |
+
<blocks>T:Mage_Page_Block_Html_Welcome,welcome,litemage.jsvar,nickname$v</blocks>
|
363 |
+
<!-- Marking a block as valueonly, denoted by the suffix “$v”, will only output
|
364 |
+
the blocks html value without the added html tags and comments when in debug mode.
|
365 |
+
The block will also not be highlighted when using the LITEMAGE_DEBUG=SHOWHOLES parameter -->
|
366 |
+
</welcome>
|
367 |
+
<cart>
|
368 |
+
<access>private</access>
|
369 |
+
<!-- Blocks can be set using class type, denoted by the prefix "T:". This will include all blocks that inherit this type in the grouping -->
|
370 |
+
<blocks>T:Mage_Checkout_Block_Cart_Abstract</blocks>
|
371 |
+
<purge_events>
|
372 |
+
<sales_quote_save_after/>
|
373 |
+
</purge_events>
|
374 |
+
</cart>
|
375 |
+
<toplinks>
|
376 |
+
<access>private</access>
|
377 |
+
<blocks>top.links</blocks>
|
378 |
+
<purge_tags>cart, wishlist</purge_tags>
|
379 |
+
<!-- This is a composite grouping. The purge events for the blocks in this grouping are
|
380 |
+
a combination of existing purge event sets from other groupings. By using purge_tags
|
381 |
+
to reference these other groupings, you do not need to redefine these purge events. -->
|
382 |
+
</toplinks>
|
383 |
+
<compare>
|
384 |
+
<access>private</access>
|
385 |
+
<blocks>T:Mage_Catalog_Block_Product_Compare_Sidebar, T:Mage_Reports_Block_Product_Compared</blocks>
|
386 |
+
<purge_events>
|
387 |
+
<catalog_product_compare_add_product/>
|
388 |
+
<catalog_product_compare_remove_product/>
|
389 |
+
<catalog_product_compare_item_collection_clear/>
|
390 |
+
</purge_events>
|
391 |
+
</compare>
|
392 |
+
<viewed>
|
393 |
+
<access>private</access>
|
394 |
+
<blocks>T:Mage_Reports_Block_Product_Viewed</blocks>
|
395 |
+
<purge_events>
|
396 |
+
<catalog_controller_product_view/>
|
397 |
+
</purge_events>
|
398 |
+
</viewed>
|
399 |
+
<poll>
|
400 |
+
<access>private</access>
|
401 |
+
<blocks>T:Mage_Poll_Block_ActivePoll</blocks>
|
402 |
+
<purge_events>
|
403 |
+
<poll_vote_add/>
|
404 |
+
</purge_events>
|
405 |
+
</poll>
|
406 |
+
<!-- messages is specially handled, cannot change the tag name here, has to be "messages" -->
|
407 |
+
<messages>
|
408 |
+
<access>private</access>
|
409 |
+
<blocks>T:Mage_Core_Block_Messages</blocks>
|
410 |
+
<purge_events>
|
411 |
+
<core_session_abstract_add_message/>
|
412 |
+
</purge_events>
|
413 |
+
</messages>
|
414 |
+
<!-- Blocks only visible when logged in -->
|
415 |
+
<reorder>
|
416 |
+
<access>private</access>
|
417 |
+
<blocks>T:Mage_Sales_Block_Reorder_Sidebar</blocks>
|
418 |
+
<purge_events>
|
419 |
+
<sales_quote_save_after/>
|
420 |
+
<checkout_onepage_controller_success_action/>
|
421 |
+
</purge_events>
|
422 |
+
</reorder>
|
423 |
+
<wishlist>
|
424 |
+
<access>private</access>
|
425 |
+
<blocks>T:Mage_Wishlist_Block_Customer_Sidebar</blocks>
|
426 |
+
<purge_events>
|
427 |
+
<wishlist_item_save_after/>
|
428 |
+
<wishlist_item_delete_after/>
|
429 |
+
</purge_events>
|
430 |
+
</wishlist>
|
431 |
+
<!-- public blocks -->
|
432 |
+
<!-- Some themes will use a variable in footer that is declared in the header,
|
433 |
+
this causes the footer block to fail to generate. You can modify the
|
434 |
+
template to generate the missing variable or simply choose to not punch
|
435 |
+
a hole in footer (comment out the footer block).
|
436 |
+
|
437 |
+
Making the footer a public block will speed up page generation and save some disk space -->
|
438 |
+
<footer>
|
439 |
+
<access>public</access>
|
440 |
+
<blocks>footer</blocks>
|
441 |
+
</footer>
|
442 |
+
</esiblock>
|
443 |
+
</litemage>
|
444 |
+
</frontend>
|
445 |
+
<default>
|
446 |
+
<litemage>
|
447 |
+
<general>
|
448 |
+
<enabled>1</enabled>
|
449 |
+
<admin_ips>127.0.0.1</admin_ips>
|
450 |
+
<public_ttl>28800</public_ttl>
|
451 |
+
<private_ttl>3600</private_ttl>
|
452 |
+
<track_viewed>1</track_viewed>
|
453 |
+
<diff_customergroup>0</diff_customergroup>
|
454 |
+
<diff_cookie/>
|
455 |
+
<alt_esi_syntax>0</alt_esi_syntax>
|
456 |
+
</general>
|
457 |
+
<warmup>
|
458 |
+
<enable_warmup>1</enable_warmup>
|
459 |
+
<load_limit>5</load_limit>
|
460 |
+
<thread_limit>6</thread_limit>
|
461 |
+
<max_time>360</max_time>
|
462 |
+
<interval>21600</interval>
|
463 |
+
<priority>100</priority>
|
464 |
+
<multi_currency/>
|
465 |
+
<custlist/>
|
466 |
+
<custlist_priority>50</custlist_priority>
|
467 |
+
<custlist_interval>7200</custlist_interval>
|
468 |
+
</warmup>
|
469 |
+
<default>
|
470 |
+
<!-- Full or partial match on controller full action name for cacheable routes. Space, return, and comma separated -->
|
471 |
+
<cache_routes><![CDATA[catalog cms contacts_index_index]]></cache_routes>
|
472 |
+
<!-- Full or partial match on controller full action name for non-cacheable routes within cacheable routes. Space, return, and comma separated -->
|
473 |
+
<nocache_subroutes><![CDATA[catalog_product_compare catalogsearch]]></nocache_subroutes>
|
474 |
+
<!-- Entire response cached based on routes, same content for all urls, such as "cms_index_noRoute" for 404 pages. Space, return, and comma separated. -->
|
475 |
+
<fullcache_routes><![CDATA[cms_index_noRoute]]></fullcache_routes>
|
476 |
+
</default>
|
477 |
+
<donotcache>
|
478 |
+
<!-- configured through Admin Panel, do not update here. Customized settings will be picked up from database -->
|
479 |
+
<cache_routes/>
|
480 |
+
<nocache_subroutes/>
|
481 |
+
<vars>no_cache</vars>
|
482 |
+
<urls/>
|
483 |
+
<welcome/>
|
484 |
+
<toplinks/>
|
485 |
+
<messages/>
|
486 |
+
</donotcache>
|
487 |
+
<test>
|
488 |
+
<debug>0</debug>
|
489 |
+
<allow_ips/>
|
490 |
+
</test>
|
491 |
+
</litemage>
|
492 |
+
</default>
|
493 |
+
<crontab>
|
494 |
+
<jobs>
|
495 |
+
<litemage_warmup_cache>
|
496 |
+
<schedule>
|
497 |
+
<!--cron_expr>0,10,20,30,40,50 * * * *</cron_expr-->
|
498 |
+
<cron_expr>0,5,10,15,20,25,30,35,40,45,50,55 * * * *</cron_expr>
|
499 |
+
</schedule>
|
500 |
+
<run>
|
501 |
+
<model>litemage/observer_cron::warmCache</model>
|
502 |
+
</run>
|
503 |
+
</litemage_warmup_cache>
|
504 |
+
</jobs>
|
505 |
+
</crontab>
|
506 |
+
</config>
|
app/code/community/Litespeed/Litemage/etc/config.xml.package
ADDED
@@ -0,0 +1,505 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
-->
|
26 |
+
<config>
|
27 |
+
<modules>
|
28 |
+
<Litespeed_Litemage>
|
29 |
+
<version>1.0.17</version>
|
30 |
+
</Litespeed_Litemage>
|
31 |
+
</modules>
|
32 |
+
<global>
|
33 |
+
<blocks>
|
34 |
+
<litemage>
|
35 |
+
<class>Litespeed_Litemage_Block</class>
|
36 |
+
</litemage>
|
37 |
+
</blocks>
|
38 |
+
<helpers>
|
39 |
+
<litemage>
|
40 |
+
<class>Litespeed_Litemage_Helper</class>
|
41 |
+
</litemage>
|
42 |
+
</helpers>
|
43 |
+
<models>
|
44 |
+
<litemage>
|
45 |
+
<class>Litespeed_Litemage_Model</class>
|
46 |
+
</litemage>
|
47 |
+
<core>
|
48 |
+
<rewrite>
|
49 |
+
<translate>Litespeed_Litemage_Model_Translate</translate>
|
50 |
+
</rewrite>
|
51 |
+
</core>
|
52 |
+
</models>
|
53 |
+
<events>
|
54 |
+
<!-- purge product cache after stock update -->
|
55 |
+
<cataloginventory_stock_item_save_after>
|
56 |
+
<observers>
|
57 |
+
<litemage_purge>
|
58 |
+
<class>litemage/observer_purge</class>
|
59 |
+
<method>purgeCatalogProductByStock</method>
|
60 |
+
</litemage_purge>
|
61 |
+
</observers>
|
62 |
+
</cataloginventory_stock_item_save_after>
|
63 |
+
</events>
|
64 |
+
</global>
|
65 |
+
<admin>
|
66 |
+
<routers>
|
67 |
+
<adminhtml>
|
68 |
+
<args>
|
69 |
+
<modules>
|
70 |
+
<litemage after="Mage_Adminhtml">Litespeed_Litemage_Adminhtml</litemage>
|
71 |
+
</modules>
|
72 |
+
</args>
|
73 |
+
</adminhtml>
|
74 |
+
</routers>
|
75 |
+
</admin>
|
76 |
+
<adminhtml>
|
77 |
+
<layout>
|
78 |
+
<updates>
|
79 |
+
<litemage>
|
80 |
+
<file>litemage.xml</file>
|
81 |
+
</litemage>
|
82 |
+
</updates>
|
83 |
+
</layout>
|
84 |
+
<acl>
|
85 |
+
<resources>
|
86 |
+
<admin>
|
87 |
+
<children>
|
88 |
+
<system>
|
89 |
+
<children>
|
90 |
+
<cache>
|
91 |
+
<children>
|
92 |
+
<litemage>
|
93 |
+
<title>LiteMage Cache Management</title>
|
94 |
+
</litemage>
|
95 |
+
</children>
|
96 |
+
</cache>
|
97 |
+
<config>
|
98 |
+
<children>
|
99 |
+
<litemage>
|
100 |
+
<title>LiteMage Cache Configuration</title>
|
101 |
+
</litemage>
|
102 |
+
</children>
|
103 |
+
</config>
|
104 |
+
</children>
|
105 |
+
</system>
|
106 |
+
</children>
|
107 |
+
</admin>
|
108 |
+
</resources>
|
109 |
+
</acl>
|
110 |
+
<events>
|
111 |
+
<controller_action_postdispatch_adminhtml_cache_flushAll>
|
112 |
+
<observers>
|
113 |
+
<litemage_purge>
|
114 |
+
<type>singleton</type>
|
115 |
+
<class>litemage/observer_purge</class>
|
116 |
+
<method>adminPurgeCache</method>
|
117 |
+
</litemage_purge>
|
118 |
+
</observers>
|
119 |
+
</controller_action_postdispatch_adminhtml_cache_flushAll>
|
120 |
+
<controller_action_postdispatch_adminhtml_cache_flushSystem>
|
121 |
+
<observers>
|
122 |
+
<litemage_purge>
|
123 |
+
<type>singleton</type>
|
124 |
+
<class>litemage/observer_purge</class>
|
125 |
+
<method>adminPurgeCache</method>
|
126 |
+
</litemage_purge>
|
127 |
+
</observers>
|
128 |
+
</controller_action_postdispatch_adminhtml_cache_flushSystem>
|
129 |
+
<controller_action_postdispatch_adminhtml_system_currency_saveRates>
|
130 |
+
<observers>
|
131 |
+
<litemage_purge>
|
132 |
+
<type>singleton</type>
|
133 |
+
<class>litemage/observer_purge</class>
|
134 |
+
<method>adminPurgeCurrency</method>
|
135 |
+
</litemage_purge>
|
136 |
+
</observers>
|
137 |
+
</controller_action_postdispatch_adminhtml_system_currency_saveRates>
|
138 |
+
<!-- purge category cache after save -->
|
139 |
+
<catalog_category_save_commit_after>
|
140 |
+
<observers>
|
141 |
+
<litemage_purge>
|
142 |
+
<class>litemage/observer_purge</class>
|
143 |
+
<method>adminPurgeCatalogCategory</method>
|
144 |
+
</litemage_purge>
|
145 |
+
</observers>
|
146 |
+
</catalog_category_save_commit_after>
|
147 |
+
<!-- purge product cache after save -->
|
148 |
+
<catalog_product_save_commit_after>
|
149 |
+
<observers>
|
150 |
+
<litemage_purge>
|
151 |
+
<class>litemage/observer_purge</class>
|
152 |
+
<method>adminPurgeCatalogProduct</method>
|
153 |
+
</litemage_purge>
|
154 |
+
</observers>
|
155 |
+
</catalog_product_save_commit_after>
|
156 |
+
<!-- purge cms page cache after save -->
|
157 |
+
<cms_page_save_commit_after>
|
158 |
+
<observers>
|
159 |
+
<litemage_purge>
|
160 |
+
<class>litemage/observer_purge</class>
|
161 |
+
<method>adminPurgeCmsPage</method>
|
162 |
+
</litemage_purge>
|
163 |
+
</observers>
|
164 |
+
</cms_page_save_commit_after>
|
165 |
+
<!-- purge all caches when module disabled -->
|
166 |
+
<admin_system_config_changed_section_litemage>
|
167 |
+
<observers>
|
168 |
+
<litemage_purge>
|
169 |
+
<class>litemage/observer_purge</class>
|
170 |
+
<method>adminConfigChangedSection</method>
|
171 |
+
</litemage_purge>
|
172 |
+
</observers>
|
173 |
+
</admin_system_config_changed_section_litemage>
|
174 |
+
<!-- displays warning if license not enabled -->
|
175 |
+
<controller_action_predispatch_adminhtml_system_config_edit>
|
176 |
+
<observers>
|
177 |
+
<litemage_purge>
|
178 |
+
<class>litemage/observer_purge</class>
|
179 |
+
<method>adminConfigEditSection</method>
|
180 |
+
</litemage_purge>
|
181 |
+
</observers>
|
182 |
+
</controller_action_predispatch_adminhtml_system_config_edit>
|
183 |
+
</events>
|
184 |
+
</adminhtml>
|
185 |
+
<frontend>
|
186 |
+
<routers>
|
187 |
+
<litemage>
|
188 |
+
<use>standard</use>
|
189 |
+
<args>
|
190 |
+
<module>Litespeed_Litemage</module>
|
191 |
+
<frontName>litemage</frontName>
|
192 |
+
</args>
|
193 |
+
</litemage>
|
194 |
+
</routers>
|
195 |
+
<layout>
|
196 |
+
<updates>
|
197 |
+
<litemage>
|
198 |
+
<file>litemage.xml</file>
|
199 |
+
</litemage>
|
200 |
+
</updates>
|
201 |
+
</layout>
|
202 |
+
<events>
|
203 |
+
<controller_action_predispatch>
|
204 |
+
<observers>
|
205 |
+
<litemage_esi>
|
206 |
+
<class>litemage/observer_esi</class>
|
207 |
+
<method>checkControllerNoCache</method>
|
208 |
+
</litemage_esi>
|
209 |
+
</observers>
|
210 |
+
</controller_action_predispatch>
|
211 |
+
<visitor_init>
|
212 |
+
<observers>
|
213 |
+
<litemage_esi>
|
214 |
+
<class>litemage/observer_esi</class>
|
215 |
+
<method>initNewVisitor</method>
|
216 |
+
</litemage_esi>
|
217 |
+
</observers>
|
218 |
+
</visitor_init>
|
219 |
+
<core_layout_block_create_after>
|
220 |
+
<observers>
|
221 |
+
<litemage_esi>
|
222 |
+
<class>litemage/observer_esi</class>
|
223 |
+
<method>checkEsiBlock</method>
|
224 |
+
</litemage_esi>
|
225 |
+
</observers>
|
226 |
+
</core_layout_block_create_after>
|
227 |
+
<controller_action_layout_generate_blocks_after>
|
228 |
+
<observers>
|
229 |
+
<litemage_esi>
|
230 |
+
<class>litemage/observer_esi</class>
|
231 |
+
<method>prepareInjection</method>
|
232 |
+
</litemage_esi>
|
233 |
+
</observers>
|
234 |
+
</controller_action_layout_generate_blocks_after>
|
235 |
+
<http_response_send_before>
|
236 |
+
<observers>
|
237 |
+
<litemage_esi>
|
238 |
+
<class>litemage/observer_esi</class>
|
239 |
+
<method>beforeResponseSend</method>
|
240 |
+
</litemage_esi>
|
241 |
+
</observers>
|
242 |
+
</http_response_send_before>
|
243 |
+
<customer_login>
|
244 |
+
<observers>
|
245 |
+
<litemage_esi>
|
246 |
+
<class>litemage/observer_esi</class>
|
247 |
+
<method>purgePrivateCache</method>
|
248 |
+
</litemage_esi>
|
249 |
+
</observers>
|
250 |
+
</customer_login>
|
251 |
+
<customer_logout>
|
252 |
+
<observers>
|
253 |
+
<litemage_esi>
|
254 |
+
<class>litemage/observer_esi</class>
|
255 |
+
<method>purgePrivateCache</method>
|
256 |
+
</litemage_esi>
|
257 |
+
</observers>
|
258 |
+
</customer_logout>
|
259 |
+
<sales_quote_save_after>
|
260 |
+
<observers>
|
261 |
+
<litemage_esi>
|
262 |
+
<class>litemage/observer_esi</class>
|
263 |
+
<method>purgeEsiCache</method>
|
264 |
+
</litemage_esi>
|
265 |
+
</observers>
|
266 |
+
</sales_quote_save_after>
|
267 |
+
<wishlist_item_save_after>
|
268 |
+
<observers>
|
269 |
+
<litemage_esi>
|
270 |
+
<class>litemage/observer_esi</class>
|
271 |
+
<method>purgeEsiCache</method>
|
272 |
+
</litemage_esi>
|
273 |
+
</observers>
|
274 |
+
</wishlist_item_save_after>
|
275 |
+
<wishlist_item_delete_after>
|
276 |
+
<observers>
|
277 |
+
<litemage_esi>
|
278 |
+
<class>litemage/observer_esi</class>
|
279 |
+
<method>purgeEsiCache</method>
|
280 |
+
</litemage_esi>
|
281 |
+
</observers>
|
282 |
+
</wishlist_item_delete_after>
|
283 |
+
<catalog_product_compare_add_product>
|
284 |
+
<observers>
|
285 |
+
<litemage_esi>
|
286 |
+
<class>litemage/observer_esi</class>
|
287 |
+
<method>purgeEsiCache</method>
|
288 |
+
</litemage_esi>
|
289 |
+
</observers>
|
290 |
+
</catalog_product_compare_add_product>
|
291 |
+
<catalog_product_compare_remove_product>
|
292 |
+
<observers>
|
293 |
+
<litemage_esi>
|
294 |
+
<class>litemage/observer_esi</class>
|
295 |
+
<method>purgeEsiCache</method>
|
296 |
+
</litemage_esi>
|
297 |
+
</observers>
|
298 |
+
</catalog_product_compare_remove_product>
|
299 |
+
<catalog_product_compare_item_collection_clear>
|
300 |
+
<observers>
|
301 |
+
<litemage_esi>
|
302 |
+
<class>litemage/observer_esi</class>
|
303 |
+
<method>purgeEsiCache</method>
|
304 |
+
</litemage_esi>
|
305 |
+
</observers>
|
306 |
+
</catalog_product_compare_item_collection_clear>
|
307 |
+
<catalog_controller_product_view>
|
308 |
+
<observers>
|
309 |
+
<litemage_esi>
|
310 |
+
<class>litemage/observer_esi</class>
|
311 |
+
<method>onCatalogProductView</method>
|
312 |
+
</litemage_esi>
|
313 |
+
</observers>
|
314 |
+
</catalog_controller_product_view>
|
315 |
+
<cms_page_render>
|
316 |
+
<observers>
|
317 |
+
<litemage_esi>
|
318 |
+
<class>litemage/observer_esi</class>
|
319 |
+
<method>onCmsPageRender</method>
|
320 |
+
</litemage_esi>
|
321 |
+
</observers>
|
322 |
+
</cms_page_render>
|
323 |
+
<poll_vote_add>
|
324 |
+
<observers>
|
325 |
+
<litemage_esi>
|
326 |
+
<class>litemage/observer_esi</class>
|
327 |
+
<method>purgeEsiCache</method>
|
328 |
+
</litemage_esi>
|
329 |
+
</observers>
|
330 |
+
</poll_vote_add>
|
331 |
+
<core_session_abstract_add_message>
|
332 |
+
<observers>
|
333 |
+
<litemage_esi>
|
334 |
+
<class>litemage/observer_esi</class>
|
335 |
+
<method>purgeEsiCache</method>
|
336 |
+
</litemage_esi>
|
337 |
+
</observers>
|
338 |
+
</core_session_abstract_add_message>
|
339 |
+
<checkout_onepage_controller_success_action>
|
340 |
+
<observers>
|
341 |
+
<litemage_esi>
|
342 |
+
<class>litemage/observer_esi</class>
|
343 |
+
<method>purgeEsiCache</method>
|
344 |
+
</litemage_esi>
|
345 |
+
</observers>
|
346 |
+
</checkout_onepage_controller_success_action>
|
347 |
+
</events>
|
348 |
+
<litemage>
|
349 |
+
<esiblock>
|
350 |
+
<!-- If you need to inject any other privately cached custom block groupings,
|
351 |
+
you can add them here. <blocks> contains the block names defined in your
|
352 |
+
layout files. All blocks that share the same purge events can be listed
|
353 |
+
together in a single grouping. If their purge events are not being watched
|
354 |
+
in the previous events section, you will also need to add a litemage esi
|
355 |
+
observer for those events.
|
356 |
+
|
357 |
+
This config file will be overwritten with upgrades to the LiteMage module.
|
358 |
+
If you have made any modifications, please make sure to keep a copy -->
|
359 |
+
<welcome>
|
360 |
+
<!-- blocks only purged by login/logout events, no purge_events configuration is required as login/logout will auto purge all private blocks -->
|
361 |
+
<access>private</access>
|
362 |
+
<blocks>T:Mage_Page_Block_Html_Welcome,welcome,litemage.jsvar,nickname$v</blocks>
|
363 |
+
<!-- Marking a block as valueonly, denoted by the suffix “$v”, will only output
|
364 |
+
the blocks html value without the added html tags and comments when in debug mode.
|
365 |
+
The block will also not be highlighted when using the LITEMAGE_DEBUG=SHOWHOLES parameter -->
|
366 |
+
</welcome>
|
367 |
+
<cart>
|
368 |
+
<access>private</access>
|
369 |
+
<!-- Blocks can be set using class type, denoted by the prefix "T:". This will include all blocks that inherit this type in the grouping -->
|
370 |
+
<blocks>T:Mage_Checkout_Block_Cart_Abstract</blocks>
|
371 |
+
<purge_events>
|
372 |
+
<sales_quote_save_after/>
|
373 |
+
</purge_events>
|
374 |
+
</cart>
|
375 |
+
<toplinks>
|
376 |
+
<access>private</access>
|
377 |
+
<blocks>top.links</blocks>
|
378 |
+
<purge_tags>cart, wishlist</purge_tags>
|
379 |
+
<!-- This is a composite grouping. The purge events for the blocks in this grouping are
|
380 |
+
a combination of existing purge event sets from other groupings. By using purge_tags
|
381 |
+
to reference these other groupings, you do not need to redefine these purge events. -->
|
382 |
+
</toplinks>
|
383 |
+
<compare>
|
384 |
+
<access>private</access>
|
385 |
+
<blocks>T:Mage_Catalog_Block_Product_Compare_Sidebar, T:Mage_Reports_Block_Product_Compared</blocks>
|
386 |
+
<purge_events>
|
387 |
+
<catalog_product_compare_add_product/>
|
388 |
+
<catalog_product_compare_remove_product/>
|
389 |
+
<catalog_product_compare_item_collection_clear/>
|
390 |
+
</purge_events>
|
391 |
+
</compare>
|
392 |
+
<viewed>
|
393 |
+
<access>private</access>
|
394 |
+
<blocks>T:Mage_Reports_Block_Product_Viewed</blocks>
|
395 |
+
<purge_events>
|
396 |
+
<catalog_controller_product_view/>
|
397 |
+
</purge_events>
|
398 |
+
</viewed>
|
399 |
+
<poll>
|
400 |
+
<access>private</access>
|
401 |
+
<blocks>T:Mage_Poll_Block_ActivePoll</blocks>
|
402 |
+
<purge_events>
|
403 |
+
<poll_vote_add/>
|
404 |
+
</purge_events>
|
405 |
+
</poll>
|
406 |
+
<!-- messages is specially handled, cannot change the tag name here, has to be "messages" -->
|
407 |
+
<messages>
|
408 |
+
<access>private</access>
|
409 |
+
<blocks>T:Mage_Core_Block_Messages</blocks>
|
410 |
+
<purge_events>
|
411 |
+
<core_session_abstract_add_message/>
|
412 |
+
</purge_events>
|
413 |
+
</messages>
|
414 |
+
<!-- Blocks only visible when logged in -->
|
415 |
+
<reorder>
|
416 |
+
<access>private</access>
|
417 |
+
<blocks>T:Mage_Sales_Block_Reorder_Sidebar</blocks>
|
418 |
+
<purge_events>
|
419 |
+
<sales_quote_save_after/>
|
420 |
+
<checkout_onepage_controller_success_action/>
|
421 |
+
</purge_events>
|
422 |
+
</reorder>
|
423 |
+
<wishlist>
|
424 |
+
<access>private</access>
|
425 |
+
<blocks>T:Mage_Wishlist_Block_Customer_Sidebar</blocks>
|
426 |
+
<purge_events>
|
427 |
+
<wishlist_item_save_after/>
|
428 |
+
<wishlist_item_delete_after/>
|
429 |
+
</purge_events>
|
430 |
+
</wishlist>
|
431 |
+
<!-- public blocks -->
|
432 |
+
<!-- Some themes will use a variable in footer that is declared in the header,
|
433 |
+
this causes the footer block to fail to generate. You can modify the
|
434 |
+
template to generate the missing variable or simply choose to not punch
|
435 |
+
a hole in footer (comment out the footer block).
|
436 |
+
|
437 |
+
Making the footer a public block will speed up page generation and save some disk space -->
|
438 |
+
<footer>
|
439 |
+
<access>public</access>
|
440 |
+
<blocks>footer</blocks>
|
441 |
+
</footer>
|
442 |
+
</esiblock>
|
443 |
+
</litemage>
|
444 |
+
</frontend>
|
445 |
+
<default>
|
446 |
+
<litemage>
|
447 |
+
<general>
|
448 |
+
<enabled>0</enabled>
|
449 |
+
<admin_ips>127.0.0.1</admin_ips>
|
450 |
+
<public_ttl>28800</public_ttl>
|
451 |
+
<private_ttl>1800</private_ttl>
|
452 |
+
<track_viewed>0</track_viewed>
|
453 |
+
<diff_customergroup>0</diff_customergroup>
|
454 |
+
<diff_cookie/>
|
455 |
+
<alt_esi_syntax>0</alt_esi_syntax>
|
456 |
+
</general>
|
457 |
+
<warmup>
|
458 |
+
<enable_warmup>0</enable_warmup>
|
459 |
+
<load_limit>5</load_limit>
|
460 |
+
<thread_limit>6</thread_limit>
|
461 |
+
<max_time>360</max_time>
|
462 |
+
<interval>21600</interval>
|
463 |
+
<priority>100</priority>
|
464 |
+
<multi_currency/>
|
465 |
+
<custlist/>
|
466 |
+
<custlist_priority>50</custlist_priority>
|
467 |
+
<custlist_interval>7200</custlist_interval>
|
468 |
+
</warmup>
|
469 |
+
<default>
|
470 |
+
<!-- Full or partial match on controller full action name for cacheable routes. Space, return, and comma separated -->
|
471 |
+
<cache_routes><![CDATA[catalog cms contacts_index_index]]></cache_routes>
|
472 |
+
<!-- Full or partial match on controller full action name for non-cacheable routes within cacheable routes. Space, return, and comma separated -->
|
473 |
+
<nocache_subroutes><![CDATA[catalog_product_compare catalogsearch]]></nocache_subroutes>
|
474 |
+
<!-- Entire response cached based on routes, same content for all urls, such as "cms_index_noRoute" for 404 pages. Space, return, and comma separated. -->
|
475 |
+
<fullcache_routes><![CDATA[cms_index_noRoute]]></fullcache_routes>
|
476 |
+
</default>
|
477 |
+
<donotcache>
|
478 |
+
<!-- configured through Admin Panel, do not update here. Customized settings will be picked up from database -->
|
479 |
+
<cache_routes/>
|
480 |
+
<nocache_subroutes/>
|
481 |
+
<vars>no_cache</vars>
|
482 |
+
<urls/>
|
483 |
+
<welcome/>
|
484 |
+
<toplinks/>
|
485 |
+
<messages/>
|
486 |
+
</donotcache>
|
487 |
+
<test>
|
488 |
+
<debug>0</debug>
|
489 |
+
<allow_ips/>
|
490 |
+
</test>
|
491 |
+
</litemage>
|
492 |
+
</default>
|
493 |
+
<crontab>
|
494 |
+
<jobs>
|
495 |
+
<litemage_warmup_cache>
|
496 |
+
<schedule>
|
497 |
+
<cron_expr>0,10,20,30,40,50 * * * *</cron_expr>
|
498 |
+
</schedule>
|
499 |
+
<run>
|
500 |
+
<model>litemage/observer_cron::warmCache</model>
|
501 |
+
</run>
|
502 |
+
</litemage_warmup_cache>
|
503 |
+
</jobs>
|
504 |
+
</crontab>
|
505 |
+
</config>
|
app/code/community/Litespeed/Litemage/etc/system.xml
CHANGED
@@ -1,17 +1,34 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
* LiteMage
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*/
|
|
|
9 |
-->
|
10 |
|
11 |
<config>
|
12 |
<tabs>
|
13 |
<Litespeed_Litemage translate="label">
|
14 |
-
<label>LiteMage Cache 1.0.
|
15 |
<sort_order>5000</sort_order>
|
16 |
</Litespeed_Litemage>
|
17 |
</tabs>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
*/
|
25 |
+
|
26 |
-->
|
27 |
|
28 |
<config>
|
29 |
<tabs>
|
30 |
<Litespeed_Litemage translate="label">
|
31 |
+
<label>LiteMage Cache 1.0.18</label>
|
32 |
<sort_order>5000</sort_order>
|
33 |
</Litespeed_Litemage>
|
34 |
</tabs>
|
app/design/adminhtml/default/default/layout/litemage.xml
CHANGED
@@ -1,4 +1,29 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<layout version="0.1.0">
|
3 |
<adminhtml_cache_index>
|
4 |
<reference name="content">
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
+
-->
|
26 |
+
|
27 |
<layout version="0.1.0">
|
28 |
<adminhtml_cache_index>
|
29 |
<reference name="content">
|
app/design/adminhtml/default/default/template/litemage/cache_management.phtml
CHANGED
@@ -1,89 +1,145 @@
|
|
1 |
-
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
?>
|
4 |
-
HR+cP/ZTSCVKY4dfjHRbv9lIVtJgyln05jyeORci5iCQ/dverUBBEkQwH4YF1bMiQHNW18Fu5NAX
|
5 |
-
uom1D3rBN/8bOyumqjTxpMSbbPH+LPdnBKzTc2xFmt9hj8uMypboUzKB2nLSgclbw1iAGPf1v/aV
|
6 |
-
aUeVgoyozz5Dwm/+OfGVCMbCziw/qvV36j9FFebmTBUrnqVYX8lsZrVqJTW9z094zi/gnWvsuYlM
|
7 |
-
HUIkFUYyze36p6VxbNbwo0yLC2pRPhl4JNzaxyRee7bgI1Au0lHWZtqQglwhpTidRYX/WseH22/l
|
8 |
-
BIlZp4xiiNKh6IhCcftT23dlSdzcPnrr3N9HfjLLTAVDj+17aG5J1fK+lN0zwrnGjUuJKSR6FmVT
|
9 |
-
dWj8OlIeBihDaL8dALIy7X8J4Tke23OuLyL3yzHy1146lh5V8BBpIJDsad3lXtzMa0Sjwnf3xoaB
|
10 |
-
A7BwIt+2REnVG5MGdV420YSCLk9lUInTjfalFfwRFyAmeKLkHBXYW/xl2M3ZMa3DCH1mmfK9sgHC
|
11 |
-
HLXmN+jWSELAgHZjyr3kA5hD1mA4QuKEBFpE9ktDHjga+nvNeHufFy5igKYe8kePq0lWNMDXp3fz
|
12 |
-
am+1xcDUtUjhCCiFrF0qEl0hYHD7DpTzBKvCgNpDJSBQLBvnr8RR63eiS61ny2/uT470wkyGMs2I
|
13 |
-
A8FX3Dk7dMCqUki98rLuzzRHin9jQ+JWAwYqm5emC7kl7IGsB1eQajTExhDwvtR4zLcQxnJ2ppcb
|
14 |
-
xQKmqEqN82oVNH5A5LScRDcD5u/QVVgi1LXFP0zPMw+808cNe7A1iXXrSyRWMrNd8/Hdcwu7Fu13
|
15 |
-
xg3MoWz6KSfqJasuC1RbfZF8wGQXO3XgZ3tXydETcZkbSWC5S7Cl/g4zr/utt5c7jTM/MxA70YTH
|
16 |
-
CprcCe6K5OneIssOUdUMXGHovUsm+grlM3EtS5n8CB3SGjXVyIzm7VFlK+wIMjQJ8+2Y9EvX6rzG
|
17 |
-
7jXGQ4wsLcIJ9P/WvjPC9gSdbksF8gHR8GPUi84PWPDsPgsK3X5llsaiDA444Ve6LD7CXQEKafOK
|
18 |
-
25XxW1ommvWelXyxM8SwsWcp2ISzMjO4R1/2xwK5ptLq/b04rPlPLP/acUV84B+mQhZBnLJsPC5t
|
19 |
-
4Fdg66MKpGhnYXIdIEQCjBxlTNkyw83zkvImLrOXZyr3H5/WKqWHh0zjAs7TVcNUMqH8pxKnM7gb
|
20 |
-
+ed0IXX/OJG/A/Lo2L4HOuIdAvZjbNo0KOBpMAHkeTMWC1tiCIJynUfbPh5EOYOiJ2/dxOoKoc63
|
21 |
-
6yd2W5E1kZvEckhhA74HrSbkXUuYf0OHyGmVAxvlm3ebM5cs0eRKnEXJqxfKBwJBoHPvXVKPEEvm
|
22 |
-
v++qUYa+5DBmiuTUX1D+CymdihhCdbGTCw6N7obWZ3Z9fNBJkWzEj9/5gCAWMB7blBspbbytd16D
|
23 |
-
hCdJOqwD9f1YaLmS5a74oQh3OiBwdWkM+6vU5LgECnuQ8yhS6JHjiZjmwOqIdAFPN6j8S14CmEmG
|
24 |
-
ddp1momwP7yooCmLURKQnvgASLGWcXFdRFL/sX/jDYZ+2pZc4c9mBk7EUR7I3MCPugMSM8/b4Jw2
|
25 |
-
3CDpw6J2XVUJzjVAJuj/m2Mx7mDwFO/stdOCft3h7o4IVadbCWbuAD6EwKRE+wgBuqHkeq2Q3pvp
|
26 |
-
x5R/f1J/T8hdE6EMVeL1ZXkjhdUgvWUEknabyFsdvKuJnd3AvyqzAw1mrVResxRQPBJp6zUPGrPN
|
27 |
-
UNL5qjmEFvZhHbmpyXcm+zeLNdrhXHzkBgNgUuMT/uQ1lkVyJiBLZWL/MqhlWBAQbKD29OfnQCGP
|
28 |
-
iQE97kN8AA4Xmf7DXiNxyRLmKUSh9FlVpfCVtjjgyTusNoK5P73529DSRAdTfeba7lHNopRB4cgJ
|
29 |
-
QjdGAJUNTcSijRnXOS0glU8T6knZ42+5PZsnv+Px0ujvtPgspVpUXxr2tYlhHeB5tj26HVYL6QtE
|
30 |
-
Gd4Ro6yHpqREcKMfakK+UOPuk6tA36gI8RPJ+OzSnrEg6sZ5AhH/DjxEzUGJEylpe177Wx8v58XB
|
31 |
-
OJslAQhGpKbd0OfBIw5ce0XGBxk+vEZI56vr4H/PEN1AwokRbYgkegzqQdljKUIKG142CxUBFhqx
|
32 |
-
w9kie7W0XP52qr9QMft8eJuYj1Y3h9tJGfi615+P4rDzdL/k9E1al2pKm18UAjpPhE/hD+8tIOy5
|
33 |
-
kzWFviKmYAvp7gF/afLsIWqehQ9BtnZDbJPRS805Uc+z1wtreqaKjHE2vyG7SKE67ckzRcxbewC5
|
34 |
-
bM5TlGpdxGQOweICV3P29LXVHpIHSuEMDh+DSlqQqsbav3D3EVwumvVNvBu9FyXRUeByKgLVJ15f
|
35 |
-
bp8b40xaBf6YK/zYZzPt9AIiq4KkAnWqGPFZMGTdMci6Ug6Ens9CCM+2QxuiS9q2qPnZD8JNtLBB
|
36 |
-
GsUdO9mjFdmKzdYUizA3BAAR1Vi//4sVEa7bSz6WKGe+KjLeuNCx3JMRnOWNMnZidtpMMGu0sRlW
|
37 |
-
LHWDazJK89BKgfLSodAsOXWwW9G6RNN1xDwYMbL6V6vqK0YIMFKhBhc9WfbYRtq0Fu6zETpR3xZZ
|
38 |
-
/gz3z/ZWTKzZwF0Q5vL9DUivt0wZor8ZKn/XSGiDENCqt8PfjkyiMbTlk2ypPq58CfeU/viUOOnF
|
39 |
-
X5crpSdWjGQHGQQIaF6pqE+S1jpbNJBze73oUfTow+iWJATFr5mSAPZMRYp/dESFh4Clrl60iQuU
|
40 |
-
uyz6dF7y71/h+SMmdPO6bhqg3kDrdFPpoi0pjVYdCQYyPxR/3y9aZgxTujjOP7iRuqk5OvYPL78s
|
41 |
-
58OQiiIvltgxyp+cJdNHL+oTJ/9G5KSWY2IALwIO7mCYHT3jT0/10XR+8AwLueIczeMa+hb9i9a1
|
42 |
-
h359dLJ6qgs45r/xR2TZYiGVgT34fLXZGRxnqv3Mt0A02657qkleCNdmsiw3f/DkKUQ2fdqGryaQ
|
43 |
-
UZ0vpAlQNW/QJ+FZ+bnZDi/TlBnAUmRB9XuaaXiSXzGWgXa4q71ILRDQBPbNBzIcqNR3VSkCuqhx
|
44 |
-
cyjO/uYRXCJiNAsMfUvzR7Lyt4uDFmE/ZM+9p+nlbvBEdRp6syIPhAAOUQHcUZ+TCo5A3TOhbJTo
|
45 |
-
n9nm1yoBGG2O2P3877vC0NffulUutRuUUiaB6gvooo7vdT7f04CZF/4up1Zx6FjFgIQzSTRuECtW
|
46 |
-
71Lwx7AGoyuCQ1904WyU/RGJBtMCk3a2AI+PRnQ676j69iIkPnK5FYWMhvwz7a0V6XgAVInSyJNp
|
47 |
-
AYQ1PHUuFH1QSZ5khVMaLFngq9Bzs6MM+XYJeslgQwkleEcWS/4phm2ac+ubwrzPvdEngbO6Hmrz
|
48 |
-
+AqKg5xNCFNvjM68Fe07KHZeU/ozLXYAxZ8GonuUzVkmWvXSbkD40cJy28bSzdAPoRWpScRqds2R
|
49 |
-
PxATYEud4/kRXDLJ8jjZA4n2HIrpRLhw+LgcAX5MOHl5L158nNS5ECTZrRd1N5khGEGA7gyBGstV
|
50 |
-
E4j5fPiwv3I92Vwums2mY/4B9HCsa92FmPRp+/A7WopmdqZClkCin7whws/Uyk9r5n3hrPD/Ouoi
|
51 |
-
tk5ZgNvONqUKFdhaKx935L8capdaeHvigBi4ftIitE5yg7PyEuwzqb/OEKJJSpgaHvJPtWALIQOB
|
52 |
-
ks9MAq+SA3anjS1kpuYncm4fY4EN/6xlAOibAYSWLpQ2CCI2p0R9GqZ7Xr3pADFvR+VmJagf0w1C
|
53 |
-
EiuDe60+LFX9oiEhU6WJs5z0KkqLtYu/1bPFOqRwdybmjZVq4xVWE/kHPCOgz1O2HdLqTMoS5vU7
|
54 |
-
ZpByJB4my0iJ6DbA0IeO4vue3jHoaXhha10gaA3fOzYPmqujBb5hz4dGGNZlsz/lbfPq1qJ7Lay5
|
55 |
-
IXB8Km87pKKl4fxP/Y2wZrFAOfRRFS6tJ8i5lwYhpNLnNAJV0EHmBPs9b4SfjsftRCUNs1qdhDVC
|
56 |
-
+bIyBqMRMeV9OMgDmqZQOt+dh/ltzx2y5YxNNFmC0tY4NbAvyzCLy8ygeJR0uEvPaL6a05Gs9xrH
|
57 |
-
KfTdFdJECZqJLdD0Com09q5Uql/Rux5+03rAu3BF2bLIEKByURqCO4ic101aGCTd7S3Y9ZVb3QNK
|
58 |
-
SHvYSl+PBUjhYSuL6fajLrEacz8ss+Km//tYP8hM4NdSDAC0b+iHb6y68sHby0GpHz5jOGX/GauN
|
59 |
-
oAbYu7Ydcfy9+mw0ZFyzeHQE/8OtCaFzVYwxX+UwdNWYslKc79R7GUjO969Ylm3aX0oNYwLpPgvW
|
60 |
-
REh1tXl2Qlc88g+I13b5WPxCRbAmVLZNYxpZ3NeCtM77FbQ657/wgv84lBC/m44fzjP94kSCscvq
|
61 |
-
C1EcWuAIhXN1tRlLYhPyv2F/m7PChjPeCpjtyCM3Yo2TFmXdQElhrGfGCFyA3RQ+3rhF5574ABT0
|
62 |
-
hJi3BjEb3qr6HQzNcCd4Gs9DExiosDjs6iMHXWGr5sT66OpqHQMNn+NPLv71SuEypB6tM/MImV05
|
63 |
-
mu66XIPyIpldf/OmbToPNTpihqXoo/4Tf52ODJ8iyAqRmhsCuKJLYyZopaef1yTvbzJ/g3+7FJbY
|
64 |
-
Xny8KKyhVfJdlRCcTnFa0qgGgolhTgVk+MM9gwp0LOcSUg/BZ4YZAp/Gov2hIzVB42UwU1313cY6
|
65 |
-
z4E2+Qe67xrrOYrDj8mn1ePCB6WNSBRh7rX37oC3obCD/y/4N9N8Dqe+tfQpBwmk9Gekge5c5wAC
|
66 |
-
fXHvBdwZoXaeVCnlhjH66AoWAum/um+OOWt7qDW3hVheKg8xVfpiKJ9jsJvERmXvZOhx4+eK6l9P
|
67 |
-
dotSYw//y31udKPFdnw96/dBlj/R/vl6snfOZ/NHzNJbeYGpZVB22QKmq2VaE2ZsrxLa/0oUdYSq
|
68 |
-
GEKuSR/3Ysbn20Lu1aoV3VG1ZKLrB59JW17zulfaHS3s8uOoIt9jdbpJ+sMi0760++RjyDeAPYSa
|
69 |
-
dAT2JsfneOKTJC04rKig69TXdkT0M//kunz5isEjulqa+CbzO3JATaxvtPmdrPa/uCmCzvFQriOo
|
70 |
-
1bXcUvT5bR3CzLAvMX5g47wnyHQc517ecGMzabaiTwQLEsetOfsBcWCRQ4xq2wOCWCRAp4SWQNPe
|
71 |
-
U2I5lcEZMkLMDJ4gWsDj88B626i6y50luil7LK0hFm4Quaxy3GuQ2JJsBaWgtJsO9KM2cJ5a3ztF
|
72 |
-
FzvQdGq/err5OyJ09y5+oWrz+jq497VQKzYl6IfxcpDWH2PqZOHS9YZzvo8oGPHxawg3brosvVV9
|
73 |
-
lUN2k3Q5vtIvExuIzueMMMwG93JByl3uj8G2AjC3qDuEdwf9y0rErhGKf9KetIxsHgoWXO8/HWq+
|
74 |
-
P2CoiG+1GIgaj7xGOc0BTWGNA29vlMJaqhz3XRTsn52X+BJHgOPziIThwIdRAe1NQwiCaMv+OMLI
|
75 |
-
AIwwIL/u/xwoI4qrz4vaU4hATX2Rl9jdyny3Z/bPYy7us7oXnjCAPXqo5seZ1KwuYndpjp4RhqO0
|
76 |
-
pe4mut1XBwe/RQOHrEBBGz3ehTRJarundQLCVvfJJ4V7tY1tgt09p3Q/lfDsmy629C8bK85DYMOD
|
77 |
-
CuDoEMqgtXQ2lXoSdb65ibTxSoSNNIMmxgJpHZ06TBiMoFdYyOY3ewAKwyV6uq/svYJxGguBARI3
|
78 |
-
gDZYmwWUVORwzMiN1fdeFU417lkS/EhMeF9dicXsx1YWbhnhE+knx306UgAUgrJyf7VKUUS/ccMI
|
79 |
-
uoO8gpPjNrzK9hoHhGHXUSmPe/j2rmQz+aVn4zspelflD1toReOfvcwjrPEBYGKFPxf6LQKnVyXr
|
80 |
-
yuaq7PKAV5VpuM5kZ06SOUy6I7mlux5yFSIsWc0Pn6AGWLfM7WK2BWclGCRcNVk41JGws2SQl4zc
|
81 |
-
n9BFNXapwqTQHLT45wtW7CtXUsAG3xcRxf6qvt0xaMWC8uIVTMfJm0bJfqaDOXplVm43dMY3sOWg
|
82 |
-
iVWuRMKQcuc5O8mDkn5sH4fsnhSeoLRqOBqRi32dCgAk4x5FP+Ko1h4hSVu3ZtbJc46CUpTtvRVA
|
83 |
-
2pwxMkfY+6B4ydNeiVHXCsvLCFbqpXUZA4BCizMX91R6QxJomxPFR0IsL8PtTBICb32oolEnc+LN
|
84 |
-
8IqQsPMNY2WpwY3WayJQ+gxSOxnWMyMoJDdpe2063V1C/xj2wtFEZNVFGlGLyPfpc5+oMK11ENbL
|
85 |
-
h19vQ5IRxHYRtIBIyGttIqm3/aULN8aeYxV+HGNuEaX+1ZahDWpdqln5q2dFENvckw/lRca8KL8e
|
86 |
-
V6CxbGIjlZj16M5T06LL0CIXJ9IdgVkV/5wWQtvSr87KPbzy6zTa7rFfZ4Qfg2QQhXwAEP//L4p4
|
87 |
-
zOmjMN8PuiXUwgsgIePidoszrNolaVe5cEOEb6tG16zIMCrE2p/rBWMYTjo360rKZaLGPbQmtezN
|
88 |
-
88LaTnMAPCaDyZfYWz847q5wk9tQsag24tW1f+JCuE4RWwLb7WpJcFwex17D6JRbGA1sRfnjhn/f
|
89 |
-
MGh+WTw5YHM7XCjJvzqK2XOki5tkFVe=
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
+
*/
|
24 |
+
|
25 |
+
if ($this->canShowButton()):
|
26 |
+
$lmhelper = Mage::helper('litemage/data');
|
27 |
+
?>
|
28 |
+
<br/>
|
29 |
+
<div class="content-header">
|
30 |
+
<table cellspacing="0">
|
31 |
+
<tr>
|
32 |
+
<td><h3><?php echo $lmhelper->__('LiteMage Cache Management (LiteSpeed Web Server)') ?></h3></td>
|
33 |
+
</tr>
|
34 |
+
</table>
|
35 |
+
</div>
|
36 |
+
<?php if (!$this->isCacheAvailable()) {
|
37 |
+
echo '<div><ul class="messages">
|
38 |
+
<li class="error-msg">LiteMage extension requires Configuration and Layouts cache types to be enabled. It will not function properly with these settings disabled.
|
39 |
+
</li></ul></div>';
|
40 |
+
}
|
41 |
+
?>
|
42 |
+
|
43 |
+
<table class="form-list">
|
44 |
+
<tr>
|
45 |
+
<td class="scope-label">
|
46 |
+
<button onclick="setLocation('<?php echo $this->getPurgeUrl('All')?>')" type="button" class="scalable"><span><?php echo $lmhelper->__('Flush All LiteMage Cache') ?></span></button>
|
47 |
+
</td>
|
48 |
+
<td class="scope-label">
|
49 |
+
<?php echo $lmhelper->__('All cache storage.')?>
|
50 |
+
</td>
|
51 |
+
</tr>
|
52 |
+
</table>
|
53 |
+
<form action="<?php echo $this->getPurgeUrl('Tag')?>" method="post" id="litemage_purgeTag">
|
54 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
55 |
+
<table class="form-list">
|
56 |
+
<tr>
|
57 |
+
<td class="scope-label">
|
58 |
+
<button type="submit" class="scalable"><span><?php echo $lmhelper->__('Flush LiteMage Cache By IDs') ?></span></button>
|
59 |
+
</td>
|
60 |
+
<td class="scope-label">
|
61 |
+
<select name="tag_types" class="required-entry select local-validation">
|
62 |
+
<option value="P"><?php echo $lmhelper->__('Product IDs')?></option>
|
63 |
+
<option value="C"><?php echo $lmhelper->__('Category IDs')?></option>
|
64 |
+
<option value="G"><?php echo $lmhelper->__('CMS IDs')?></option>
|
65 |
+
</select>
|
66 |
+
</td>
|
67 |
+
<td class="scope-label">
|
68 |
+
<input type="text" name="purge_tag" class="input-text required-entry" style="width:150px"/>
|
69 |
+
</td>
|
70 |
+
<td class="scope-label">
|
71 |
+
<?php echo $lmhelper->__('Specify one or more IDs separated by spaces. (Under normal operation, related pages will automatically be purged when saving changes to an item through the Admin Panel.)')?>
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
</table>
|
75 |
+
</form>
|
76 |
+
<form action="<?php echo $this->getPurgeUrl('Url')?>" method="post" id="litemage_purgeUrl">
|
77 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
78 |
+
<table class="form-list">
|
79 |
+
<tr>
|
80 |
+
<td class="scope-label">
|
81 |
+
<button type="submit" class="scalable"><span><?php echo $lmhelper->__('Flush LiteMage Cache By URL') ?></span></button>
|
82 |
+
</td>
|
83 |
+
<td class="scope-label">
|
84 |
+
<input type="text" name="purge_url" class="input-text required-entry" style="width:350px"/>
|
85 |
+
</td>
|
86 |
+
<td class="scope-label">
|
87 |
+
<?php echo $lmhelper->__('Specify a relative URL starting with /.')?>
|
88 |
+
</td>
|
89 |
+
</tr>
|
90 |
+
</table>
|
91 |
+
</form>
|
92 |
+
<br/>
|
93 |
+
<?php echo $this->getChildHtml();
|
94 |
+
|
95 |
+
if ($status = $this->getCrawlerStatus()) : ?>
|
96 |
+
<form method="get" action="<?php echo $this->getPurgeUrl('Refresh')?>" id="litemage_crawlstatus">
|
97 |
+
<div class="content-header">
|
98 |
+
<table class="form-list" cellspacing="0">
|
99 |
+
<tr>
|
100 |
+
<td><h3><?php echo $lmhelper->__('LiteMage Crawler Warm-up Status') ?><button type="submit" class="scalable"><span><?php echo $lmhelper->__('Refresh') ?></span></button></h3></td>
|
101 |
+
</tr>
|
102 |
+
<tr><td class="scope-label"><?php echo $lmhelper->__('You can click Reset All / Reset links below to restart a crawler queue.') ?></td></tr>
|
103 |
+
</table>
|
104 |
+
</div>
|
105 |
+
</form>
|
106 |
+
|
107 |
+
<div class="grid"><div class="hor-scroll"><table>
|
108 |
+
<tr class="headings">
|
109 |
+
<th class="no-link a-center"><?php echo $lmhelper->__('Prioirty');?></th>
|
110 |
+
<th class="no-link a-center"><?php echo $lmhelper->__('List ID')
|
111 |
+
. '<br><a href="' . $status['url_reset'] . '" title="Click to reset all crawler queues">' . $lmhelper->__('Reset All') . '</a>'; ?>
|
112 |
+
</th>
|
113 |
+
<th class="no-link"><?php echo $lmhelper->__('Base URL') . '<br>' . $lmhelper->__('Custom List Path'); ?></th>
|
114 |
+
<th class="no-link a-right"><?php echo $lmhelper->__('Run Interval (secs)')
|
115 |
+
. '<br>' . $lmhelper->__('Store Public TTL (secs)'); ?>
|
116 |
+
</th>
|
117 |
+
<th class="no-link a-center"><?php echo $lmhelper->__('Generated') . '<br>' . $lmhelper->__('Finished'); ?></th>
|
118 |
+
<th class="no-link"><?php echo $lmhelper->__('Environment') . '<br>' . $lmhelper->__('Current Vary'); ?></th>
|
119 |
+
<th class="no-link a-right"><?php echo $lmhelper->__('Current Position') . ' | ' . $lmhelper->__('List Size')
|
120 |
+
. '<br>' . $lmhelper->__('Last Query Time | Total Queried'); ?></th>
|
121 |
+
</tr>
|
122 |
+
<?php foreach ($status['stores'] as $s) {
|
123 |
+
$buf = '<tr>';
|
124 |
+
$buf .= '<td class="a-center">' . $s['priority'] . '</td>'
|
125 |
+
. '<td class="a-center">' . $s['id'] . '<br>'
|
126 |
+
. '<a target="_blank" href="' . $status['url_details'] . '?list=' . $s['id'] . '">' . $lmhelper->__('Details')
|
127 |
+
. '</a> | <a href="' . $status['url_reset'] . '?list=' . $s['id'] . '" title="Click to reset this crawler queue">' . $lmhelper->__('Reset') . '</a></td>'
|
128 |
+
. '<td>' . $s['baseurl'] . '<br>' . $s['file'] . '</td>'
|
129 |
+
. '<td class="a-right">' . $s['interval'] . '<br>' . $s['ttl'] . '</td>'
|
130 |
+
. '<td class="a-center">' . $s['gentime'] . '<br>' . $s['endtime'] . '</td>'
|
131 |
+
. '<td>' . $s['env'] . '<br>' . $s['curvary'] . '</td>'
|
132 |
+
. '<td class="a-right">' . $s['curpos'] . ' | ' . $s['listsize'] . '<br>' . $s['lastquerytime'] . ' | '. $s['queried'] . '</td>'
|
133 |
+
. "</tr>\n";
|
134 |
+
echo $buf;
|
135 |
+
}
|
136 |
+
?>
|
137 |
+
</table></div>
|
138 |
+
<p class="comment"><?php echo $lmhelper->__('Crawler status updated on') . ' ' . $status['lastupdate'] . '. ' . $status['endreason']; ?></p>
|
139 |
+
</div>
|
140 |
+
|
141 |
+
<?php endif;
|
142 |
+
|
143 |
+
endif;
|
144 |
+
|
145 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/layout/litemage.xml
CHANGED
@@ -1,7 +1,27 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
-->
|
6 |
|
7 |
<layout>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
-->
|
26 |
|
27 |
<layout>
|
app/design/frontend/base/default/template/litemage/inject/jsvar.phtml
CHANGED
@@ -1,9 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* LiteMage
|
4 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
*/
|
6 |
|
|
|
7 |
/* This is a private block (place holder template) to correct any variable that was set in public cached javascript earlier.
|
8 |
* So you do not need to modify your existing code in third-part's theme/template/extension.
|
9 |
* Since this will be in private block, so all the information can be set correctly for a particular user based on his own session information
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* LiteMage
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
19 |
+
*
|
20 |
+
* @package LiteSpeed_LiteMage
|
21 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
22 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
23 |
*/
|
24 |
|
25 |
+
|
26 |
/* This is a private block (place holder template) to correct any variable that was set in public cached javascript earlier.
|
27 |
* So you do not need to modify your existing code in third-part's theme/template/extension.
|
28 |
* Since this will be in private block, so all the information can be set correctly for a particular user based on his own session information
|
app/etc/modules/Litespeed_Litemage.xml
CHANGED
@@ -1,7 +1,27 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
-->
|
6 |
<config>
|
7 |
<modules>
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
+
/**
|
4 |
+
* LiteMage
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
|
20 |
+
*
|
21 |
+
* @package LiteSpeed_LiteMage
|
22 |
+
* @copyright Copyright (c) 2015-2016 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
|
23 |
+
* @license https://opensource.org/licenses/GPL-3.0
|
24 |
+
*/
|
25 |
-->
|
26 |
<config>
|
27 |
<modules>
|
package.xml
CHANGED
@@ -1,21 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LiteSpeed_LiteMage</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="https://
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>LiteMage Cache speeds up Magento by automatically integrating Magento with LiteSpeed's superior ESI implementation.</summary>
|
10 |
<description>LiteMage Cache is a powerful Magento page caching utility built into LiteSpeed Web Server. It combines superior ESI implementation with easy set up. LiteMage Cache contains a number of optimizations, including combined subrequests, that give it faster, more efficient performance than other page caching utilities. In addition, because it is part of the web server, LiteMage Cache does away with the communication problems and overhead other page caching solutions suffer from. The LiteMage Magento extension then automatically integrates Magento installations with LiteSpeed's top-of-the-line ESI implementation, combining the greatest Magento performance enhancement possible with a painless set up.</description>
|
11 |
-
<notes>
|
12 |
-

|
13 |
-
Switched cache warm up URL list handling from Magento's cache backend to a file-based system to decrease the chance of large lists exceeding memcached's maximum object size.
|
14 |
-
</notes>
|
15 |
<authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
|
16 |
-
<date>2016-
|
17 |
-
<time>
|
18 |
-
<contents><target name="magecommunity"><dir name="Litespeed"><dir name="Litemage"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Management.php" hash="
|
19 |
<compatible/>
|
20 |
-
<dependencies><required><php><min>5.3.0</min><max>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LiteSpeed_LiteMage</name>
|
4 |
+
<version>1.0.18</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/GPL-3.0 ">GPL v3</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>LiteMage Cache speeds up Magento by automatically integrating Magento with LiteSpeed's superior ESI implementation.</summary>
|
10 |
<description>LiteMage Cache is a powerful Magento page caching utility built into LiteSpeed Web Server. It combines superior ESI implementation with easy set up. LiteMage Cache contains a number of optimizations, including combined subrequests, that give it faster, more efficient performance than other page caching utilities. In addition, because it is part of the web server, LiteMage Cache does away with the communication problems and overhead other page caching solutions suffer from. The LiteMage Magento extension then automatically integrates Magento installations with LiteSpeed's top-of-the-line ESI implementation, combining the greatest Magento performance enhancement possible with a painless set up.</description>
|
11 |
+
<notes>License changed from LiteSpeed proprietary to GPLv3.</notes>
|
|
|
|
|
|
|
12 |
<authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
|
13 |
+
<date>2016-04-07</date>
|
14 |
+
<time>21:10:55</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Litespeed"><dir name="Litemage"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Management.php" hash="a16c9978a7177adf4aacc00a4a18476a"/></dir></dir><dir name="Core"><file name="Esi.php" hash="e491916a3654cb031113498934e36a81"/><file name="Messages.php" hash="89704ce091098dd0f2c6b5bf091ff32f"/></dir><dir name="Inject"><file name="Jsvar.php" hash="cc0590fe211c81d6d29de570503fe8fd"/><file name="Nickname.php" hash="3edf87b7d3f3da4093110bd4c98e0738"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6640a1843d63da08f36b9bce57a0d5d3"/><file name="Esi.php" hash="7f28730e2be3437ff8e52146d2f1de60"/><file name="Viewvary.php" hash="00b51b413114123c8e5d7bfd44e1cfdc"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="CustomerGroup.php" hash="2aa52d9a1614a545035267958be0656f"/><file name="EnableWarmUp.php" hash="d32dd158463297672dfb58628007a88c"/></dir></dir><dir name="Layout"><file name="Update.php" hash="aed09d2eb10c38680839a7fef957c59c"/></dir><file name="Layout.php" hash="73aa0b370d35111dcc420abbff118782"/><dir name="Observer"><file name="Cron.php" hash="9e397b360d2e5b81efccbd3e4bd2792c"/><file name="Esi.php" hash="655342014432ea5ad124ef3fc6babeee"/><file name="Purge.php" hash="aa3672d74e943a63a6267c2e4025e05c"/></dir><file name="Session.php" hash="558a80fb45a532af59727ae5657cd380"/><file name="Translate.php" hash="35326b8d2214f516d7dba82519902529"/></dir><dir name="controllers"><file name="AdminController.php" hash="d4d81dfdcb28354a7aabd9d9f6f10c86"/><dir name="Adminhtml"><file name="LitemageCacheController.php" hash="18b8cd29b5cf0fe20bd8d18d515fd79d"/></dir><file name="EsiController.php" hash="af5573b7eb74b48873a9c6a922d0a64d"/></dir><dir name="etc"><file name="config.xml" hash="f3f33da74787e94064688ab640ab563a"/><file name="config.xml.dev" hash="cd3f0860f7eeb206787d5c2d3297ebc4"/><file name="config.xml.package" hash="4220542c5e7689bf0b14f3adf05dcb23"/><file name="system.xml" hash="dc6bce0102d756500c8285a1db68a025"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="70c8a6fc5f5eaf99b8c0648a33bb3b7d"/></dir><dir name="template"><dir name="litemage"><file name="cache_management.phtml" hash="25be160ae1cb42391e4caa87049f272f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="4c840b12cc6246f68b1b028f0ef1056d"/></dir><dir name="template"><dir name="litemage"><dir name="inject"><file name="jsvar.phtml" hash="5bbd9992e7ba5925d09f21cf03237676"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Litespeed_Litemage.xml" hash="ba0c8904bc89219c6829e37cc14d9bdd"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
|
18 |
</package>
|