r37375 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37374‎ | r37375 | r37376 >
Date:09:10, 9 July 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Fix some misuse of message functions
* Part of bug 14767
* This code duplication makes me puke
* Removed historysize, redundant when we have nbytes
Modified paths:
  • /trunk/phase3/includes/PageHistory.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMergeHistory.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialProtectedpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUndelete.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUndelete.php
@@ -1086,10 +1086,12 @@
10871087 $userLink = $sk->revUserTools( $rev );
10881088
10891089 if(!is_null($size = $row->ar_len)) {
1090 - if($size == 0)
1091 - $stxt = wfMsgHtml('historyempty');
1092 - else
1093 - $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
 1090+ if($size == 0) {
 1091+ $stxt = wfMsg('historyempty');
 1092+ } else {
 1093+ $stxt = '(' . wfMsg('nbytes', $wgLang->formatNum( $size ) ) . ')';
 1094+ }
 1095+ $stxt = htmlspecialchars( $stxt );
10941096 }
10951097 $comment = $sk->revComment( $rev );
10961098 $revdlink = '';
@@ -1131,12 +1133,13 @@
11321134 }
11331135 $userLink = $this->getFileUser( $file, $sk );
11341136 $data =
1135 - wfMsgHtml( 'widthheight',
 1137+ wfMsg( 'widthheight',
11361138 $wgLang->formatNum( $row->fa_width ),
11371139 $wgLang->formatNum( $row->fa_height ) ) .
11381140 ' (' .
1139 - wfMsgHtml( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
 1141+ wfMsg( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
11401142 ')';
 1143+ $data = htmlspecialchars( $data );
11411144 $comment = $this->getFileComment( $file, $sk );
11421145 $revdlink = '';
11431146 if( $wgUser->isAllowed( 'deleterevision' ) ) {
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -21,7 +21,7 @@
2222 # If this is a revision, then we need a target page
2323 $page = Title::newFromUrl( $target );
2424 if( is_null($page) ) {
25 - $wgOut->addWikiText( wfMsgHtml( 'undelete-header' ) );
 25+ $wgOut->addWikiMsg( 'undelete-header' );
2626 return;
2727 }
2828 # Only one target set at a time please!
@@ -256,7 +256,7 @@
257257
258258 $wgOut->addHtml( "</ul>" );
259259
260 - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) );
 260+ $wgOut->addWikiMsg( 'revdelete-text' );
261261
262262 // Normal sysops can always see what they did, but can't always change it
263263 if( !$UserAllowed ) return;
@@ -272,10 +272,10 @@
273273 );
274274 if( $this->deleteKey=='oldid' ) {
275275 foreach( $revObjs as $rev )
276 - $hidden[] = wfHidden( 'oldid[]', $rev->getId() );
 276+ $hidden[] = Xml::hidden( 'oldid[]', $rev->getId() );
277277 } else {
278278 foreach( $revObjs as $rev )
279 - $hidden[] = wfHidden( 'artimestamp[]', $rev->getTimestamp() );
 279+ $hidden[] = Xml::hidden( 'artimestamp[]', $rev->getTimestamp() );
280280 }
281281 $special = SpecialPage::getTitleFor( 'Revisiondelete' );
282282 $wgOut->addHtml(
@@ -306,13 +306,15 @@
307307 * This lets a user set restrictions for archived images
308308 */
309309 function showImages() {
310 - global $wgOut, $wgUser, $action;
 310+ // What is $action doing here???
 311+ global $wgOut, $wgUser, $action, $wgLang;
311312
312313 $UserAllowed = true;
313314
314315 $count = ($this->deleteKey=='oldimage') ? count($this->ofiles) : count($this->afiles);
315 - $wgOut->addWikiText( wfMsgExt( 'revdelete-selected', array('parsemag'),
316 - $this->page->getPrefixedText(), $count ) );
 316+ $wgOut->addWikiMsg( 'revdelete-selected',
 317+ $this->page->getPrefixedText(),
 318+ $wgLang->formatNum($count) );
317319
318320 $bitfields = 0;
319321 $wgOut->addHtml( "<ul>" );
@@ -393,7 +395,7 @@
394396
395397 $wgOut->addHtml( "</ul>" );
396398
397 - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) );
 399+ $wgOut->addWikiMsg('revdelete-text' );
398400 //Normal sysops can always see what they did, but can't always change it
399401 if( !$UserAllowed ) return;
400402
@@ -408,17 +410,16 @@
409411 );
410412 if( $this->deleteKey=='oldimage' ) {
411413 foreach( $this->ofiles as $filename )
412 - $hidden[] = wfHidden( 'oldimage[]', $filename );
 414+ $hidden[] = Xml::hidden( 'oldimage[]', $filename );
413415 } else {
414416 foreach( $this->afiles as $fileid )
415 - $hidden[] = wfHidden( 'fileid[]', $fileid );
 417+ $hidden[] = Xml::hidden( 'fileid[]', $fileid );
416418 }
417419 $special = SpecialPage::getTitleFor( 'Revisiondelete' );
418420 $wgOut->addHtml(
419421 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
420422 'id' => 'mw-revdel-form-filerevisions' ) ) .
421 - Xml::openElement( 'fieldset' ) .
422 - xml::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
 423+ Xml::fiedlset( wfMsg( 'revdelete-legend' ) )
