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


PHP ParserOutput::getText方法代码示例

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


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

示例1: extractWikitextParts

 /**
  * Extract parts of the text - opening, main and auxiliary.
  */
 private function extractWikitextParts()
 {
     if (!is_null($this->allText)) {
         return;
     }
     $this->parserOutput->setEditSectionTokens(false);
     $this->parserOutput->setTOCEnabled(false);
     $text = $this->parserOutput->getText();
     if (strlen($text) == 0) {
         $this->allText = "";
         // empty text - nothing to seek here
         return;
     }
     $opening = null;
     $this->openingText = $this->extractHeadingBeforeFirstHeading($text);
     // Add extra spacing around break tags so text crammed together like<br>this
     // doesn't make one word.
     $text = str_replace('<br', "\n<br", $text);
     $formatter = new HtmlFormatter($text);
     // Strip elements from the page that we never want in the search text.
     $formatter->remove($this->excludedElementSelectors);
     $formatter->filterContent();
     // Strip elements from the page that are auxiliary text.  These will still be
     // searched but matches will be ranked lower and non-auxiliary matches will be
     // preferred in highlighting.
     $formatter->remove($this->auxiliaryElementSelectors);
     $auxiliaryElements = $formatter->filterContent();
     $this->allText = trim(Sanitizer::stripAllTags($formatter->getText()));
     foreach ($auxiliaryElements as $auxiliaryElement) {
         $this->auxText[] = trim(Sanitizer::stripAllTags($formatter->getText($auxiliaryElement)));
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:35,代码来源:WikiTextStructure.php

示例2: outputPageParserOutput

 /**
  * OutputPageParserOutput hook handler
  * @param OutputPage $out
  * @param ParserOutput $parserOutput
  * @return type 
  */
 public static function outputPageParserOutput(OutputPage &$out, ParserOutput $parserOutput)
 {
     $out->addModuleStyles('ext.articleEmblems');
     if (isset($parserOutput->articleEmblems)) {
         $emblems = array();
         foreach ($parserOutput->articleEmblems as $emblem) {
             $emblems[] = '<li class="articleEmblem">' . $emblem . '</li>';
         }
         $parserOutput->setText('<ul id="articleEmblems" class="noprint">' . implode($emblems) . '</ul>' . $parserOutput->getText());
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:ArticleEmblems.hooks.php

示例3: onOutputPageParserOutput

 /**
  * OutputPageParserOutput hook handler
  * Disables TOC in output before it grabs HTML
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
  *
  * @param OutputPage $outputPage
  * @param ParserOutput $po
  * @return bool
  */
 public static function onOutputPageParserOutput($outputPage, ParserOutput $po)
 {
     global $wgMFWikibaseImageCategory;
     $context = MobileContext::singleton();
     $isBeta = $context->isBetaGroupMember();
     $mfUseWikibaseDescription = $context->getMFConfig()->get('MFUseWikibaseDescription');
     if ($context->shouldDisplayMobileView()) {
         $outputPage->enableTOC(false);
         $outputPage->setProperty('MinervaTOC', $po->getTOCHTML() !== '');
         if ($mfUseWikibaseDescription && $isBeta) {
             $item = $po->getProperty('wikibase_item');
             if ($item) {
                 $desc = ExtMobileFrontend::getWikibaseDescription($item);
                 $category = ExtMobileFrontend::getWikibasePropertyValue($item, $wgMFWikibaseImageCategory);
                 if ($desc) {
                     $outputPage->setProperty('wgMFDescription', $desc);
                 }
                 if ($category) {
                     $outputPage->setProperty('wgMFImagesCategory', $category);
                 }
             }
         }
         // Enable wrapped sections
         $po->setText(ExtMobileFrontend::DOMParse($outputPage, $po->getText(), $isBeta));
     }
     return true;
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:36,代码来源:MobileFrontend.hooks.php

示例4: addParserOutputText

 /**
  * Add the HTML associated with a ParserOutput object, without any metadata.
  *
  * @since 1.24
  * @param ParserOutput $parserOutput
  */
 public function addParserOutputText($parserOutput)
 {
     $text = $parserOutput->getText();
     Hooks::run('OutputPageBeforeHTML', array(&$this, &$text));
     $this->addHTML($text);
 }
开发者ID:GoProjectOwner,项目名称:mediawiki,代码行数:12,代码来源:OutputPage.php

示例5: visualiseStrayTagsAndRemoveNotSupportedTags

 /**
  * Visualize <add> and <del> tags that are nested in themselves correctly. Remove tags that are not available in the editor for visualization.
  * These tags will still be visible in the editor. 
  */
 private function visualiseStrayTagsAndRemoveNotSupportedTags(ParserOutput $parser_output)
 {
     $text = $parser_output->getText();
     //look for stray </add> tags, and replace them with a tei-add span element
     $text = preg_replace('/<\\/span><\\/span>(.*?)&lt;\\/add&gt;/', '</span></span><span class="tei-add">$1</span>', $text);
     //look for stray </del> tags, and replace them with a tei-del span element
     $text = preg_replace('/<\\/span><\\/span>(.*?)&lt;\\/del&gt;/', '</span></span><span class="tei-del">$1</span>', $text);
     $text = preg_replace('/<\\/span><\\/span>(.*?)&lt;\\/hi&gt;/', '</span></span><span class="tei-hi superscript">$1</span>', $text);
     //look for any other escaped tags, and remove them
     $text = preg_replace('/&lt;(.*?)&gt;/s', '', $text);
     $parser_output->setText($text);
     return true;
 }
开发者ID:akvankorlaar,项目名称:manuscriptdesk,代码行数:17,代码来源:NewManuscript.hooks.php

示例6: execute

 public function execute()
 {
     // The data is hot but user-dependent, like page views, so we set vary cookies
     $this->getMain()->setCacheMode('anon-public-user-private');
     // Get parameters
     $params = $this->extractRequestParams();
     $text = $params['text'];
     $title = $params['title'];
     $page = $params['page'];
     $pageid = $params['pageid'];
     $oldid = $params['oldid'];
     if (!is_null($page) && (!is_null($text) || $title != 'API')) {
         $this->dieUsage('The page parameter cannot be used together with the text and title parameters', 'params');
     }
     $prop = array_flip($params['prop']);
     if (isset($params['section'])) {
         $this->section = $params['section'];
     } else {
         $this->section = false;
     }
     // The parser needs $wgTitle to be set, apparently the
     // $title parameter in Parser::parse isn't enough *sigh*
     // TODO: Does this still need $wgTitle?
     global $wgParser, $wgTitle, $wgLang;
     // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks
     $oldLang = null;
     if (isset($params['uselang']) && $params['uselang'] != $wgLang->getCode()) {
         $oldLang = $wgLang;
         // Backup wgLang
         $wgLang = Language::factory($params['uselang']);
     }
     $popts = ParserOptions::newFromContext($this->getContext());
     $popts->setTidy(true);
     $popts->enableLimitReport(!$params['disablepp']);
     $redirValues = null;
     // Return result
     $result = $this->getResult();
     if (!is_null($oldid) || !is_null($pageid) || !is_null($page)) {
         if (!is_null($oldid)) {
             // Don't use the parser cache
             $rev = Revision::newFromID($oldid);
             if (!$rev) {
                 $this->dieUsage("There is no revision ID {$oldid}", 'missingrev');
             }
             if (!$rev->userCan(Revision::DELETED_TEXT, $this->getUser())) {
                 $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
             }
             $titleObj = $rev->getTitle();
             $wgTitle = $titleObj;
             // If for some reason the "oldid" is actually the current revision, it may be cached
             if ($titleObj->getLatestRevID() === intval($oldid)) {
                 // May get from/save to parser cache
                 $p_result = $this->getParsedSectionOrText($titleObj, $popts, $pageid, isset($prop['wikitext']));
             } else {
                 // This is an old revision, so get the text differently
                 $this->text = $rev->getText(Revision::FOR_THIS_USER, $this->getUser());
                 if ($this->section !== false) {
                     $this->text = $this->getSectionText($this->text, 'r' . $rev->getId());
                 }
                 // Should we save old revision parses to the parser cache?
                 $p_result = $wgParser->parse($this->text, $titleObj, $popts);
             }
         } else {
             // Not $oldid, but $pageid or $page
             if ($params['redirects']) {
                 $reqParams = array('action' => 'query', 'redirects' => '');
                 if (!is_null($pageid)) {
                     $reqParams['pageids'] = $pageid;
                 } else {
                     // $page
                     $reqParams['titles'] = $page;
                 }
                 $req = new FauxRequest($reqParams);
                 $main = new ApiMain($req);
                 $main->execute();
                 $data = $main->getResultData();
                 $redirValues = isset($data['query']['redirects']) ? $data['query']['redirects'] : array();
                 $to = $page;
                 foreach ((array) $redirValues as $r) {
                     $to = $r['to'];
                 }
                 $titleObj = Title::newFromText($to);
             } else {
                 if (!is_null($pageid)) {
                     $reqParams['pageids'] = $pageid;
                     $titleObj = Title::newFromID($pageid);
                 } else {
                     // $page
                     $to = $page;
                     $titleObj = Title::newFromText($to);
                 }
             }
             if (!is_null($pageid)) {
                 if (!$titleObj) {
                     // Still throw nosuchpageid error if pageid was provided
                     $this->dieUsageMsg(array('nosuchpageid', $pageid));
                 }
             } elseif (!$titleObj || !$titleObj->exists()) {
                 $this->dieUsage("The page you specified doesn't exist", 'missingtitle');
             }
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:ApiParse.php


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