PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/app/code/community/AW/Blog/Block/Manage/Blog/Grid.php

https://bitbucket.org/acidel/buykoala
PHP | 169 lines | 120 code | 23 blank | 26 comment | 1 complexity | 8512cedb5d215792e88738a9c3ecc758 MD5 | raw file
  1. <?php
  2. /**
  3. * aheadWorks Co.
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the EULA
  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://ecommerce.aheadworks.com/AW-LICENSE-COMMUNITY.txt
  11. *
  12. * =================================================================
  13. * MAGENTO EDITION USAGE NOTICE
  14. * =================================================================
  15. * This package designed for Magento COMMUNITY edition
  16. * aheadWorks does not guarantee correct work of this extension
  17. * on any other Magento edition except Magento COMMUNITY edition.
  18. * aheadWorks does not provide extension support in case of
  19. * incorrect edition usage.
  20. * =================================================================
  21. *
  22. * @category AW
  23. * @package AW_Blog
  24. * @version 1.1.1
  25. * @copyright Copyright (c) 2010-2012 aheadWorks Co. (http://www.aheadworks.com)
  26. * @license http://ecommerce.aheadworks.com/AW-LICENSE-COMMUNITY.txt
  27. */
  28. class AW_Blog_Block_Manage_Blog_Grid extends Mage_Adminhtml_Block_Widget_Grid {
  29. public function __construct() {
  30. parent::__construct();
  31. $this->setId('blogGrid');
  32. $this->setDefaultSort('created_time');
  33. $this->setDefaultDir('DESC');
  34. $this->setSaveParametersInSession(true);
  35. }
  36. protected function _getStore() {
  37. $storeId = (int) $this->getRequest()->getParam('store', 0);
  38. return Mage::app()->getStore($storeId);
  39. }
  40. protected function _prepareCollection() {
  41. $collection = Mage::getModel('blog/blog')->getCollection();
  42. $store = $this->_getStore();
  43. if ($store->getId()) {
  44. $collection->addStoreFilter($store);
  45. }
  46. $this->setCollection($collection);
  47. return parent::_prepareCollection();
  48. }
  49. protected function _prepareColumns() {
  50. $this->addColumn('post_id', array(
  51. 'header' => Mage::helper('blog')->__('ID'),
  52. 'align' => 'right',
  53. 'width' => '50px',
  54. 'index' => 'post_id',
  55. ));
  56. $this->addColumn('title', array(
  57. 'header' => Mage::helper('blog')->__('Title'),
  58. 'align' => 'left',
  59. 'index' => 'title',
  60. ));
  61. $this->addColumn('identifier', array(
  62. 'header' => Mage::helper('blog')->__('Identifier'),
  63. 'align' => 'left',
  64. 'index' => 'identifier',
  65. ));
  66. $this->addColumn('user', array(
  67. 'header' => Mage::helper('blog')->__('Poster'),
  68. 'width' => '150px',
  69. 'index' => 'user',
  70. ));
  71. $this->addColumn('created_time', array(
  72. 'header' => Mage::helper('blog')->__('Created at'),
  73. 'index' => 'created_time',
  74. 'type' => 'datetime',
  75. 'width' => '120px',
  76. 'gmtoffset' => true,
  77. 'default' => ' -- '
  78. ));
  79. $this->addColumn('update_time', array(
  80. 'header' => Mage::helper('blog')->__('Updated at'),
  81. 'index' => 'update_time',
  82. 'width' => '120px',
  83. 'type' => 'datetime',
  84. 'gmtoffset' => true,
  85. 'default' => ' -- '
  86. ));
  87. $this->addColumn('status', array(
  88. 'header' => Mage::helper('blog')->__('Status'),
  89. 'align' => 'left',
  90. 'width' => '80px',
  91. 'index' => 'status',
  92. 'type' => 'options',
  93. 'options' => array(
  94. 1 => Mage::helper('blog')->__('Enabled'),
  95. 2 => Mage::helper('blog')->__('Disabled'),
  96. 3 => Mage::helper('blog')->__('Hidden'),
  97. ),
  98. ));
  99. $this->addColumn('action', array(
  100. 'header' => Mage::helper('blog')->__('Action'),
  101. 'width' => '100',
  102. 'type' => 'action',
  103. 'getter' => 'getId',
  104. 'actions' => array(
  105. array(
  106. 'caption' => Mage::helper('blog')->__('Edit'),
  107. 'url' => array('base' => '*/*/edit'),
  108. 'field' => 'id'
  109. )
  110. ),
  111. 'filter' => false,
  112. 'sortable' => false,
  113. 'index' => 'stores',
  114. 'is_system' => true,
  115. ));
  116. return parent::_prepareColumns();
  117. }
  118. protected function _prepareMassaction() {
  119. $this->setMassactionIdField('post_id');
  120. $this->getMassactionBlock()->setFormFieldName('blog');
  121. $this->getMassactionBlock()->addItem('delete', array(
  122. 'label' => Mage::helper('blog')->__('Delete'),
  123. 'url' => $this->getUrl('*/*/massDelete'),
  124. 'confirm' => Mage::helper('blog')->__('Are you sure?')
  125. ));
  126. $statuses = Mage::getSingleton('blog/status')->getOptionArray();
  127. array_unshift($statuses, array('label' => '', 'value' => ''));
  128. $this->getMassactionBlock()->addItem('status', array(
  129. 'label' => Mage::helper('blog')->__('Change status'),
  130. 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
  131. 'additional' => array(
  132. 'visibility' => array(
  133. 'name' => 'status',
  134. 'type' => 'select',
  135. 'class' => 'required-entry',
  136. 'label' => Mage::helper('blog')->__('Status'),
  137. 'values' => $statuses
  138. )
  139. )
  140. ));
  141. return $this;
  142. }
  143. public function getRowUrl($row) {
  144. return $this->getUrl('*/*/edit', array('id' => $row->getId()));
  145. }
  146. }