本文整理汇总了PHP中Mage_Adminhtml_Block_Widget_Grid::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Adminhtml_Block_Widget_Grid::getRequest方法的具体用法?PHP Mage_Adminhtml_Block_Widget_Grid::getRequest怎么用?PHP Mage_Adminhtml_Block_Widget_Grid::getRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Adminhtml_Block_Widget_Grid
的用法示例。
在下文中一共展示了Mage_Adminhtml_Block_Widget_Grid::getRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyGridBlockFilters
/**
* Verify validities of filters applied to given grid block,
* and return safely appliable filters
* Mostly used for custom columns, which may change of renderers
* (and those renderers may crash with unexpected kind of filter values)
*
* @param Mage_Adminhtml_Block_Widget_Grid $grid Grid block
* @param array $filters Applied filters
* @return array
*/
public function verifyGridBlockFilters(Mage_Adminhtml_Block_Widget_Grid $grid, $filters)
{
// Get previous filters informations from session
$session = Mage::getSingleton('adminhtml/session');
// Applied ones
$sessionFilters = $session->getData(self::SESSION_BASE_KEY_APPLIED_FILTERS . $this->getId());
$sessionFilters = is_array($sessionFilters) ? $sessionFilters : array();
// Removed ones
$removedFilters = $session->getData(self::SESSION_BASE_KEY_REMOVED_FILTERS . $this->getId());
$removedFilters = is_array($removedFilters) ? $removedFilters : array();
$foundIds = array();
$newRemovedIds = array();
$attributesRenderers = $this->getAvailableAttributesRendererTypes();
/*
Verify grid tokens, if request one does not correspond to session one,
then it is almost sure that we currently come from anywhere but from an effective grid action
(such as search, sort, export, pagination, ...)
May be too restrictive, but at the moment, rather be too restrictive than not enough
*/
if ($grid->getRequest()->has(self::GRID_TOKEN_PARAM_NAME) && $session->hasData(self::SESSION_BASE_KEY_TOKEN . $this->getId())) {
$requestValue = $grid->getRequest()->getParam(self::GRID_TOKEN_PARAM_NAME, null);
$sessionValue = $session->getData(self::SESSION_BASE_KEY_TOKEN . $this->getId());
$isGridAction = $requestValue == $sessionValue;
} else {
$isGridAction = false;
}
$columns = $this->getColumns(false, true);
foreach ($filters as $columnId => $data) {
if (isset($columns[$columnId])) {
$column = $columns[$columnId];
if (isset($sessionFilters[$columnId])) {
// Previously existing/applied filter
$changed = false;
if ($sessionFilters[$columnId]['origin'] != $column['origin']) {
$changed = true;
} elseif ($this->isCollectionColumnOrigin($column['origin'])) {
// Check renderer types for collection columns
$changed = $sessionFilters[$columnId]['renderer_type'] != $column['renderer_type'];
} elseif ($this->isAttributeColumnOrigin($column['origin'])) {
// Check corrresponding attributes renderers for attribute columns
$oldIndex = $sessionFilters[$columnId]['index'];
if (isset($attributesRenderers[$oldIndex])) {
$changed = $attributesRenderers[$oldIndex] != $attributesRenderers[$column['index']];
} else {
$changed = true;
}
} elseif ($this->isCustomColumnOrigin($column['origin'])) {
/*
Check index (= corresponding model - although not meant to change),
renderer type and custom params for custom columns
*/
$oldIndex = $sessionFilters[$columnId]['index'];
$typeModel = Mage::getSingleton('customgrid/grid_type');
$rendererTypes = array('old' => $sessionFilters[$columnId]['renderer_type'], 'new' => $column['renderer_type']);
$customParams = array('old' => $typeModel->decodeParameters($sessionFilters[$columnId]['custom_params'], true), 'new' => $typeModel->decodeParameters($column['custom_params'], true));
if ($oldIndex != $column['index'] || !is_object($column['custom_column']) || $column['custom_column']->shouldInvalidateFilters($this, $column, $customParams, $rendererTypes)) {
$changed = true;
}
}
if ($changed) {
// Column has significantly changed, unvalidate filter
// Remove filter from filters array, to prevent it from being applied
unset($filters[$columnId]);
// Remove filter from session, to allow new filters to later be set on this column
unset($sessionFilters[$columnId]);
// Remember which value has been unvalidated, to prevent it to be re-applied from, eg, a page refresh
$removedFilters[$columnId] = $data;
$newRemovedIds[] = $columnId;
}
} elseif (isset($removedFilters[$columnId]) && !$isGridAction) {
// Filter on a column for which another applied filter was previously removed
if ($this->compareGridFilterValues($removedFilters[$columnId], $data)) {
// Previously removed filter had same value, unvalidate it again
unset($filters[$columnId]);
}
} else {
// New filter, remember some needed informations in session
$sessionFilters[$columnId] = array('index' => $column['index'], 'origin' => $column['origin'], 'renderer_type' => $column['renderer_type'], 'custom_params' => $column['custom_params']);
}
$foundIds[] = $columnId;
} else {
// Unexisting column : unneeded filter
unset($filters[$columnId]);
}
}
/**
* Note : adding new parameters to grid request
* will make them be added to, eg, URLs got from next retrievals of current URL
*/
/*
//.........这里部分代码省略.........