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