本文整理汇总了PHP中ParserOutput::addHeadItem方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::addHeadItem方法的具体用法?PHP ParserOutput::addHeadItem怎么用?PHP ParserOutput::addHeadItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::addHeadItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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;
}
示例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);
}
// Check if the resource loader can be used or not.
if (method_exists($parserOutput, 'addModules')) {
$parserOutput->addModules(array_values(self::$resourceModules));
} else {
self::addModulesBC($parserOutput);
}
self::$resourceModules = array();
self::$headItems = array();
}