Add canonical id to header on action=info

Have to use the h2, because the span can have only one id attribute

Bug: T44629
Change-Id: Iaa1c46611c56210b1177a665a5edfa082683977f
This commit is contained in:
Umherirrender 2017-06-28 21:56:37 +02:00
parent db920e6cf1
commit 3ed80375f2

View 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 ) );
}
/**