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


PHP ParserOutput::addCategory方法代码示例

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


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

示例1: addTrackingCategory

 /**
  * Add a tracking category, getting the title from a system message,
  * or print a debug message if the title is invalid.
  *
  * Please add any message that you use with this function to
  * $wgTrackingCategories. That way they will be listed on
  * Special:TrackingCategories.
  *
  * @param string $msg Message key
  * @return bool Whether the addition was successful
  */
 public function addTrackingCategory($msg)
 {
     if ($this->mTitle->getNamespace() === NS_SPECIAL) {
         wfDebug(__METHOD__ . ": Not adding tracking category {$msg} to special page!\n");
         return false;
     }
     // Important to parse with correct title (bug 31469)
     $cat = wfMessage($msg)->title($this->getTitle())->inContentLanguage()->text();
     # Allow tracking categories to be disabled by setting them to "-"
     if ($cat === '-') {
         return false;
     }
     $containerCategory = Title::makeTitleSafe(NS_CATEGORY, $cat);
     if ($containerCategory) {
         $this->mOutput->addCategory($containerCategory->getDBkey(), $this->getDefaultSort());
         return true;
     } else {
         wfDebug(__METHOD__ . ": [[MediaWiki:{$msg}]] is not a valid title!\n");
         return false;
     }
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:32,代码来源:Parser.php

示例2: addTrackingCategory

 /**
  * Add a tracking category, getting the title from a system message,
  * or print a debug message if the title is invalid.
  *
  * @param $msg String: message key
  * @return Boolean: whether the addition was successful
  */
 protected function addTrackingCategory($msg)
 {
     if ($this->mTitle->getNamespace() === NS_SPECIAL) {
         wfDebug(__METHOD__ . ": Not adding tracking category {$msg} to special page!\n");
         return false;
     }
     $cat = wfMsgForContent($msg);
     # Allow tracking categories to be disabled by setting them to "-"
     if ($cat === '-') {
         return false;
     }
     $containerCategory = Title::makeTitleSafe(NS_CATEGORY, $cat);
     if ($containerCategory) {
         $this->mOutput->addCategory($containerCategory->getDBkey(), $this->getDefaultSort());
         return true;
     } else {
         wfDebug(__METHOD__ . ": [[MediaWiki:{$msg}]] is not a valid title!\n");
         return false;
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:27,代码来源:Parser.php

示例3: replaceInternalLinks2


//.........这里部分代码省略.........
         }
         $wasblank = $text == '';
         if ($wasblank) {
             $text = $link;
         } else {
             # Bug 4598 madness. Handle the quotes only if they come from the alternate part
             # [[Lista d''e paise d''o munno]] -> <a href="...">Lista d''e paise d''o munno</a>
             # [[Criticism of Harry Potter|Criticism of ''Harry Potter'']]
             #    -> <a href="Criticism of Harry Potter">Criticism of <i>Harry Potter</i></a>
             $text = $this->doQuotes($text);
         }
         # Link not escaped by : , create the various objects
         if ($noforce && !$nt->wasLocalInterwiki()) {
             # Interwikis
             if ($iw && $this->mOptions->getInterwikiMagic() && $nottalk && (Language::fetchLanguageName($iw, null, 'mw') || in_array($iw, $wgExtraInterlanguageLinkPrefixes))) {
                 # Bug 24502: filter duplicates
                 if (!isset($this->mLangLinkLanguages[$iw])) {
                     $this->mLangLinkLanguages[$iw] = true;
                     $this->mOutput->addLanguageLink($nt->getFullText());
                 }
                 $s = rtrim($s . $prefix);
                 $s .= trim($trail, "\n") == '' ? '' : $prefix . $trail;
                 continue;
             }
             if ($ns == NS_FILE) {
                 if (!wfIsBadImage($nt->getDBkey(), $this->mTitle)) {
                     if ($wasblank) {
                         # if no parameters were passed, $text
                         # becomes something like "File:Foo.png",
                         # which we don't want to pass on to the
                         # image generator
                         $text = '';
                     } else {
                         # recursively parse links inside the image caption
                         # actually, this will parse them in any other parameters, too,
                         # but it might be hard to fix that, and it doesn't matter ATM
                         $text = $this->replaceExternalLinks($text);
                         $holders->merge($this->replaceInternalLinks2($text));
                     }
                     # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
                     $s .= $prefix . $this->armorLinks($this->makeImage($nt, $text, $holders)) . $trail;
                 } else {
                     $s .= $prefix . $trail;
                 }
                 continue;
             }
             if ($ns == NS_CATEGORY) {
                 $s = rtrim($s . "\n");
                 # bug 87
                 if ($wasblank) {
                     $sortkey = $this->getDefaultSort();
                 } else {
                     $sortkey = $text;
                 }
                 $sortkey = Sanitizer::decodeCharReferences($sortkey);
                 $sortkey = str_replace("\n", '', $sortkey);
                 $sortkey = $this->getConverterLanguage()->convertCategoryKey($sortkey);
                 $this->mOutput->addCategory($nt->getDBkey(), $sortkey);
                 /**
                  * Strip the whitespace Category links produce, see bug 87
                  */
                 $s .= trim($prefix . $trail, "\n") == '' ? '' : $prefix . $trail;
                 continue;
             }
         }
         # Self-link checking. For some languages, variants of the title are checked in
         # LinkHolderArray::doVariants() to allow batching the existence checks necessary
         # for linking to a different variant.
         if ($ns != NS_SPECIAL && $nt->equals($this->mTitle) && !$nt->hasFragment()) {
             $s .= $prefix . Linker::makeSelfLinkObj($nt, $text, '', $trail);
             continue;
         }
         # NS_MEDIA is a pseudo-namespace for linking directly to a file
         # @todo FIXME: Should do batch file existence checks, see comment below
         if ($ns == NS_MEDIA) {
             # Give extensions a chance to select the file revision for us
             $options = array();
             $descQuery = false;
             Hooks::run('BeforeParserFetchFileAndTitle', array($this, $nt, &$options, &$descQuery));
             # Fetch and register the file (file title may be different via hooks)
             list($file, $nt) = $this->fetchFileAndTitle($nt, $options);
             # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
             $s .= $prefix . $this->armorLinks(Linker::makeMediaLinkFile($nt, $file, $text)) . $trail;
             continue;
         }
         # Some titles, such as valid special pages or files in foreign repos, should
         # be shown as bluelinks even though they're not included in the page table
         #
         # @todo FIXME: isAlwaysKnown() can be expensive for file links; we should really do
         # batch file existence checks for NS_FILE and NS_MEDIA
         if ($iw == '' && $nt->isAlwaysKnown()) {
             $this->mOutput->addLink($nt);
             $s .= $this->makeKnownLinkHolder($nt, $text, array(), $trail, $prefix);
         } else {
             # Links will be added to the output link list after checking
             $s .= $holders->makeHolder($nt, $text, array(), $trail, $prefix);
         }
     }
     return $holders;
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:101,代码来源:Parser.php

示例4: onContentGetParserOutput

 /**
  * @param $content
  * @param Title $title
  * @param $revId
  * @param $options
  * @param $generateHtml
  * @param ParserOutput $output
  *
  * @return bool
  */
 public static function onContentGetParserOutput($content, $title, $revId, $options, $generateHtml, &$output)
 {
     $output->addCategory('approvedrevs-tracking-category', '');
     return true;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-WRApprovedRevs,代码行数:15,代码来源:ApprovedRevs.hooks.php


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