* Fix some misuse of message functions
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Wed, 9 Jul 2008 09:10:23 +0000 (09:10 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Wed, 9 Jul 2008 09:10:23 +0000 (09:10 +0000)
* Part of bug 14767
* This code duplication makes me puke
* Removed historysize, redundant when we have nbytes

includes/PageHistory.php
includes/specials/SpecialMergeHistory.php
includes/specials/SpecialProtectedpages.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialUndelete.php
languages/messages/MessagesEn.php

index 0821734..0819441 100644 (file)
@@ -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 .= " <span class=\"history-size\">$stxt</span>";
                }
 
index 6183374..12b3d1f 100644 (file)
@@ -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 );
 
index e168902..58deff1 100644 (file)
@@ -89,10 +89,13 @@ class ProtectedPagesForm {
                }
 
                if (!is_null($size = $row->page_len)) {
-                       if ($size == 0)
-                               $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
-                       else
-                               $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum( $size ) ) . '</small>';
+                       if ($size == 0) {
+                               $stxt = wfMsg('historyempty');
+                       } else {
+                               $stxt = wfMsg('nbytes', $wgLang->formatNum( $size ) );
+                               $stxt = "($stxt)";
+                       }
+                       $stxt = htmlspecialchars( $stxt );
                        $stxt = $wgContLang->getDirMark() . $stxt;
                }
 
index a3d4b7e..4226ff5 100644 (file)
@@ -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( "</ul>" );
 
-               $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( "<ul>" );
@@ -393,7 +395,7 @@ class RevisionDeleteForm {
                
                $wgOut->addHtml( "</ul>" );
 
-               $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( "<p>$item</p>" );
                }
                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( "<ul>" );
@@ -508,8 +509,7 @@ class RevisionDeleteForm {
                $wgOut->addHtml(
                        Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ), 
                                'id' => 'mw-revdel-form-logs' ) ) .
-                       Xml::openElement( 'fieldset' ) .
-                       xml::element( 'legend', null,  wfMsg( 'revdelete-legend' ) )
+                       Xml::fieldset( wfMsg( 'revdelete-legend' ) )
                );
                // FIXME: all items checked for just on event are checked, even if not set for the others
                foreach( $this->checks as $item ) {
@@ -517,7 +517,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( "<p>$item</p>" );
                }
                foreach( $hidden as $item ) {
                        $wgOut->addHtml( $item );
@@ -592,10 +592,11 @@ class RevisionDeleteForm {
                        $pageLink = "<a href=\"{$url}\">{$date}</a>";
                }
 
-               $data = wfMsgHtml( 'widthheight',
+               $data = wfMsg( 'widthheight',
                                        $wgContLang->formatNum( $file->getWidth() ),
                                        $wgContLang->formatNum( $file->getHeight() ) ) .
-                       ' (' . wfMsgHtml( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
+                       ' (' . wfMsg( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
+               $data = htmlspecialchars( $data );
 
                return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
        }
@@ -618,10 +619,11 @@ class RevisionDeleteForm {
                        $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
                }
 
-               $data = wfMsgHtml( 'widthheight',
+               $data = wfMsg( 'widthheight',
                                        $wgContLang->formatNum( $file->getWidth() ),
                                        $wgContLang->formatNum( $file->getHeight() ) ) .
-                       ' (' . wfMsgHtml( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
+                       ' (' . wfMsg( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
+               $data = htmlspecialchars( $data );
 
                return "<li> $pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
        }
@@ -728,19 +730,21 @@ class RevisionDeleteForm {
        private function success() {
                global $wgOut;
 
-               $wgOut->setPagetitle( wfMsgHtml( 'actioncomplete' ) );
+               $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
+
+               $wrap = '<span class="success">$1</span>';
 
                if( $this->deleteKey=='logid' ) {
-                       $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'logdelete-success' ) ), false );
+                       $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
                        $this->showLogItems();
                } else if( $this->deleteKey=='oldid' || $this->deleteKey=='artimestamp' ) {
-                       $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'revdelete-success' ) ), false );
+                               $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
                        $this->showRevs();
                } else if( $this->deleteKey=='fileid' ) {
-                       $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'revdelete-success' ) ), false );
+                       $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
                        $this->showImages();
                } else if( $this->deleteKey=='oldimage' ) {
-                       $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'revdelete-success' ) ), false );
+                       $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
                        $this->showImages();
                }
        }
index c031865..805f451 100644 (file)
@@ -1086,10 +1086,12 @@ class UndeleteForm {
                $userLink = $sk->revUserTools( $rev );
 
                if(!is_null($size = $row->ar_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 = htmlspecialchars( $stxt );
                }
                $comment = $sk->revComment( $rev );
                $revdlink = '';
@@ -1131,12 +1133,13 @@ class UndeleteForm {
                }
                $userLink = $this->getFileUser( $file, $sk );
                $data =
-                       wfMsgHtml( 'widthheight',
+                       wfMsg( 'widthheight',
                                $wgLang->formatNum( $row->fa_width ),
                                $wgLang->formatNum( $row->fa_height ) ) .
                        ' (' .
-                       wfMsgHtml( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
+                       wfMsg( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
                        ')';
+               $data = htmlspecialchars( $data );
                $comment = $this->getFileComment( $file, $sk );
                $revdlink = '';
                if( $wgUser->isAllowed( 'deleterevision' ) ) {
index a0f7127..58f293c 100644 (file)
@@ -1209,7 +1209,6 @@ Legend: (cur) = difference with current version,
 'deletedrev'            => '[deleted]',
 'histfirst'             => 'Earliest',
 'histlast'              => 'Latest',
-'historysize'           => '({{PLURAL:$1|1 byte|$1 bytes}})',
 'historyempty'          => '(empty)',
 
 # Revision feed