/** * Set and apply filter values * * @param array $data Filter values * @return this */ protected function _setFilterValues($data) { if ($this->_blcg_holdPrepareCollection) { // Do not allow to set filters now, as we want to get the maximum of chances of getting items return $this; } else { if (!is_null($this->_blcg_gridModel)) { // Filter filters $data = $this->_blcg_gridModel->verifyGridBlockFilters($this, $data); } return parent::_setFilterValues($data); } }
/** * Rewrite a grid block, to add it some useful/needed methods * * @param BL_CustomGrid_Model_Grid $grid * @return bool */ protected function _rewriteGridBlock($grid) { // Get block infos list($group, $class, $rewritingClassName) = $this->_getBlockTypeInfos($grid->getBlockType()); if (!$rewritingClassName && $grid->getRewritingClassName() == '' || $rewritingClassName == $grid->getRewritingClassName()) { // Grid model corresponds to current configuration if (Mage::helper('customgrid/config')->isExcludedGrid($grid->getBlockType(), $rewritingClassName)) { // Do not rewrite if now excluded $this->_excludedModels[] = $grid->getId(); } elseif (!isset($this->_rewritedTypes[$grid->getBlockType()])) { // Register our rewriting class (extending previous rewrite if existing) $className = 'BL_CustomGrid_Block_Rewrite_' . uc_words($class); $extends = $rewritingClassName ? $rewritingClassName : $this->_getBlockClassName($group, $class); $this->_registerGridClass($className, $extends); if ($rewritingClassName) { $this->_originalRewrites[$grid->getBlockType()] = $rewritingClassName; } // Register rewrite in config (this will also replace previous rewrite if existing) // This doesnt seem to affect Magento config cache in any way $rewriteXml = new Varien_Simplexml_Config(); $rewriteXml->loadString(' <config> <global> <blocks> <' . $group . '> <rewrite> <' . $class . '>' . $className . '</' . $class . '> </rewrite> </' . $group . '> </blocks> </global> </config> '); $this->_getConfig()->extend($rewriteXml, true); // Remember current type is now rewrited $this->_rewritedTypes[$grid->getBlockType()] = true; } return true; } else { return false; } }
/** * Check if user can edit given value * * @param string $type Grid block type * @param array $config Edited value config * @param array $params Edit parameters * @param mixed $entity Edited entity * @param BL_CustomGrid_Model_Grid $model Custom grid model * @return bool */ protected function _canEditValue($type, $config, $params, $entity, $model) { if ($this->isEditableValue($type, $config['id'], $config['origin'])) { if (isset($params['additional']['column_id']) && ($column = $model->getColumnFromDbId($params['additional']['column_id'])) && $column['allow_edit']) { return $this->checkUserEditPermissions($type, $model, null, $params); } } return false; }
/** * Rewrite a grid block, to add it some useful/needed methods * * @param BL_CustomGrid_Model_Grid $grid * @return bool */ protected function _rewriteGridBlock($grid) { // Get block infos list($group, $class, $rewritingClassName) = $this->_getBlockTypeInfos($grid->getBlockType()); if (!$rewritingClassName && $grid->getRewritingClassName() == '' || $rewritingClassName == $grid->getRewritingClassName()) { // Grid model corresponds to current configuration if ($this->_getConfigHelper()->isExcludedGrid($grid->getBlockType(), $rewritingClassName)) { // Do not rewrite if now excluded $this->_excludedModels[] = $grid->getId(); } elseif (!isset($this->_rewritedTypes[$grid->getBlockType()])) { // Generate and register our rewriting class (extending previous rewrite if existing) $rewriters = Mage::getSingleton('customgrid/grid_rewriter')->getEnabledRewriters(true); $blcgClass = false; $originalClass = $rewritingClassName ? $rewritingClassName : $this->_getBlockClassName($group, $class); $rewriteErrors = array(); foreach ($rewriters as $rewriter) { try { $blcgClass = $rewriter->rewriteGrid($originalClass, $grid->getBlockType()); } catch (Exception $e) { $blcgClass = false; $rewriteErrors[] = array('exception' => $e, 'rewriter' => $rewriter); } if ($blcgClass) { break; } } if ($blcgClass) { foreach ($rewriteErrors as $error) { if ($error['rewriter']->getDisplayErrorsIfSuccess()) { $this->_getSession()->addError($error['exception']->getMessage()); } if ($error['rewriter']->getLogErrorsIfSuccess()) { Mage::logException($error['exception']); } } if ($rewritingClassName) { $this->_originalRewrites[$grid->getBlockType()] = $rewritingClassName; } // Register rewrite in config (this will also replace previous rewrite if existing) // This doesnt seem to affect Magento config cache in any way $rewriteXml = new Varien_Simplexml_Config(); $rewriteXml->loadString(' <config> <global> <blocks> <' . $group . '> <rewrite> <' . $class . '>' . $blcgClass . '</' . $class . '> </rewrite> </' . $group . '> </blocks> </global> </config> '); $this->_getConfig()->extend($rewriteXml, true); if ($this->_getConfigHelper()->getForceGridRewrites()) { // Put the rewriting class name in the config cache (should prevent some problems when the config gets overriden afterwards) $this->_getConfig()->getBlockClassName($grid->getBlockType()); } // Remember current type is now rewrited $this->_rewritedTypes[$grid->getBlockType()] = true; } else { foreach ($rewriteErrors as $error) { if ($error['rewriter']->getDisplayErrors()) { $this->_getSession()->addError($error['exception']->getMessage()); } if ($error['rewriter']->getLogErrors()) { Mage::logException($error['exception']); } } // Exclude failed rewrites $this->_excludedModels[] = $grid->getId(); } } return true; } else { return false; } }
public static function getGridActions() { if (is_null(self::$_gridActions)) { $helper = Mage::helper('customgrid'); self::$_gridActions = array(self::GRID_ACTION_CUSTOMIZE_COLUMNS => $helper->__('Customize Columns'), self::GRID_ACTION_USE_CUSTOMIZED_COLUMNS => $helper->__('Use Customized Columns'), self::GRID_ACTION_VIEW_GRID_INFOS => $helper->__('View Grids Informations'), self::GRID_ACTION_EDIT_DEFAULT_PARAMS => $helper->__('Edit Default Parameters'), self::GRID_ACTION_USE_DEFAULT_PARAMS => $helper->__('Use Default Parameters'), self::GRID_ACTION_EXPORT_RESULTS => $helper->__('Export Results'), self::GRID_ACTION_CHOOSE_EDITABLE_COLUMNS => $helper->__('Choose Editable Columns'), self::GRID_ACTION_EDIT_COLUMNS_VALUES => $helper->__('Edit Columns Values')); } return self::$_gridActions; }
/** * Return column origins options hash * * @return array */ public static function getColumnOrigins() { if (is_null(self::$_columnOrigins)) { $helper = Mage::helper('customgrid'); self::$_columnOrigins = array(self::GRID_COLUMN_ORIGIN_GRID => $helper->__('Grid'), self::GRID_COLUMN_ORIGIN_COLLECTION => $helper->__('Collection'), self::GRID_COLUMN_ORIGIN_ATTRIBUTE => $helper->__('Attribute')); } return self::$_columnOrigins; }