MediaWiki  1.23.16
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  if ( $parser->getOptions()->getAllowUnsafeRawHtml() ) {
87  return array( $content, 'markerType' => 'nowiki' );
88  } else {
89  // In a system message where raw html is
90  // not allowed (but it is allowed in other
91  // contexts).
92  return Html::rawElement(
93  'span',
94  array( 'class' => 'error' ),
95  // Using ->text() not ->parse() as
96  // a paranoia measure against a loop.
97  wfMessage( 'rawhtml-notallowed' )->escaped()
98  );
99  }
100  } else {
101  throw new MWException( '<html> extension tag encountered unexpectedly' );
102  }
103  }
104 
117  static function nowiki( $content, $attributes, $parser ) {
118  $content = strtr( $content, array(
119  // lang converter
120  '-{' => '-&#123;',
121  '}-' => '&#125;-',
122  // html tags
123  '<' => '&lt;',
124  '>' => '&gt;'
125  // Note: Both '"' and '&' are not converted.
126  // This allows strip markers and entities through.
127  ) );
128  return array( $content, 'markerType' => 'nowiki' );
129  }
130 
146  static function gallery( $content, $attributes, $parser ) {
147  return $parser->renderImageGallery( $content, $attributes );
148  }
149 }
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:117
CoreTagHooks\gallery
static gallery( $content, $attributes, $parser)
Core parser tag hook function for 'gallery'.
Definition: CoreTagHooks.php:146
MWException
MediaWiki exception.
Definition: MWException.php:26
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:1961
wfMessage
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 after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
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:121
$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