Add canonical id to header on action=info
authorUmherirrender <umherirrender_de.wp@web.de>
Wed, 28 Jun 2017 19:56:37 +0000 (21:56 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Wed, 28 Jun 2017 19:56:37 +0000 (21:56 +0200)
Have to use the h2, because the span can have only one id attribute

Bug: T44629
Change-Id: Iaa1c46611c56210b1177a665a5edfa082683977f

includes/actions/InfoAction.php

index 886bf37..baec944 100644 (file)
@@ -127,7 +127,10 @@ class InfoAction extends FormlessAction {
                        // Messages:
                        // pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions,
                        // pageinfo-header-properties, pageinfo-category-info
-                       $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
+                       $content .= $this->makeHeader(
+                               $this->msg( "pageinfo-${header}" )->escaped(),
+                               "mw-pageinfo-${header}"
+                       ) . "\n";
                        $table = "\n";
                        foreach ( $infoTable as $infoRow ) {
                                $name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
@@ -152,10 +155,11 @@ class InfoAction extends FormlessAction {
         * @param string $header The header text.
         * @return string The HTML.
         */
-       protected function makeHeader( $header ) {
+       protected function makeHeader( $header, $canonicalId ) {
                $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) ];
+               $h2Attribs = [ 'id' => Sanitizer::escapeId( $canonicalId ) ];
 
-               return Html::rawElement( 'h2', [], Html::element( 'span', $spanAttribs, $header ) );
+               return Html::rawElement( 'h2', $h2Attribs, Html::element( 'span', $spanAttribs, $header ) );
        }
 
        /**