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


PHP ParserOutput::addHeadItem方法代码示例

本文整理汇总了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();
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:17,代码来源:SMW_Outputs.php

示例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;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:55,代码来源:SyntaxHighlight_GeSHi.class.php

示例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();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:SMW_Outputs.php


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