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


PHP ParserOutput::setText方法代码示例

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


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

示例1: fillParserOutput

 /**
  * Set the HTML and add the appropriate styles
  *
  *
  * @param Title $title
  * @param int $revId
  * @param ParserOptions $options
  * @param bool $generateHtml
  * @param ParserOutput $output
  */
 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     if ($generateHtml) {
         $html = Html::element('pre', array('class' => 'mw-code mw-yaml', 'dir' => 'ltr'), $this->getNativeData());
         $output->setText($html);
     } else {
         $output->setText('');
     }
 }
开发者ID:valhallasw,项目名称:mediawiki-extensions-OpenStackManager,代码行数:19,代码来源:YamlContent.php

示例2: fillParserOutput

 /**
  * Set the HTML and add the appropriate styles
  *
  *
  * @param Title $title
  * @param int $revId
  * @param ParserOptions $options
  * @param bool $generateHtml
  * @param ParserOutput $output
  */
 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     if ($generateHtml) {
         $output->setText($this->objectTable($this->getJsonData()));
         $output->addModuleStyles('mediawiki.content.json');
     } else {
         $output->setText('');
     }
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:19,代码来源:JSONContent.php

示例3: fillParserOutput

 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     // FIXME: WikiPage::doEditContent generates parser output before validation.
     // As such, native data may be invalid (though output is discarded later in that case).
     if ($generateHtml && $this->isValid()) {
         $output->setText($this->renderNotebook($this->getNativeData()));
     } else {
         $output->setText('error');
     }
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-NotebookViewer,代码行数:10,代码来源:NotebookContent.php

