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


PHP LinkBatch::add方法代码示例

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


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

示例1: execute

 /**
  * Main execution point
  *
  * @param string $subpage
  */
 public function execute($subpage)
 {
     $this->rcSubpage = $subpage;
     $this->setHeaders();
     $this->outputHeader();
     $this->addModules();
     $rows = $this->getRows();
     $opts = $this->getOptions();
     if ($rows === false) {
         if (!$this->including()) {
             $this->doHeader($opts, 0);
             $this->getOutput()->setStatusCode(404);
         }
         return;
     }
     $batch = new LinkBatch();
     foreach ($rows as $row) {
         $batch->add(NS_USER, $row->rc_user_text);
         $batch->add(NS_USER_TALK, $row->rc_user_text);
         $batch->add($row->rc_namespace, $row->rc_title);
     }
     $batch->execute();
     $this->webOutput($rows, $opts);
     $rows->free();
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:30,代码来源:ChangesListSpecialPage.php

示例2: execute

 /**
  * Main execution point
  *
  * @param string $subpage
  */
 public function execute($subpage)
 {
     $this->rcSubpage = $subpage;
     $this->setHeaders();
     $this->outputHeader();
     $this->addModules();
     $rows = $this->getRows();
     $opts = $this->getOptions();
     if ($rows === false) {
         if (!$this->including()) {
             $this->doHeader($opts, 0);
             $this->getOutput()->setStatusCode(404);
         }
         return;
     }
     $batch = new LinkBatch();
     foreach ($rows as $row) {
         $batch->add(NS_USER, $row->rc_user_text);
         $batch->add(NS_USER_TALK, $row->rc_user_text);
         $batch->add($row->rc_namespace, $row->rc_title);
         if ($row->rc_source === RecentChange::SRC_LOG) {
             $formatter = LogFormatter::newFromRow($row);
             foreach ($formatter->getPreloadTitles() as $title) {
                 $batch->addObj($title);
             }
         }
     }
     $batch->execute();
     $this->webOutput($rows, $opts);
     $rows->free();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:36,代码来源:ChangesListSpecialPage.php

示例3: getBody

 /**
  * @return string
  */
 function getBody()
 {
     $s = '';
     $this->doQuery();
     if (count($this->mHist)) {
         if ($this->mImg->isLocal()) {
             // Do a batch existence check for user pages and talkpages
             $linkBatch = new LinkBatch();
             for ($i = $this->mRange[0]; $i <= $this->mRange[1]; $i++) {
                 $file = $this->mHist[$i];
                 $user = $file->getUser('text');
                 $linkBatch->add(NS_USER, $user);
                 $linkBatch->add(NS_USER_TALK, $user);
             }
             $linkBatch->execute();
         }
         $list = new ImageHistoryList($this->mImagePage);
         # Generate prev/next links
         $navLink = $this->getNavigationBar();
         $s = $list->beginImageHistoryList($navLink);
         // Skip rows there just for paging links
         for ($i = $this->mRange[0]; $i <= $this->mRange[1]; $i++) {
             $file = $this->mHist[$i];
             $s .= $list->imageHistoryLine(!$file->isOld(), $file);
         }
         $s .= $list->endImageHistoryList($navLink);
         if ($list->getPreventClickjacking()) {
             $this->preventClickjacking();
         }
     }
     return $s;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:35,代码来源:ImageHistoryPseudoPager.php

示例4: getRevIncludes

 /**
  * Get template and image versions from parsing a revision
  * @param Page $article
  * @param Revision $rev
  * @param User $user
  * @param string $regen use 'regen' to force regeneration
  * @return array( templateIds, fileSHA1Keys )
  * templateIds like ParserOutput->mTemplateIds
  * fileSHA1Keys like ParserOutput->mImageTimeKeys
  */
 public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
 {
     global $wgParser, $wgMemc;
     wfProfileIn(__METHOD__);
     $versions = false;
     $key = self::getCacheKey($article->getTitle(), $rev->getId());
     if ($regen !== 'regen') {
         // check cache
         $versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
     }
     if (!is_array($versions)) {
         // cache miss
         $pOut = false;
         if ($rev->isCurrent()) {
             $parserCache = ParserCache::singleton();
             # Try current version parser cache (as anon)...
             $pOut = $parserCache->get($article, $article->makeParserOptions($user));
             if ($pOut == false && $rev->getUser()) {
                 // try the user who saved the change
                 $author = User::newFromId($rev->getUser());
                 $pOut = $parserCache->get($article, $article->makeParserOptions($author));
             }
         }
         // ParserOutput::mImageTimeKeys wasn't always there
         if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
             $title = $article->getTitle();
             $pOpts = ParserOptions::newFromUser($user);
             // Note: tidy off
             $pOut = $wgParser->parse($rev->getText(), $title, $pOpts, true, true, $rev->getId());
         }
         # Get the template/file versions used...
         $versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
         # Save to cache (check cache expiry for dynamic elements)...
         $data = FlaggedRevs::makeMemcObj($versions);
         $wgMemc->set($key, $data, $pOut->getCacheExpiry());
     } else {
         $tVersions =& $versions[0];
         // templates
         # Do a link batch query for page_latest...
         $lb = new LinkBatch();
         foreach ($tVersions as $ns => $tmps) {
             foreach ($tmps as $dbKey => $revIdDraft) {
                 $lb->add($ns, $dbKey);
             }
         }
         $lb->execute();
         # Update array with the current page_latest values.
         # This kludge is there since $newTemplates (thus $revIdDraft) is cached.
         foreach ($tVersions as $ns => &$tmps) {
             foreach ($tmps as $dbKey => &$revIdDraft) {
                 $title = Title::makeTitle($ns, $dbKey);
                 $revIdDraft = (int) $title->getLatestRevID();
             }
         }
     }
     wfProfileOut(__METHOD__);
     return $versions;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:68,代码来源:FRInclusionCache.php

示例5: preprocessResults

 /**
  * Pre-cache page existence to speed up link generation
  *
  * @param Database $dbr Database connection
  * @param int $res Result pointer
  */
 public function preprocessResults($db, $res)
 {
     $batch = new LinkBatch();
     while ($row = $db->fetchObject($res)) {
         $batch->add($row->namespace, $row->title);
     }
     $batch->execute();
     if ($db->numRows($res) > 0) {
         $db->dataSeek($res, 0);
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:17,代码来源:SpecialMostlinkedtemplates.php

示例6: preprocessResults

 /**
  * Pre-fill the link cache
  *
  * @param DatabaseBase $db
  * @param ResultWrapper $res
  */
 function preprocessResults($db, $res)
 {
     if ($res->numRows() > 0) {
         $linkBatch = new LinkBatch();
         foreach ($res as $row) {
             $linkBatch->add($row->namespace, $row->title);
         }
         $res->seek(0);
         $linkBatch->execute();
     }
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:17,代码来源:SpecialListDuplicatedFiles.php

示例7: preprocessResults

 /**
  * Pre-cache page existence to speed up link generation
  *
  * @param $db Database connection
  * @param $res ResultWrapper
  */
 public function preprocessResults($db, $res)
 {
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add($row->namespace, $row->title);
     }
     $batch->execute();
     if ($db->numRows($res) > 0) {
         $db->dataSeek($res, 0);
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:17,代码来源:SpecialMostlinkedtemplates.php

示例8: getStartBody

 function getStartBody()
 {
     # Do a link batch query
     $this->mResult->seek(0);
     $lb = new LinkBatch();
     foreach ($this->mResult as $row) {
         $lb->add($row->pt_namespace, $row->pt_title);
     }
     $lb->execute();
     return '';
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:11,代码来源:ProtectedTitlesPager.php

示例9: preprocessResults

 /**
  * Pre-cache page existence to speed up link generation
  *
  * @param $db DatabaseBase connection
  * @param $res ResultWrapper
  */
 public function preprocessResults($db, $res)
 {
     if (!$res->numRows()) {
         return;
     }
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add($row->namespace, $row->title);
     }
     $batch->execute();
     $res->seek(0);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:18,代码来源:SpecialMostlinkedtemplates.php

示例10: preprocessResults

 /**
  * Fetch user page links and cache their existence
  *
  * @param $db DatabaseBase
  * @param $res DatabaseResult
  */
 function preprocessResults($db, $res)
 {
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add(NS_CATEGORY, $row->title);
     }
     $batch->execute();
     // Back to start for display
     if ($db->numRows($res) > 0) {
         // If there are no rows we get an error seeking.
         $db->dataSeek($res, 0);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:SpecialMostlinkedcategories.php

示例11: preprocessResults

 /**
  * Fetch user page links and cache their existence
  */
 function preprocessResults($db, $res)
 {
     $batch = new LinkBatch();
     while ($row = $db->fetchObject($res)) {
         $batch->add($row->namespace, $row->title);
     }
     $batch->execute();
     // Back to start for display
     if ($db->numRows($res) > 0) {
         // If there are no rows we get an error seeking.
         $db->dataSeek($res, 0);
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:16,代码来源:SpecialWantedtemplates.php

示例12: preprocessResults

 /**
  * Fetch user page links and cache their existence
  *
  * @param $db DatabaseBase
  * @param $res DatabaseResult
  */
 function preprocessResults($db, $res)
 {
     if (!$res->numRows()) {
         return;
     }
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add(NS_CATEGORY, $row->title);
     }
     $batch->execute();
     // Back to start for display
     $res->seek(0);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:19,代码来源:SpecialMostlinkedcategories.php

示例13: execute

 /**
  * Main execution point
  *
  * @param string $subpage
  */
 public function execute($subpage)
 {
     $this->rcSubpage = $subpage;
     $this->feedFormat = $this->including() ? null : $this->getRequest()->getVal('feed');
     if ($this->feedFormat !== 'atom' && $this->feedFormat !== 'rss') {
         $this->feedFormat = null;
     }
     $this->setHeaders();
     $this->outputHeader();
     $this->addModules();
     $opts = $this->getOptions();
     // Fetch results, prepare a batch link existence check query
     $conds = $this->buildMainQueryConds($opts);
     $rows = $this->doMainQuery($conds, $opts);
     if ($rows === false || $rows->numRows() == 0) {
         if (!$this->including()) {
             $this->doHeader($opts);
         }
         return;
     }
     if (!$this->feedFormat) {
         $batch = new LinkBatch();
         foreach ($rows as $row) {
             $batch->add(NS_USER, $row->rc_user_text);
             $batch->add(NS_USER_TALK, $row->rc_user_text);
             $batch->add($row->rc_namespace, $row->rc_title);
         }
         $batch->execute();
     }
     if ($this->feedFormat) {
         list($changesFeed, $formatter) = $this->getFeedObject($this->feedFormat);
         /** @var ChangesFeed $changesFeed */
         $changesFeed->execute($formatter, $rows, $this->checkLastModified($this->feedFormat), $opts);
     } else {
         $this->webOutput($rows, $opts);
     }
     $rows->free();
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:43,代码来源:ChangesListSpecialPage.php

示例14: preprocessResults

 /**
  * Cache page existence for performance
  *
  * @param IDatabase $db
  * @param ResultWrapper $res
  */
 function preprocessResults($db, $res)
 {
     if (!$res->numRows()) {
         return;
     }
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add($row->namespace, $row->title);
         $batch->addObj($this->getRedirectTarget($row));
     }
     $batch->execute();
     // Back to start for display
     $res->seek(0);
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:20,代码来源:SpecialListredirects.php

示例15: preprocessResults

 /**
  * Cache page existence for performance
  *
  * @param $db DatabaseBase
  * @param $res ResultWrapper
  */
 function preprocessResults($db, $res)
 {
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add($row->namespace, $row->title);
         $batch->addObj($this->getRedirectTarget($row));
     }
     $batch->execute();
     // Back to start for display
     if ($db->numRows($res) > 0) {
         // If there are no rows we get an error seeking.
         $db->dataSeek($res, 0);
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:20,代码来源:SpecialListredirects.php


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