r7877 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7876‎ | r7877 | r7878 >
Date:01:28, 26 March 2005
Author:avar
Status:old
Tags:
Comment:
* (bug 1668) a redesign of the "Date format" system, languages are now able to
specify an arbitary amount of date formats which they wish to use in the
$wgDateFormatsXx array, if the array is empty the "Date format" option will
not be shown, the only languages that currently take atvantage of the
multiple formats are Icelandic, English and Frysk, I removed all but the
first item of the $wgDateFormatsXx array from those that don't which should
show something like "use default".
Modified paths:
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageBg.php (modified) (history)
  • /trunk/phase3/languages/LanguageBn.php (modified) (history)
  • /trunk/phase3/languages/LanguageCa.php (modified) (history)
  • /trunk/phase3/languages/LanguageCy.php (modified) (history)
  • /trunk/phase3/languages/LanguageDa.php (modified) (history)
  • /trunk/phase3/languages/LanguageEs.php (modified) (history)
  • /trunk/phase3/languages/LanguageFo.php (modified) (history)
  • /trunk/phase3/languages/LanguageFy.php (modified) (history)
  • /trunk/phase3/languages/LanguageGa.php (modified) (history)
  • /trunk/phase3/languages/LanguageHu.php (modified) (history)
  • /trunk/phase3/languages/LanguageId.php (modified) (history)
  • /trunk/phase3/languages/LanguageIs.php (modified) (history)
  • /trunk/phase3/languages/LanguageLt.php (modified) (history)
  • /trunk/phase3/languages/LanguageMs.php (modified) (history)
  • /trunk/phase3/languages/LanguageNn.php (modified) (history)
  • /trunk/phase3/languages/LanguageNv.php (modified) (history)
  • /trunk/phase3/languages/LanguagePt.php (modified) (history)
  • /trunk/phase3/languages/LanguageRo.php (modified) (history)
  • /trunk/phase3/languages/LanguageSl.php (modified) (history)
  • /trunk/phase3/languages/LanguageSq.php (modified) (history)
  • /trunk/phase3/languages/LanguageSr.php (modified) (history)
  • /trunk/phase3/languages/LanguageSv.php (modified) (history)
  • /trunk/phase3/languages/LanguageTa.php (modified) (history)
  • /trunk/phase3/languages/LanguageTh.php (modified) (history)
  • /trunk/phase3/languages/LanguageTt.php (modified) (history)
  • /trunk/phase3/languages/LanguageUk.php (modified) (history)
  • /trunk/phase3/languages/LanguageWa.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPreferences.php
