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


PHP SpecialPage::exists方法代码示例

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


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

示例1: ifexistCommon

 public static function ifexistCommon($parser, $frame, $titletext = '', $then = '', $else = '')
 {
     global $wgContLang;
     $title = Title::newFromText($titletext);
     $wgContLang->findVariantLink($titletext, $title, true);
     if ($title) {
         if ($title->getNamespace() == NS_MEDIA) {
             /* If namespace is specified as NS_MEDIA, then we want to
              * check the physical file, not the "description" page.
              */
             if (!self::incrementIfexistCount($parser, $frame)) {
                 return $else;
             }
             $file = wfFindFile($title);
             if (!$file) {
                 return $else;
             }
             $parser->mOutput->addImage($file->getName(), $file->getTimestamp(), $file->getSha1());
             return $file->exists() ? $then : $else;
         } elseif ($title->getNamespace() == NS_SPECIAL) {
             /* Don't bother with the count for special pages,
              * since their existence can be checked without
              * accessing the database.
              */
             return SpecialPage::exists($title->getDBkey()) ? $then : $else;
         } elseif ($title->isExternal()) {
             /* Can't check the existence of pages on other sites,
              * so just return $else.  Makes a sort of sense, since
              * they don't exist _locally_.
              */
             return $else;
         } else {
             $pdbk = $title->getPrefixedDBkey();
             $lc = LinkCache::singleton();
             if (!self::incrementIfexistCount($parser, $frame)) {
                 return $else;
             }
             if (0 != ($id = $lc->getGoodLinkID($pdbk))) {
                 $parser->mOutput->addLink($title, $id);
                 return $then;
             } elseif ($lc->isBadLink($pdbk)) {
                 $parser->mOutput->addLink($title, 0);
                 return $else;
             }
             $id = $title->getArticleID();
             $parser->mOutput->addLink($title, $id);
             if ($id) {
                 return $then;
             }
         }
     }
     return $else;
 }
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:53,代码来源:ParserFunctions_body.php

