00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Cms_Block_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('cmsBlockGrid');
00041 $this->setDefaultSort('block_identifier');
00042 $this->setDefaultDir('ASC');
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047 $collection = Mage::getModel('cms/block')->getCollection();
00048
00049 $this->setCollection($collection);
00050 return parent::_prepareCollection();
00051 }
00052
00053 protected function _prepareColumns()
00054 {
00055 $baseUrl = $this->getUrl();
00056
00057 $this->addColumn('title', array(
00058 'header' => Mage::helper('cms')->__('Title'),
00059 'align' => 'left',
00060 'index' => 'title',
00061 ));
00062
00063 $this->addColumn('identifier', array(
00064 'header' => Mage::helper('cms')->__('Identifier'),
00065 'align' => 'left',
00066 'index' => 'identifier'
00067 ));
00068
00069 if (!Mage::app()->isSingleStoreMode()) {
00070 $this->addColumn('store_id', array(
00071 'header' => Mage::helper('cms')->__('Store View'),
00072 'index' => 'store_id',
00073 'type' => 'store',
00074 'store_all' => true,
00075 'store_view' => true,
00076 'sortable' => false,
00077 'filter_condition_callback'
00078 => array($this, '_filterStoreCondition'),
00079 ));
00080 }
00081
00082 $this->addColumn('is_active', array(
00083 'header' => Mage::helper('cms')->__('Status'),
00084 'index' => 'is_active',
00085 'type' => 'options',
00086 'options' => array(
00087 0 => Mage::helper('cms')->__('Disabled'),
00088 1 => Mage::helper('cms')->__('Enabled')
00089 ),
00090 ));
00091
00092 $this->addColumn('creation_time', array(
00093 'header' => Mage::helper('cms')->__('Date Created'),
00094 'index' => 'creation_time',
00095 'type' => 'datetime',
00096 ));
00097
00098 $this->addColumn('update_time', array(
00099 'header' => Mage::helper('cms')->__('Last Modified'),
00100 'index' => 'update_time',
00101 'type' => 'datetime',
00102 ));
00103
00104 return parent::_prepareColumns();
00105 }
00106
00107 protected function _afterLoadCollection()
00108 {
00109 $this->getCollection()->walk('afterLoad');
00110 parent::_afterLoadCollection();
00111 }
00112
00113 protected function _filterStoreCondition($collection, $column)
00114 {
00115 if (!$value = $column->getFilter()->getValue()) {
00116 return;
00117 }
00118
00119 $this->getCollection()->addStoreFilter($value);
00120 }
00121
00122
00123
00124
00125
00126
00127 public function getRowUrl($row)
00128 {
00129 return $this->getUrl('*/*/edit', array('block_id' => $row->getId()));
00130 }
00131
00132 }