示例4: getParserOutput

 /**
  * Override getParserOutput, since we require $title to generate our output
  */
 function getParserOutput(Title $title, $revId = null, ParserOptions $otpions = null, $generateHtml = true)
 {
     $po = new ParserOutput();
     if ($generateHtml) {
         $po->setText($this->generateHtml($title));
     }
     return $po;
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:11,代码来源:CampaignContent.php

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

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

示例7: parse


//.........这里部分代码省略.........
      * c) It's a conversion table
      * d) it is an interface message (which is in the user language)
      */
     if (!($options->getDisableContentConversion() || isset($this->mDoubleUnderscores['nocontentconvert']))) {
         if (!$this->mOptions->getInterfaceMessage()) {
             # The position of the convert() call should not be changed. it
             # assumes that the links are all replaced and the only thing left
             # is the <nowiki> mark.
             $text = $this->getConverterLanguage()->convert($text);
         }
     }
     /**
      * A converted title will be provided in the output object if title and
      * content conversion are enabled, the article text does not contain
      * a conversion-suppressing double-underscore tag, and no
      * {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over
      * automatic link conversion.
      */
     if (!($options->getDisableTitleConversion() || isset($this->mDoubleUnderscores['nocontentconvert']) || isset($this->mDoubleUnderscores['notitleconvert']) || $this->mOutput->getDisplayTitle() !== false)) {
         $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
         if ($convruletitle) {
             $this->mOutput->setTitleText($convruletitle);
         } else {
             $titleText = $this->getConverterLanguage()->convertTitle($title);
             $this->mOutput->setTitleText($titleText);
         }
     }
     $text = $this->mStripState->unstripNoWiki($text);
     wfRunHooks('ParserBeforeTidy', array(&$this, &$text));
     $text = $this->replaceTransparentTags($text);
     $text = $this->mStripState->unstripGeneral($text);
     $text = Sanitizer::normalizeCharReferences($text);
     if ($wgUseTidy && $this->mOptions->getTidy() || $wgAlwaysUseTidy) {
         $text = MWTidy::tidy($text);
     } else {
         # attempt to sanitize at least some nesting problems
         # (bug #2702 and quite a few others)
         $tidyregs = array('/(<([bi])>)(<([bi])>)?([^<]*)(<\\/?a[^<]*>)([^<]*)(<\\/\\4>)?(<\\/\\2>)/' => '\\1\\3\\5\\8\\9\\6\\1\\3\\7\\8\\9', '/(<a[^>]+>)([^<]*)(<a[^>]+>[^<]*)<\\/a>(.*)<\\/a>/' => '\\1\\2</a>\\3</a>\\1\\4</a>', '/(<([aib]) [^>]+>)([^<]*)(<div([^>]*)>)(.*)(<\\/div>)([^<]*)(<\\/\\2>)/' => '\\1\\3&lt;div\\5&gt;\\6&lt;/div&gt;\\8\\9', '/<([bi])><\\/\\1>/' => '');
         $text = preg_replace(array_keys($tidyregs), array_values($tidyregs), $text);
     }
     if ($this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit()) {
         $this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit());
     }
     wfRunHooks('ParserAfterTidy', array(&$this, &$text));
     # Information on include size limits, for the benefit of users who try to skirt them
     if ($this->mOptions->getEnableLimitReport()) {
         $max = $this->mOptions->getMaxIncludeSize();
         $cpuTime = $this->mOutput->getTimeSinceStart('cpu');
         if ($cpuTime !== null) {
             $this->mOutput->setLimitReportData('limitreport-cputime', sprintf("%.3f", $cpuTime));
         }
         $wallTime = $this->mOutput->getTimeSinceStart('wall');
         $this->mOutput->setLimitReportData('limitreport-walltime', sprintf("%.3f", $wallTime));
         $this->mOutput->setLimitReportData('limitreport-ppvisitednodes', array($this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount()));
         $this->mOutput->setLimitReportData('limitreport-ppgeneratednodes', array($this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount()));
         $this->mOutput->setLimitReportData('limitreport-postexpandincludesize', array($this->mIncludeSizes['post-expand'], $max));
         $this->mOutput->setLimitReportData('limitreport-templateargumentsize', array($this->mIncludeSizes['arg'], $max));
         $this->mOutput->setLimitReportData('limitreport-expansiondepth', array($this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth()));
         $this->mOutput->setLimitReportData('limitreport-expensivefunctioncount', array($this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit()));
         wfRunHooks('ParserLimitReportPrepare', array($this, $this->mOutput));
         $limitReport = "NewPP limit report\n";
         if ($wgShowHostnames) {
             $limitReport .= 'Parsed by ' . wfHostname() . "\n";
         }
         foreach ($this->mOutput->getLimitReportData() as $key => $value) {
             if (wfRunHooks('ParserLimitReportFormat', array($key, &$value, &$limitReport, false, false))) {
                 $keyMsg = wfMessage($key)->inLanguage('en')->useDatabase(false);
                 $valueMsg = wfMessage(array("{$key}-value-text", "{$key}-value"))->inLanguage('en')->useDatabase(false);
                 if (!$valueMsg->exists()) {
                     $valueMsg = new RawMessage('$1');
                 }
                 if (!$keyMsg->isDisabled() && !$valueMsg->isDisabled()) {
                     $valueMsg->params($value);
                     $limitReport .= "{$keyMsg->text()}: {$valueMsg->text()}\n";
                 }
             }
         }
         // Since we're not really outputting HTML, decode the entities and
         // then re-encode the things that need hiding inside HTML comments.
         $limitReport = htmlspecialchars_decode($limitReport);
         wfRunHooks('ParserLimitReport', array($this, &$limitReport));
         // Sanitize for comment. Note '‐' in the replacement is U+2010,
         // which looks much like the problematic '-'.
         $limitReport = str_replace(array('-', '&'), array('‐', '&amp;'), $limitReport);
         $text .= "\n<!-- \n{$limitReport}-->\n";
         if ($this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10) {
             wfDebugLog('generated-pp-node-count', $this->mGeneratedPPNodeCount . ' ' . $this->mTitle->getPrefixedDBkey());
         }
     }
     $this->mOutput->setText($text);
     $this->mRevisionId = $oldRevisionId;
     $this->mRevisionObject = $oldRevisionObject;
     $this->mRevisionTimestamp = $oldRevisionTimestamp;
     $this->mRevisionUser = $oldRevisionUser;
     $this->mRevisionSize = $oldRevisionSize;
     $this->mInputSize = false;
     wfProfileOut($fname);
     wfProfileOut(__METHOD__);
     return $this->mOutput;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:Parser.php

示例8: parse


