本文整理汇总了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);