当前位置: 首页>>代码示例>>PHP>>正文


PHP PageList::limit方法代码示例

本文整理汇总了PHP中PageList::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP PageList::limit方法的具体用法?PHP PageList::limit怎么用?PHP PageList::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PageList的用法示例。


在下文中一共展示了PageList::limit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if ($debug) {
         $timer = new DebugTimer();
     }
     $group = $request->getGroup();
     if (method_exists($group, '_allUsers')) {
         $allusers = $group->_allUsers();
     } else {
         $allusers = array();
     }
     $args['count'] = count($allusers);
     // deleted pages show up as version 0.
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption(_("Authenticated users on this wiki (%d total):"));
     }
     if ($include_empty and empty($info)) {
         $pagelist->_addColumn('version');
     }
     list($offset, $pagesize) = $pagelist->limit($args['limit']);
     if (!$pagesize) {
         $pagelist->addPageList($allusers);
     } else {
         for ($i = $offset; $i < $offset + $pagesize - 1; $i++) {
             if ($i >= $args['count']) {
                 break;
             }
             $pagelist->addPage($allusers[$i]);
         }
     }
     /*
     $page_iter = $dbi->getAllPages($include_empty, $sortby, $limit);
     while ($page = $page_iter->next()) {
         if ($page->isUserPage($include_empty))
             $pagelist->addPage($page);
     }
     */
     if ($debug) {
         return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
     } else {
         return $pagelist;
     }
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:46,代码来源:AllUsers.php

示例2: run

 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     // There's probably a more efficient way to do this (eg a
     // tailored SQL query via the backend, but this does the job
     $allpages_iter = $dbi->getAllPages($include_empty);
     $pages = array();
     while ($page = $allpages_iter->next()) {
         $links_iter = $page->getBackLinks();
         // Test for absence of backlinks. If a page is linked to
         // only by itself, it is still an orphan
         $parent = $links_iter->next();
         if (!$parent or $parent->getName() == $page->getName() and !$links_iter->next()) {
             $pages[] = $page;
         }
     }
     $args['count'] = count($pages);
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption(_("Orphaned Pages in this wiki (%d total):"));
     }
     // deleted pages show up as version 0.
     if ($include_empty) {
         $pagelist->_addColumn('version');
     }
     list($offset, $pagesize) = $pagelist->limit($args['limit']);
     if (!$pagesize) {
         $pagelist->addPageList($pages);
     } else {
         for ($i = $offset; $i < $offset + $pagesize - 1; $i++) {
             if ($i >= $args['count']) {
                 break;
             }
             $pagelist->addPage($pages[$i]);
         }
     }
     return $pagelist;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:39,代码来源:OrphanedPages.php

示例3: run

 function run($dbi, $argstr, &$request, $basepage)
 {
     global $DBParams;
     //$request->setArg('nocache','1');
     extract($this->getArgs($argstr, $request));
     if (!$alias) {
         return $this->error(_("No DSN alias for SqlResult.ini specified"));
     }
     $sql = $this->_sql;
     // apply custom filters
     if ($where and strstr($sql, "%%where%%")) {
         $sql = str_replace("%%where%%", $where, $sql);
     }
     // TODO: use a SQL construction library?
     if ($limit) {
         $pagelist = new PageList();
         $limit = $pagelist->limit($limit);
         if (strstr($sql, "%%limit%%")) {
             $sql = str_replace("%%limit%%", $limit, $sql);
         } else {
             if (strstr($sql, "LIMIT")) {
                 $sql = preg_replace("/LIMIT\\s+[\\d,]+\\s+/m", "LIMIT " . $limit . " ", $sql);
             }
         }
     }
     if (strstr($sql, "%%sortby%%")) {
         if (!$sortby) {
             $sql = preg_replace("/ORDER BY .*%%sortby%%\\s/m", "", $sql);
         } else {
             $sql = str_replace("%%sortby%%", $sortby, $sql);
         }
     } elseif (PageList::sortby($sortby, 'db')) {
         // add sorting: support paging sortby links
         if (preg_match("/\\sORDER\\s/", $sql)) {
             $sql = preg_replace("/ORDER BY\\s\\S+\\s/m", "ORDER BY " . PageList::sortby($sortby, 'db'), $sql);
         } else {
             $sql .= " ORDER BY " . PageList::sortby($sortby, 'db');
         }
     }
     $inidsn = $this->getDsn($alias);
     if (!$inidsn) {
         return $this->error(sprintf(_("No DSN for alias %s in SqlResult.ini found"), $alias));
     }
     // adodb or pear? adodb as default, since we distribute per default it.
     // for pear there may be overrides.
     // TODO: native PDO support (for now we use ADODB)
     if ($DBParams['dbtype'] == 'SQL') {
         $dbh = DB::connect($inidsn);
         $all = $dbh->getAll($sql);
         if (DB::isError($all)) {
             return $this->error($all->getMessage() . ' ' . $all->userinfo);
         }
     } else {
         // unless PearDB use the included ADODB, regardless if dba, file or PDO, ...
         if ($DBParams['dbtype'] != 'ADODB') {
             // require_once('lib/WikiDB/adodb/adodb-errorhandler.inc.php');
             require_once 'lib/WikiDB/adodb/adodb.inc.php';
         }
         $parsed = parseDSN($inidsn);
         $dbh =& ADONewConnection($parsed['phptype']);
         $conn = $dbh->Connect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']);
         if (!$conn) {
             return $this->error($dbh->errorMsg());
         }
         $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
         $dbh->SetFetchMode(ADODB_FETCH_ASSOC);
         $all = $dbh->getAll($sql);
         $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM;
         $dbh->SetFetchMode(ADODB_FETCH_NUM);
         if (!$all) {
             return $this->error($dbh->errorMsg());
         }
     }
     $args = array();
     if ($limit) {
         // fill paging vars (see PageList)
         $args = $pagelist->pagingTokens(count($all), count($all[0]), $limit);
         if (!$args) {
             $args = array();
         }
     }
     if ($template) {
         $args = array_merge(array('SqlResult' => $all, 'ordered' => $ordered, 'where' => $where, 'sortby' => $sortby, 'limit' => $limit), $args);
         // paging params override given params
         return Template($template, $args);
     } else {
         if ($ordered) {
             $html = HTML::ol(array('class' => 'sqlresult'));
             if ($all) {
                 foreach ($all as $row) {
                     $html->pushContent(HTML::li(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow'), $row[0]));
                 }
             }
         } else {
             $html = HTML::table(array('class' => 'sqlresult'));
             $i = 0;
             if ($all) {
                 foreach ($all as $row) {
                     $tr = HTML::tr(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow'));
                     if ($row) {
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:tuleap,代码行数:101,代码来源:SqlResult.php

示例4: 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;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:67,代码来源:WantedPages.php


注:本文中的PageList::limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。