r106668 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106667‎ | r106668 | r106669 >
Date:18:19, 19 December 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Use Language::userTimeAndDate() and related instead of Language::timeanddate() when using user preferences to display dates
* Use local variables instead of calling some methods three times
* Fixed casing of remaining Language::timeanddate() call
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Preferences.php
@@ -193,14 +193,16 @@
194194 );
195195
196196 if ( $user->getRegistration() ) {
 197+ $displayUser = $context->getUser();
 198+ $userRegistration = $user->getRegistration();
197199 $defaultPreferences['registrationdate'] = array(
198200 'type' => 'info',
199201 'label-message' => 'prefs-registration',
200202 'default' => $context->msg(
201203 'prefs-registration-date-time',
202 - $lang->timeanddate( $user->getRegistration(), true ),
203 - $lang->date( $user->getRegistration(), true ),
204 - $lang->time( $user->getRegistration(), true )
 204+ $lang->userTimeAndDate( $userRegistration, $displayUser ),
 205+ $lang->userDate( $userRegistration, $displayUser ),
 206+ $lang->userTime( $userRegistration, $displayUser )
205207 )->parse(),
206208 'section' => 'personal/info',
207209 );
@@ -368,9 +370,11 @@
369371 // date and time are separate parameters to facilitate localisation.
370372 // $time is kept for backward compat reasons.
371373 // 'emailauthenticated' is also used in SpecialConfirmemail.php
372 - $time = $lang->timeAndDate( $user->getEmailAuthenticationTimestamp(), true );
373 - $d = $lang->date( $user->getEmailAuthenticationTimestamp(), true );
374 - $t = $lang->time( $user->getEmailAuthenticationTimestamp(), true );
 374+ $displayUser = $context->getUser();
 375+ $emailTimestamp = $user->getEmailAuthenticationTimestamp();
 376+ $time = $lang->userTimeAndDate( $emailTimestamp, $displayUser );
 377+ $d = $lang->userDate( $emailTimestamp, $displayUser );
 378+ $t = $lang->userTime( $emailTimestamp, $displayUser );
375379 $emailauthenticated = $context->msg( 'emailauthenticated',
376380 $time, $d, $t )->parse() . '<br />';
377381 $disableEmailPrefs = false;
@@ -1094,7 +1098,8 @@
10951099 * @return array
10961100 */
10971101 static function getDateOptions( IContextSource $context ) {
1098 - $dateopts = $context->getLanguage()->getDatePreferences();
 1102+ $lang = $context->getLanguage();
 1103+ $dateopts = $lang->getDatePreferences();
10991104
11001105 $ret = array();
11011106
@@ -1115,7 +1120,7 @@
11161121 if ( $key == 'default' ) {
11171122 $formatted = $context->msg( 'datedefault' )->escaped();
11181123 } else {
1119 - $formatted = htmlspecialchars( $context->getLanguage()->timeanddate( $epoch, false, $key ) );
 1124+ $formatted = htmlspecialchars( $lang->timeanddate( $epoch, false, $key ) );
11201125 }
11211126 $ret[$formatted] = $key;
11221127 }

Comments

#Comment by Nikerabbit (talk | contribs)   07:23, 20 December 2011
* Fixed casing of remaining Language::timeanddate() call

Don't see this.

#Comment by IAlex (talk | contribs)   08:09, 20 December 2011

Oh yes, the false casing was the one in the middle chunck.

Status & tagging log