Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / parser / CoreTagHooks.php
index 85920cc..d4c4f6d 100644 (file)
@@ -32,11 +32,12 @@ class CoreTagHooks {
         */
        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( 'pre', [ __CLASS__, 'pre' ] );
+               $parser->setHook( 'nowiki', [ __CLASS__, 'nowiki' ] );
+               $parser->setHook( 'gallery', [ __CLASS__, 'gallery' ] );
+               $parser->setHook( 'indicator', [ __CLASS__, 'indicator' ] );
                if ( $wgRawHtml ) {
-                       $parser->setHook( 'html', array( __CLASS__, 'html' ) );
+                       $parser->setHook( 'html', [ __CLASS__, 'html' ] );
                }
        }
 
@@ -78,7 +79,7 @@ class CoreTagHooks {
        public static function html( $content, $attributes, $parser ) {
                global $wgRawHtml;
                if ( $wgRawHtml ) {
-                       return array( $content, 'markerType' => 'nowiki' );
+                       return [ $content, 'markerType' => 'nowiki' ];
                } else {
                        throw new MWException( '<html> extension tag encountered unexpectedly' );
                }
@@ -97,8 +98,8 @@ class CoreTagHooks {
         * @return array
         */
        public static function nowiki( $content, $attributes, $parser ) {
-               $content = strtr( $content, array( '-{' => '-&#123;', '}-' => '&#125;-' ) );
-               return array( Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' );
+               $content = strtr( $content, [ '-{' => '-&#123;', '}-' => '&#125;-' ] );
+               return [ Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' ];
        }
 
        /**
@@ -119,4 +120,30 @@ class CoreTagHooks {
        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 '<span class="error">' .
+                               wfMessage( 'invalid-indicator-name' )->inContentLanguage()->parse() .
+                               '</span>';
+               }
+
+               $parser->getOutput()->setIndicator(
+                       trim( $attributes['name'] ),
+                       Parser::stripOuterParagraph( $parser->recursiveTagParseFully( $content, $frame ) )
+               );
+
+               return '';
+       }
 }