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: class Mage_Adminhtml_Block_Cms_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('cmsBlockGrid');
41: $this->setDefaultSort('block_identifier');
42: $this->setDefaultDir('ASC');
43: }
44:
45: protected function _prepareCollection()
46: {
47: $collection = Mage::getModel('cms/block')->getCollection();
48:
49: $this->setCollection($collection);
50: return parent::_prepareCollection();
51: }
52:
53: protected function _prepareColumns()
54: {
55: $baseUrl = $this->getUrl();
56:
57: $this->addColumn('title', array(
58: 'header' => Mage::helper('cms')->__('Title'),
59: 'align' => 'left',
60: 'index' => 'title',
61: ));
62:
63: $this->addColumn('identifier', array(
64: 'header' => Mage::helper('cms')->__('Identifier'),
65: 'align' => 'left',
66: 'index' => 'identifier'
67: ));
68:
69: if (!Mage::app()->isSingleStoreMode()) {
70: $this->addColumn('store_id', array(
71: 'header' => Mage::helper('cms')->__('Store View'),
72: 'index' => 'store_id',
73: 'type' => 'store',
74: 'store_all' => true,
75: 'store_view' => true,
76: 'sortable' => false,
77: 'filter_condition_callback'
78: => array($this, '_filterStoreCondition'),
79: ));
80: }
81:
82: $this->addColumn('is_active', array(
83: 'header' => Mage::helper('cms')->__('Status'),
84: 'index' => 'is_active',
85: 'type' => 'options',
86: 'options' => array(
87: 0 => Mage::helper('cms')->__('Disabled'),
88: 1 => Mage::helper('cms')->__('Enabled')
89: ),
90: ));
91:
92: $this->addColumn('creation_time', array(
93: 'header' => Mage::helper('cms')->__('Date Created'),
94: 'index' => 'creation_time',
95: 'type' => 'datetime',
96: ));
97:
98: $this->addColumn('update_time', array(
99: 'header' => Mage::helper('cms')->__('Last Modified'),
100: 'index' => 'update_time',
101: 'type' => 'datetime',
102: ));
103:
104: return parent::_prepareColumns();
105: }
106:
107: protected function _afterLoadCollection()
108: {
109: $this->getCollection()->walk('afterLoad');
110: parent::_afterLoadCollection();
111: }
112:
113: protected function _filterStoreCondition($collection, $column)
114: {
115: if (!$value = $column->getFilter()->getValue()) {
116: return;
117: }
118:
119: $this->getCollection()->addStoreFilter($value);
120: }
121:
122: 123: 124: 125: 126:
127: public function getRowUrl($row)
128: {
129: return $this->getUrl('*/*/edit', array('block_id' => $row->getId()));
130: }
131:
132: }
133: