Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Index_Adminhtml_ProcessController
  • Mage_Index_Block_Adminhtml_Notifications
  • Mage_Index_Block_Adminhtml_Process
  • Mage_Index_Block_Adminhtml_Process_Edit
  • Mage_Index_Block_Adminhtml_Process_Edit_Form
  • Mage_Index_Block_Adminhtml_Process_Edit_Tab_Main
  • Mage_Index_Block_Adminhtml_Process_Edit_Tabs
  • Mage_Index_Block_Adminhtml_Process_Grid
  • Mage_Index_Block_Adminhtml_Process_Grid_Massaction
  • Mage_Index_Helper_Data
  • Mage_Index_Model_Event
  • Mage_Index_Model_Indexer
  • Mage_Index_Model_Indexer_Abstract
  • Mage_Index_Model_Mysql4_Abstract
  • Mage_Index_Model_Mysql4_Event
  • Mage_Index_Model_Mysql4_Event_Collection
  • Mage_Index_Model_Mysql4_Process
  • Mage_Index_Model_Mysql4_Process_Collection
  • Mage_Index_Model_Mysql4_Setup
  • Mage_Index_Model_Observer
  • Mage_Index_Model_Process
  • Mage_Index_Model_Resource_Abstract
  • Mage_Index_Model_Resource_Event
  • Mage_Index_Model_Resource_Event_Collection
  • Mage_Index_Model_Resource_Helper_Mysql4
  • Mage_Index_Model_Resource_Process
  • Mage_Index_Model_Resource_Process_Collection
  • Mage_Index_Model_Resource_Setup
  • Overview
  • Package
  • Class
  • Tree
  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_Index
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: class Mage_Index_Block_Adminhtml_Process_Grid extends Mage_Adminhtml_Block_Widget_Grid
 28: {
 29:     /**
 30:      * Process model
 31:      *
 32:      * @var Mage_Index_Model_Process
 33:      */
 34:     protected $_processModel;
 35: 
 36:     /**
 37:      * Mass-action block
 38:      *
 39:      * @var string
 40:      */
 41:     protected $_massactionBlockName = 'index/adminhtml_process_grid_massaction';
 42: 
 43:     /**
 44:      * Class constructor
 45:      */
 46:     public function __construct()
 47:     {
 48:         parent::__construct();
 49:         $this->_processModel = Mage::getSingleton('index/process');
 50:         $this->setId('indexer_processes_grid');
 51:         $this->_filterVisibility = false;
 52:         $this->_pagerVisibility  = false;
 53:     }
 54: 
 55:     /**
 56:      * Prepare grid collection
 57:      */
 58:     protected function _prepareCollection()
 59:     {
 60:         $collection = Mage::getResourceModel('index/process_collection');
 61:         $this->setCollection($collection);
 62:         return parent::_prepareCollection();
 63:     }
 64: 
 65:     /**
 66:      * Add name and description to collection elements
 67:      */
 68:     protected function _afterLoadCollection()
 69:     {
 70:         /** @var $item Mage_Index_Model_Process */
 71:         foreach ($this->_collection as $key => $item) {
 72:             if (!$item->getIndexer()->isVisible()) {
 73:                 $this->_collection->removeItemByKey($key);
 74:                 continue;
 75:             }
 76:             $item->setName($item->getIndexer()->getName());
 77:             $item->setDescription($item->getIndexer()->getDescription());
 78:             $item->setUpdateRequired($item->getUnprocessedEventsCollection()->count() > 0 ? 1 : 0);
 79:             if ($item->isLocked()) {
 80:                 $item->setStatus(Mage_Index_Model_Process::STATUS_RUNNING);
 81:             }
 82:         }
 83:         return $this;
 84:     }
 85: 
 86:     /**
 87:      * Prepare grid columns
 88:      */
 89:     protected function _prepareColumns()
 90:     {
 91:         $baseUrl = $this->getUrl();
 92:         $this->addColumn('indexer_code', array(
 93:             'header'    => Mage::helper('index')->__('Index'),
 94:             'width'     => '180',
 95:             'align'     => 'left',
 96:             'index'     => 'name',
 97:             'sortable'  => false,
 98:         ));
 99: 
100:         $this->addColumn('description', array(
101:             'header'    => Mage::helper('index')->__('Description'),
102:             'align'     => 'left',
103:             'index'     => 'description',
104:             'sortable'  => false,
105:         ));
106: 
107:         $this->addColumn('mode', array(
108:             'header'    => Mage::helper('index')->__('Mode'),
109:             'width'     => '150',
110:             'align'     => 'left',
111:             'index'     => 'mode',
112:             'type'      => 'options',
113:             'options'   => $this->_processModel->getModesOptions()
114:         ));
115: 
116:         $this->addColumn('status', array(
117:             'header'    => Mage::helper('index')->__('Status'),
118:             'width'     => '120',
119:             'align'     => 'left',
120:             'index'     => 'status',
121:             'type'      => 'options',
122:             'options'   => $this->_processModel->getStatusesOptions(),
123:             'frame_callback' => array($this, 'decorateStatus')
124:         ));
125: 
126:         $this->addColumn('update_required', array(
127:             'header'    => Mage::helper('index')->__('Update Required'),
128:             'sortable'  => false,
129:             'width'     => '120',
130:             'align'     => 'left',
131:             'index'     => 'update_required',
132:             'type'      => 'options',
133:             'options'   => $this->_processModel->getUpdateRequiredOptions(),
134:             'frame_callback' => array($this, 'decorateUpdateRequired')
135:         ));
136: 
137:         $this->addColumn('ended_at', array(
138:             'header'    => Mage::helper('index')->__('Updated At'),
139:             'type'      => 'datetime',
140:             'width'     => '180',
141:             'align'     => 'left',
142:             'index'     => 'ended_at',
143:             'frame_callback' => array($this, 'decorateDate')
144:         ));
145: 
146:         $this->addColumn('action',
147:             array(
148:                 'header'    =>  Mage::helper('index')->__('Action'),
149:                 'width'     => '100',
150:                 'type'      => 'action',
151:                 'getter'    => 'getId',
152:                 'actions'   => array(
153:                     array(
154:                         'caption'   => Mage::helper('index')->__('Reindex Data'),
155:                         'url'       => array('base'=> '*/*/reindexProcess'),
156:                         'field'     => 'process'
157:                     ),
158:                 ),
159:                 'filter'    => false,
160:                 'sortable'  => false,
161:                 'is_system' => true,
162:         ));
163: 
164:         return parent::_prepareColumns();
165:     }
166: 
167:     /**
168:      * Decorate status column values
169:      *
170:      * @param string $value
171:      * @param Mage_Index_Model_Process $row
172:      * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
173:      * @param bool $isExport
174:      * @return string
175:      */
176:     public function decorateStatus($value, $row, $column, $isExport)
177:     {
178:         $class = '';
179:         switch ($row->getStatus()) {
180:             case Mage_Index_Model_Process::STATUS_PENDING :
181:                 $class = 'grid-severity-notice';
182:                 break;
183:             case Mage_Index_Model_Process::STATUS_RUNNING :
184:                 $class = 'grid-severity-major';
185:                 break;
186:             case Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX :
187:                 $class = 'grid-severity-critical';
188:                 break;
189:         }
190:         return '<span class="'.$class.'"><span>'.$value.'</span></span>';
191:     }
192: 
193:     /**
194:      * Decorate "Update Required" column values
195:      *
196:      * @param string $value
197:      * @param Mage_Index_Model_Process $row
198:      * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
199:      * @param bool $isExport
200:      * @return string
201:      */
202:     public function decorateUpdateRequired($value, $row, $column, $isExport)
203:     {
204:         $class = '';
205:         switch ($row->getUpdateRequired()) {
206:             case 0:
207:                 $class = 'grid-severity-notice';
208:                 break;
209:             case 1:
210:                 $class = 'grid-severity-critical';
211:                 break;
212:         }
213:         return '<span class="'.$class.'"><span>'.$value.'</span></span>';
214:     }
215: 
216:     /**
217:      * Decorate last run date coumn
218:      *
219:      * @return string
220:      */
221:     public function decorateDate($value, $row, $column, $isExport)
222:     {
223:         if(!$value) {
224:             return $this->__('Never');
225:         }
226:         return $value;
227:     }
228: 
229:     /**
230:      * Get row edit url
231:      *
232:      * @return string
233:      */
234:     public function getRowUrl($row)
235:     {
236:         return $this->getUrl('*/*/edit', array('process'=>$row->getId()));
237:     }
238: 
239:     /**
240:      * Add mass-actions to grid
241:      */
242:     protected function _prepareMassaction()
243:     {
244:         $this->setMassactionIdField('process_id');
245:         $this->getMassactionBlock()->setFormFieldName('process');
246: 
247:         $modeOptions = Mage::getModel('index/process')->getModesOptions();
248: 
249:         $this->getMassactionBlock()->addItem('change_mode', array(
250:             'label'         => Mage::helper('index')->__('Change Index Mode'),
251:             'url'           => $this->getUrl('*/*/massChangeMode'),
252:             'additional'    => array(
253:                 'mode'      => array(
254:                     'name'      => 'index_mode',
255:                     'type'      => 'select',
256:                     'class'     => 'required-entry',
257:                     'label'     => Mage::helper('index')->__('Index mode'),
258:                     'values'    => $modeOptions
259:                 )
260:             )
261:         ));
262: 
263:         $this->getMassactionBlock()->addItem('reindex', array(
264:             'label'    => Mage::helper('index')->__('Reindex Data'),
265:             'url'      => $this->getUrl('*/*/massReindex'),
266:             'selected' => true,
267:         ));
268: 
269:         return $this;
270:     }
271: }
272: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0