423424 );
424425 // FIXME: all items checked for just one file are checked, even if not set for the others
425426 foreach( $this->checks as $item ) {
@@ -426,7 +427,7 @@
427428 $wgOut->addHtml( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
428429 }
429430 foreach( $items as $item ) {
430 - $wgOut->addHtml( Xml::tags( 'p', null, $item ) );
 431+ $wgOut->addHtml( "<p>$item</p>" );
431432 }
432433 foreach( $hidden as $item ) {
433434 $wgOut->addHtml( $item );
@@ -442,10 +443,10 @@
443444 * This lets a user set restrictions for log items
444445 */
445446 function showLogItems() {
446 - global $wgOut, $wgUser, $action, $wgMessageCache;
 447+ global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang;
447448
448449 $UserAllowed = true;
449 - $wgOut->addWikiText( wfMsgExt( 'logdelete-selected', array('parsemag'), count($this->events) ) );
 450+ $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events) ) );
450451
451452 $bitfields = 0;
452453 $wgOut->addHtml( "<ul>" );
@@ -508,8 +509,7 @@
509510 $wgOut->addHtml(
510511 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
511512 'id' => 'mw-revdel-form-logs' ) ) .
512 - Xml::openElement( 'fieldset' ) .
513 - xml::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
 513+ Xml::fieldset( wfMsg( 'revdelete-legend' ) )
514514 );
515515 // FIXME: all items checked for just on event are checked, even if not set for the others
516516 foreach( $this->checks as $item ) {
@@ -517,7 +517,7 @@
518518 $wgOut->addHtml( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
519519 }
520520 foreach( $items as $item ) {
521 - $wgOut->addHtml( Xml::tags( 'p', null, $item ) );
 521+ $wgOut->addHtml( "<p>$item</p>" );
522522 }
523523 foreach( $hidden as $item ) {
524524 $wgOut->addHtml( $item );
@@ -592,10 +592,11 @@
593593 $pageLink = "<a href=\"{$url}\">{$date}</a>";
594594 }
595595
596 - $data = wfMsgHtml( 'widthheight',
 596+ $data = wfMsg( 'widthheight',
597597 $wgContLang->formatNum( $file->getWidth() ),
598598 $wgContLang->formatNum( $file->getHeight() ) ) .
599 - ' (' . wfMsgHtml( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
 599+ ' (' . wfMsg( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
 600+ $data = htmlspecialchars( $data );
600601
601602 return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
602603 }
@@ -618,10 +619,11 @@
619620 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
620621 }
621622
622 - $data = wfMsgHtml( 'widthheight',
 623+ $data = wfMsg( 'widthheight',
623624 $wgContLang->formatNum( $file->getWidth() ),
624625 $wgContLang->formatNum( $file->getHeight() ) ) .
625 - ' (' . wfMsgHtml( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
 626+ ' (' . wfMsg( 'nbytes', $wgContLang->formatNum( $file->getSize() ) ) . ')';
 627+ $data = htmlspecialchars( $data );
626628
627629 return "<li> $pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
628630 }
@@ -728,19 +730,21 @@
729731 private function success() {
730732 global $wgOut;
731733
732 - $wgOut->setPagetitle( wfMsgHtml( 'actioncomplete' ) );
 734+ $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
733735
 736+ $wrap = '<span class="success">$1</span>';
 737+
734738 if( $this->deleteKey=='logid' ) {
735 - $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'logdelete-success' ) ), false );
 739+ $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
736740 $this->showLogItems();
737741 } else if( $this->deleteKey=='oldid' || $this->deleteKey=='artimestamp' ) {
738 - $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'revdelete-success' ) ), false );
 742+ $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
