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


PHP PageList::addPages方法代码示例

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


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

示例1: 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));
             }
         }
//.........这里部分代码省略.........
开发者ID:hugcoday,项目名称:wiki,代码行数:101,代码来源:BackLinks.php

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

示例3: run

 function run($dbi, $argstr, $request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     $pages = false;
     // Todo: extend given _GET args
     if (DEBUG && $args['debug']) {
         $timer = new DebugTimer();
     }
     $caption = _("All pages in this wiki (%d total):");
     if (!empty($args['userpages'])) {
         $pages = PageList::allUserPages($args['include_empty'], $args['sortby'], '');
         $caption = _("List of user-created pages (%d total):");
         $args['count'] = $request->getArg('count');
     } elseif (!empty($args['owner'])) {
         $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'], $args['sortby'], '');
         $args['count'] = $request->getArg('count');
         if (!$args['count']) {
             $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
         }
         $caption = fmt("List of pages owned by [%s] (%d total):", WikiLink($args['owner'] == '[]' ? $request->_user->getAuthenticatedId() : $args['owner'], 'if_known'), $args['count']);
         $pages->_options['count'] = $args['count'];
     } elseif (!empty($args['author'])) {
         $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'], $args['sortby'], '');
         $args['count'] = $request->getArg('count');
         if (!$args['count']) {
             $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
         }
         $caption = fmt("List of pages last edited by [%s] (%d total):", WikiLink($args['author'] == '[]' ? $request->_user->getAuthenticatedId() : $args['author'], 'if_known'), $args['count']);
         $pages->_options['count'] = $args['count'];
     } elseif (!empty($args['creator'])) {
         $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'], $args['sortby'], '');
         $args['count'] = $request->getArg('count');
         if (!$args['count']) {
             $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
         }
         $caption = fmt("List of pages created by [%s] (%d total):", WikiLink($args['creator'] == '[]' ? $request->_user->getAuthenticatedId() : $args['creator'], 'if_known'), $args['count']);
         $pages->_options['count'] = $args['count'];
         //} elseif ($pages) {
         //    $args['count'] = count($pages);
     } else {
         if (!$request->getArg('count')) {
             $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
         } else {
             $args['count'] = $request->getArg('count');
         }
     }
     if (empty($args['count']) and !empty($pages)) {
         $args['count'] = count($pages);
     }
     $pagelist = new PageList($args['info'], $args['exclude'], $args);
     if (!$args['noheader']) {
         $pagelist->setCaption($caption);
     }
     // deleted pages show up as version 0.
     //if ($args['include_empty'])
     //    $pagelist->_addColumn('version');
     if ($pages !== false) {
         $pagelist->addPageList($pages);
     } else {
         $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit']));
     }
     if (DEBUG && $args['debug']) {
         return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
     } else {
         return $pagelist;
     }
 }
开发者ID:hugcoday,项目名称:wiki,代码行数:67,代码来源:AllPages.php

示例4: run

 function run($dbi, $argstr, $request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     $caption = _("All pages with all links in this wiki (%d total):");
     if (!empty($args['owner'])) {
         $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'], $args['sortby'], $args['limit']);
         if ($args['owner']) {
             $caption = fmt("List of pages owned by [%s] (%d total):", WikiLink($args['owner'], 'if_known'), count($pages));
         }
     } elseif (!empty($args['author'])) {
         $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'], $args['sortby'], $args['limit']);
         if ($args['author']) {
             $caption = fmt("List of pages last edited by [%s] (%d total):", WikiLink($args['author'], 'if_known'), count($pages));
         }
     } elseif (!empty($args['creator'])) {
         $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'], $args['sortby'], $args['limit']);
         if ($args['creator']) {
             $caption = fmt("List of pages created by [%s] (%d total):", WikiLink($args['creator'], 'if_known'), count($pages));
         }
     } else {
         if (!$request->getArg('count')) {
             $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude_from']);
         } else {
             $args['count'] = $request->getArg('count');
         }
         $pages = $dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit'], $args['exclude_from']);
     }
     if ($args['format'] == 'html') {
         $args['types']['links'] = new _PageList_Column_LinkDatabase_links('links', _("Links"), 'left');
         $pagelist = new PageList($args['info'], $args['exclude_from'], $args);
         //$pagelist->_addColumn("links");
         if (!$args['noheader']) {
             $pagelist->setCaption($caption);
         }
         $pagelist->addPages($pages);
         return $pagelist;
     } elseif ($args['format'] == 'text') {
         $request->discardOutput();
         $request->buffer_output(false);
         if (!headers_sent()) {
             header("Content-Type: text/plain");
         }
         $request->checkValidators();
         while ($page = $pages->next()) {
             echo preg_replace("/ /", "%20", $page->getName());
             $links = $page->getPageLinks(false, $args['sortby'], $args['limit'], $args['exclude']);
             while ($link = $links->next()) {
                 echo " ", preg_replace("/ /", "%20", $link->getName());
             }
             echo "\n";
         }
         flush();
         if (empty($WikiTheme->DUMP_MODE)) {
             $request->finish();
         }
     } elseif ($args['format'] == 'xml') {
         // For hypergraph.jar. Best dump it to a local sitemap.xml periodically
         global $WikiTheme, $charset;
         $currpage = $request->getArg('pagename');
         $request->discardOutput();
         $request->buffer_output(false);
         if (!headers_sent()) {
             header("Content-Type: text/xml");
         }
         $request->checkValidators();
         echo "<?xml version=\"1.0\" encoding=\"{$charset}\"?>";
         // As applet it prefers only "GraphXML.dtd", but then we must copy it to the webroot.
         $dtd = $WikiTheme->_findData("GraphXML.dtd");
         echo "<!DOCTYPE GraphXML SYSTEM \"{$dtd}\">\n";
         echo "<GraphXML xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
         echo "<graph id=\"", MangleXmlIdentifier(WIKI_NAME), "\">\n";
         echo '<style><line tag="node" class="main" colour="#ffffff"/><line tag="node" class="child" colour="blue"/><line tag="node" class="relation" colour="green"/></style>', "\n\n";
         while ($page = $pages->next()) {
             $pageid = MangleXmlIdentifier($page->getName());
             $pagename = $page->getName();
             echo "<node name=\"{$pageid}\"";
             if ($pagename == $currpage) {
                 echo " class=\"main\"";
             }
             echo "><label>{$pagename}</label>";
             echo "<dataref><ref xlink:href=\"", WikiURL($pagename, '', true), "\"/></dataref></node>\n";
             $links = $page->getPageLinks(false, $args['sortby'], $args['limit'], $args['exclude']);
             while ($link = $links->next()) {
                 $edge = MangleXmlIdentifier($link->getName());
                 echo "<edge source=\"{$pageid}\" target=\"{$edge}\" />\n";
             }
             echo "\n";
         }
         echo "</graph>\n";
         echo "</GraphXML>\n";
         if (empty($WikiTheme->DUMP_MODE)) {
             unset($GLOBALS['ErrorManager']->_postponed_errors);
             $request->finish();
         }
     } else {
         return $this->error(fmt("Unsupported format argument %s", $args['format']));
     }
 }
开发者ID:hugcoday,项目名称:wiki,代码行数:99,代码来源:LinkDatabase.php

示例5: run

 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->args = $this->getArgs($argstr, $request);
     extract($this->args);
     $this->request =& $request;
     if (!$from_lang) {
         $from_lang = $request->getPref('lang');
     }
     if (!$from_lang) {
         $from_lang = $GLOBALS['LANG'];
     }
     $this->lang = $from_lang;
     if (empty($languages)) {
         $available_languages = listAvailableLanguages();
         if ($from_lang == 'en') {
             // "en" is always the first.
             array_shift($available_languages);
         }
         // put from_lang to the very end.
         if (in_array($from_lang, $available_languages)) {
             $languages = $available_languages;
         } else {
             $languages = array_merge($available_languages, array($from_lang));
         }
     } elseif (strstr($languages, ',')) {
         $languages = explode(',', $languages);
     } else {
         $languages = array($languages);
     }
     if (in_array('zh', $languages) or in_array('ja', $languages)) {
         // If the current charset != utf-8 the text will not be displayed correctly.
         // But here we cannot change the header anymore. So we can decide to ignore them,
         // or display them with all the errors.
         //FIXME: do iconv the ob
         if ($GLOBALS['charset'] != 'utf-8' and !defined('NEED_ICONV_TO')) {
             define('NEED_ICONV_TO', 'utf-8');
             //either the extension or external
             //$GLOBALS['charset'] = 'utf-8';
         }
     }
     $to_lang = $languages[0];
     if (!empty($string) and count($languages) == 1) {
         return $this->translate($string, $to_lang, $from_lang);
     }
     if (!empty($page)) {
         $pagename = $page;
         if ($dbi->isWikiPage($pagename)) {
             $url = '';
             // google can only translate from english and french
             if (in_array($from_lang, array('en', 'fr'))) {
                 $url = "http://translate.google.com/translate";
                 $url .= "?langpair=" . urlencode($from_lang . "|" . $to_lang);
                 $url .= "&u=" . urlencode(WikiURL($pagename, false, true));
             }
             // redirect or transclude?
             if ($url) {
                 return $request->redirect($url);
             }
             return HTML(fmt("TODO: Google can only translate from english and french. Find a translation service for %s to language %s", WikiURL($pagename, false, true), $to_lang));
         } else {
             return $this->error(fmt("%s is empty", $pagename));
         }
     }
     $pagelist = new PageList('', $exclude, $this->args);
     $pagelist->_columns[0]->_heading = "{$from_lang}";
     foreach ($languages as $lang) {
         if ($lang == $from_lang) {
             continue;
         }
         $field = "custom:{$lang}";
         $pagelist->addColumnObject(new _PageList_Column_customlang($field, $from_lang, $this));
     }
     if (!empty($string)) {
         $pagelist->addPage($string);
         return $pagelist;
     }
     switch ($what) {
         case 'allpages':
             $pagelist->addPages($dbi->getAllPages($include_empty, $sortby, $limit, $exclude));
             break;
         case 'pages':
             // not all pages, only the pgsrc pages
             if (!is_array($exclude)) {
                 $exclude = $pagelist->explodePageList($exclude, false, $sortby, $limit, $exclude);
             }
             $path = FindLocalizedFile(WIKI_PGSRC);
             $pgsrc = new fileSet($path);
             foreach ($pgsrc->getFiles($exclude, $sortby, $limit) as $pagename) {
                 $pagename = urldecode($pagename);
                 if (substr($pagename, -1, 1) == '~') {
                     continue;
                 }
                 if (in_array($pagename, $exclude)) {
                     continue;
                 }
                 // exclude page.
                 if ($match != '*' and !glob_match($match, $pagename)) {
                     continue;
                 }
                 $page_handle = $dbi->getPage($pagename);
//.........这里部分代码省略.........
开发者ID:hugcoday,项目名称:wiki,代码行数:101,代码来源:_WikiTranslation.php


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