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


PHP ParserOptions::getTargetLanguage方法代码示例

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


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

示例1: getTargetLanguage

 /**
  * Get the target language for the content being parsed. This is usually the
  * language that the content is in.
  *
  * @since 1.19
  *
  * @throws MWException
  * @return Language|null
  */
 public function getTargetLanguage()
 {
     $target = $this->mOptions->getTargetLanguage();
     if ($target !== null) {
         return $target;
     } elseif ($this->mOptions->getInterfaceMessage()) {
         return $this->mOptions->getUserLangObj();
     } elseif (is_null($this->mTitle)) {
         throw new MWException(__METHOD__ . ': $this->mTitle is null');
     }
     return $this->mTitle->getPageLanguage();
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:21,代码来源:Parser.php

示例2: fillParserOutput

 /**
  * Fill $output with information derived from the content.
  * @param $title Title
  * @param $revId int
  * @param $options ParserOptions
  * @param $generateHtml bool
  * @param $output ParserOutput
  */
 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     global $wgParser;
     $this->decode();
     $lang = $options->getTargetLanguage();
     if (!$lang) {
         $lang = $title->getPageLanguage();
     }
     $listOptions = $this->getFullRenderListOptions() + (array) $this->options + $this->getDefaultOptions();
     $text = $this->convertToWikitext($lang, $listOptions);
     $output = $wgParser->parse($text, $title, $options, true, true, $revId);
     if ($this->displaymode == 'members') {
         $isMemberList = true;
     } else {
         $isMemberList = false;
     }
     $output->addJsConfigVars('wgCollaborationKitIsMemberList', $isMemberList);
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-CollaborationKit,代码行数:26,代码来源:CollaborationListContent.php

示例3: getFunctionLang

 /**
  * @return Language
  */
 function getFunctionLang()
 {
     $target = $this->mOptions->getTargetLanguage();
     if ($target !== null) {
         return $target;
     } elseif ($this->mOptions->getInterfaceMessage()) {
         global $wgLang;
         return $wgLang;
     } elseif (is_null($this->mTitle)) {
         throw new MWException(__METHOD__ . ': $this->mTitle is null');
     }
     return $this->mTitle->getPageLanguage();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:16,代码来源:Parser.php

示例4: 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


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