From: C. Scott Ananian Date: Fri, 26 Oct 2018 17:04:36 +0000 (-0400) Subject: Use Html:rawElement() where possible in special pages. X-Git-Tag: 1.34.0-rc.0~3585^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=b702f5a659caad091148a817563715b9f4760b96;p=lhc%2Fweb%2Fwiklou.git Use Html:rawElement() where possible in special pages. Gently discourage building HTML by raw string concatenation. Fixes for Special{Contributions/Recentchanges*/Undelete/Upload}. Change-Id: I4a128e902dcce93372b2f188a1f37223c58ebe9a --- diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 63b64eab5b..43c7d2921d 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -744,7 +744,9 @@ class SpecialContributions extends IncludableSpecialPage { $explain = $this->msg( 'sp-contributions-explain' ); if ( !$explain->isBlank() ) { - $form .= "

{$explain->parse()}

"; + $form .= Html::rawElement( + 'p', [ 'id' => 'mw-sp-contributions-explain' ], $explain->parse() + ); } $form .= Xml::closeElement( 'form' ); diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 170f792ead..01ad657f3a 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -800,7 +800,11 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $note = ''; $msg = $this->msg( 'rclegend' ); if ( !$msg->isDisabled() ) { - $note .= '
' . $msg->parse() . "
\n"; + $note .= Html::rawElement( + 'div', + [ 'class' => 'mw-rclegend' ], + $msg->parse() + ); } $lang = $this->getLanguage(); @@ -898,14 +902,21 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $datenow = $lang->userDate( $timestamp, $user ); $pipedLinks = '' . $lang->pipeList( $links ) . ''; - $rclinks = '' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' ) - ->parse() . ''; + $rclinks = Html::rawElement( + 'span', + [ 'class' => 'rclinks' ], + $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )->parse() + ); - $rclistfrom = '' . $this->makeOptionsLink( - $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(), - [ 'from' => $timestamp ], - $nondefaults - ) . ''; + $rclistfrom = Html::rawElement( + 'span', + [ 'class' => 'rclistfrom' ], + $this->makeOptionsLink( + $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(), + [ 'from' => $timestamp ], + $nondefaults + ) + ); return "{$note}$rclinks
$pipedLinks
$rclistfrom"; } diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 181b4db4c9..e42cc70c51 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -297,15 +297,19 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { $targetTitle = $this->getTargetTitle(); if ( $targetTitle === false ) { $this->getOutput()->addHTML( - '
' . - $this->msg( 'recentchanges-notargetpage' )->parse() . - '
' + Html::rawElement( + 'div', + [ 'class' => 'mw-changeslist-empty mw-changeslist-notargetpage' ], + $this->msg( 'recentchanges-notargetpage' )->parse() + ) ); } elseif ( !$targetTitle || $targetTitle->isExternal() ) { $this->getOutput()->addHTML( - '
' . - $this->msg( 'allpagesbadtitle' )->parse() . - '
' + Html::rawElement( + 'div', + [ 'class' => 'mw-changeslist-empty mw-changeslist-invalidtargetpage' ], + $this->msg( 'allpagesbadtitle' )->parse() + ) ); } else { parent::outputNoResults(); diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index a93dec0313..70a26ac9fe 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -347,7 +347,13 @@ class SpecialUndelete extends SpecialPage { ); } $revs = $this->msg( 'undeleterevisions' )->numParams( $row->count )->parse(); - $out->addHTML( "
  • {$item} ({$revs})
  • \n" ); + $out->addHTML( + Html::rawElement( + 'li', + [ 'class' => 'undeleteResult' ], + "{$item} ({$revs})" + ) + ); } $result->free(); $out->addHTML( "\n" ); diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 836b6df47e..4dbfc5482d 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -324,7 +324,13 @@ class SpecialUpload extends SpecialPage { ); $link = $this->msg( $user->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted' ) ->rawParams( $restorelink )->parseAsBlock(); - $this->getOutput()->addHTML( "
    {$link}
    " ); + $this->getOutput()->addHTML( + Html::rawElement( + 'div', + [ 'id' => 'contentSub2' ], + $link + ) + ); } } }