|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* User: [email protected] |
|
4
|
|
|
* Date: 08/01/14 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
require_once Mage::getModuleDir('controllers', 'Mage_Adminhtml').DS.'CacheController.php'; |
|
8
|
|
|
|
|
9
|
|
|
class Nexcessnet_Turpentine_Adminhtml_CacheController extends Mage_Adminhtml_CacheController |
|
10
|
|
|
{ |
|
11
|
|
|
public function indexAction() |
|
12
|
|
|
{ |
|
13
|
|
|
$allTypes = Mage::app()->useCache(); |
|
14
|
|
|
|
|
15
|
|
|
$turpentineEnabled = ($allTypes['turpentine_pages'] == 1) || ($allTypes['turpentine_esi_blocks'] == 1); |
|
16
|
|
|
$fullPageEnabled = (array_key_exists('full_page', $allTypes)) && ($allTypes['full_page'] == 1); |
|
17
|
|
|
|
|
18
|
|
|
if ($fullPageEnabled && $turpentineEnabled) { |
|
19
|
|
|
$allTypes['full_page'] = 0; |
|
20
|
|
|
Mage::app()->saveUseCache($allTypes); |
|
21
|
|
|
|
|
22
|
|
|
Mage::getSingleton('core/session')->addWarning( |
|
23
|
|
|
Mage::helper('adminhtml')->__('Both Varnish and Full Page caches were enabled. Full Page cache has now been disabled.') |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
|
|
$this->_redirect('*/*'); |
|
27
|
|
|
return; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
parent::indexAction(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Mass action for cache enabeling |
|
35
|
|
|
*/ |
|
36
|
|
|
public function massEnableAction() |
|
37
|
|
|
{ |
|
38
|
|
|
$types = $this->getRequest()->getParam('types'); |
|
39
|
|
|
$allTypes = Mage::app()->useCache(); |
|
40
|
|
|
|
|
41
|
|
|
$updatedTypes = 0; |
|
42
|
|
|
foreach ($types as $code) { |
|
43
|
|
|
if (empty($allTypes[$code])) { |
|
44
|
|
|
$allTypes[$code] = 1; |
|
45
|
|
|
$updatedTypes++; |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
if ($updatedTypes > 0) { |
|
49
|
|
|
// disable FPC when Varnish cache is enabled: |
|
50
|
|
|
if ($allTypes['turpentine_pages'] == 1 || $allTypes['turpentine_esi_blocks'] == 1) |
|
51
|
|
|
{ |
|
52
|
|
|
$allTypes['full_page'] = 0; |
|
53
|
|
|
Mage::getSingleton('core/session')->addSuccess(Mage::helper('adminhtml')->__("Full page cache has been disabled since Varnish cache is enabled.")); |
|
54
|
|
|
} else if ($allTypes['full_page'] == 1) { |
|
55
|
|
|
Mage::getSingleton('core/session')->addSuccess(Mage::helper('adminhtml')->__("Turpentine cache has been disabled since Full Page cache is enabled.")); |
|
56
|
|
|
} |
|
57
|
|
|
// disable FPC when Varnish cache is enabled. |
|
58
|
|
|
Mage::app()->saveUseCache($allTypes); |
|
59
|
|
|
$this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("%s cache type(s) enabled.", $updatedTypes)); |
|
60
|
|
|
} |
|
61
|
|
|
$this->_redirect('*/*'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|