r69493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69492‎ | r69493 | r69494 >
Date:23:38, 17 July 2010
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
Use addWikiMsg and formatNum in more places
Modified paths:
  • /trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php
@@ -80,12 +80,12 @@
8181 $pager = new UnreviewedPagesPager( $this, $live, $namespace,
8282 !$hideRedirs, $category, $level );
8383 if ( $pager->getNumRows() ) {
84 - $wgOut->addHTML( wfMsgExt( 'unreviewed-list', array( 'parse' ) ) );
 84+ $wgOut->addWikiMsg( 'unreviewed-list' );
8585 $wgOut->addHTML( $pager->getNavigationBar() );
8686 $wgOut->addHTML( $pager->getBody() );
8787 $wgOut->addHTML( $pager->getNavigationBar() );
8888 } else {
89 - $wgOut->addHTML( wfMsgExt( 'unreviewed-none', array( 'parse' ) ) );
 89+ $wgOut->addWikiMsg( 'unreviewed-none' );
9090 }
9191 }
9292
@@ -110,11 +110,11 @@
111111 $hours = ( $currentTime - $firstPendingTime ) / 3600;
112112 // After three days, just use days
113113 if ( $hours > ( 3 * 24 ) ) {
114 - $days = round( $hours / 24, 0 );
 114+ $days = $wgLang->formatNum( round( $hours / 24, 0 ) );
115115 $age = ' ' . wfMsgExt( 'unreviewed-days', array( 'parsemag' ), $wgLang->formatNum( $days ) );
116116 // If one or more hours, use hours
117117 } elseif ( $hours >= 1 ) {
118 - $hours = round( $hours, 0 );
 118+ $hours = $wgLang->formatNum( round( $hours, 0 ) );
119119 $age = ' ' . wfMsgExt( 'unreviewed-hours', array( 'parsemag' ), $wgLang->formatNum( $hours ) );
120120 } else {
121121 $age = ' ' . wfMsg( 'unreviewed-recent' ); // hot off the press :)
@@ -122,7 +122,7 @@
123123 if ( $wgUser->isAllowed( 'unwatchedpages' ) ) {
124124 $uw = self::usersWatching( $title );
125125 $watching = $uw
126 - ? wfMsgExt( 'unreviewed-watched', array( 'parsemag' ), $wgLang->formatNum( $uw ) )
 126+ ? wfMsgExt( 'unreviewed-watched', 'parsemag', $wgLang->formatNum( $uw ) )
127127 : wfMsgHtml( 'unreviewed-unwatched' );
128128 $watching = " $watching"; // Oh-noes!
129129 } else {
@@ -130,7 +130,8 @@
131131 }
132132 $css = self::getLineClass( $hours, $uw );
133133 $css = $css ? " class='$css'" : "";
134 - $pageId = isset( $row->page_id ) ? $row->page_id : $row->qc_value;
 134+ $pageId = isset( $row->page_id ) ?
 135+ $row->page_id : $row->qc_value;
135136 $key = wfMemcKey( 'unreviewedPages', 'underReview', $pageId );
136137 $val = $wgMemc->get( $key );
137138 # Show if a user is looking at this page
@@ -146,9 +147,10 @@
147148 /**
148149 * Get number of users watching a page. Max is 5.
149150 * @param Title $title
 151+ * @return int
150152 */
151 - public static function usersWatching( $title ) {
152 - global $wgMiserMode;
 153+ public static function usersWatching( Title $title ) {
 154+ global $wgMiserMode, $wgCookieExpiration;
153155 $dbr = wfGetDB( DB_SLAVE );
154156 $count = - 1;
155157 if ( $wgMiserMode ) {
@@ -160,7 +162,6 @@
161163 }
162164 # If it is small, just COUNT() it, otherwise, stick with estimate...
163165 if ( $count == - 1 || $count <= 100 ) {
164 - global $wgCookieExpiration;
165166 # Get number of active editors watchling this
166167 $cutoff = $dbr->timestamp( wfTimestamp( TS_UNIX ) - 2 * $wgCookieExpiration );
167168 $res = $dbr->select( array( 'watchlist', 'user' ), '1',
@@ -174,7 +175,7 @@
175176 );
176177 $count = $dbr->numRows( $res );
177178 }
178 - return $count;
 179+ return (int)$count;
179180 }
180181
181182 protected static function getLineClass( $hours, $uw ) {
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php
@@ -31,18 +31,17 @@
3232 }
3333
3434 protected function showStableList() {
35 - global $wgOut, $wgUser;
 35+ global $wgOut, $wgUser, $wgLang;
3636 # Must be a content page
3737 if ( !FlaggedRevs::inReviewNamespace( $this->page ) ) {
38 - $wgOut->addHTML( wfMsgExt( 'reviewedversions-none', array( 'parse' ),
39 - $this->page->getPrefixedText() ) );
 38+ $wgOut->addWikiMsg( 'reviewedversions-none', $this->page->getPrefixedText() );
4039 return;
4140 }
4241 $pager = new ReviewedVersionsPager( $this, array(), $this->page );
4342 $num = $pager->getNumRows();
4443 if ( $num ) {
45 - $wgOut->addHTML( wfMsgExt( 'reviewedversions-list', array( 'parse' ),
46 - $this->page->getPrefixedText(), $num ) );
 44+ $wgOut->addWikiMsg( 'reviewedversions-list',
 45+ $this->page->getPrefixedText(), $wgLang->formatNum( $num ) );
4746 $wgOut->addHTML( $pager->getNavigationBar() );
4847 $wgOut->addHTML( "<ul>" . $pager->getBody() . "</ul>" );
4948 $wgOut->addHTML( $pager->getNavigationBar() );
Index: trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php
@@ -79,14 +79,14 @@
8080 $wgOut->addHTML( $pager->getBody() );
8181 $wgOut->addHTML( $pager->getNavigationBar() );
8282 } else {
83 - $wgOut->addHTML( wfMsgExt( 'problemchanges-none', array( 'parse' ) ) );
 83+ $wgOut->addWikiMsg( 'problemchanges-none' );
8484 }
8585 // If this page is transcluded...
8686 } else {
8787 if ( $pager->getNumRows() ) {
8888 $wgOut->addHTML( $pager->getBody() );
8989 } else {
90 - $wgOut->addHTML( wfMsgExt( 'problemchanges-none', array( 'parse' ) ) );
 90+ $wgOut->addWikiMsg( 'problemchanges-none' );
9191 }
9292 }
9393 }
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php
@@ -71,7 +71,7 @@
7272 if ( $num ) {
7373 // Text to explain level select (if there are several levels)
7474 if ( FlaggedRevs::qualityVersions() ) {
75 - $wgOut->addHTML( wfMsgExt( 'reviewedpages-list', array( 'parse' ), $wgLang->formatNum( $num ) ) );
 75+ $wgOut->addWikiMsg( 'reviewedpages-list', $wgLang->formatNum( $num ) );
7676 }
7777 $wgOut->addHTML( $pager->getNavigationBar() );
7878 $wgOut->addHTML( $pager->getBody() );

Comments

#Comment by Raymond (talk | contribs)   09:44, 18 July 2010

formatNum is applied twice now in some lines, i.e.

-			$days = round( $hours / 24, 0 );
+			$days = $wgLang->formatNum( round( $hours / 24, 0 ) );
 			$age = ' ' . wfMsgExt( 'unreviewed-days', array( 'parsemag' ), $wgLang->formatNum( $days ) );
#Comment by Aaron Schulz (talk | contribs)   17:15, 18 July 2010

Changed in r69513.

Status & tagging log