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: class Mage_Adminhtml_Block_Cache_Grid extends Mage_Adminhtml_Block_Widget_Grid
28: {
29: protected $_invalidatedTypes = array();
30: 31: 32:
33: public function __construct()
34: {
35: parent::__construct();
36: $this->setId('cache_grid');
37: $this->_filterVisibility = false;
38: $this->_pagerVisibility = false;
39: $this->_invalidatedTypes = Mage::app()->getCacheInstance()->getInvalidatedTypes();
40: }
41:
42: 43: 44:
45: protected function _prepareCollection()
46: {
47: $collection = new Varien_Data_Collection();
48: foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
49: $collection->addItem($type);
50: }
51: $this->setCollection($collection);
52: return parent::_prepareCollection();
53: }
54:
55: 56: 57:
58: protected function _afterLoadCollection()
59: {
60: foreach ($this->_collection as $item) {
61: }
62: return $this;
63: }
64:
65: 66: 67:
68: protected function _prepareColumns()
69: {
70: $baseUrl = $this->getUrl();
71: $this->addColumn('cache_type', array(
72: 'header' => $this->__('Cache Type'),
73: 'width' => '180',
74: 'align' => 'left',
75: 'index' => 'cache_type',
76: 'sortable' => false,
77: ));
78:
79: $this->addColumn('description', array(
80: 'header' => $this->__('Description'),
81: 'align' => 'left',
82: 'index' => 'description',
83: 'sortable' => false,
84: ));
85:
86: $this->addColumn('tags', array(
87: 'header' => $this->__('Associated Tags'),
88: 'align' => 'left',
89: 'index' => 'tags',
90: 'width' => '180',
91: 'sortable' => false,
92: ));
93:
94: $this->addColumn('status', array(
95: 'header' => $this->__('Status'),
96: 'width' => '120',
97: 'align' => 'left',
98: 'index' => 'status',
99: 'type' => 'options',
100: 'options' => array(0 => $this->__('Disabled'), 1 => $this->__('Enabled')),
101: 'frame_callback' => array($this, 'decorateStatus')
102: ));
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122: return parent::_prepareColumns();
123: }
124:
125: 126: 127: 128: 129:
130: public function decorateStatus($value, $row, $column, $isExport)
131: {
132: $class = '';
133: if (isset($this->_invalidatedTypes[$row->getId()])) {
134: $cell = '<span class="grid-severity-minor"><span>'.$this->__('Invalidated').'</span></span>';
135: } else {
136: if ($row->getStatus()) {
137: $cell = '<span class="grid-severity-notice"><span>'.$value.'</span></span>';
138: } else {
139: $cell = '<span class="grid-severity-critical"><span>'.$value.'</span></span>';
140: }
141: }
142: return $cell;
143: }
144:
145: 146: 147: 148: 149:
150: public function getRowUrl($row)
151: {
152: return false;
153:
154: }
155:
156: 157: 158:
159: protected function _prepareMassaction()
160: {
161: $this->setMassactionIdField('id');
162: $this->getMassactionBlock()->setFormFieldName('types');
163:
164: $modeOptions = Mage::getModel('index/process')->getModesOptions();
165:
166: $this->getMassactionBlock()->addItem('enable', array(
167: 'label' => Mage::helper('index')->__('Enable'),
168: 'url' => $this->getUrl('*/*/massEnable'),
169: ));
170: $this->getMassactionBlock()->addItem('disable', array(
171: 'label' => Mage::helper('index')->__('Disable'),
172: 'url' => $this->getUrl('*/*/massDisable'),
173: ));
174: $this->getMassactionBlock()->addItem('refresh', array(
175: 'label' => Mage::helper('index')->__('Refresh'),
176: 'url' => $this->getUrl('*/*/massRefresh'),
177: 'selected' => true,
178: ));
179:
180: return $this;
181: }
182: }
183: