X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fparser%2FCoreTagHooks.php;h=9755ea93f6b3a61b474c074fc20f665d2fe3e471;hb=7798b70e7e66b5a2e228f13714dd82d3b40a4573;hp=a2eb69877e0844b7b076edd6c86a2ff180d85709;hpb=2525ceb3cdc1b1c50526ea128af3677fed2049b4;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/parser/CoreTagHooks.php b/includes/parser/CoreTagHooks.php
index a2eb69877e..9755ea93f6 100644
--- a/includes/parser/CoreTagHooks.php
+++ b/includes/parser/CoreTagHooks.php
@@ -27,14 +27,15 @@
*/
class CoreTagHooks {
/**
- * @param $parser Parser
+ * @param Parser $parser
* @return void
*/
- static function register( $parser ) {
+ public static function register( $parser ) {
global $wgRawHtml;
$parser->setHook( 'pre', array( __CLASS__, 'pre' ) );
$parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) );
$parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) );
+ $parser->setHook( 'indicator', array( __CLASS__, 'indicator' ) );
if ( $wgRawHtml ) {
$parser->setHook( 'html', array( __CLASS__, 'html' ) );
}
@@ -50,7 +51,7 @@ class CoreTagHooks {
* @param Parser $parser
* @return string HTML
*/
- static function pre( $text, $attribs, $parser ) {
+ public static function pre( $text, $attribs, $parser ) {
// Backwards-compatibility hack
$content = StringUtils::delimiterReplace( '', '', '$1', $text, 'i' );
@@ -69,13 +70,13 @@ class CoreTagHooks {
*
* Uses undocumented extended tag hook return values, introduced in r61913.
*
- * @param $content string
- * @param $attributes array
- * @param $parser Parser
+ * @param string $content
+ * @param array $attributes
+ * @param Parser $parser
* @throws MWException
* @return array
*/
- static function html( $content, $attributes, $parser ) {
+ public static function html( $content, $attributes, $parser ) {
global $wgRawHtml;
if ( $wgRawHtml ) {
return array( $content, 'markerType' => 'nowiki' );
@@ -91,12 +92,12 @@ class CoreTagHooks {
*
* Uses undocumented extended tag hook return values, introduced in r61913.
*
- * @param $content string
- * @param $attributes array
- * @param $parser Parser
+ * @param string $content
+ * @param array $attributes
+ * @param Parser $parser
* @return array
*/
- static function nowiki( $content, $attributes, $parser ) {
+ public static function nowiki( $content, $attributes, $parser ) {
$content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) );
return array( Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
}
@@ -107,7 +108,7 @@ class CoreTagHooks {
* Renders a thumbnail list of the given images, with optional captions.
* Full syntax documented on the wiki:
*
- * http://www.mediawiki.org/wiki/Help:Images#Gallery_syntax
+ * https://www.mediawiki.org/wiki/Help:Images#Gallery_syntax
*
* @todo break Parser::renderImageGallery out here too.
*
@@ -116,7 +117,33 @@ class CoreTagHooks {
* @param Parser $parser
* @return string HTML
*/
- static function gallery( $content, $attributes, $parser ) {
+ public static function gallery( $content, $attributes, $parser ) {
return $parser->renderImageGallery( $content, $attributes );
}
+
+ /**
+ * XML-style tag for page status indicators: icons (or short text snippets) usually displayed in
+ * the top-right corner of the page, outside of the main content.
+ *
+ * @param string $content
+ * @param array $attributes
+ * @param Parser $parser
+ * @param PPFrame $frame
+ * @return string
+ * @since 1.25
+ */
+ public static function indicator( $content, array $attributes, Parser $parser, PPFrame $frame ) {
+ if ( !isset( $attributes['name'] ) || trim( $attributes['name'] ) === '' ) {
+ return '' .
+ wfMessage( 'invalid-indicator-name' )->inContentLanguage()->parse() .
+ '';
+ }
+
+ $parser->getOutput()->setIndicator(
+ trim( $attributes['name'] ),
+ Parser::stripOuterParagraph( $parser->recursiveTagParseFully( $content, $frame ) )
+ );
+
+ return '';
+ }
}