//.........这里部分代码省略.........
         $this->mRevisionId = $revid;
         $this->mRevisionObject = null;
         $this->mRevisionTimestamp = null;
         $this->mRevisionUser = null;
         $this->mRevisionSize = null;
     }
     Hooks::run('ParserBeforeStrip', array(&$this, &$text, &$this->mStripState));
     # No more strip!
     Hooks::run('ParserAfterStrip', array(&$this, &$text, &$this->mStripState));
     $text = $this->internalParse($text);
     Hooks::run('ParserAfterParse', array(&$this, &$text, &$this->mStripState));
     $text = $this->internalParseHalfParsed($text, true, $linestart);
     /**
      * A converted title will be provided in the output object if title and
      * content conversion are enabled, the article text does not contain
      * a conversion-suppressing double-underscore tag, and no
      * {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over
      * automatic link conversion.
      */
     if (!($options->getDisableTitleConversion() || isset($this->mDoubleUnderscores['nocontentconvert']) || isset($this->mDoubleUnderscores['notitleconvert']) || $this->mOutput->getDisplayTitle() !== false)) {
         $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
         if ($convruletitle) {
             $this->mOutput->setTitleText($convruletitle);
         } else {
             $titleText = $this->getConverterLanguage()->convertTitle($title);
             $this->mOutput->setTitleText($titleText);
         }
     }
     if ($this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit()) {
         $this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit());
     }
     # Information on include size limits, for the benefit of users who try to skirt them
     if ($this->mOptions->getEnableLimitReport()) {
         $max = $this->mOptions->getMaxIncludeSize();
         $cpuTime = $this->mOutput->getTimeSinceStart('cpu');
         if ($cpuTime !== null) {
             $this->mOutput->setLimitReportData('limitreport-cputime', sprintf("%.3f", $cpuTime));
         }
         $wallTime = $this->mOutput->getTimeSinceStart('wall');
         $this->mOutput->setLimitReportData('limitreport-walltime', sprintf("%.3f", $wallTime));
         $this->mOutput->setLimitReportData('limitreport-ppvisitednodes', array($this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount()));
         $this->mOutput->setLimitReportData('limitreport-ppgeneratednodes', array($this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount()));
         $this->mOutput->setLimitReportData('limitreport-postexpandincludesize', array($this->mIncludeSizes['post-expand'], $max));
         $this->mOutput->setLimitReportData('limitreport-templateargumentsize', array($this->mIncludeSizes['arg'], $max));
         $this->mOutput->setLimitReportData('limitreport-expansiondepth', array($this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth()));
         $this->mOutput->setLimitReportData('limitreport-expensivefunctioncount', array($this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit()));
         Hooks::run('ParserLimitReportPrepare', array($this, $this->mOutput));
         $limitReport = "NewPP limit report\n";
         if ($wgShowHostnames) {
             $limitReport .= 'Parsed by ' . wfHostname() . "\n";
         }
         $limitReport .= 'Cached time: ' . $this->mOutput->getCacheTime() . "\n";
         $limitReport .= 'Cache expiry: ' . $this->mOutput->getCacheExpiry() . "\n";
         $limitReport .= 'Dynamic content: ' . ($this->mOutput->hasDynamicContent() ? 'true' : 'false') . "\n";
         foreach ($this->mOutput->getLimitReportData() as $key => $value) {
             if (Hooks::run('ParserLimitReportFormat', array($key, &$value, &$limitReport, false, false))) {
                 $keyMsg = wfMessage($key)->inLanguage('en')->useDatabase(false);
                 $valueMsg = wfMessage(array("{$key}-value-text", "{$key}-value"))->inLanguage('en')->useDatabase(false);
                 if (!$valueMsg->exists()) {
                     $valueMsg = new RawMessage('$1');
                 }
                 if (!$keyMsg->isDisabled() && !$valueMsg->isDisabled()) {
                     $valueMsg->params($value);
                     $limitReport .= "{$keyMsg->text()}: {$valueMsg->text()}\n";
                 }
             }
         }
         // Since we're not really outputting HTML, decode the entities and
         // then re-encode the things that need hiding inside HTML comments.
         $limitReport = htmlspecialchars_decode($limitReport);
         Hooks::run('ParserLimitReport', array($this, &$limitReport));
         // Sanitize for comment. Note '‐' in the replacement is U+2010,
         // which looks much like the problematic '-'.
         $limitReport = str_replace(array('-', '&'), array('‐', '&amp;'), $limitReport);
         $text .= "\n<!-- \n{$limitReport}-->\n";
         // Add on template profiling data
         $dataByFunc = $this->mProfiler->getFunctionStats();
         uasort($dataByFunc, function ($a, $b) {
             return $a['real'] < $b['real'];
             // descending order
         });
         $profileReport = "Transclusion expansion time report (%,ms,calls,template)\n";
         foreach (array_slice($dataByFunc, 0, 10) as $item) {
             $profileReport .= sprintf("%6.2f%% %8.3f %6d - %s\n", $item['%real'], $item['real'], $item['calls'], htmlspecialchars($item['name']));
         }
         $text .= "\n<!-- \n{$profileReport}-->\n";
         if ($this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10) {
             wfDebugLog('generated-pp-node-count', $this->mGeneratedPPNodeCount . ' ' . $this->mTitle->getPrefixedDBkey());
         }
     }
     $this->mOutput->setText($text);
     $this->mRevisionId = $oldRevisionId;
     $this->mRevisionObject = $oldRevisionObject;
     $this->mRevisionTimestamp = $oldRevisionTimestamp;
     $this->mRevisionUser = $oldRevisionUser;
     $this->mRevisionSize = $oldRevisionSize;
     $this->mInputSize = false;
     $this->currentRevisionCache = null;
     return $this->mOutput;
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:101,代码来源:Parser.php

