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_Tag_Tag_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: 37: 38: 39: 40:
41: public function __construct()
42: {
43: parent::__construct();
44: $this->setId('tag_tag_grid')
45: ->setDefaultSort('name')
46: ->setDefaultDir('ASC')
47: ->setUseAjax(true)
48: ->setSaveParametersInSession(true);
49: }
50:
51: protected function _addColumnFilterToCollection($column)
52: {
53: if($column->getIndex()=='stores') {
54: $this->getCollection()->addStoreFilter($column->getFilter()->getCondition(), false);
55: } else {
56: parent::_addColumnFilterToCollection($column);
57: }
58: return $this;
59: }
60:
61: protected function _prepareCollection()
62: {
63: $collection = Mage::getResourceModel('tag/tag_collection')
64: ->addSummary(Mage::app()->getStore()->getId())
65: ->addStoresVisibility();
66: $this->setCollection($collection);
67: return parent::_prepareCollection();
68: }
69:
70: protected function _prepareColumns()
71: {
72: $this->addColumn('name', array(
73: 'header' => Mage::helper('tag')->__('Tag'),
74: 'index' => 'name',
75: ));
76:
77: $this->addColumn('products', array(
78: 'header' => Mage::helper('tag')->__('Products'),
79: 'width' => 140,
80: 'align' => 'right',
81: 'index' => 'products',
82: 'type' => 'number',
83: ));
84:
85: $this->addColumn('customers', array(
86: 'header' => Mage::helper('tag')->__('Customers'),
87: 'width' => 140,
88: 'align' => 'right',
89: 'index' => 'customers',
90: 'type' => 'number',
91: ));
92:
93: $this->addColumn('status', array(
94: 'header' => Mage::helper('tag')->__('Status'),
95: 'width' => 90,
96: 'index' => 'status',
97: 'type' => 'options',
98: 'options' => $this->helper('tag/data')->getStatusesArray(),
99: ));
100:
101: if (!Mage::app()->isSingleStoreMode()) {
102: $this->addColumn('visible_in', array(
103: 'header' => Mage::helper('tag')->__('Store View'),
104: 'type' => 'store',
105: 'skipAllStoresLabel' => true,
106: 'index' => 'stores',
107: 'sortable' => false,
108: 'store_view' => true
109: ));
110: }
111:
112: return parent::_prepareColumns();
113: }
114:
115: protected function _prepareMassaction()
116: {
117: $this->setMassactionIdField('tag_id');
118: $this->getMassactionBlock()->setFormFieldName('tag');
119:
120: $this->getMassactionBlock()->addItem('delete', array(
121: 'label' => Mage::helper('tag')->__('Delete'),
122: 'url' => $this->getUrl('*/*/massDelete'),
123: 'confirm' => Mage::helper('tag')->__('Are you sure?')
124: ));
125:
126: $statuses = $this->helper('tag/data')->getStatusesOptionsArray();
127:
128: array_unshift($statuses, array('label'=>'', 'value'=>''));
129:
130: $this->getMassactionBlock()->addItem('status', array(
131: 'label'=> Mage::helper('tag')->__('Change status'),
132: 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
133: 'additional' => array(
134: 'visibility' => array(
135: 'name' => 'status',
136: 'type' => 'select',
137: 'class' => 'required-entry',
138: 'label' => Mage::helper('tag')->__('Status'),
139: 'values' => $statuses
140: )
141: )
142: ));
143:
144: return $this;
145: }
146:
147: 148: 149: 150: 151:
152: public function getGridUrl()
153: {
154: return $this->getUrl('*/tag/ajaxGrid', array('_current' => true));
155: }
156:
157: 158: 159: 160: 161: 162:
163: public function getRowUrl($row)
164: {
165: return $this->getUrl('*/*/edit', array('tag_id' => $row->getId()));
166: }
167: }
168: