本文整理匯總了PHP中PageList::setPermissionsChecker方法的典型用法代碼示例。如果您正苦於以下問題:PHP PageList::setPermissionsChecker方法的具體用法?PHP PageList::setPermissionsChecker怎麽用?PHP PageList::setPermissionsChecker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PageList
的用法示例。
在下文中一共展示了PageList::setPermissionsChecker方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: view
public function view()
{
session_write_close();
$keywords = $_REQUEST['q'];
$pl = new \PageList();
$pl->filterByName($keywords);
$pl->sortBy('cID', 'asc');
$pl->setItemsPerPage(5);
$pl->setPermissionsChecker(function ($page) {
$pp = new \Permissions($page);
return $pp->canViewPageInSitemap();
});
$pagination = $pl->getPagination();
$pages = $pagination->getCurrentPageResults();
$results = array();
$nh = \Core::make('helper/navigation');
foreach ($pages as $c) {
$obj = new \stdClass();
$obj->href = $nh->getLinkToCollection($c);
$obj->cID = $c->getCollectionID();
$obj->name = $c->getCollectionName();
$results[] = $obj;
}
echo json_encode($results);
\Core::shutdown(array('jobs' => true));
}
示例2: die
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$u = new User();
$sh = Loader::helper('concrete/dashboard/sitemap');
if (!$sh->canRead()) {
die(t('Access Denied'));
}
session_write_close();
session_write_close();
$keywords = $_REQUEST['q'];
$pl = new PageList();
$pl->filterByName($keywords);
$pl->sortBy('cID', 'asc');
$pl->setItemsPerPage(5);
$pl->setPermissionsChecker(function ($page) {
$pp = new Permissions($page);
return $pp->canViewPageInSitemap();
});
$pagination = $pl->getPagination();
$pages = $pagination->getCurrentPageResults();
$results = array();
$nh = Loader::helper('navigation');
foreach ($pages as $c) {
$obj = new stdClass();
$obj->href = $nh->getLinkToCollection($c);
$obj->cID = $c->getCollectionID();
$obj->name = $c->getCollectionName();
$results[] = $obj;
}
print Loader::helper("json")->encode($results);