739743 $this->showRevs();
740744 } else if( $this->deleteKey=='fileid' ) {
741 - $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'revdelete-success' ) ), false );
 745+ $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
742746 $this->showImages();
743747 } else if( $this->deleteKey=='oldimage' ) {
744 - $wgOut->addWikiText( Xml::element( 'span', array( 'class' => 'success' ), wfMsg( 'revdelete-success' ) ), false );
 748+ $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
745749 $this->showImages();
746750 }
747751 }
Index: trunk/phase3/includes/specials/SpecialProtectedpages.php
@@ -89,10 +89,13 @@
9090 }
9191
9292 if (!is_null($size = $row->page_len)) {
93 - if ($size == 0)
94 - $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
95 - else
96 - $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum( $size ) ) . '</small>';
 93+ if ($size == 0) {
 94+ $stxt = wfMsg('historyempty');
 95+ } else {
 96+ $stxt = wfMsg('nbytes', $wgLang->formatNum( $size ) );
 97+ $stxt = "($stxt)";
 98+ }
 99+ $stxt = htmlspecialchars( $stxt );
97100 $stxt = $wgContLang->getDirMark() . $stxt;
98101 }
99102
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php
@@ -247,10 +247,13 @@
248248 $userLink = $this->sk->revUserTools( $rev );
249249
250250 if(!is_null($size = $row->rev_len)) {
251 - if($size == 0)
252 - $stxt = wfMsgHtml('historyempty');
253 - else
254 - $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
 251+ if($size == 0) {
 252+ $stxt = wfMsg('historyempty');
 253+ } else {
 254+ $stxt = wfMsg('nbytes', $wgLang->formatNum( $size ) );
 255+ $stxt = "($stxt)";
 256+ }
 257+ $stxt = htmlspecialchars( $stxt );
255258 }
256259 $comment = $this->sk->revComment( $rev );
257260
Index: trunk/phase3/includes/PageHistory.php
@@ -245,10 +245,13 @@
246246 }
247247
248248 if ( !is_null( $size = $rev->getSize() ) && $rev->userCan( Revision::DELETED_TEXT ) ) {
249 - if ( $size == 0 )
250 - $stxt = wfMsgHtml( 'historyempty' );
251 - else
252 - $stxt = wfMsgExt( 'historysize', array( 'parsemag' ), $wgLang->formatNum( $size ) );
 249+ if ( $size == 0 ) {
 250+ $stxt = wfMsg( 'historyempty' );
 251+ } else {
 252+ $stxt = wfMsg( 'nbytes', $wgLang->formatNum( $size ) );
 253+ $stxt = "($stxt)";
 254+ }
 255+ $stxt = htmlspecialchars( $stxt );
253256 $s .= " <span class=\"history-size\">$stxt</span>";
254257 }
255258
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1209,7 +1209,6 @@
12101210 'deletedrev' => '[deleted]',
12111211 'histfirst' => 'Earliest',
12121212 'histlast' => 'Latest',
1213 -'historysize' => '({{PLURAL:$1|1 byte|$1 bytes}})',
12141213 'historyempty' => '(empty)',
12151214
12161215 # Revision feed

Follow-up revisions

RevisionCommit summaryAuthorDate
r37376* More fixes to misuse of wfmsg functions...nikerabbit09:17, 9 July 2008
r37408fix to r37375 -- spell fieldset correctly :)brion16:49, 9 July 2008
r37659* Cleanup for r37375. Split duplicated code into function and really fix itnikerabbit19:10, 14 July 2008

Status & tagging log