@@ -101,7 +101,7 @@
102102 }
103103
104104 function execute() {
105 - global $wgUser, $wgOut, $wgUseDynamicDates;
 105+ global $wgUser, $wgOut;
106106
107107 if ( $wgUser->isAnon() ) {
108108 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
@@ -367,7 +367,7 @@
368368 * @access private
369369 */
370370 function mainPrefsForm( $err ) {
371 - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames;
 371+ global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
372372 global $wgAllowRealName, $wgImageLimits;
373373 global $wgLanguageNames, $wgDisableLangConversion;
374374 global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
@@ -605,16 +605,13 @@
606606
607607 # Date format
608608 #
609 - if ( $wgUseDynamicDates ) {
 609+
 610+ if ($dateopts) {
610611 $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
611 - for ( $i = 0; $i < count( $dateopts ); ++$i) {
612 - if ( $i == $this->mDate ) {
613 - $checked = ' checked="checked"';
614 - } else {
615 - $checked = "";
616 - }
 612+ foreach($dateopts as $key => $option) {
 613+ ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
617614 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
618 - "value=\"$i\"$checked /> {$dateopts[$i]}</label></div>\n" );
 615+ "value=\"$key\"$checked />$option</label></div>\n" );
619616 }
620617 $wgOut->addHTML( "</fieldset>\n\n");
621618 }
Index: trunk/phase3/languages/LanguageWa.php
@@ -44,10 +44,6 @@
4545
4646 /* private */ $wgDateFormatsWa = array( /* cwè fé chal ??? */
4747 "Nole preferince",
48 - "January 15, 2001",
49 - "15 January 2001",
50 - "2001 January 15",
51 - "2001-01-15"
5248 );
5349
5450 /* private */ $wgBookstoreListWa = array(
Index: trunk/phase3/languages/LanguageCy.php
@@ -37,10 +37,6 @@
3838
3939 /* private */ $wgDateFormatsCy = array(
4040 "Dim dewis",
41 - "Ionawr 15, 2001",
42 - "15 Ionawr 2001",
43 - "2001 Ionawr 15",
44 - "2001-01-15"
4541 );
4642
4743 /* private */ $wgBookstoreListCy = array(
Index: trunk/phase3/languages/LanguageSl.php
@@ -117,10 +117,6 @@
118118
119119 /* private */ $wgDateFormatsSl = array(
120120 'No preference',
121 - 'januar 15, 2001',
122 - '15 januar 2001',
123 - '2001 januar 15',
124 - '2001-01-15'
125121 );
126122
127123
Index: trunk/phase3/languages/LanguageSq.php
@@ -48,9 +48,6 @@
4949
5050 /* private */ $wgDateFormatsSq = array(
5151 "Pa preferencë",
52 - "Janar 15, 2001",
53 - "15 Janar 2001",
54 - "2001 Janar 15"
5552 );
5653
5754
Index: trunk/phase3/languages/LanguageDa.php
@@ -57,10 +57,6 @@
5858
5959 /* private */ $wgDateFormatsDa = array(
6060 "Ingen foretrukken",
61 - "januar 15, 2001",
62 - "15. januar 2001",
63 - "2001 januar 15",
64 - "2001-01-15"
6561 );
6662
6763
Index: trunk/phase3/languages/LanguageSr.php
@@ -34,9 +34,6 @@
3535
3636 /* private */ $wgDateFormatsSr = array(
3737 "Без посебних жеља",
38 - "Јануар 15, 2001",
39 - "15 Јануар 2001",
40 - "2001 Јануар 15"
4138 );
4239
4340
Index: trunk/phase3/languages/LanguageSv.php
@@ -62,10 +62,6 @@
6363
6464 /* private */ $wgDateFormatsSv = array(
6565 "Ingen inställning",
66 - "Januari 15, 2001",
67 - "15 Januari 2001",
68 - "2001 Januari 15",
69 - "2001-01-15"
7066 );
7167
7268 /* private */ $wgBookstoreListSv = array(
Index: trunk/phase3/languages/LanguageTa.php
@@ -57,9 +57,6 @@
5858
5959 /* private */ $wgDateFormatsTa = array(
6060 "முன்னுரிமை இல்லை",
61 - "ஜனவரி 15, 2001",
62 - "15 ஜனவரி 2001",
63 - "2001 ஜனவரி 15"
6461 );
6562
6663
Index: trunk/phase3/languages/LanguageTh.php
@@ -40,10 +40,6 @@
4141
4242 /* private */ $wgDateFormatsTh = array(
4343 "No preference",
44 - "มกราคม 15, 2001",
45 - "15 มกราคม 2001",
46 - "2001 มกราคม 15",
47 - "2001-01-15"
4844 );
4945
5046
Index: trunk/phase3/languages/LanguageHu.php
@@ -79,9 +79,6 @@
8080
8181 /* private */ $wgDateFormatsHu = array(
8282 "Mindegy",
83 - "Július 8, 2003",
84 - "8 Július, 2003",
85 - "2003 Július 8"
8683 );
8784
8885
Index: trunk/phase3/languages/LanguageLt.php
@@ -27,10 +27,6 @@
2828
2929 /* private */ $wgDateFormatsLt = array(
3030 "Nesvarbu",
31 - "Sausio 15, 2001",
32 - "15 Sausio 2001",
33 - "2001 Sausio 15",
34 - "2001-01-15"
3531 );
3632
3733 /* private */ $wgWeekdayNamesLt = array(
Index: trunk/phase3/languages/LanguagePt.php
@@ -60,9 +60,6 @@
6161
6262 /* private */ $wgDateFormatsPt = array(
6363 "Sem preferência",
64 - "Janeiro 15, 2001",
65 - "15 Janeiro 2001",
66 - "2001 Janeiro 15"
6764 );
6865
6966
Index: trunk/phase3/languages/LanguageTt.php
@@ -55,10 +55,6 @@
5656
5757 /* private */ $wgDateFormatsTt = array(
5858 "köyläwsez",
59 - "Ğínwar 15, 2001",
60 - "15. Ğínwar 2001",
61 - "2001 Ğínwar 15",
62 - "2001-01-15"
6359 );
6460
6561
Index: trunk/phase3/languages/LanguageId.php
@@ -72,10 +72,6 @@
7373
7474 /* private */ $wgDateFormatsId = array(
7575 "Tiada pilihan",
76 - "Januari 15, 2001",
77 - "15 Januari 2001",
78 - "2001 Januari 15",
79 - "2001-01-15"
8076 );
8177
8278 /* private */ $wgUserTogglesId = array(
Index: trunk/phase3/languages/LanguageEs.php
@@ -56,9 +56,6 @@
5757
5858 /* private */ $wgDateFormatsEs = array(
5959 "Sin preferencia",
60 - "enero 15, 2001",
61 - "15 de enero de 2001",
62 - "2001 enero 15"
6360 );
6461
6562 /* Please customize this with some Spanish-language bookshops
Index: trunk/phase3/languages/LanguageIs.php
@@ -869,7 +869,7 @@
870870
871871 switch( $wgUser->getOption( 'date' ) ) {
872872 # 15. jan. 2001 kl. 16:12 || 16:12, 15. jan. 2001
873 - case 2: case 4: return (0 + substr( $ts, 6, 2 )) . '. ' .
 873+ case '2': case '4': return (0 + substr( $ts, 6, 2 )) . '. ' .
874874 $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . '. ' .
875875 substr($ts, 0, 4);
876876 # 2001-01-15 16:12:34
@@ -900,7 +900,7 @@
901901
902902 switch ( $wgUser->getOption( 'date' ) ) {
903903 # 16:12, 15. janúar 2001 || 16:12, 15. jan. 2001
904 - case 3: case 4: return $this->time( $ts, $adj ) . ', ' . $this->date( $ts, $adj );
 904+ case '3': case '4': return $this->time( $ts, $adj ) . ', ' . $this->date( $ts, $adj );
905905 # 2001-01-15 16:12:34
906906 case 'ISO 8601': return $this->date( $ts, $adj ) . ' ' . $this->time( $ts, $adj );
907907 # 15. janúar 2001 kl. 16:12 || 15. jan. 2001 kl. 16:12
Index: trunk/phase3/languages/LanguageUk.php
@@ -51,9 +51,6 @@
5252 /* Non-std date formats are only enabled for English, which is idiosyncratic that way */
5353 /* private */ $wgDateFormatsUk = array(
5454 "Немає значення",
55 - "Січень 15, 2001",
56 - "15 січня 2001",
57 - "2001 січень 15"
5855 );
5956
6057
Index: trunk/phase3/languages/LanguageMs.php
@@ -46,8 +46,6 @@
4747
4848 /* private */ $wgDateFormatsMs = array(
4949 "Tiada pilihan", # "No preference",
50 - "15 Januari 2001", # "Januari 15, 2001",
51 - "15 Januari 2001", # "2001 Januari 15"
5250 );
5351
5452
Index: trunk/phase3/languages/LanguageBg.php
@@ -48,10 +48,6 @@
4949
5050 /* private */ $wgDateFormatsBg = array(
5151 'Без предпочитание',
52 - 'януари 15, 2001',
53 - '15 януари 2001',
54 - '2001 януари 15',
55 - '2001-01-15'
5652 );
5753
5854
Index: trunk/phase3/languages/LanguageBn.php
@@ -43,9 +43,6 @@
4444
4545 /* private */ $wgDateFormatsBn = array(
4646 "No preference",
47 - "January 15, 2001",
48 - "15 January 2001",
49 - "2001 January 15"
5047 );
5148
5249
Index: trunk/phase3/languages/LanguageFo.php
@@ -49,10 +49,6 @@
5050
5151 /* private */ $wgDateFormatsFo = array(
5252 "Ongi forrættindi",
53 - "januar 15, 2001",
54 - "15. januar 2001",
55 - "2001 januar 15",
56 - "2001-01-15"
5753 );
5854
5955 /* private */ $wgBookstoreListFo = array(
Index: trunk/phase3/languages/LanguageNn.php
@@ -74,10 +74,6 @@
7575
7676 /* private */ $wgDateFormatsNn = array(
7777 'Ingen preferanse',
78 - 'januar 15, 2001',
79 - '15 januar 2001',
80 - '2001 januar 15',
81 - '2001-01-15'
8278 );
8379
8480 /* private */ $wgBookstoreListNn = array(
Index: trunk/phase3/languages/LanguageFy.php
@@ -53,10 +53,11 @@
5454
5555
5656 /* private */ $wgDateFormatsFy = array(
57 - "Gjin foarkar",
58 - "jannewaris 8, 2001",
59 - "8 jannewaris 2001",
60 - "2001 jannewaris 8"
 57+ 'Gjin foarkar',
 58+ '16:12, jan 15, 2001',
 59+ '16:12, 15 jan 2001',
 60+ '16:12, 2001 jan 15',
 61+ 'ISO 8601' => '2001-01-15 16:12:34'
6162 );
6263
6364 /* private */ $wgBookstoreListFy = array(
@@ -1081,52 +1082,35 @@
10821083
10831084 # Inherit userAdjust()
10841085
1085 - function date( $ts, $adj = false )
1086 - {
1087 - global $wgAmericanDates, $wgUser, $wgUseDynamicDates;
 1086+ function date( $ts, $adj = false ) {
 1087+ global $wgUser;
10881088
10891089 if ( $adj ) { $ts = $this->userAdjust( $ts ); }
10901090
1091 - if ( $wgUseDynamicDates ) {
1092 - $datePreference = $wgUser->getOption( 'date' );
1093 - if ( $datePreference == 0 ) {
1094 - $datePreference = $wgAmericanDates ? 1 : 2;
1095 - }
1096 - } else {
1097 - $datePreference = $wgAmericanDates ? 1 : 2;
 1091+ switch ( $wgUser->getOption( 'date' ) ) {
 1092+ # jan 8, 2001
 1093+ case '0': case '1': return $d = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) )
 1094+ . ' ' . (0 + substr( $ts, 6, 2 )) . ', ' . substr( $ts, 0, 4 );
 1095+ # 8 jannewaris 2001
 1096+ case '2': return (0 + substr( $ts, 6, 2 )) . ' ' .
 1097+ $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . ' ' .
 1098+ substr( $ts, 0, 4 );
 1099+ case 'ISO 8601': return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
 1100+ # 2001 jannewaris 8
 1101+ default: return substr( $ts, 0, 4 ) . ' ' .
 1102+ $this->getMonthAbbreviation( substr( $ts, 4, 2 ) )
 1103+ . ' ' . (0 + substr( $ts, 6, 2 ));
10981104 }
 1105+ }
 1106+ function timeanddate( $ts, $adj = false ) {
 1107+ global $wgUser;
10991108
1100 - if ( $datePreference == 1 ) {
1101 - # MDY
1102 - $d = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) .
1103 - " " . (0 + substr( $ts, 6, 2 )) . ", " .
1104 - substr( $ts, 0, 4 );
1105 - } else if ( $datePreference == 2 ) {
1106 - #DMY
1107 - $d = (0 + substr( $ts, 6, 2 )) . " " .
1108 - $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) . " " .
1109 - substr( $ts, 0, 4 );
1110 - } else {
1111 - #YMD
1112 - $d = substr( $ts, 0, 4 ) . " " . $this->getMonthAbbreviation( substr( $ts, 4, 2 ) ) .
1113 - " " . (0 + substr( $ts, 6, 2 ));
 1109+ switch ( $wgUser->getOption( 'date' ) ) {
 1110+ case 'ISO 8601': return $this->date( $ts, $adj ) . ' ' . $this->time( $ts, $adj );
 1111+ default: return $this->time( $ts, $adj ) . ', ' . $this->date( $ts, $adj );
11141112 }
1115 -
1116 - return $d;
11171113 }
11181114
1119 - function time( $ts, $adj = false )
1120 - {
1121 - if ( $adj ) { $ts = $this->userAdjust( $ts ); }
1122 -
1123 - $t = substr( $ts, 8, 2 ) . "." . substr( $ts, 10, 2 );
1124 - return $t;
1125 - }
1126 -
1127 -# Inherit timeanddate()
1128 -
1129 -# Inherit rfc1123()
1130 -
11311115 function getValidSpecialPages()
11321116 {
11331117 global $wgValidSpecialPagesFy;
Index: trunk/phase3/languages/Language.php
@@ -122,11 +122,11 @@
123123 define( 'MW_DATE_USER_FORMAT', true );
124124
125125 /* private */ $wgDateFormatsEn = array(
126 - 'No preference',
127 - 'January 15, 2001',
128 - '15 January 2001',
129 - '2001 January 15',
130 - '2001-01-15'
 126+ 'Default',
 127+ '16:12, January 15, 2001',
 128+ '16:12, 15 January 2001',
 129+ '16:12, 2001 January 15',
 130+ 'ISO 8601' => '2001-01-15 16:12:34'
131131 );
132132
133133 /* private */ $wgUserTogglesEn = array(
@@ -1788,10 +1788,6 @@
17891789 'specialloguserlabel' => 'User: ',
17901790 'speciallogtitlelabel' => 'Title: ',
17911791
1792 -# labels for Group: and User: ond Special:Listusers
1793 -'speciallistusersuserlabel' => 'User: ',
1794 -'speciallistusersgrouplabel' => 'Group: ',
1795 -
17961792 'passwordtooshort' => 'Your password is too short. It must have at least $1 characters.',
17971793
17981794 # external editor support
@@ -1971,35 +1967,33 @@
19721968 }
19731969
19741970 function date( $ts, $adj = false, $format = MW_DATE_USER_FORMAT, $timecorrection = false ) {
1975 - global $wgAmericanDates, $wgUser, $wgUseDynamicDates;
1976 -
 1971+ global $wgAmericanDates, $wgUser;
 1972+
19771973 $ts=wfTimestamp(TS_MW,$ts);
19781974
19791975 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
19801976
1981 - if ( $wgUseDynamicDates ) {
1982 - if ( $format == MW_DATE_USER_FORMAT ) {
1983 - $datePreference = $wgUser->getOption( 'date' );
1984 - } else {
1985 - $options = $this->getDefaultUserOptions();
1986 - $datePreference = $options['date'];
1987 - }
1988 - if ( $datePreference == 0 ) {
1989 - $datePreference = $wgAmericanDates ? 1 : 2;
1990 - }
 1977+
 1978+ if ( $format == MW_DATE_USER_FORMAT ) {
 1979+ $datePreference = $wgUser->getOption( 'date' );
19911980 } else {
 1981+ $options = $this->getDefaultUserOptions();
 1982+ $datePreference = $options['date'];
 1983+ }
 1984+
 1985+ if ($datePreference == '0') {
19921986 $datePreference = $wgAmericanDates ? 1 : 2;
19931987 }
19941988
19951989 $month = $this->getMonthAbbreviation( substr( $ts, 4, 2 ) );
19961990 $day = $this->formatNum( 0 + substr( $ts, 6, 2 ) );
19971991 $year = $this->formatNum( substr( $ts, 0, 4 ) );
1998 -
 1992+
19991993 switch( $datePreference ) {
2000 - case 1: return "$month $day, $year";
2001 - case 2: return "$day $month $year";
2002 - case 4: return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
2003 - default: return "$year $month $day";
 1994+ case '2': return "$day $month $year";
 1995+ case '3': return "$year $month $day";
 1996+ case 'ISO 8601': return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
 1997+ default: return "$month $day, $year";
20041998 }
20051999 }
20062000
@@ -2010,7 +2004,7 @@
20112005 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
20122006
20132007 $t = substr( $ts, 8, 2 ) . ':' . substr( $ts, 10, 2 );
2014 - if ( $seconds || $wgUser->getOption( 'date' ) == 4) {
 2008+ if ( $seconds || $wgUser->getOption( 'date' ) == 'ISO 8601' ) {
20152009 $t .= ':' . substr( $ts, 12, 2 );
20162010 }
20172011 return $this->formatNum( $t );
@@ -2019,11 +2013,11 @@
20202014 function timeanddate( $ts, $adj = false, $format = MW_DATE_USER_FORMAT, $timecorrection = false, $dateandtime = false) {
20212015 global $wgUser;
20222016 $ts=wfTimestamp(TS_MW,$ts);
2023 - if ( 4 == $wgUser->getOption( 'date' ) ) {
2024 - return $this->date( $ts, $adj, $format, $timecorrection ) . ' ' .
 2017+
 2018+ switch ( $wgUser->getOption( 'date' ) ) {
 2019+ case 'ISO 8601': return $this->date( $ts, $adj, $format, $timecorrection ) . ' ' .
20252020 $this->time( $ts, $adj, false, $timecorrection );
2026 - } else {
2027 - return $this->time( $ts, $adj, false, $timecorrection ) . ', ' .
 2021+ default: return $this->time( $ts, $adj, false, $timecorrection ) . ', ' .
20282022 $this->date( $ts, $adj, $format, $timecorrection );
20292023 }
20302024 }
Index: trunk/phase3/languages/LanguageRo.php
@@ -50,9 +50,6 @@
5151
5252 /* private */ $wgDateFormatsRo = array(
5353 "Nici o preferinţă",
54 - "Ianuarie 15, 2001",
55 - "15 Ianuarie 2001",
56 - "2001 Ianuarie 15"
5754 );
5855
5956 /* private */ $wgBookstoreListRo = array(
Index: trunk/phase3/languages/LanguageNv.php
@@ -54,10 +54,6 @@
5555
5656 /* private */ $wgDateFormatsNv = array(
5757 'No preference',
58 - 'Yas Niłt\'ees 15, 2001',
59 - '15 Yas Niłt\'ees 2001',
60 - '2001 Yas Niłt\'ees 15',
61 - '2001-01-15'
6258 );
6359
6460 /* private */ $wgUserTogglesNv = array(
Index: trunk/phase3/languages/LanguageCa.php
@@ -46,10 +46,6 @@
4747
4848 /* private */ $wgDateFormatsCa = array(
4949 "No preference",
50 - "January 15, 2001",
51 - "15 January 2001",
52 - "2001 January 15",
53 - "2001-01-15"
5450 );
5551
5652
Index: trunk/phase3/languages/LanguageGa.php
@@ -63,10 +63,6 @@
6464
6565 /* private */ $wgDateFormatsGa = array(
6666 "Is cuma liom",
67 - "Eanáir 15, 2001",
68 - "15 Eanáir 2001",
69 - "2001 Eanáir 15",
70 - "2001-01-15"
7167 );
7268
7369 # If possible, find Irish language book services on the Internet, searchable by ISBN

Status & tagging log