本文整理汇总了PHP中PKPHandler::hashPageContext方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPHandler::hashPageContext方法的具体用法?PHP PKPHandler::hashPageContext怎么用?PHP PKPHandler::hashPageContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PKPHandler
的用法示例。
在下文中一共展示了PKPHandler::hashPageContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* Return the DBResultRange structure and misc. variables describing the current page of a set of pages.
* @param $rangeName string Symbolic name of range of pages; must match the Smarty {page_list ...} name.
* @param $contextData array If set, this should contain a set of data that are required to
* define the context of this request (for maintaining page numbers across requests).
* To disable persistent page contexts, set this variable to null.
* @return array ($pageNum, $dbResultRange)
*/
function &getRangeInfo($rangeName, $contextData = null)
{
//FIXME: is there any way to get around calling a Request (instead of a PKPRequest) here?
$context =& Request::getContext();
$pageNum = PKPRequest::getUserVar($rangeName . 'Page');
if (empty($pageNum)) {
$session =& PKPRequest::getSession();
$pageNum = 1;
// Default to page 1
if ($session && $contextData !== null) {
// See if we can get a page number from a prior request
$contextHash = PKPHandler::hashPageContext($contextData);
if (PKPRequest::getUserVar('clearPageContext')) {
// Explicitly clear the old page context
$session->unsetSessionVar("page-{$contextHash}");
} else {
$oldPage = $session->getSessionVar("page-{$contextHash}");
if (is_numeric($oldPage)) {
$pageNum = $oldPage;
}
}
}
} else {
$session =& PKPRequest::getSession();
if ($session && $contextData !== null) {
// Store the page number
$contextHash = PKPHandler::hashPageContext($contextData);
$session->setSessionVar("page-{$contextHash}", $pageNum);
}
}
if ($context) {
$count = $context->getSetting('itemsPerPage');
}
if (!isset($count)) {
$count = Config::getVar('interface', 'items_per_page');
}
import('db.DBResultRange');
if (isset($count)) {
$returner = new DBResultRange($count, $pageNum);
} else {
$returner = new DBResultRange(-1, -1);
}
return $returner;
}