本文整理汇总了PHP中ParserOutput::addModuleStyles方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::addModuleStyles方法的具体用法?PHP ParserOutput::addModuleStyles怎么用?PHP ParserOutput::addModuleStyles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::addModuleStyles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
$output->setText($this->objectTable($this->getJsonData()));
$output->addModuleStyles('mediawiki.content.json');
} else {
$output->setText('');
}
}
示例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)
{
// 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('');
}
}
示例3: internalParseHalfParsed
/**
* Helper function for parse() that transforms half-parsed HTML into fully
* parsed HTML.
*
* @param string $text
* @param bool $isMain
* @param bool $linestart
* @return string
*/
private function internalParseHalfParsed($text, $isMain = true, $linestart = true)
{
$text = $this->mStripState->unstripGeneral($text);
if ($isMain) {
Hooks::run('ParserAfterUnstrip', array(&$this, &$text));
}
# Clean up special characters, only run once, next-to-last before doBlockLevels
$fixtags = array('/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 ', '/(\\302\\253) /' => '\\1 ', '/ (!\\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 (!($this->mOptions->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);
}
}
$text = $this->mStripState->unstripNoWiki($text);
if ($isMain) {
Hooks::run('ParserBeforeTidy', array(&$this, &$text));
}
$text = $this->replaceTransparentTags($text);
$text = $this->mStripState->unstripGeneral($text);
$text = Sanitizer::normalizeCharReferences($text);
if (MWTidy::isEnabled() && $this->mOptions->getTidy()) {
$text = MWTidy::tidy($text);
$this->mOutput->addModuleStyles(MWTidy::getModuleStyles());
} 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<div\\5>\\6</div>\\8\\9', '/<([bi])><\\/\\1>/' => '');
$text = preg_replace(array_keys($tidyregs), array_values($tidyregs), $text);
}
if ($isMain) {
Hooks::run('ParserAfterTidy', array(&$this, &$text));
}
return $text;
}
示例4: 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;
}
示例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;
}
示例6: 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;
}