Fix missing <thead> and <tr> in various places

This removes the last usages of the problematic open/closeElement
from this codebase.

One actual issue gets fixed: Some of the <th> floated around without
a <tr>. That's technically invalid. Luckily the browsers are flexible
and show it correctly. Visually nothing changes.

Similarly <th> should be wrapped in a <thead>. This wasn't done
before.

Change-Id: Ia45096670888173e49f9c25e72f429f0961b75ae
This commit is contained in:
thiemowmde 2024-05-13 12:36:12 +02:00 committed by Thiemo Kreuz (WMDE)
parent f9dcf46d70
commit fc50073fb5
2 changed files with 40 additions and 49 deletions

View file

@ -875,25 +875,7 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
* @return string The HTML output
*/
private function buildPrivateDetailsTable( $row ) {
$output = Html::element(
'legend',
[],
$this->msg( 'abusefilter-log-details-privatedetails' )->text()
);
$header =
Html::element( 'th', [], $this->msg( 'abusefilter-log-details-var' )->text() ) .
Html::element( 'th', [], $this->msg( 'abusefilter-log-details-val' )->text() );
$output .=
Html::openElement( 'table',
[
'class' => 'wikitable mw-abuselog-private',
'style' => 'width: 80%;'
]
) .
Html::openElement( 'tbody' );
$output .= $header;
$output = '';
// Log ID
$linkRenderer = $this->getLinkRenderer();
@ -903,12 +885,10 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
[ 'style' => 'width: 30%;' ],
$this->msg( 'abusefilter-log-details-id' )->text()
) .
Html::openElement( 'td' ) .
$linkRenderer->makeKnownLink(
Html::rawElement( 'td', [], $linkRenderer->makeKnownLink(
$this->getPageTitle( $row->afl_id ),
$this->getLanguage()->formatNum( $row->afl_id )
) .
Html::closeElement( 'td' )
) )
);
// Timestamp
@ -944,12 +924,10 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
[ 'style' => 'width: 30%;' ],
$this->msg( 'abusefilter-list-id' )->text()
) .
Html::openElement( 'td' ) .
$linkRenderer->makeKnownLink(
Html::rawElement( 'td', [], $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( 'AbuseFilter', $row->af_id ),
$this->getLanguage()->formatNum( $row->af_id )
) .
Html::closeElement( 'td' )
) )
);
// Filter description
@ -1007,9 +985,28 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
);
}
$output .= Html::closeElement( 'tbody' ) . Html::closeElement( 'table' );
return Html::rawElement( 'fieldset', [], $output );
return Html::rawElement( 'fieldset', [],
Html::element( 'legend', [],
$this->msg( 'abusefilter-log-details-privatedetails' )->text()
) .
Html::rawElement( 'table',
[
'class' => 'wikitable mw-abuselog-private',
'style' => 'width: 80%;'
],
Html::rawElement( 'thead', [],
Html::rawElement( 'tr', [],
Html::element( 'th', [],
$this->msg( 'abusefilter-log-details-var' )->text()
) .
Html::element( 'th', [],
$this->msg( 'abusefilter-log-details-val' )->text()
)
)
) .
Html::rawElement( 'tbody', [], $output )
)
);
}
/**

View file

@ -50,22 +50,6 @@ class VariablesFormatter {
$output = '';
$output .=
Html::openElement( 'table', [ 'class' => 'mw-abuselog-details' ] ) .
Html::openElement( 'tbody' ) .
"\n";
$header =
Html::element( 'th', [], $this->messageLocalizer->msg( 'abusefilter-log-details-var' )->text() ) .
Html::element( 'th', [], $this->messageLocalizer->msg( 'abusefilter-log-details-val' )->text() );
$output .= Html::rawElement( 'tr', [], $header ) . "\n";
if ( !count( $vars ) ) {
$output .= Html::closeElement( 'tbody' ) . Html::closeElement( 'table' );
return $output;
}
// Now, build the body of the table.
foreach ( $vars as $key => $value ) {
$key = strtolower( $key );
@ -97,9 +81,19 @@ class VariablesFormatter {
) . "\n";
}
$output .= Html::closeElement( 'tbody' ) . Html::closeElement( 'table' );
return $output;
return Html::rawElement( 'table', [ 'class' => 'mw-abuselog-details' ],
Html::rawElement( 'thead', [],
Html::rawElement( 'tr', [],
Html::element( 'th', [],
$this->messageLocalizer->msg( 'abusefilter-log-details-var' )->text()
) .
Html::element( 'th', [],
$this->messageLocalizer->msg( 'abusefilter-log-details-val' )->text()
)
)
) .
Html::rawElement( 'tbody', [], $output )
);
}
/**