MediaWiki  1.23.14
CoreTagHooks.php
Go to the documentation of this file.
1 <?php
28 class CoreTagHooks {
33  static function register( $parser ) {
34  global $wgRawHtml;
35  $parser->setHook( 'pre', array( __CLASS__, 'pre' ) );
36  $parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) );
37  $parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) );
38  if ( $wgRawHtml ) {
39  $parser->setHook( 'html', array( __CLASS__, 'html' ) );
40  }
41  }
42 
53  static function pre( $text, $attribs, $parser ) {
54  // Backwards-compatibility hack
55  $content = StringUtils::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
56 
58  // We need to let both '"' and '&' through,
59  // for strip markers and entities respectively.
60  $content = str_replace(
61  array( '>', '<' ),
62  array( '&gt;', '&lt;' ),
63  $content
64  );
65  return Html::rawElement( 'pre', $attribs, $content );
66  }
67 
83  static function html( $content, $attributes, $parser ) {
84  global $wgRawHtml;
85  if ( $wgRawHtml ) {
86  return array( $content, 'markerType' => 'nowiki' );
87  } else {
88  throw new MWException( '<html> extension tag encountered unexpectedly' );
89  }
90  }
91 
104  static function nowiki( $content, $attributes, $parser ) {
105  $content = strtr( $content, array(
106  // lang converter
107  '-{' => '-&#123;',
108  '}-' => '&#125;-',
109  // html tags
110  '<' => '&lt;',
111  '>' => '&gt;'
112  // Note: Both '"' and '&' are not converted.
113  // This allows strip markers and entities through.
114  ) );
115  return array( $content, 'markerType' => 'nowiki' );
116  }
117 
133  static function gallery( $content, $attributes, $parser ) {
134  return $parser->renderImageGallery( $content, $attributes );
135  }
136 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
CoreTagHooks
Various tag hooks, registered in Parser::firstCallInit()
Definition: CoreTagHooks.php:28
CoreTagHooks\nowiki
static nowiki( $content, $attributes, $parser)
Core parser tag hook function for 'nowiki'.
Definition: CoreTagHooks.php:104
CoreTagHooks\gallery
static gallery( $content, $attributes, $parser)
Core parser tag hook function for 'gallery'.
Definition: CoreTagHooks.php:133
MWException
MediaWiki exception.
Definition: MWException.php:26
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:1961
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
CoreTagHooks\html
static html( $content, $attributes, $parser)
Core parser tag hook function for 'html', used only when $wgRawHtml is enabled.
Definition: CoreTagHooks.php:83
Sanitizer\validateTagAttributes
static validateTagAttributes( $attribs, $element)
Take an array of attribute names and values and normalize or discard illegal values for the given ele...
Definition: Sanitizer.php:691
StringUtils\delimiterReplace
static delimiterReplace( $startDelim, $endDelim, $replace, $subject, $flags='')
Perform an operation equivalent to.
Definition: StringUtils.php:256
CoreTagHooks\pre
static pre( $text, $attribs, $parser)
Core parser tag hook function for 'pre'.
Definition: CoreTagHooks.php:53
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1530