本文整理汇总了PHP中PageList::setItemsPerPage方法的典型用法代码示例。如果您正苦于以下问题:PHP PageList::setItemsPerPage方法的具体用法?PHP PageList::setItemsPerPage怎么用?PHP PageList::setItemsPerPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageList
的用法示例。
在下文中一共展示了PageList::setItemsPerPage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: run
public function run()
{
$cfg = new Config();
$pNum = (int) $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
$pNum = $pNum < 0 ? 1 : $pNum + 1;
$pl = new PageList();
$pl->setItemsPerPage(3);
/* probably want to keep a record of pages that have been gone through
* so you don't start from the beginning each time..
*/
$pages = $pl->getPage($pNum);
if (!count($pages)) {
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
return t("All pages have been processed, starting from beginning on next run.");
}
$versionCount = 0;
$pagesAffected = array();
foreach ($pages as $page) {
if ($page instanceof Page) {
$pvl = new VersionList($page);
$pagesAffected[] = $page->getCollectionID();
foreach (array_slice(array_reverse($pvl->getVersionListArray()), 10) as $v) {
if ($v instanceof CollectionVersion && !$v->isApproved() && !$v->isMostRecent()) {
@$v->delete();
$versionCount++;
}
}
}
}
$pageCount = count($pagesAffected);
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
//i18n: %1$d is the number of versions deleted, %2$d is the number of affected pages, %3$d is the number of times that the Remove Old Page Versions job has been executed.
return t2('%1$d versions deleted from %2$d page (%3$d)', '%1$d versions deleted from %2$d pages (%3$s)', $pageCount, $versionCount, $pageCount, implode(',', $pagesAffected));
}
示例3: run
public function run()
{
//$u = new User();
//if(!$u->isSuperUser()) { die(t("Access Denied."));} // cheap security check...
$cfg = new Config();
Loader::model('page_list');
$pl = new PageList();
//$pl->ignorePermissions();
$pNum = $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
if ($pNum <= 0) {
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
}
$pl->setItemsPerPage(3);
/* probably want to keep a record of pages that have been gone through
* so you don't start from the beginning each time..
*/
$pNum = $pNum + 1;
$pages = $pl->getPage($pNum);
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
$pageCount = 0;
$versionCount = 0;
if (count($pages) == 0) {
$cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
return t("All pages have been processes, starting from beginning on next run.");
}
foreach ($pages as $page) {
if ($page instanceof Page) {
$pvl = new VersionList($page);
$versions = $pvl->getVersionListArray();
$versions = array_reverse($versions);
$vCount = count($versions);
if ($vCount <= 10) {
continue;
}
$pageCount++;
$stopAt = $vCount - 10;
$i = 0;
foreach ($versions as $v) {
if ($v instanceof CollectionVersion) {
if ($v->isApproved() || $v->isMostRecent()) {
// may want to add a date check here too
continue;
} else {
@$v->delete();
$versionCount++;
}
}
$i++;
if ($i >= $stopAt) {
break;
}
}
}
}
$pages = $pageCount == 1 ? t("Page") : t("Pages");
return $versionCount . " " . t("versions deleted from") . " " . $pageCount . " " . $pages . " (" . $pNum . ")";
}
示例4: getPages
function getPages($query = null)
{
Loader::model('page_list');
$db = Loader::db();
$bID = $this->bID;
if ($this->bID) {
$q = "select * from btDateNav where bID = '{$bID}'";
$r = $db->query($q);
if ($r) {
$row = $r->fetchRow();
}
} else {
$row['num'] = $this->num;
$row['cParentID'] = $this->cParentID;
$row['cThis'] = $this->cThis;
$row['orderBy'] = $this->orderBy;
$row['ctID'] = $this->ctID;
$row['rss'] = $this->rss;
}
$pl = new PageList();
$pl->setNameSpace('b' . $this->bID);
$cArray = array();
//$pl->sortByPublicDate();
$pl->sortByPublicDateDescending();
$num = (int) $row['num'];
if ($num > 0) {
$pl->setItemsPerPage($num);
}
$c = $this->getCollectionObject();
if (is_object($c)) {
$this->cID = $c->getCollectionID();
}
$cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
if ($this->displayFeaturedOnly == 1) {
Loader::model('attribute/categories/collection');
$cak = CollectionAttributeKey::getByHandle('is_featured');
if (is_object($cak)) {
$pl->filterByIsFeatured(1);
}
}
$pl->filter('cvName', '', '!=');
if ($row['ctID']) {
$pl->filterByCollectionTypeID($row['ctID']);
}
$pl->filterByAttribute('exclude_nav', false);
if ($row['cParentID'] != 0) {
$pl->filterByParentID($cParentID);
}
if ($num > 0) {
$pages = $pl->getPage();
} else {
$pages = $pl->get();
}
$this->set('pl', $pl);
return $pages;
}
示例5: getRequestedSearchResults
public function getRequestedSearchResults()
{
$dh = Loader::helper('concrete/dashboard/sitemap');
if (!$dh->canRead()) {
return false;
}
$pageList = new PageList();
$pageList->ignoreAliases();
$pageList->enableStickySearchRequest();
if ($_REQUEST['submit_search']) {
$pageList->resetSearchRequest();
}
$req = $pageList->getSearchRequest();
$pageList->displayUnapprovedPages();
$pageList->sortBy('cDateModified', 'desc');
$columns = PageSearchColumnSet::getCurrent();
$this->set('columns', $columns);
$cvName = htmlentities($req['cvName'], ENT_QUOTES, APP_CHARSET);
if ($cvName != '') {
$pageList->filterByName($cvName);
}
if ($req['cParentIDSearchField'] > 0) {
if ($req['cParentAll'] == 1) {
$pc = Page::getByID($req['cParentIDSearchField']);
$cPath = $pc->getCollectionPath();
$pageList->filterByPath($cPath);
} else {
$pageList->filterByParentID($req['cParentIDSearchField']);
}
$parentDialogOpen = 1;
}
$keywords = htmlentities($req['keywords'], ENT_QUOTES, APP_CHARSET);
$pageList->filterByKeywords($keywords);
if ($req['numResults']) {
$pageList->setItemsPerPage($req['numResults']);
}
if ($req['ctID']) {
$pageList->filterByCollectionTypeID($req['ctID']);
}
if ($_REQUEST['noKeywords'] == 1) {
$pageList->filter('CollectionSearchIndexAttributes.ak_meta_keywords', NULL, '=');
$this->set('keywordCheck', true);
$parentDialogOpen = 1;
}
if ($_REQUEST['noDescription'] == 1) {
$pageList->filter('CollectionSearchIndexAttributes.ak_meta_description', NULL, '=');
$this->set('descCheck', true);
$parentDialogOpen = 1;
}
$this->set('searchRequest', $req);
$this->set('parentDialogOpen', $parentDialogOpen);
return $pageList;
}
示例6: getPages
function getPages($query = null)
{
Loader::model('page_list');
$db = Loader::db();
$bID = $this->bID;
if ($this->bID) {
$q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btEasyNewsList where bID = '{$bID}'";
$r = $db->query($q);
if ($r) {
$row = $r->fetchRow();
}
} else {
$row['num'] = $this->num;
$row['cParentID'] = $this->cParentID;
$row['cThis'] = $this->cThis;
$row['orderBy'] = $this->orderBy;
$row['ctID'] = $this->ctID;
$row['rss'] = $this->rss;
}
$pl = new PageList();
$pl->setNameSpace('b' . $this->bID);
$cArray = array();
switch ($row['orderBy']) {
case 'public_desc':
$pl->sortBy('cvDatePublic', 'desc');
break;
case 'public_asc':
$pl->sortBy('cvDatePublic', 'asc');
break;
case 'display_asc':
$pl->sortByDisplayOrder();
break;
case 'display_desc':
$pl->sortByDisplayOrderDescending();
break;
case 'chrono_asc':
$pl->sortByPublicDate();
break;
case 'alpha_asc':
$pl->sortByName();
break;
case 'alpha_desc':
$pl->sortByNameDescending();
break;
default:
$pl->sortByPublicDateDescending();
break;
}
$num = (int) $row['num'];
if ($num > 0) {
$pl->setItemsPerPage($num);
}
$c = Page::getCurrentPage();
if (is_object($c)) {
$this->cID = $c->getCollectionID();
}
$cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
Loader::model('attribute/categories/collection');
if ($this->displayFeaturedOnly == 1) {
$cak = CollectionAttributeKey::getByHandle('is_featured');
if (is_object($cak)) {
$pl->filterByIsFeatured(1);
}
}
if (!$row['displayAliases']) {
$pl->filterByIsAlias(0);
}
$pl->filter('cvName', '', '!=');
if ($row['ctID']) {
$pl->filterByCollectionTypeID($row['ctID']);
}
$columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable());
if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) {
$pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
}
if (intval($row['cParentID']) != 0) {
$pl->filterByParentID($cParentID);
}
//Publish Date Filter
$dt = Loader::helper('date');
$pl->filter('cvDatePublic', $dt->getLocalDateTime(), '<');
if ($num > 0) {
$pages = $pl->getPage();
} else {
$pages = $pl->get();
}
$this->set('pl', $pl);
return $pages;
}
示例7: getRequestedSearchResults
public function getRequestedSearchResults()
{
$dh = Loader::helper('concrete/dashboard/sitemap');
if (!$dh->canRead()) {
return false;
}
$pageList = new PageList();
$pageList->ignoreAliases();
$pageList->enableStickySearchRequest();
if ($_REQUEST['submit_search']) {
$pageList->resetSearchRequest();
}
$req = $pageList->getSearchRequest();
$pageList->displayUnapprovedPages();
$columns = PageSearchColumnSet::getCurrent();
$this->set('columns', $columns);
$cvName = h($req['cvName']);
if ($cvName != '') {
$pageList->filterByName($cvName);
}
if ($req['numResults'] && Loader::helper('validation/numbers')->integer($req['numResults'])) {
$pageList->setItemsPerPage($req['numResults']);
}
if ($req['ctID']) {
$pageList->filterByCollectionTypeID($req['ctID']);
}
if (is_array($req['selectedSearchField'])) {
foreach ($req['selectedSearchField'] as $i => $item) {
// due to the way the form is setup, index will always be one more than the arrays
if ($item != '') {
switch ($item) {
case 'keywords':
$keywords = htmlentities($req['keywords'], ENT_QUOTES, APP_CHARSET);
$pageList->filterByKeywords($keywords);
break;
case 'num_children':
$symbol = '=';
if ($req['cChildrenSelect'] == 'gt') {
$symbol = '>';
} else {
if ($req['cChildrenSelect'] == 'lt') {
$symbol = '<';
}
}
$pageList->filterByNumberOfChildren($req['cChildren'], $symbol);
break;
case 'owner':
$ui = UserInfo::getByUserName($req['owner']);
if (is_object($ui)) {
$pageList->filterByUserID($ui->getUserID());
} else {
$pageList->filterByUserID(-1);
}
break;
case 'theme':
$pageList->filter('ptID', $_REQUEST['ptID']);
break;
case 'parent':
if (isset($req['_cParentAll'])) {
$req['cParentAll'] = $req['_cParentAll'];
}
if ($req['cParentIDSearchField'] > 0) {
if ($req['cParentAll'] == 1) {
$pc = Page::getByID($req['cParentIDSearchField']);
$cPath = $pc->getCollectionPath();
$pageList->filterByPath($cPath);
} else {
$pageList->filterByParentID($req['cParentIDSearchField']);
}
}
break;
case 'version_status':
if (isset($req['_cvIsApproved'])) {
$req['cvIsApproved'] = $req['_cvIsApproved'];
}
$pageList->filterByIsApproved($req['cvIsApproved']);
break;
case 'permissions_inheritance':
$pageList->filter('cInheritPermissionsFrom', $req['cInheritPermissionsFrom']);
break;
case "date_public":
$dateFrom = $req['date_public_from'];
$dateTo = $req['date_public_to'];
if ($dateFrom != '') {
$dateFrom = date('Y-m-d', strtotime($dateFrom));
$pageList->filterByPublicDate($dateFrom, '>=');
$dateFrom .= ' 00:00:00';
}
if ($dateTo != '') {
$dateTo = date('Y-m-d', strtotime($dateTo));
$dateTo .= ' 23:59:59';
$pageList->filterByPublicDate($dateTo, '<=');
}
break;
case "last_modified":
$dateFrom = $req['last_modified_from'];
$dateTo = $req['last_modified_to'];
if ($dateFrom != '') {
$dateFrom = date('Y-m-d', strtotime($dateFrom));
$pageList->filterByDateLastModified($dateFrom, '>=');
//.........这里部分代码省略.........
示例8: getSubNodes
function getSubNodes($cID, $level = 0, $keywords = '', $autoOpenNodes = true)
{
$db = Loader::db();
$obj = new stdClass();
if (isset($cID) && (Loader::helper('validation/numbers')->integer($cID) || $cID == 0)) {
if ($keywords != '' && $keywords != false) {
$nc = Page::getByID($cID, 'RECENT');
$pl = new PageList();
if (PERMISSIONS_MODEL != 'simple') {
$pl->setViewPagePermissionKeyHandle('view_page_in_sitemap');
}
$obj->keywords = $keywords;
$pl->filterByName($keywords);
$pl->ignoreAliases();
$pl->filterByPath($nc->getCollectionPath());
$pl->displayUnapprovedPages();
$pl->sortByDisplayOrder();
$results = $pl->get(SITEMAP_PAGES_LIMIT);
$total = $pl->getTotal();
} else {
$pl = new PageList();
if (PERMISSIONS_MODEL != 'simple') {
$pl->setViewPagePermissionKeyHandle('view_page_in_sitemap');
}
$pl->sortByDisplayOrder();
if (ConcreteDashboardSitemapHelper::showSystemPages()) {
$pl->includeSystemPages();
$pl->includeInactivePages();
}
$pl->filterByParentID($cID);
$pl->displayUnapprovedPages();
$total = $pl->getTotal();
if ($cID == 1) {
$results = $pl->get();
} else {
$pl->setItemsPerPage(SITEMAP_PAGES_LIMIT);
$results = $pl->getPage();
}
}
$nodes = array();
foreach ($results as $c) {
$n = ConcreteDashboardSitemapHelper::getNode($c, $level + 1, $autoOpenNodes);
if ($n != false) {
$nodes[] = $n;
}
}
$obj->total = $total;
$obj->nodeID = $cID;
$obj->pageList = $pl;
$obj->results = $nodes;
} else {
$obj->total = 0;
$obj->nodeID = 0;
$obj->pageList = null;
$obj->results = null;
}
return $obj;
}
示例9: die
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$sh = Loader::helper('concrete/dashboard/sitemap');
if (!$sh->canRead()) {
die(t('Access Denied'));
}
session_write_close();
$keywords = $_REQUEST['q'];
Loader::model('page_list');
$pl = new PageList();
$pl->filterByName($keywords);
if (PERMISSIONS_MODEL != 'simple') {
$pl->setViewPagePermissionKeyHandle('view_page_in_sitemap');
}
$pl->ignoreAliases();
$pl->sortBy('cID', 'asc');
$pl->setItemsPerPage(5);
$pages = $pl->getPage();
$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);
示例10: getSubNodes
function getSubNodes($cID, $level = 0, $keywords = '', $autoOpenNodes = true) {
$db = Loader::db();
$obj = new stdClass;
if ($keywords != '' && $keywords != false) {
$nc = Page::getByID($cID, 'RECENT');
$pl = new PageList();
$obj->keywords = $keywords;
$pl->filterByName($keywords);
$pl->filterByPath($nc->getCollectionPath());
$pl->displayUnapprovedPages();
$pl->sortByDisplayOrder();
$results = $pl->get(SITEMAP_PAGES_LIMIT);
$total = $pl->getTotal();
} else {
$pl = new PageList();
$pl->sortByDisplayOrder();
if (ConcreteDashboardSitemapHelper::showSystemPages()) {
$pl->includeSystemPages();
}
$pl->filterByParentID($cID);
$pl->displayUnapprovedPages();
$total = $pl->getTotal();
if ($cID == 1) {
$results = $pl->get();
} else {
$pl->setItemsPerPage(SITEMAP_PAGES_LIMIT);
$results = $pl->getPage();
}
}
$nodes = array();
foreach($results as $c) {
$n = ConcreteDashboardSitemapHelper::getNode($c, $level+1, $autoOpenNodes);
if ($n != false) {
$nodes[] = $n;
}
}
$obj->total = $total;
$obj->nodeID = $cID;
$obj->pageList = $pl;
$obj->results = $nodes;
return $obj;
}
示例11: getPageList
public function getPageList()
{
Loader::model('page_list');
$db = Loader::db();
$bID = $this->bID;
if ($this->bID) {
$q = 'select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btPageList where bID = \'' . $bID . '\'';
$r = $db->query($q);
if ($r) {
$row = $r->fetchRow();
}
} else {
$row['num'] = $this->num;
$row['cParentID'] = $this->cParentID;
$row['cThis'] = $this->cThis;
$row['orderBy'] = $this->orderBy;
$row['ctID'] = $this->ctID;
$row['rss'] = $this->rss;
$row['displayAliases'] = $this->displayAliases;
}
$pl = new PageList();
$pl->setNameSpace('b' . $this->bID);
$cArray = array();
switch ($row['orderBy']) {
case 'display_asc':
$pl->sortByDisplayOrder();
break;
case 'display_desc':
$pl->sortByDisplayOrderDescending();
break;
case 'chrono_asc':
$pl->sortByPublicDate();
break;
case 'alpha_asc':
$pl->sortByName();
break;
case 'alpha_desc':
$pl->sortByNameDescending();
break;
case 'random':
$pl->sortBy('RAND()');
break;
default:
$pl->sortByPublicDateDescending();
break;
}
$num = (int) $row['num'];
$pl->setItemsPerPage($num);
$c = Page::getCurrentPage();
if (is_object($c)) {
$this->cID = $c->getCollectionID();
}
Loader::model('attribute/categories/collection');
if ((int) $this->displayFeaturedOnly === 1) {
$cak = CollectionAttributeKey::getByHandle('is_featured');
if (is_object($cak)) {
$pl->filterByIsFeatured(1);
}
}
if (!$row['displayAliases']) {
$pl->filterByIsAlias(0);
}
$pl->filter('cvName', '', '!=');
if ($row['ctID']) {
$pl->filterByCollectionTypeID($row['ctID']);
}
$columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable());
if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) {
$pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
}
if (intval($row['cParentID']) != 0) {
$cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
if ($this->includeAllDescendents) {
$pl->filterByPath(Page::getByID($cParentID)->getCollectionPath());
} else {
$pl->filterByParentID($cParentID);
}
}
return $pl;
}
示例12: OR
}
$value1 = $cat[0];
$value2 = $cat[1];
if (!empty($value2)) {
$pl->filter(false, "(ak_{$attribute} LIKE '%\n{$value1}\n%') OR (ak_{$attribute} LIKE '%\n{$value2}\n%')");
} else {
$pl->filter(false, "(ak_{$attribute} LIKE '%\n{$value1}\n%')");
}
}
}
/*
* Set up pagination and retrieve pages
*/
$paginate_list = $row['paginate'];
$num = (int) $row['num'];
$pl->setItemsPerPage($num);
if ($paginate_list == 1) {
$current_page_get_var = 'ccm_paging_p_b' . $bID;
$current_page = intval($_GET[$current_page_get_var]);
// Page of results requested in query string
$current_page = empty($current_page) ? 1 : $current_page;
// PageList object returns this page of results
$pages = $pl->getPage($current_page);
} else {
$pages = $pl->getPage(1);
}
// Display attribute filter links
if (count($row['displayAttributes']) > 0) {
Loader::model('attribute/categories/collection');
$satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
// Get existing query string to pass through filtering parameters