本文整理汇总了PHP中PageList::getTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP PageList::getTotal方法的具体用法?PHP PageList::getTotal怎么用?PHP PageList::getTotal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageList
的用法示例。
在下文中一共展示了PageList::getTotal方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPageList
function testPageList()
{
// Completely empty PageList
$columns = "";
$exclude = "";
$options = "";
$pl = new PageList($columns, $exclude, $options);
$this->assertTrue($pl->isEmpty(), "empty");
$this->assertEquals(0, $pl->getTotal(), "count 0");
$cap = $pl->getCaption();
$this->assertTrue(empty($cap), "empty caption");
// PageList sorting
$columns[] = 'pagename';
$pl = new PageList($columns, $exclude, $options);
//global $request;
$pl->addPage("foo");
$pl->addPage("blarg");
$this->assertEquals(2, $pl->getTotal(), "count 2");
//print_r($pl->getContent());
}
示例2: 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;
}
示例3: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
if (empty($args['s'])) {
return '';
}
$query = new TextSearchQuery($args['s'], $args['case_exact'], $args['regex']);
$pages = $dbi->titleSearch($query, $args['sortby'], $args['limit'], $args['exclude']);
$pagelist = new PageList($args['info'], $args['exclude'], $args);
while ($page = $pages->next()) {
$pagelist->addPage($page);
$last_name = $page->getName();
}
if ($args['format'] == 'livesearch') {
$request->discardOutput();
$request->buffer_output(false);
echo '<div class="LSRes">';
echo $pagelist->asXml();
echo '</div>';
if (empty($WikiTheme->DUMP_MODE)) {
unset($GLOBALS['ErrorManager']->_postponed_errors);
$request->finish();
}
}
// Provide an unknown WikiWord link to allow for page creation
// when a search returns no results
if (!$args['noheader']) {
$s = $args['s'];
if (!$pagelist->getTotal() and !$query->_regex) {
$s = WikiLink($args['s'], 'auto');
}
$pagelist->setCaption(fmt("Title search results for '%s'", $s));
}
if ($args['auto_redirect'] && $pagelist->getTotal() == 1) {
return HTML($request->redirect(WikiURL($last_name, false, 'absurl'), false), $pagelist);
}
return $pagelist;
}
示例4: 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;
}
示例5: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
if (!empty($args['exclude_from'])) {
$args['exclude_from'] = is_string($args['exclude_from']) ? explodePageList($args['exclude_from']) : $args['exclude_from'];
}
// <! plugin-list !>
extract($args);
if ($page == _("WantedPages")) {
$page = "";
}
// There's probably a more memory-efficient way to do this (eg
// a tailored SQL query via the backend, but this gets the job
// done.
// TODO: Move this to backend/dumb/WantedPagesIter.php
if (!$page) {
$GLOBALS['WikiTheme']->addPageListColumn(array('wanted' => array('_PageList_Column_WantedPages_wanted', 'custom:wanted', _("Wanted From"), 'left')));
}
$pagelist = new PageList($page ? '' : 'pagename,wanted', $exclude, $args);
// search button?
$pagelist->_wpagelist = array();
if (!$page) {
list($offset, $maxcount) = $pagelist->limit($limit);
$wanted_iter = $dbi->wantedPages($exclude_from, $exclude, $sortby, $limit);
while ($row = $wanted_iter->next()) {
$wanted = $row['pagename'];
$wantedfrom = $row['wantedfrom'];
// ignore duplicates:
if (empty($pagelist->_wpagelist[$wanted])) {
$pagelist->addPage($wanted);
}
$pagelist->_wpagelist[$wanted][] = $wantedfrom;
}
$wanted_iter->free();
// update limit, but it's still a hack.
$pagelist->_options['limit'] = "{$offset}," . min($pagelist->getTotal(), $maxcount);
} elseif ($dbi->isWikiPage($page)) {
//only get WantedPages links for one page
$page_handle = $dbi->getPage($page);
$links = $page_handle->getPageLinks(true);
// include_empty
while ($link_handle = $links->next()) {
if (!$dbi->isWikiPage($linkname = $link_handle->getName())) {
$pagelist->addPage($linkname);
//if (!array_key_exists($linkname, $this->_wpagelist))
$pagelist->_wpagelist[$linkname][] = 1;
}
}
}
/*
if ($sortby) {
ksort($this->_wpagelist);
arsort($this->_wpagelist);
}*/
if (!$noheader) {
if ($page) {
$pagelist->setCaption(sprintf(_("Wanted Pages for %s:"), $page));
} else {
$pagelist->setCaption(sprintf(_("Wanted Pages in this wiki:")));
}
}
// reference obviously doesn't work, so force an update to add _wpagelist to parentobj
if (isset($pagelist->_columns[1]) and $pagelist->_columns[1]->_field == 'wanted') {
$pagelist->_columns[1]->parentobj =& $pagelist;
}
return $pagelist;
}
示例6: view
/**
* Call model data needed by view
*
* @param int $userID The user ID of who we're viewing
* @return null
*/
public function view($userID = 0)
{
// Load helpers
Loader::model('page_list');
$nh = Loader::helper('navigation');
$ah = Loader::helper('concrete/avatar');
$th = Loader::helper('text');
$ih = Loader::helper('image');
// Set helpers for view
// Set the page view first
$this->set('bodyData', ['pageViewName' => 'ProfilePageView']);
parent::view($userID);
// Load the current user
$u = new User();
$ui = UserInfo::getByID($u->getUserID());
$profile = $this->get('profile');
// Basic flags identifying the type of user
// Whether or not the logged in user is viewing their own "profile"
$userIsViewingSelf = $u->getUserID() === $profile->getUserID();
// User is a CO
$userIsCityOrganizer = in_array('City Organizers', $profile->getUserObject()->getUserGroups());
/**
* New dashboard variables
*
*/
// Remaining variables/logic only needed for "self viewing"
if ($userIsViewingSelf) {
/**
* Helper
*
*/
$html = Loader::helper('html');
$this->addHeaderItem($html->javascript('swfobject.js'));
/**
* User data
*
*/
// Whether the logged in user has set their first and last name
$this->set('userHasSetName', (bool) trim($ui->getAttribute('first_name') . ' ' . $ui->getAttribute('last_name')));
// The home city for the logged in user (false otherwise)
$userHomeCity = $ui->getAttribute('home_city');
$this->set('userHomeCity', $userHomeCity);
// Whether the logged in user has chosen an avatar/display picture
$this->set('userPicture', $ah->getImagePath($ui));
// Walks owned by user
$pl = new PageList();
$pl->filterByCollectionTypeHandle('walk');
$pl->filterByUserID($u->getUserID());
// Include the names of draft walks, not last published
$pl->displayUnapprovedPages();
$this->set('userWalks', $pl->get());
// Whether the logged in user has created any blog posts
$pl = new PageList();
$pl->filterByCollectionTypeHandle(['walk_blog_entry', 'city_blog_entry']);
$pl->filterByUserID($u->getUserID());
$this->set('userBlogPosts', $pl->get());
/**
* User city data
*
*/
if ($userHomeCity) {
// Set the city
$city = $ui->getAttribute('home_city');
// Load organizer user for this city
$cityOrganizer = UserInfo::getByID($userHomeCity->getCollectionUserID());
if ($cityOrganizer) {
// The email address of the city organizer for the logged in user's
// home city
$cityOrganizerEmailAddress = $cityOrganizer->getUserEmail();
$this->set('cityOrganizerEmailAddress', $cityOrganizerEmailAddress);
}
// Whether the city has a blog page set up for it
$pl = new PageList();
$pl->filterByCollectionTypeHandle('blog');
$pl->filterByParentID($userHomeCity->getCollectionID());
$cityHasBlogSetup = (bool) $pl->getTotal();
$this->set('cityHasBlogSetup', $cityHasBlogSetup);
// List of basic data for three walks we want to highlight to city
// organizers/walk leaders that showcase creative/unique walks
$pl = new PageList();
$pl->filterByCollectionTypeHandle('walk');
$pl->filter(false, 'p1.uID !=' . $u->getUserID());
$pl->filterByAttribute('exclude_page_list', false);
$pl->sortBy('RAND()');
// Load this list of featured walks
$featuredWalkData = array_map(function ($page) use($nh, $ih) {
$_city = Page::getByID($page->getCollectionParentID());
$_country = Page::getByID($_city->getCollectionParentID());
$_thumb = $page->getAttribute('thumbnail');
$countryName = $_country->getCollectionName();
if ($countryName === 'United States') {
$countryName = 'United States of America';
}
$countryName = str_replace(' ', '_', $countryName);
//.........这里部分代码省略.........
示例7: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
extract($args);
if (empty($page) and $page != '0') {
return '';
}
// exclude is now already expanded in WikiPlugin::getArgs()
if (empty($exclude)) {
$exclude = array();
}
if (!$include_self) {
$exclude[] = $page;
}
if ($info) {
$info = explode(",", $info);
if (in_array('count', $info)) {
$args['types']['count'] = new _PageList_Column_BackLinks_count('count', _("#"), 'center');
}
}
if (!empty($limit)) {
$args['limit'] = $limit;
}
$args['dosort'] = !empty($args['sortby']);
// override DB sort (??)
$pagelist = new PageList($info, $exclude, $args);
// support logical AND: page1,page2
$pages = explodePageList($page);
$count = count($pages);
if (count($pages) > 1) {
// AND: the intersection of all these pages
$bl = array();
foreach ($pages as $p) {
$dp = $dbi->getPage($p);
$bi = $dp->getBackLinks(false, $sortby, 0, $exclude);
while ($b = $bi->next()) {
$name = $b->getName();
if (isset($bl[$name])) {
$bl[$name]++;
} else {
$bl[$name] = 1;
}
}
}
foreach ($bl as $b => $v) {
if ($v == $count) {
$pagelist->addPage($b);
}
}
} else {
$p = $dbi->getPage($page);
$pagelist->addPages($p->getBackLinks(false, $sortby, 0, $exclude));
}
$total = $pagelist->getTotal();
// Localization note: In English, the differences between the
// various phrases spit out here may seem subtle or negligible
// enough to tempt you to combine/normalize some of these
// strings together, but the grammar employed most by other
// languages does not always end up with so subtle a
// distinction as it does with English in this case. :)
if (!$noheader) {
if ($page == $request->getArg('pagename') and !$dbi->isWikiPage($page)) {
// BackLinks plugin is more than likely being called
// upon for an empty page on said page, while either
// 'browse'ing, 'create'ing or 'edit'ing.
//
// Don't bother displaying a WikiLink 'unknown', just
// the Un~WikiLink~ified (plain) name of the uncreated
// page currently being viewed.
$pagelink = $page;
if ($pagelist->isEmpty()) {
return HTML::p(fmt("No other page links to %s yet.", $pagelink));
}
if ($total == 1) {
$pagelist->setCaption(fmt("One page would link to %s:", $pagelink));
} else {
$pagelist->setCaption(fmt("%s pages would link to %s:", $total, $pagelink));
}
} else {
if ($count) {
$tmp_pages = $pages;
$p = array_shift($tmp_pages);
$pagelink = HTML(WikiLink($p, 'auto'));
foreach ($tmp_pages as $p) {
$pagelink->pushContent(" ", _("AND"), " ", WikiLink($p, 'auto'));
}
} else {
// BackLinks plugin is being displayed on a normal page.
$pagelink = WikiLink($page, 'auto');
}
if ($pagelist->isEmpty()) {
return HTML::p(fmt("No page links to %s.", $pagelink));
}
//trigger_error("DEBUG: " . $pagelist->getTotal());
if ($total == 1) {
$pagelist->setCaption(fmt("One page links to %s:", $pagelink));
} else {
$pagelist->setCaption(fmt("%s pages link to %s:", $limit > 0 ? $total : _("Those"), $pagelink));
}
}
//.........这里部分代码省略.........
示例8: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
extract($args);
if (empty($page) and $page != '0') {
return '';
}
// exclude is now already expanded in WikiPlugin::getArgs()
if (empty($exclude)) {
$exclude = array();
}
if (!$include_self) {
$exclude[] = $page;
}
if ($info) {
$info = explode(",", $info);
if (in_array('count', $info)) {
$args['types']['count'] = new _PageList_Column_BackLinks_count('count', _("#"), 'center');
}
}
$args['dosort'] = !empty($args['sortby']);
// override DB sort (??)
$pagelist = new PageList($info, $exclude, $args);
$p = $dbi->getPage($page);
$pagelist->addPages($p->getBackLinks(false, $sortby, $limit, $exclude));
// Localization note: In English, the differences between the
// various phrases spit out here may seem subtle or negligible
// enough to tempt you to combine/normalize some of these
// strings together, but the grammar employed most by other
// languages does not always end up with so subtle a
// distinction as it does with English in this case. :)
if (!$noheader) {
if ($page == $request->getArg('pagename') and !$dbi->isWikiPage($page)) {
// BackLinks plugin is more than likely being called
// upon for an empty page on said page, while either
// 'browse'ing, 'create'ing or 'edit'ing.
//
// Don't bother displaying a WikiLink 'unknown', just
// the Un~WikiLink~ified (plain) name of the uncreated
// page currently being viewed.
$pagelink = $page;
if ($pagelist->isEmpty()) {
return HTML::p(fmt("No other page links to %s yet.", $pagelink));
}
if ($pagelist->getTotal() == 1) {
$pagelist->setCaption(fmt("One page would link to %s:", $pagelink));
} else {
$pagelist->setCaption(fmt("%s pages would link to %s:", $pagelist->getTotal(), $pagelink));
}
} else {
// BackLinks plugin is being displayed on a normal page.
$pagelink = WikiLink($page, 'auto');
if ($pagelist->isEmpty()) {
return HTML::p(fmt("No page links to %s.", $pagelink));
}
//trigger_error("DEBUG: " . $pagelist->getTotal());
if ($pagelist->getTotal() == 1) {
$pagelist->setCaption(fmt("One page links to %s:", $pagelink));
} else {
$pagelist->setCaption(fmt("%s pages link to %s:", $pagelist->getTotal(), $pagelink));
}
}
}
return $pagelist;
}