示例9: fillParserOutput

 /**
  * Set the HTML and add the appropriate styles.
  *
  * @param Title $title
  * @param int $revId
  * @param ParserOptions $options
  * @param bool $generateHtml
  * @param ParserOutput $output
  */
 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     // FIXME: WikiPage::doEditContent generates parser output before validation.
     // As such, native data may be invalid (though output is discarded later in that case).
     if ($generateHtml && $this->isValid()) {
         $output->setText($this->rootValueTable($this->getData()->getValue()));
         $output->addModuleStyles('mediawiki.content.json');
     } else {
         $output->setText('');
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:20,代码来源:JsonContent.php

示例10: parse


//.........这里部分代码省略.........
     global $wgUseTidy, $wgAlwaysUseTidy;
     $fname = __METHOD__ . '-' . wfGetCaller();
     wfProfileIn(__METHOD__);
     wfProfileIn($fname);
     $this->startParse($title, $options, self::OT_HTML, $clearState);
     # Remove the strip marker tag prefix from the input, if present.
     if ($clearState) {
         $text = str_replace($this->mUniqPrefix, '', $text);
     }
     $oldRevisionId = $this->mRevisionId;
     $oldRevisionObject = $this->mRevisionObject;
     $oldRevisionTimestamp = $this->mRevisionTimestamp;
     $oldRevisionUser = $this->mRevisionUser;
     if ($revid !== null) {
         $this->mRevisionId = $revid;
         $this->mRevisionObject = null;
         $this->mRevisionTimestamp = null;
         $this->mRevisionUser = null;
     }
     wfRunHooks('ParserBeforeStrip', array(&$this, &$text, &$this->mStripState));
     # No more strip!
     wfRunHooks('ParserAfterStrip', array(&$this, &$text, &$this->mStripState));
     $text = $this->internalParse($text);
     wfRunHooks('ParserAfterParse', array(&$this, &$text, &$this->mStripState));
     $text = $this->mStripState->unstripGeneral($text);
     # Clean up special characters, only run once, next-to-last before doBlockLevels
     $fixtags = array('/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1&#160;', '/(\\302\\253) /' => '\\1&#160;', '/&#160;(!\\s*important)/' => ' \\1');
     $text = preg_replace(array_keys($fixtags), array_values($fixtags), $text);
     $text = $this->doBlockLevels($text, $linestart);
     $this->replaceLinkHolders($text);
     /**
      * The input doesn't get language converted if
      * a) It's disabled
      * b) Content isn't converted
      * c) It's a conversion table
      * d) it is an interface message (which is in the user language)
      */
     if (!($options->getDisableContentConversion() || isset($this->mDoubleUnderscores['nocontentconvert']))) {
         # Run convert unconditionally in 1.18-compatible mode
         global $wgBug34832TransitionalRollback;
         if ($wgBug34832TransitionalRollback || !$this->mOptions->getInterfaceMessage()) {
             # The position of the convert() call should not be changed. it
             # assumes that the links are all replaced and the only thing left
             # is the <nowiki> mark.
             $text = $this->getConverterLanguage()->convert($text);
         }
     }
     /**
      * A converted title will be provided in the output object if title and
      * content conversion are enabled, the article text does not contain
      * a conversion-suppressing double-underscore tag, and no
      * {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over
      * automatic link conversion.
      */
     if (!($options->getDisableTitleConversion() || isset($this->mDoubleUnderscores['nocontentconvert']) || isset($this->mDoubleUnderscores['notitleconvert']) || $this->mOutput->getDisplayTitle() !== false)) {
         $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
         if ($convruletitle) {
             $this->mOutput->setTitleText($convruletitle);
         } else {
             $titleText = $this->getConverterLanguage()->convertTitle($title);
             $this->mOutput->setTitleText($titleText);
         }
     }
     $text = $this->mStripState->unstripNoWiki($text);
     wfRunHooks('ParserBeforeTidy', array(&$this, &$text));
     $text = $this->replaceTransparentTags($text);
     $text = $this->mStripState->unstripGeneral($text);
     $text = Sanitizer::normalizeCharReferences($text);
     if ($wgUseTidy && $this->mOptions->getTidy() || $wgAlwaysUseTidy) {
         $text = MWTidy::tidy($text);
     } else {
         # attempt to sanitize at least some nesting problems
         # (bug #2702 and quite a few others)
         $tidyregs = array('/(<([bi])>)(<([bi])>)?([^<]*)(<\\/?a[^<]*>)([^<]*)(<\\/\\4>)?(<\\/\\2>)/' => '\\1\\3\\5\\8\\9\\6\\1\\3\\7\\8\\9', '/(<a[^>]+>)([^<]*)(<a[^>]+>[^<]*)<\\/a>(.*)<\\/a>/' => '\\1\\2</a>\\3</a>\\1\\4</a>', '/(<([aib]) [^>]+>)([^<]*)(<div([^>]*)>)(.*)(<\\/div>)([^<]*)(<\\/\\2>)/' => '\\1\\3&lt;div\\5&gt;\\6&lt;/div&gt;\\8\\9', '/<([bi])><\\/\\1>/' => '');
         $text = preg_replace(array_keys($tidyregs), array_values($tidyregs), $text);
     }
     if ($this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit()) {
         $this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit());
     }
     wfRunHooks('ParserAfterTidy', array(&$this, &$text));
     # Information on include size limits, for the benefit of users who try to skirt them
     if ($this->mOptions->getEnableLimitReport()) {
         $max = $this->mOptions->getMaxIncludeSize();
         $PFreport = "Expensive parser function count: {$this->mExpensiveFunctionCount}/{$this->mOptions->getExpensiveParserFunctionLimit()}\n";
         $limitReport = "NewPP limit report\n" . "Preprocessor visited node count: {$this->mPPNodeCount}/{$this->mOptions->getMaxPPNodeCount()}\n" . "Preprocessor generated node count: " . "{$this->mGeneratedPPNodeCount}/{$this->mOptions->getMaxGeneratedPPNodeCount()}\n" . "Post-expand include size: {$this->mIncludeSizes['post-expand']}/{$max} bytes\n" . "Template argument size: {$this->mIncludeSizes['arg']}/{$max} bytes\n" . "Highest expansion depth: {$this->mHighestExpansionDepth}/{$this->mOptions->getMaxPPExpandDepth()}\n" . $PFreport;
         wfRunHooks('ParserLimitReport', array($this, &$limitReport));
         $text .= "\n<!-- \n{$limitReport}-->\n";
         if ($this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10) {
             wfDebugLog('generated-pp-node-count', $this->mGeneratedPPNodeCount . ' ' . $this->mTitle->getPrefixedDBkey());
         }
     }
     $this->mOutput->setText($text);
     $this->mRevisionId = $oldRevisionId;
     $this->mRevisionObject = $oldRevisionObject;
     $this->mRevisionTimestamp = $oldRevisionTimestamp;
     $this->mRevisionUser = $oldRevisionUser;
     wfProfileOut($fname);
     wfProfileOut(__METHOD__);
     return $this->mOutput;
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:101,代码来源:Parser.php

示例11: getParserOutput

 /**
  * Returns a generic ParserOutput object, wrapping the HTML returned by
  * getHtml().
  *
  * @param $title Title Context title for parsing
  * @param $revId int|null Revision ID (for {{REVISIONID}})
  * @param $options ParserOptions|null Parser options
  * @param $generateHtml bool Whether or not to generate HTML
  *
  * @return ParserOutput representing the HTML form of the text
  */
 public function getParserOutput(Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true)
 {
     global $wgParser, $wgTextModelsToParse;
     if (!$options) {
         //NOTE: use canonical options per default to produce cacheable output
         $options = $this->getContentHandler()->makeParserOptions('canonical');
     }
     if (in_array($this->getModel(), $wgTextModelsToParse)) {
         // parse just to get links etc into the database
         $po = $wgParser->parse($this->getNativeData(), $title, $options, true, true, $revId);
     } else {
         $po = new ParserOutput();
     }
     if ($generateHtml) {
         $html = $this->getHtml();
     } else {
         $html = '';
     }
     $po->setText($html);
     return $po;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:32,代码来源:TextContent.php

示例12: parse


//.........这里部分代码省略.........
     $this->mInputSize = strlen($text);
     if ($this->mOptions->getEnableLimitReport()) {
         $this->mOutput->resetParseStartTime();
     }
     $oldRevisionId = $this->mRevisionId;
     $oldRevisionObject = $this->mRevisionObject;
     $oldRevisionTimestamp = $this->mRevisionTimestamp;
     $oldRevisionUser = $this->mRevisionUser;
     $oldRevisionSize = $this->mRevisionSize;
     if ($revid !== null) {
         $this->mRevisionId = $revid;
         $this->mRevisionObject = null;
         $this->mRevisionTimestamp = null;
         $this->mRevisionUser = null;
         $this->mRevisionSize = null;
     }
     Hooks::run('ParserBeforeStrip', [&$this, &$text, &$this->mStripState]);
     # No more strip!
     Hooks::run('ParserAfterStrip', [&$this, &$text, &$this->mStripState]);
     $text = $this->internalParse($text);
     Hooks::run('ParserAfterParse', [&$this, &$text, &$this->mStripState]);
     $text = $this->internalParseHalfParsed($text, true, $linestart);
     /**
      * A converted title will be provided in the output object if title and
      * content conversion are enabled, the article text does not contain
      * a conversion-suppressing double-underscore tag, and no
      * {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over
      * automatic link conversion.
      */
     if (!($options->getDisableTitleConversion() || isset($this->mDoubleUnderscores['nocontentconvert']) || isset($this->mDoubleUnderscores['notitleconvert']) || $this->mOutput->getDisplayTitle() !== false)) {
         $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
         if ($convruletitle) {
             $this->mOutput->setTitleText($convruletitle);
         } else {
             $titleText = $this->getConverterLanguage()->convertTitle($title);
             $this->mOutput->setTitleText($titleText);
         }
     }
     # Done parsing! Compute runtime adaptive expiry if set
     $this->mOutput->finalizeAdaptiveCacheExpiry();
     # Warn if too many heavyweight parser functions were used
     if ($this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit()) {
         $this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit());
     }
     # Information on include size limits, for the benefit of users who try to skirt them
     if ($this->mOptions->getEnableLimitReport()) {
         $max = $this->mOptions->getMaxIncludeSize();
         $cpuTime = $this->mOutput->getTimeSinceStart('cpu');
         if ($cpuTime !== null) {
             $this->mOutput->setLimitReportData('limitreport-cputime', sprintf("%.3f", $cpuTime));
         }
         $wallTime = $this->mOutput->getTimeSinceStart('wall');
         $this->mOutput->setLimitReportData('limitreport-walltime', sprintf("%.3f", $wallTime));
         $this->mOutput->setLimitReportData('limitreport-ppvisitednodes', [$this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount()]);
         $this->mOutput->setLimitReportData('limitreport-ppgeneratednodes', [$this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount()]);
         $this->mOutput->setLimitReportData('limitreport-postexpandincludesize', [$this->mIncludeSizes['post-expand'], $max]);
         $this->mOutput->setLimitReportData('limitreport-templateargumentsize', [$this->mIncludeSizes['arg'], $max]);
         $this->mOutput->setLimitReportData('limitreport-expansiondepth', [$this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth()]);
         $this->mOutput->setLimitReportData('limitreport-expensivefunctioncount', [$this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit()]);
         Hooks::run('ParserLimitReportPrepare', [$this, $this->mOutput]);
         $limitReport = '';
         Hooks::run('ParserLimitReport', [$this, &$limitReport]);
         if ($limitReport != '') {
             // Sanitize for comment. Note '‐' in the replacement is U+2010,
             // which looks much like the problematic '-'.
             $limitReport = str_replace(['-', '&'], ['‐', '&amp;'], $limitReport);
             $text .= "\n<!-- \nNewPP limit report\n{$limitReport}-->\n";
         }
         // Add on template profiling data in human/machine readable way
         $dataByFunc = $this->mProfiler->getFunctionStats();
         uasort($dataByFunc, function ($a, $b) {
             return $a['real'] < $b['real'];
             // descending order
         });
         $profileReport = [];
         foreach (array_slice($dataByFunc, 0, 10) as $item) {
             $profileReport[] = sprintf("%6.2f%% %8.3f %6d %s", $item['%real'], $item['real'], $item['calls'], $item['name']);
         }
         $this->mOutput->setLimitReportData('limitreport-timingprofile', $profileReport);
         // Add other cache related metadata
         if ($wgShowHostnames) {
             $this->mOutput->setLimitReportData('cachereport-origin', wfHostname());
         }
         $this->mOutput->setLimitReportData('cachereport-timestamp', $this->mOutput->getCacheTime());
         $this->mOutput->setLimitReportData('cachereport-ttl', $this->mOutput->getCacheExpiry());
         $this->mOutput->setLimitReportData('cachereport-transientcontent', $this->mOutput->hasDynamicContent());
         if ($this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10) {
             wfDebugLog('generated-pp-node-count', $this->mGeneratedPPNodeCount . ' ' . $this->mTitle->getPrefixedDBkey());
         }
     }
     $this->mOutput->setText($text);
     $this->mRevisionId = $oldRevisionId;
     $this->mRevisionObject = $oldRevisionObject;
     $this->mRevisionTimestamp = $oldRevisionTimestamp;
     $this->mRevisionUser = $oldRevisionUser;
     $this->mRevisionSize = $oldRevisionSize;
     $this->mInputSize = false;
     $this->currentRevisionCache = null;
     return $this->mOutput;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:Parser.php

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

示例14: renderHook

	/**
	 * Hook into Content::getParserOutput to provide syntax highlighting for
	 * script content.
	 *
	 * @return bool
	 * @since MW 1.21
	 */
	public static function renderHook( Content $content, Title $title,
			ParserOptions $options, $generateHtml, ParserOutput &$output
	) {

		global $wgSyntaxHighlightModels, $wgUseSiteCss;

		// Determine the language
		$model = $content->getModel();
		if ( !isset( $wgSyntaxHighlightModels[$model] ) ) {
			// We don't care about this model, carry on.
			return true;
		}

		if ( !$generateHtml ) {
			// Nothing to do.
			return false;
		}

		// Hope that $wgSyntaxHighlightModels does not contain silly types.
		$text = Contenthandler::getContentText( $content );

		if ( $text === null || $text === false ) {
			// Oops! Non-text content?
			return false;
		}

		$lang = $wgSyntaxHighlightModels[$model];

		// Attempt to format
		$geshi = self::prepare( $text, $lang );
		if( $geshi instanceof GeSHi ) {

			$out = $geshi->parse_code();
			if( !$geshi->error() ) {
				// Done
				$output->addHeadItem( self::buildHeadItem( $geshi ), "source-$lang" );
				$output->setText( "<div dir=\"ltr\">{$out}</div>" );

				if( $wgUseSiteCss ) {
					$output->addModuleStyles( 'ext.geshi.local' );
				}
				return false;
			}
		}

		// Bottle out
		return true;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:55,代码来源:SyntaxHighlight_GeSHi.class.php

示例15: getFullOutput

 /**
  * Get the formatted result list, with navigation bars.
  *
  * Calls getBody(), getNavigationBar() and getModuleStyles() and
  * builds a ParserOutput object. (This is a bit hacky but works well.)
  *
  * @since 1.24
  * @return ParserOutput
  */
 public function getFullOutput()
 {
     $navigation = $this->getNavigationBar();
     $body = parent::getBody();
     $pout = new ParserOutput();
     $pout->setText($navigation . $body . $navigation);
     $pout->addModuleStyles($this->getModuleStyles());
     return $pout;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:TablePager.php


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