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_Tag_Grid_Pending extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('pending_grid');
00041 $this->setDefaultSort('name');
00042 $this->setDefaultDir('ASC');
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047 $collection = Mage::getResourceModel('tag/tag_collection')
00048 ->addSummary(0)
00049 ->addStoresVisibility()
00050 ->addStatusFilter(Mage_Tag_Model_Tag::STATUS_PENDING);
00051 $this->setCollection($collection);
00052 return parent::_prepareCollection();
00053 }
00054
00055 protected function _prepareColumns()
00056 {
00057 $baseUrl = $this->getUrl();
00058
00059 $this->addColumn('name', array(
00060 'header' => Mage::helper('tag')->__('Tag'),
00061 'index' => 'name',
00062 ));
00063
00064 $this->addColumn('total_used', array(
00065 'header' => Mage::helper('tag')->__('Uses'),
00066 'width' => '140px',
00067 'align' => 'right',
00068 'index' => 'uses',
00069 'type' => 'number',
00070 ));
00071
00072 $this->addColumn('products', array(
00073 'header' => Mage::helper('tag')->__('Products'),
00074 'width' => '140px',
00075 'align' => 'right',
00076 'index' => 'products',
00077 'type' => 'number',
00078 ));
00079
00080 $this->addColumn('customers', array(
00081 'header' => Mage::helper('tag')->__('Customers'),
00082 'width' => '140px',
00083 'align' => 'right',
00084 'index' => 'customers',
00085 'type' => 'number',
00086 ));
00087
00088 $this->addColumn('popularity', array(
00089 'header' => Mage::helper('tag')->__('Popularity'),
00090 'width' => '140px',
00091 'align' => 'right',
00092 'index' => 'popularity',
00093 'type' => 'number',
00094 ));
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 if (!$collection = Mage::registry('stores_select_collection')) {
00114 $collection = Mage::app()->getStore()->getResourceCollection()
00115 ->load();
00116 Mage::register('stores_select_collection', $collection);
00117 }
00118
00119 if (!Mage::app()->isSingleStoreMode()) {
00120 $this->addColumn('visible_in', array(
00121 'header' => Mage::helper('tag')->__('Visible In'),
00122 'type' => 'store',
00123 'index' => 'stores',
00124 'sortable' => false,
00125 'store_view'=> true
00126 ));
00127 }
00128
00129 $this->addColumn('actions', array(
00130 'header' => Mage::helper('tag')->__('Actions'),
00131 'width' => '100px',
00132 'type' => 'action',
00133 'sortable' => false,
00134 'filter' => false,
00135 'actions' => array(
00136 array(
00137 'caption' => Mage::helper('tag')->__('Edit Tag'),
00138 'url' => $this->getUrl('*/*/edit', array('ret' => 'pending', 'tag_id'=>'$tag_id')),
00139 ),
00140 array(
00141 'caption' => Mage::helper('tag')->__('View Products'),
00142 'url' => $this->getUrl('*/*/product', array('ret' => 'pending', 'tag_id'=>'$tag_id')),
00143 ),
00144
00145 array(
00146 'caption' => Mage::helper('tag')->__('View Customers'),
00147 'url' => $this->getUrl('*/*/customer', array('ret' => 'pending', 'tag_id'=>'$tag_id')),
00148 )
00149 ),
00150 ));
00151
00152 return parent::_prepareColumns();
00153 }
00154
00155 public function getRowUrl($row)
00156 {
00157 return $this->getUrl('*/*/edit', array(
00158 'tag_id' => $row->getId(),
00159 'ret' => 'pending',
00160 ));
00161 }
00162
00163 protected function _addColumnFilterToCollection($column)
00164 {
00165 if($column->getIndex()=='stores') {
00166 $this->getCollection()->addStoreFilter($column->getFilter()->getCondition(), false);
00167 } else {
00168 parent::_addColumnFilterToCollection($column);
00169 }
00170
00171 return $this;
00172 }
00173
00174 protected function _prepareMassaction()
00175 {
00176 $this->setMassactionIdField('tag_id');
00177 $this->getMassactionBlock()->setFormFieldName('tag');
00178
00179 $this->getMassactionBlock()->addItem('delete', array(
00180 'label'=> Mage::helper('tag')->__('Delete'),
00181 'url' => $this->getUrl('*/*/massDelete', array('ret' => 'pending')),
00182 'confirm' => Mage::helper('tag')->__('Are you sure?')
00183 ));
00184
00185 $statuses = $this->helper('tag/data')->getStatusesOptionsArray();
00186
00187 array_unshift($statuses, array('label'=>'', 'value'=>''));
00188
00189 $this->getMassactionBlock()->addItem('status', array(
00190 'label'=> Mage::helper('tag')->__('Change status'),
00191 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true, 'ret' => 'pending')),
00192 'additional' => array(
00193 'visibility' => array(
00194 'name' => 'status',
00195 'type' => 'select',
00196 'class' => 'required-entry',
00197 'label' => Mage::helper('tag')->__('Status'),
00198 'values' => $statuses
00199 )
00200 )
00201 ));
00202
00203 return $this;
00204 }
00205
00206 }