示例2: shouldFollow

 private function shouldFollow(&$title)
 {
     global $wgUser;
     if ($title) {
         $namespace = $title->getNamespace();
         if (!Misc::allowRedirectFromLogin($title)) {
             return false;
         }
         //leaving in case we open it back up
         /*if( $namespace == NS_MAIN && $title->exists() ) {
         			return true;
         		}*/
         if ($namespace == NS_SPECIAL && SpecialPage::exists($title->getText())) {
             $requiresLogin = Misc::requiresLogin($title);
             if ($wgUser->getID() > 0 || !$requiresLogin) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:21,代码来源:SpecialUserlogin.php

示例3: outputGeneralPageInfo

 /**
  * Appends an element for each page in the current pageSet with the
  * most general information (id, title), plus any title normalizations
  * and missing or invalid title/pageids/revids.
  */
 private function outputGeneralPageInfo()
 {
     $pageSet = $this->getPageSet();
     $result = $this->getResult();
     // We don't check for a full result set here because we can't be adding
     // more than 380K. The maximum revision size is in the megabyte range,
     // and the maximum result size must be even higher than that.
     // Title normalizations
     $normValues = array();
     foreach ($pageSet->getNormalizedTitles() as $rawTitleStr => $titleStr) {
         $normValues[] = array('from' => $rawTitleStr, 'to' => $titleStr);
     }
     if (count($normValues)) {
         $result->setIndexedTagName($normValues, 'n');
         $result->addValue('query', 'normalized', $normValues);
     }
     // Title conversions
     $convValues = array();
     foreach ($pageSet->getConvertedTitles() as $rawTitleStr => $titleStr) {
         $convValues[] = array('from' => $rawTitleStr, 'to' => $titleStr);
     }
     if (count($convValues)) {
         $result->setIndexedTagName($convValues, 'c');
         $result->addValue('query', 'converted', $convValues);
     }
     // Interwiki titles
     $intrwValues = array();
     foreach ($pageSet->getInterwikiTitles() as $rawTitleStr => $interwikiStr) {
         $intrwValues[] = array('title' => $rawTitleStr, 'iw' => $interwikiStr);
     }
     if (count($intrwValues)) {
         $result->setIndexedTagName($intrwValues, 'i');
         $result->addValue('query', 'interwiki', $intrwValues);
     }
     // Show redirect information
     $redirValues = array();
     foreach ($pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo) {
         $redirValues[] = array('from' => strval($titleStrFrom), 'to' => $titleStrTo);
     }
     if (count($redirValues)) {
         $result->setIndexedTagName($redirValues, 'r');
         $result->addValue('query', 'redirects', $redirValues);
     }
     // Missing revision elements
     $missingRevIDs = $pageSet->getMissingRevisionIDs();
     if (count($missingRevIDs)) {
         $revids = array();
         foreach ($missingRevIDs as $revid) {
             $revids[$revid] = array('revid' => $revid);
         }
         $result->setIndexedTagName($revids, 'rev');
         $result->addValue('query', 'badrevids', $revids);
     }
     // Page elements
     $pages = array();
     // Report any missing titles
     foreach ($pageSet->getMissingTitles() as $fakeId => $title) {
         $vals = array();
         ApiQueryBase::addTitleInfo($vals, $title);
         $vals['missing'] = '';
         $pages[$fakeId] = $vals;
     }
     // Report any invalid titles
     foreach ($pageSet->getInvalidTitles() as $fakeId => $title) {
         $pages[$fakeId] = array('title' => $title, 'invalid' => '');
     }
     // Report any missing page ids
     foreach ($pageSet->getMissingPageIDs() as $pageid) {
         $pages[$pageid] = array('pageid' => $pageid, 'missing' => '');
     }
     // Report special pages
     foreach ($pageSet->getSpecialTitles() as $fakeId => $title) {
         $vals = array();
         ApiQueryBase::addTitleInfo($vals, $title);
         $vals['special'] = '';
         if ($title->getNamespace() == NS_SPECIAL && !SpecialPage::exists($title->getDbKey())) {
             $vals['missing'] = '';
         } elseif ($title->getNamespace() == NS_MEDIA && !wfFindFile($title)) {
             $vals['missing'] = '';
         }
         $pages[$fakeId] = $vals;
     }
     // Output general page information for found titles
     foreach ($pageSet->getGoodTitles() as $pageid => $title) {
         $vals = array();
         $vals['pageid'] = $pageid;
         ApiQueryBase::addTitleInfo($vals, $title);
         $pages[$pageid] = $vals;
     }
     if (count($pages)) {
         if ($this->params['indexpageids']) {
             $pageIDs = array_keys($pages);
             // json treats all map keys as strings - converting to match
             $pageIDs = array_map('strval', $pageIDs);
             $result->setIndexedTagName($pageIDs, 'id');
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:ApiQuery.php

示例4: replaceLinkHolders

 /**
  * Replace <!--LINK--> link placeholders with actual links, in the buffer
  * Placeholders created in Skin::makeLinkObj()
  * Returns an array of link CSS classes, indexed by PDBK.
  * $options is a bit field, RLH_FOR_UPDATE to select for update
  */
 function replaceLinkHolders(&$text, $options = 0)
 {
     global $wgUser;
     global $wgContLang;
     $fname = 'Parser::replaceLinkHolders';
     wfProfileIn($fname);
     $pdbks = array();
     $colours = array();
     $linkcolour_ids = array();
     $sk = $this->mOptions->getSkin();
     $linkCache =& LinkCache::singleton();
     if (!empty($this->mLinkHolders['namespaces'])) {
         wfProfileIn($fname . '-check');
         $dbr = wfGetDB(DB_SLAVE);
         $page = $dbr->tableName('page');
         $threshold = $wgUser->getOption('stubthreshold');
         # Sort by namespace
         asort($this->mLinkHolders['namespaces']);
         # Generate query
         $query = false;
         $current = null;
         foreach ($this->mLinkHolders['namespaces'] as $key => $ns) {
             # Make title object
             $title = $this->mLinkHolders['titles'][$key];
             # Skip invalid entries.
             # Result will be ugly, but prevents crash.
             if (is_null($title)) {
                 continue;
             }
             $pdbk = $pdbks[$key] = $title->getPrefixedDBkey();
             # Check if it's a static known link, e.g. interwiki
             if ($title->isAlwaysKnown()) {
                 $colours[$pdbk] = '';
             } elseif (($id = $linkCache->getGoodLinkID($pdbk)) != 0) {
                 $colours[$pdbk] = '';
                 $this->mOutput->addLink($title, $id);
             } elseif ($linkCache->isBadLink($pdbk)) {
                 $colours[$pdbk] = 'new';
             } elseif ($title->getNamespace() == NS_SPECIAL && !SpecialPage::exists($pdbk)) {
                 $colours[$pdbk] = 'new';
             } else {
                 # Not in the link cache, add it to the query
                 if (!isset($current)) {
                     $current = $ns;
                     $query = "SELECT page_id, page_namespace, page_title, page_is_redirect";
                     if ($threshold > 0) {
                         $query .= ', page_len';
                     }
                     $query .= " FROM {$page} WHERE (page_namespace={$ns} AND page_title IN(";
                 } elseif ($current != $ns) {
                     $current = $ns;
                     $query .= ")) OR (page_namespace={$ns} AND page_title IN(";
                 } else {
                     $query .= ', ';
                 }
                 $query .= $dbr->addQuotes($this->mLinkHolders['dbkeys'][$key]);
             }
         }
         if ($query) {
             $query .= '))';
             if ($options & RLH_FOR_UPDATE) {
                 $query .= ' FOR UPDATE';
             }
             $res = $dbr->query($query, $fname);
             # Fetch data and form into an associative array
             # non-existent = broken
             while ($s = $dbr->fetchObject($res)) {
                 $title = Title::makeTitle($s->page_namespace, $s->page_title);
                 $pdbk = $title->getPrefixedDBkey();
                 $linkCache->addGoodLinkObj($s->page_id, $title);
                 $this->mOutput->addLink($title, $s->page_id);
                 $colours[$pdbk] = $sk->getLinkColour($s, $threshold);
                 //add id to the extension todolist
                 $linkcolour_ids[$s->page_id] = $pdbk;
             }
             //pass an array of page_ids to an extension
             wfRunHooks('GetLinkColours', array($linkcolour_ids, &$colours));
         }
         wfProfileOut($fname . '-check');
         # Do a second query for different language variants of links and categories
         if ($wgContLang->hasVariants()) {
             $linkBatch = new LinkBatch();
             $variantMap = array();
             // maps $pdbkey_Variant => $keys (of link holders)
             $categoryMap = array();
             // maps $category_variant => $category (dbkeys)
             $varCategories = array();
             // category replacements oldDBkey => newDBkey
             $categories = $this->mOutput->getCategoryLinks();
             // Add variants of links to link batch
             foreach ($this->mLinkHolders['namespaces'] as $key => $ns) {
                 $title = $this->mLinkHolders['titles'][$key];
                 if (is_null($title)) {
                     continue;
//.........这里部分代码省略.........
开发者ID:renemilk,项目名称:spring-website,代码行数:101,代码来源:Parser.php

示例5: isAlwaysKnown

 /**
  * Should links to this title be shown as potentially viewable (i.e. as
  * "bluelinks"), even if there's no record by this title in the page
  * table?
  *
  * This function is semi-deprecated for public use, as well as somewhat
  * misleadingly named.  You probably just want to call isKnown(), which
  * calls this function internally.
  *
  * (ISSUE: Most of these checks are cheap, but the file existence check
  * can potentially be quite expensive.  Including it here fixes a lot of
  * existing code, but we might want to add an optional parameter to skip
  * it and any other expensive checks.)
  *
  * @return \type{\bool}
  */
 public function isAlwaysKnown()
 {
     if ($this->mInterwiki != '') {
         return true;
         // any interwiki link might be viewable, for all we know
     }
     switch ($this->mNamespace) {
         case NS_MEDIA:
         case NS_FILE:
             return (bool) wfFindFile($this);
             // file exists, possibly in a foreign repo
         // file exists, possibly in a foreign repo
         case NS_SPECIAL:
             return SpecialPage::exists($this->getDBkey());
             // valid special page
         // valid special page
         case NS_MAIN:
             return $this->mDbkeyform == '';
             // selflink, possibly with fragment
         // selflink, possibly with fragment
         case NS_MEDIAWIKI:
             // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes
             // the full l10n of that language to be loaded. That takes much memory and
             // isn't needed. So we strip the language part away.
             list($basename, ) = explode('/', $this->mDbkeyform, 2);
             return (bool) wfMsgWeirdKey($basename);
             // known system message
         // known system message
         default:
             return false;
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:48,代码来源:Title.php

示例6: makeLinkObj

 /**
  * Make a link for a title which may or may not be in the database. If you need to
  * call this lots of times, pre-fill the link cache with a LinkBatch, otherwise each
  * call to this will result in a DB query.
  * 
  * @param $nt     Title: the title object to make the link from, e.g. from
  *                      Title::newFromText.
  * @param $text  String: link text
  * @param $query String: optional query part
  * @param $trail String: optional trail. Alphabetic characters at the start of this string will
  *                      be included in the link text. Other characters will be appended after
  *                      the end of the link.
  * @param $prefix String: optional prefix. As trail, only before instead of after.
  */
 function makeLinkObj($nt, $text = '', $query = '', $trail = '', $prefix = '')
 {
     global $wgUser;
     wfProfileIn(__METHOD__);
     if (!$nt instanceof Title) {
         # Fail gracefully
         wfProfileOut(__METHOD__);
         return "<!-- ERROR -->{$prefix}{$text}{$trail}";
     }
     if ($nt->isExternal()) {
         $u = $nt->getFullURL();
         $link = $nt->getPrefixedURL();
         if ('' == $text) {
             $text = $nt->getPrefixedText();
         }
         $style = $this->getInterwikiLinkAttributes($link, $text, 'extiw');
         $inside = '';
         if ('' != $trail) {
             $m = array();
             if (preg_match('/^([a-z]+)(.*)$$/sD', $trail, $m)) {
                 $inside = $m[1];
                 $trail = $m[2];
             }
         }
         $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
         wfProfileOut(__METHOD__);
         return $t;
     } elseif ($nt->isAlwaysKnown()) {
         # Image links, special page links and self-links with fragements are always known.
         $retVal = $this->makeKnownLinkObj($nt, $text, $query, $trail, $prefix);
     } else {
         wfProfileIn(__METHOD__ . '-immediate');
         # Handles links to special pages which do not exist in the database:
         if ($nt->getNamespace() == NS_SPECIAL) {
             if (SpecialPage::exists($nt->getDBkey())) {
                 $retVal = $this->makeKnownLinkObj($nt, $text, $query, $trail, $prefix);
             } else {
                 $retVal = $this->makeBrokenLinkObj($nt, $text, $query, $trail, $prefix);
             }
             wfProfileOut(__METHOD__ . '-immediate');
             wfProfileOut(__METHOD__);
             return $retVal;
         }
         # Work out link colour immediately
         $aid = $nt->getArticleID();
         if (0 == $aid) {
             $retVal = $this->makeBrokenLinkObj($nt, $text, $query, $trail, $prefix);
         } else {
             $colour = '';
             if ($nt->isContentPage()) {
                 # FIXME: This is stupid, we should combine this query with
                 # the Title::getArticleID() query above.
                 $threshold = $wgUser->getOption('stubthreshold');
                 $dbr = wfGetDB(DB_SLAVE);
                 $s = $dbr->selectRow(array('page'), array('page_len', 'page_is_redirect', 'page_namespace'), array('page_id' => $aid), __METHOD__);
                 $colour = $this->getLinkColour($s, $threshold);
             }
             $retVal = $this->makeColouredLinkObj($nt, $colour, $text, $query, $trail, $prefix);
         }
         wfProfileOut(__METHOD__ . '-immediate');
     }
     wfProfileOut(__METHOD__);
     return $retVal;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:78,代码来源:Linker.php


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