From 6bf9502eb6d5646cd2056244406327ca4e82ed10 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Wed, 9 Jul 2008 09:10:23 +0000 Subject: [PATCH] * Fix some misuse of message functions * Part of bug 14767 * This code duplication makes me puke * Removed historysize, redundant when we have nbytes --- includes/PageHistory.php | 11 ++-- includes/specials/SpecialMergeHistory.php | 11 ++-- includes/specials/SpecialProtectedpages.php | 11 ++-- includes/specials/SpecialRevisiondelete.php | 58 +++++++++++---------- includes/specials/SpecialUndelete.php | 15 +++--- languages/messages/MessagesEn.php | 1 - 6 files changed, 61 insertions(+), 46 deletions(-) diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 08217343ab..08194413f8 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -245,10 +245,13 @@ class PageHistory { } if ( !is_null( $size = $rev->getSize() ) && $rev->userCan( Revision::DELETED_TEXT ) ) { - if ( $size == 0 ) - $stxt = wfMsgHtml( 'historyempty' ); - else - $stxt = wfMsgExt( 'historysize', array( 'parsemag' ), $wgLang->formatNum( $size ) ); + if ( $size == 0 ) { + $stxt = wfMsg( 'historyempty' ); + } else { + $stxt = wfMsg( 'nbytes', $wgLang->formatNum( $size ) ); + $stxt = "($stxt)"; + } + $stxt = htmlspecialchars( $stxt ); $s .= " $stxt"; } diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 6183374ee4..12b3d1f6f6 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -247,10 +247,13 @@ class MergehistoryForm { $userLink = $this->sk->revUserTools( $rev ); if(!is_null($size = $row->rev_len)) { - if($size == 0) - $stxt = wfMsgHtml('historyempty'); - else - $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) ); + if($size == 0) { + $stxt = wfMsg('historyempty'); + } else { + $stxt = wfMsg('nbytes', $wgLang->formatNum( $size ) ); + $stxt = "($stxt)"; + } + $stxt = htmlspecialchars( $stxt ); } $comment = $this->sk->revComment( $rev ); diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index e168902897..58deff1f10 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -89,10 +89,13 @@ class ProtectedPagesForm { } if (!is_null($size = $row->page_len)) { - if ($size == 0) - $stxt = ' ' . wfMsgHtml('historyempty') . ''; - else - $stxt = ' ' . wfMsgHtml('historysize', $wgLang->formatNum( $size ) ) . ''; + if ($size == 0) { + $stxt = wfMsg('historyempty'); + } else { + $stxt = wfMsg('nbytes', $wgLang->formatNum( $size ) ); + $stxt = "($stxt)"; + } + $stxt = htmlspecialchars( $stxt ); $stxt = $wgContLang->getDirMark() . $stxt; } diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index a3d4b7ee82..4226ff5373 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -21,7 +21,7 @@ function wfSpecialRevisiondelete( $par = null ) { # If this is a revision, then we need a target page $page = Title::newFromUrl( $target ); if( is_null($page) ) { - $wgOut->addWikiText( wfMsgHtml( 'undelete-header' ) ); + $wgOut->addWikiMsg( 'undelete-header' ); return; } # Only one target set at a time please! @@ -256,7 +256,7 @@ class RevisionDeleteForm { $wgOut->addHtml( "" ); - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) ); + $wgOut->addWikiMsg( 'revdelete-text' ); // Normal sysops can always see what they did, but can't always change it if( !$UserAllowed ) return; @@ -272,10 +272,10 @@ class RevisionDeleteForm { ); if( $this->deleteKey=='oldid' ) { foreach( $revObjs as $rev ) - $hidden[] = wfHidden( 'oldid[]', $rev->getId() ); + $hidden[] = Xml::hidden( 'oldid[]', $rev->getId() ); } else { foreach( $revObjs as $rev ) - $hidden[] = wfHidden( 'artimestamp[]', $rev->getTimestamp() ); + $hidden[] = Xml::hidden( 'artimestamp[]', $rev->getTimestamp() ); } $special = SpecialPage::getTitleFor( 'Revisiondelete' ); $wgOut->addHtml( @@ -306,13 +306,15 @@ class RevisionDeleteForm { * This lets a user set restrictions for archived images */ function showImages() { - global $wgOut, $wgUser, $action; + // What is $action doing here??? + global $wgOut, $wgUser, $action, $wgLang; $UserAllowed = true; $count = ($this->deleteKey=='oldimage') ? count($this->ofiles) : count($this->afiles); - $wgOut->addWikiText( wfMsgExt( 'revdelete-selected', array('parsemag'), - $this->page->getPrefixedText(), $count ) ); + $wgOut->addWikiMsg( 'revdelete-selected', + $this->page->getPrefixedText(), + $wgLang->formatNum($count) ); $bitfields = 0; $wgOut->addHtml( "" ); - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) ); + $wgOut->addWikiMsg('revdelete-text' ); //Normal sysops can always see what they did, but can't always change it if( !$UserAllowed ) return; @@ -408,17 +410,16 @@ class RevisionDeleteForm { ); if( $this->deleteKey=='oldimage' ) { foreach( $this->ofiles as $filename ) - $hidden[] = wfHidden( 'oldimage[]', $filename ); + $hidden[] = Xml::hidden( 'oldimage[]', $filename ); } else { foreach( $this->afiles as $fileid ) - $hidden[] = wfHidden( 'fileid[]', $fileid ); + $hidden[] = Xml::hidden( 'fileid[]', $fileid ); } $special = SpecialPage::getTitleFor( 'Revisiondelete' ); $wgOut->addHtml( Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ), 'id' => 'mw-revdel-form-filerevisions' ) ) . - Xml::openElement( 'fieldset' ) . - xml::element( 'legend', null, wfMsg( 'revdelete-legend' ) ) + Xml::fiedlset( wfMsg( 'revdelete-legend' ) ) ); // FIXME: all items checked for just one file are checked, even if not set for the others foreach( $this->checks as $item ) { @@ -426,7 +427,7 @@ class RevisionDeleteForm { $wgOut->addHtml( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) ); } foreach( $items as $item ) { - $wgOut->addHtml( Xml::tags( 'p', null, $item ) ); + $wgOut->addHtml( "

$item

" ); } foreach( $hidden as $item ) { $wgOut->addHtml( $item ); @@ -442,10 +443,10 @@ class RevisionDeleteForm { * This lets a user set restrictions for log items */ function showLogItems() { - global $wgOut, $wgUser, $action, $wgMessageCache; + global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang; $UserAllowed = true; - $wgOut->addWikiText( wfMsgExt( 'logdelete-selected', array('parsemag'), count($this->events) ) ); + $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events) ) ); $bitfields = 0; $wgOut->addHtml( "