本文整理汇总了PHP中Mage_Adminhtml_Block_Widget_Grid::blcg_getSaveParametersInSession方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Adminhtml_Block_Widget_Grid::blcg_getSaveParametersInSession方法的具体用法?PHP Mage_Adminhtml_Block_Widget_Grid::blcg_getSaveParametersInSession怎么用?PHP Mage_Adminhtml_Block_Widget_Grid::blcg_getSaveParametersInSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Adminhtml_Block_Widget_Grid
的用法示例。
在下文中一共展示了Mage_Adminhtml_Block_Widget_Grid::blcg_getSaveParametersInSession方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyGridBlockFilters
//.........这里部分代码省略.........
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
*/
/*
Add our token to current request and session
Use ":" in hash to force Varien_Db_Adapter_Pdo_Mysql::query() using a bind param instead of full request path,
(as it uses this condition : strpos($sql, ':') !== false),
when querying core_url_rewrite table, else the query could be too long,
making Zend_Db_Statement::_stripQuoted() sometimes crash on one of its call to preg_replace()
*/
$tokenValue = Mage::helper('core')->uniqHash('blcg:');
$grid->getRequest()->setParam(self::GRID_TOKEN_PARAM_NAME, $tokenValue);
$session->setData(self::SESSION_BASE_KEY_TOKEN . $this->getId(), $tokenValue);
// Remove obsolete filters and save up-to-date filters array to session
$obsoleteIds = array_diff(array_keys($sessionFilters), $foundIds);
foreach ($obsoleteIds as $columnId) {
unset($sessionFilters[$columnId]);
}
$session->setData(self::SESSION_BASE_KEY_APPLIED_FILTERS . $this->getId(), $sessionFilters);
/*
Remove removed filters once a grid action is done
The only remaining potential source of "maybe wrong" filters could come from
the use of an old URL with obsolete filter(s) in it (eg from browser history),
but there is no way at the moment to detect them
(at least I didnt find a simple one with few impacts)
*/
if ($isGridAction) {
$session->setData(self::SESSION_BASE_KEY_REMOVED_FILTERS . $this->getId(), array_intersect_key($removedFilters, $newRemovedIds));
} else {
$session->setData(self::SESSION_BASE_KEY_REMOVED_FILTERS . $this->getId(), $removedFilters);
}
$filterParam = $this->encodeGridFiltersArray($filters);
if ($grid->blcg_getSaveParametersInSession()) {
$session->setData($grid->blcg_getSessionParamKey($grid->getVarNameFilter()), $filterParam);
}
if ($grid->getRequest()->has($grid->getVarNameFilter())) {
$grid->getRequest()->setParam($grid->getVarNameFilter(), $filterParam);
}
$grid->blcg_setFilterParam($filterParam);
return $filters;
}