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


PHP ParserOutput::addTemplate方法代码示例

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


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

示例1: testGetTemplates

 public function testGetTemplates()
 {
     $title = Title::makeTitle(NS_TEMPLATE, 'Cite_news');
     $parserOutput = new ParserOutput();
     $parserOutput->addTemplate($title, 10, 100);
     $searchDataExtractor = new ParserOutputSearchDataExtractor();
     $this->assertEquals(['Template:Cite news'], $searchDataExtractor->getTemplates($parserOutput));
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:8,代码来源:ParserOutputSearchDataExtractorTest.php

示例2: fetchTemplateAndTitle

 /**
  * Fetch the unparsed text of a template and register a reference to it.
  * @param Title $title
  * @return Array ( string or false, Title )
  */
 function fetchTemplateAndTitle($title)
 {
     $templateCb = $this->mOptions->getTemplateCallback();
     # Defaults to Parser::statelessFetchTemplate()
     $stuff = call_user_func($templateCb, $title, $this);
     $text = $stuff['text'];
     $finalTitle = isset($stuff['finalTitle']) ? $stuff['finalTitle'] : $title;
     if (isset($stuff['deps'])) {
         foreach ($stuff['deps'] as $dep) {
             $this->mOutput->addTemplate($dep['title'], $dep['page_id'], $dep['rev_id']);
             if ($dep['title']->equals($this->getTitle())) {
                 // If we transclude ourselves, the final result
                 // will change based on the new version of the page
                 $this->mOutput->setFlag('vary-revision');
             }
         }
     }
     return array($text, $finalTitle);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:24,代码来源:Parser.php

示例3: fetchTemplateAndTitle

 /**
  * Fetch the unparsed text of a template and register a reference to it.
  * @param Title $title
  * @return array ( string or false, Title )
  */
 public function fetchTemplateAndTitle($title)
 {
     // Defaults to Parser::statelessFetchTemplate()
     $templateCb = $this->mOptions->getTemplateCallback();
     $stuff = call_user_func($templateCb, $title, $this);
     // We use U+007F DELETE to distinguish strip markers from regular text.
     $text = $stuff['text'];
     if (is_string($stuff['text'])) {
         $text = strtr($text, "", "?");
     }
     $finalTitle = isset($stuff['finalTitle']) ? $stuff['finalTitle'] : $title;
     if (isset($stuff['deps'])) {
         foreach ($stuff['deps'] as $dep) {
             $this->mOutput->addTemplate($dep['title'], $dep['page_id'], $dep['rev_id']);
             if ($dep['title']->equals($this->getTitle())) {
                 // If we transclude ourselves, the final result
                 // will change based on the new version of the page
                 $this->mOutput->setFlag('vary-revision');
             }
         }
     }
     return array($text, $finalTitle);
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:28,代码来源:Parser.php

示例4: fetchTemplateAndTitle

 /**
  * Fetch the unparsed text of a template and register a reference to it.
  * @param Title $title
  * @return Array ( string or false, Title )
  */
 function fetchTemplateAndTitle($title)
 {
     $templateCb = $this->mOptions->getTemplateCallback();
     # Defaults to Parser::statelessFetchTemplate()
     $stuff = call_user_func($templateCb, $title, $this);
     $text = $stuff['text'];
     $finalTitle = isset($stuff['finalTitle']) ? $stuff['finalTitle'] : $title;
     if (isset($stuff['deps'])) {
         foreach ($stuff['deps'] as $dep) {
             $this->mOutput->addTemplate($dep['title'], $dep['page_id'], $dep['rev_id']);
         }
     }
     return array($text, $finalTitle);
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:19,代码来源:Parser.php

示例5: getParsedContent

 /**
  * Helper function for fillParserOutput; the bulk of the actual content
  * @param $title Title
  * @param $options ParserOptions
  * @param &$output ParserOutput
  * @return string
  */
 protected function getParsedContent(Title $title, ParserOptions $options, ParserOutput &$output)
 {
     global $wgParser;
     $lang = $options->getTargetLanguage();
     if (!$lang) {
         $lang = $title->getPageLanguage();
     }
     $html = '';
     foreach ($this->getContent() as $item) {
         if (!isset($item['title']) || $item['title'] == '') {
             continue;
         }
         $spTitle = Title::newFromText($item['title']);
         $spRev = Revision::newFromTitle($spTitle);
         // open element and do header
         $html .= $this->makeHeader($title, $item);
         if (isset($spRev)) {
             // DO CONTENT FROM PAGE
             $spContent = $spRev->getContent();
             $spContentModel = $spRev->getContentModel();
             if ($spContentModel == 'CollaborationHubContent') {
                 // this is dumb, but we'll just rebuild the intro here for now
                 $text = Html::rawElement('div', ['class' => 'mw-ck-hub-image'], $spContent->getParsedImage($spContent->getImage(), 100));
                 $text .= $spContent->getParsedIntroduction($spTitle, $options);
             } elseif ($spContentModel == 'CollaborationListContent') {
                 // convert to wikitext with maxItems limit in place
                 $wikitext = $spContent->convertToWikitext($lang, ['includeDesc' => false, 'maxItems' => 4, 'defaultSort' => 'random']);
                 $text = $wgParser->parse($wikitext, $title, $options)->getText();
             } elseif ($spContentModel == 'wikitext') {
                 // to grab first section only
                 $spContent = $spContent->getSection(0);
                 // Do template preproccessing magic
                 // ... parse, get text into $text
                 $rawText = $spContent->serialize();
                 // Get rid of all <noinclude>'s.
                 $wgParser->startExternalParse($title, $options, Parser::OT_WIKI);
                 $frame = $wgParser->getPreprocessor()->newFrame()->newChild([], $spTitle);
                 $node = $wgParser->preprocessToDom($rawText, Parser::PTD_FOR_INCLUSION);
                 $processedText = $frame->expand($node, PPFrame::RECOVER_ORIG & ~PPFrame::NO_IGNORE);
                 $parsedWikitext = $wgParser->parse($processedText, $title, $options);
                 $text = $parsedWikitext->getText();
                 $output->addModuleStyles($parsedWikitext->getModuleStyles());
             } else {
                 // Parse whatever (else) as whatever
                 $contentOutput = $spContent->getParserOutput($spTitle, $spRev, $options);
                 $output->addModuleStyles($contentOutput->getModuleStyles());
                 $text = $contentOutput->getRawText();
             }
             $html .= $text;
             // register as template for stuff
             $output->addTemplate($spTitle, $spTitle->getArticleId(), $spRev->getId());
         } else {
             // DO CONTENT FOR NOT YET MADE PAGE
             $html .= Html::rawElement('p', ['class' => 'mw-ck-hub-missingfeature-note'], wfMessage('collaborationkit-hub-missingpage-note')->inContentLanguage()->parse());
             $html .= new OOUI\ButtonWidget(['label' => wfMessage('collaborationkit-hub-missingpage-create')->inContentLanguage()->text(), 'href' => SpecialPage::getTitleFor('CreateHubFeature')->getFullUrl(['collaborationhub' => $title->getFullText(), 'feature' => $spTitle->getSubpageText()])]);
             // register as template for stuff
             $output->addTemplate($spTitle, $spTitle->getArticleId(), null);
         }
         $html .= Html::closeElement('div');
     }
     return $html;
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-CollaborationKit,代码行数:69,代码来源:CollaborationHubContent.php


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