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_Page_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('cmsPageGrid');
41: $this->setDefaultSort('identifier');
42: $this->setDefaultDir('ASC');
43: }
44:
45: protected function _prepareCollection()
46: {
47: $collection = Mage::getModel('cms/page')->getCollection();
48:
49: $collection->setFirstStoreFlag(true);
50: $this->setCollection($collection);
51:
52: return parent::_prepareCollection();
53: }
54:
55: protected function _prepareColumns()
56: {
57: $baseUrl = $this->getUrl();
58:
59: $this->addColumn('title', array(
60: 'header' => Mage::helper('cms')->__('Title'),
61: 'align' => 'left',
62: 'index' => 'title',
63: ));
64:
65: $this->addColumn('identifier', array(
66: 'header' => Mage::helper('cms')->__('URL Key'),
67: 'align' => 'left',
68: 'index' => 'identifier'
69: ));
70:
71:
72:
73: $this->addColumn('root_template', array(
74: 'header' => Mage::helper('cms')->__('Layout'),
75: 'index' => 'root_template',
76: 'type' => 'options',
77: 'options' => Mage::getSingleton('page/source_layout')->getOptions(),
78: ));
79:
80: 81: 82:
83: if (!Mage::app()->isSingleStoreMode()) {
84: $this->addColumn('store_id', array(
85: 'header' => Mage::helper('cms')->__('Store View'),
86: 'index' => 'store_id',
87: 'type' => 'store',
88: 'store_all' => true,
89: 'store_view' => true,
90: 'sortable' => false,
91: 'filter_condition_callback'
92: => array($this, '_filterStoreCondition'),
93: ));
94: }
95:
96: $this->addColumn('is_active', array(
97: 'header' => Mage::helper('cms')->__('Status'),
98: 'index' => 'is_active',
99: 'type' => 'options',
100: 'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
101: ));
102:
103: $this->addColumn('creation_time', array(
104: 'header' => Mage::helper('cms')->__('Date Created'),
105: 'index' => 'creation_time',
106: 'type' => 'datetime',
107: ));
108:
109: $this->addColumn('update_time', array(
110: 'header' => Mage::helper('cms')->__('Last Modified'),
111: 'index' => 'update_time',
112: 'type' => 'datetime',
113: ));
114:
115: $this->addColumn('page_actions', array(
116: 'header' => Mage::helper('cms')->__('Action'),
117: 'width' => 10,
118: 'sortable' => false,
119: 'filter' => false,
120: 'renderer' => 'adminhtml/cms_page_grid_renderer_action',
121: ));
122:
123: return parent::_prepareColumns();
124: }
125:
126: protected function _afterLoadCollection()
127: {
128: $this->getCollection()->walk('afterLoad');
129: parent::_afterLoadCollection();
130: }
131:
132: protected function _filterStoreCondition($collection, $column)
133: {
134: if (!$value = $column->getFilter()->getValue()) {
135: return;
136: }
137:
138: $this->getCollection()->addStoreFilter($value);
139: }
140:
141: 142: 143: 144: 145:
146: public function getRowUrl($row)
147: {
148: return $this->getUrl('*/*/edit', array('page_id' => $row->getId()));
149: }
150: }
151: