本文整理汇总了PHP中ParserOutput::addModules方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::addModules方法的具体用法?PHP ParserOutput::addModules怎么用?PHP ParserOutput::addModules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::addModules方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reportLimitData
function reportLimitData(ParserOutput $output)
{
try {
$this->load();
} catch (Exception $e) {
return;
}
if ($this->initialStatus) {
$status = $this->interpreter->getStatus();
$output->setLimitReportData('scribunto-limitreport-timeusage', array(sprintf("%.3f", $status['time'] / $this->getClockTick()), sprintf("%.3f", $this->options['cpuLimit'])));
$output->setLimitReportData('scribunto-limitreport-virtmemusage', array($status['vsize'], $this->options['memoryLimit']));
$output->setLimitReportData('scribunto-limitreport-estmemusage', $status['vsize'] - $this->initialStatus['vsize']);
}
$logs = $this->getLogBuffer();
if ($logs !== '') {
$output->addModules('ext.scribunto.logs');
$output->setLimitReportData('scribunto-limitreport-logs', $logs);
}
}
示例2: formatHeadings
//.........这里部分代码省略.........
break;
}
}
$byteOffset += mb_strlen($this->mStripState->unstripBoth($frame->expand($node, PPFrame::RECOVER_ORIG)));
$node = $node->getNextSibling();
}
$tocraw[] = array('toclevel' => $toclevel, 'level' => $level, 'line' => $tocline, 'number' => $numbering, 'index' => ($isTemplate ? 'T-' : '') . $sectionIndex, 'fromtitle' => $titleText, 'byteoffset' => $noOffset ? null : $byteOffset, 'anchor' => $anchor);
# give headline the correct <h#> tag
if ($maybeShowEditLink && $sectionIndex !== false) {
// Output edit section links as markers with styles that can be customized by skins
if ($isTemplate) {
# Put a T flag in the section identifier, to indicate to extractSections()
# that sections inside <includeonly> should be counted.
$editsectionPage = $titleText;
$editsectionSection = "T-{$sectionIndex}";
$editsectionContent = null;
} else {
$editsectionPage = $this->mTitle->getPrefixedText();
$editsectionSection = $sectionIndex;
$editsectionContent = $headlineHint;
}
// We use a bit of pesudo-xml for editsection markers. The
// language converter is run later on. Using a UNIQ style marker
// leads to the converter screwing up the tokens when it
// converts stuff. And trying to insert strip tags fails too. At
// this point all real inputted tags have already been escaped,
// so we don't have to worry about a user trying to input one of
// these markers directly. We use a page and section attribute
// to stop the language converter from converting these
// important bits of data, but put the headline hint inside a
// content block because the language converter is supposed to
// be able to convert that piece of data.
// Gets replaced with html in ParserOutput::getText
$editlink = '<mw:editsection page="' . htmlspecialchars($editsectionPage);
$editlink .= '" section="' . htmlspecialchars($editsectionSection) . '"';
if ($editsectionContent !== null) {
$editlink .= '>' . $editsectionContent . '</mw:editsection>';
} else {
$editlink .= '/>';
}
} else {
$editlink = '';
}
$head[$headlineCount] = Linker::makeHeadline($level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink, $legacyAnchor);
$headlineCount++;
}
$this->setOutputType($oldType);
# Never ever show TOC if no headers
if ($numVisible < 1) {
$enoughToc = false;
}
if ($enoughToc) {
if ($prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel) {
$toc .= Linker::tocUnindent($prevtoclevel - 1);
}
$toc = Linker::tocList($toc, $this->mOptions->getUserLangObj());
$this->mOutput->setTOCHTML($toc);
$toc = self::TOC_START . $toc . self::TOC_END;
$this->mOutput->addModules('mediawiki.toc');
}
if ($isMain) {
$this->mOutput->setSections($tocraw);
}
# split up and insert constructed headlines
$blocks = preg_split('/<H[1-6].*?>[\\s\\S]*?<\\/H[1-6]>/i', $text);
$i = 0;
// build an array of document sections
$sections = array();
foreach ($blocks as $block) {
// $head is zero-based, sections aren't.
if (empty($head[$i - 1])) {
$sections[$i] = $block;
} else {
$sections[$i] = $head[$i - 1] . $block;
}
/**
* Send a hook, one per section.
* The idea here is to be able to make section-level DIVs, but to do so in a
* lower-impact, more correct way than r50769
*
* $this : caller
* $section : the section number
* &$sectionContent : ref to the content of the section
* $showEditLinks : boolean describing whether this section has an edit link
*/
Hooks::run('ParserSectionCreate', array($this, $i, &$sections[$i], $showEditLink));
$i++;
}
if ($enoughToc && $isMain && !$this->mForceTocPosition) {
// append the TOC at the beginning
// Top anchor now in skin
$sections[0] = $sections[0] . $toc . "\n";
}
$full .= join('', $sections);
if ($this->mForceTocPosition) {
return str_replace('<!--MWTOC-->', $toc, $full);
} else {
return $full;
}
}
示例3: commitToParserOutput
/**
* Similar to SMWOutputs::commitToParser() but acting on a ParserOutput object.
*
* @param ParserOutput $parserOutput
*/
public static function commitToParserOutput(ParserOutput $parserOutput)
{
foreach (self::$scripts as $key => $script) {
$parserOutput->addHeadItem($script . "\n", $key);
}
foreach (self::$headItems as $key => $item) {
$parserOutput->addHeadItem("\t\t" . $item . "\n", $key);
}
$parserOutput->addModules(array_values(self::$resourceModules));
self::$resourceModules = array();
self::$headItems = array();
}
示例4: reportLimitData
public function reportLimitData(ParserOutput $output)
{
$data = $this->getLimitReportData();
foreach ($data as $k => $v) {
$output->setLimitReportData($k, $v);
}
if (isset($data['scribunto-limitreport-logs'])) {
$output->addModules('ext.scribunto.logs');
}
}