PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/core/Mage/Adminhtml/Block/Tag/Tag/Grid.php

https://github.com/guiohm/magento-french
PHP | 183 lines | 117 code | 19 blank | 47 comment | 3 complexity | e31e1a36af8d1c560b7b6538c5e9e3d5 MD5 | raw file
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Adminhtml
  23. * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Adminhtml all tags grid
  28. *
  29. * @category Mage
  30. * @package Mage_Adminhtml
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Adminhtml_Block_Tag_Tag_Grid extends Mage_Adminhtml_Block_Widget_Grid
  34. {
  35. /**
  36. * Constructor
  37. *
  38. * @return void
  39. */
  40. public function __construct()
  41. {
  42. parent::__construct();
  43. $this->setId('tag_tag_grid')
  44. ->setDefaultSort('name')
  45. ->setDefaultDir('ASC')
  46. ->setUseAjax(true)
  47. ->setSaveParametersInSession(true);
  48. }
  49. protected function _addColumnFilterToCollection($column)
  50. {
  51. if($column->getIndex()=='stores') {
  52. $this->getCollection()->addStoreFilter($column->getFilter()->getCondition(), false);
  53. } else {
  54. parent::_addColumnFilterToCollection($column);
  55. }
  56. return $this;
  57. }
  58. protected function _prepareCollection()
  59. {
  60. $collection = Mage::getResourceModel('tag/tag_collection')
  61. ->addSummary(Mage::app()->getStore()->getId())
  62. ->addStoresVisibility();
  63. $this->setCollection($collection);
  64. return parent::_prepareCollection();
  65. }
  66. protected function _prepareColumns()
  67. {
  68. $this->addColumn('name', array(
  69. 'header' => Mage::helper('tag')->__('Tag'),
  70. 'index' => 'name',
  71. ));
  72. $this->addColumn('total_used', array(
  73. 'header' => Mage::helper('tag')->__('Uses'),
  74. 'width' => 140,
  75. 'align' => 'right',
  76. 'index' => 'uses',
  77. 'type' => 'number',
  78. ));
  79. $this->addColumn('products', array(
  80. 'header' => Mage::helper('tag')->__('Products'),
  81. 'width' => 140,
  82. 'align' => 'right',
  83. 'index' => 'products',
  84. 'type' => 'number',
  85. ));
  86. $this->addColumn('customers', array(
  87. 'header' => Mage::helper('tag')->__('Customers'),
  88. 'width' => 140,
  89. 'align' => 'right',
  90. 'index' => 'customers',
  91. 'type' => 'number',
  92. ));
  93. $this->addColumn('popularity', array(
  94. 'header' => Mage::helper('tag')->__('Popularity'),
  95. 'width' => 140,
  96. 'align' => 'right',
  97. 'index' => 'popularity',
  98. 'type' => 'number',
  99. ));
  100. $this->addColumn('status', array(
  101. 'header' => Mage::helper('tag')->__('Status'),
  102. 'width' => 90,
  103. 'index' => 'status',
  104. 'type' => 'options',
  105. 'options' => $this->helper('tag/data')->getStatusesArray(),
  106. ));
  107. if (!Mage::app()->isSingleStoreMode()) {
  108. $this->addColumn('visible_in', array(
  109. 'header' => Mage::helper('tag')->__('Visible In'),
  110. 'type' => 'store',
  111. 'skipAllStoresLabel' => true,
  112. 'index' => 'stores',
  113. 'sortable' => false,
  114. 'store_view' => true
  115. ));
  116. }
  117. return parent::_prepareColumns();
  118. }
  119. protected function _prepareMassaction()
  120. {
  121. $this->setMassactionIdField('tag_id');
  122. $this->getMassactionBlock()->setFormFieldName('tag');
  123. $this->getMassactionBlock()->addItem('delete', array(
  124. 'label' => Mage::helper('tag')->__('Delete'),
  125. 'url' => $this->getUrl('*/*/massDelete'),
  126. 'confirm' => Mage::helper('tag')->__('Are you sure?')
  127. ));
  128. $statuses = $this->helper('tag/data')->getStatusesOptionsArray();
  129. array_unshift($statuses, array('label'=>'', 'value'=>''));
  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. return $this;
  144. }
  145. /*
  146. * Retrieves Grid Url
  147. *
  148. * @return string
  149. */
  150. public function getGridUrl()
  151. {
  152. return $this->getUrl('*/tag/ajaxGrid', array('_current' => true));
  153. }
  154. /**
  155. * Retrives row click URL
  156. *
  157. * @param mixed $row
  158. * @return string
  159. */
  160. public function getRowUrl($row)
  161. {
  162. return $this->getUrl('*/*/edit', array('tag_id' => $row->getId()));
  163. }
  164. }