| Index: trunk/phase3/languages/Language.php |
| — | — | @@ -25,7 +25,8 @@ |
| 26 | 26 | "contextlines" => 5, "contextchars" => 50, |
| 27 | 27 | "skin" => 0, "math" => 1, "rcdays" => 7, "rclimit" => 50, |
| 28 | 28 | "highlightbroken" => 1, "stubthreshold" => 0, |
| 29 | | - "previewontop" => 1, "editsection"=>1, "showtoc"=>1 |
| | 29 | + "previewontop" => 1, "editsection"=>1, "showtoc"=>1, |
| | 30 | + "date" => 0 |
| 30 | 31 | ); |
| 31 | 32 | |
| 32 | 33 | /* private */ $wgQuickbarSettingsEn = array( |
| — | — | @@ -1225,8 +1226,8 @@ |
| 1226 | 1227 | |
| 1227 | 1228 | if ( $adj ) { $ts = $this->userAdjust( $ts ); } |
| 1228 | 1229 | |
| 1229 | | - $datePreference = $wgUser->getOption('date'); |
| 1230 | | - if ( $datePrefernce == 0 ) { |
| | 1230 | + $datePreference = $wgUser->getOption( 'date' ); |
| | 1231 | + if ( $datePreference == 0 ) { |
| 1231 | 1232 | $datePreference = $wgAmericanDates ? 1 : 2; |
| 1232 | 1233 | } |
| 1233 | 1234 | |
| — | — | @@ -1259,7 +1260,7 @@ |
| 1260 | 1261 | |
| 1261 | 1262 | function timeanddate( $ts, $adj = false ) |
| 1262 | 1263 | { |
| 1263 | | - return $this->time( $ts, $adj ) . " " . $this->date( $ts, $adj ); |
| | 1264 | + return $this->time( $ts, $adj ) . ", " . $this->date( $ts, $adj ); |
| 1264 | 1265 | } |
| 1265 | 1266 | |
| 1266 | 1267 | function rfc1123( $ts ) |
| — | — | @@ -1370,55 +1371,69 @@ |
| 1371 | 1372 | |
| 1372 | 1373 | function replaceDates( $text ) |
| 1373 | 1374 | { |
| 1374 | | - global $wgUser; |
| | 1375 | + global $wgUser, $wgInputEncoding; |
| 1375 | 1376 | |
| 1376 | 1377 | # Setup |
| 1377 | 1378 | |
| 1378 | | - $datePreference = $wgUser->getOption('date'); |
| | 1379 | + $datePreference = $wgUser->getOption( 'date' ); |
| | 1380 | + |
| 1379 | 1381 | static $monthNames = "", $rxDM, $rxMD, $rxY, $rxDMY, $rxYMD, $rxMDY, $rxYMD; |
| 1380 | 1382 | if ( $monthNames == "" ) { |
| 1381 | 1383 | $monthNames = $this->getMonthRegex(); |
| 1382 | | - $rxDM = '\[\[(\d{1,2})[ _](' . $monthNames . ')]](?![a-z])'; |
| 1383 | | - $rxMD = '\[\[(' . $monthNames . ')[ _](\d{1,2})]](?![a-z])'; |
| 1384 | | - $rxY = '\[\[(\d{1,4}([ _]BC|))]](?![a-z])'; |
| 1385 | 1384 | |
| 1386 | | - $rxDMY = "/{$rxDM} *, *{$rxY}/i"; |
| 1387 | | - $rxYDM = "/{$rxY} *, *{$rxDM}/i"; |
| 1388 | | - $rxMDY = "/{$rxMD} *, *{$rxY}/i"; |
| 1389 | | - $rxYMD = "/{$rxY} *, *{$rxMD}/i"; |
| | 1385 | + # Attempt at UTF-8 support, untested at the moment |
| | 1386 | + if ( $wgInputEncoding == 'UTF-8' ) { |
| | 1387 | + $regexTrail = '(?![a-z])/iu'; |
| | 1388 | + } else { |
| | 1389 | + $regexTrail = '(?![a-z])/i'; |
| | 1390 | + } |
| | 1391 | + |
| | 1392 | + # Partial regular expressions |
| | 1393 | + $prxDM = '\[\[(\d{1,2})[ _](' . $monthNames . ')]]'; |
| | 1394 | + $prxMD = '\[\[(' . $monthNames . ')[ _](\d{1,2})]]'; |
| | 1395 | + $prxY = '\[\[(\d{1,4}([ _]BC|))]]'; |
| | 1396 | + |
| | 1397 | + # Real regular expressions |
| | 1398 | + $rxDMY = "/{$prxDM} *,? *{$prxY}{$regexTrail}"; |
| | 1399 | + $rxYDM = "/{$prxY} *,? *{$prxDM}{$regexTrail}"; |
| | 1400 | + $rxMDY = "/{$prxMD} *,? *{$prxY}{$regexTrail}"; |
| | 1401 | + $rxYMD = "/{$prxY} *,? *{$prxMD}{$regexTrail}"; |
| | 1402 | + $rxDM = "/{$prxDM}{$regexTrail}"; |
| | 1403 | + $rxMD = "/{$prxMD}{$regexTrail}"; |
| | 1404 | + $rxY = "/{$prxY}{$regexTrail}"; |
| 1390 | 1405 | } |
| 1391 | 1406 | |
| 1392 | 1407 | # Do replacements |
| 1393 | 1408 | # TODO: month capitalisation? |
| 1394 | 1409 | if ( $datePreference == 0 ) { |
| 1395 | 1410 | # no preference |
| 1396 | | - $text = preg_replace( $rxDMY, '[[$2 $1|$1 $2]], [[$3]]', $text); |
| | 1411 | + $text = preg_replace( $rxDMY, '[[$2 $1|$1 $2]] [[$3]]', $text); |
| 1397 | 1412 | $text = preg_replace( $rxYDM, '[[$1]] [[$4 $3]]', $text); |
| 1398 | 1413 | $text = preg_replace( $rxMDY, '[[$1 $2]], [[$3]]', $text); |
| 1399 | 1414 | $text = preg_replace( $rxYMD, '[[$1]] [[$3 $4]]', $text); |
| 1400 | | - $text = preg_replace ( "/$rxDM/i", '[[$2 $1|$1 $2]]', $text); |
| | 1415 | + $text = preg_replace ( $rxDM, '[[$2 $1|$1 $2]]', $text); |
| 1401 | 1416 | } else if ( $datePreference == 1 ) { |
| 1402 | 1417 | # MDY preferred |
| 1403 | 1418 | $text = preg_replace( $rxDMY, '[[$2 $1]], [[$3]]', $text); |
| 1404 | 1419 | $text = preg_replace( $rxYDM, '[[$4 $3]], [[$1]]', $text); |
| 1405 | 1420 | $text = preg_replace( $rxMDY, '[[$1 $2]], [[$3]]', $text); |
| 1406 | 1421 | $text = preg_replace( $rxYMD, '[[$3 $4]], [[$1]]', $text); |
| 1407 | | - $text = preg_replace ( "/$rxDM/i", '[[$2 $1]]', $text); |
| | 1422 | + $text = preg_replace ( $rxDM, '[[$2 $1]]', $text); |
| 1408 | 1423 | } else if ( $datePreference == 2 ) { |
| 1409 | 1424 | # DMY preferred |
| 1410 | | - $text = preg_replace( $rxDMY, '[[$2 $1|$1 $2]], [[$3]]', $text); |
| 1411 | | - $text = preg_replace( $rxYDM, '[[$4 $3|$3 $4]], [[$1]]', $text); |
| 1412 | | - $text = preg_replace( $rxMDY, '[[$1 $2|$2 $1]], [[$3]]', $text); |
| 1413 | | - $text = preg_replace( $rxYMD, '[[$3 $4|$4 $3]], [[$1]]', $text); |
| 1414 | | - $text = preg_replace ( "/$rxDM/i", '[[$2 $1|$1 $2]]', $text); |
| 1415 | | - $text = preg_replace ( "/$rxMD/i", '[[$1 $2|$2 $1]]', $text); |
| | 1425 | + $text = preg_replace( $rxDMY, '[[$2 $1|$1 $2]] [[$3]]', $text); |
| | 1426 | + $text = preg_replace( $rxYDM, '[[$4 $3|$3 $4]] [[$1]]', $text); |
| | 1427 | + $text = preg_replace( $rxMDY, '[[$1 $2|$2 $1]] [[$3]]', $text); |
| | 1428 | + $text = preg_replace( $rxYMD, '[[$3 $4|$4 $3]] [[$1]]', $text); |
| | 1429 | + $text = preg_replace ( $rxDM, '[[$2 $1|$1 $2]]', $text); |
| | 1430 | + $text = preg_replace ( $rxMD, '[[$1 $2|$2 $1]]', $text); |
| 1416 | 1431 | } else if ( $datePreference == 3 ) { |
| 1417 | 1432 | # YMD preferred |
| 1418 | 1433 | $text = preg_replace( $rxDMY, '[[$3]] [[$2 $1]]', $text); |
| 1419 | 1434 | $text = preg_replace( $rxYDM, '[[$1]] [[$4 $3]]', $text); |
| 1420 | 1435 | $text = preg_replace( $rxMDY, '[[$3]] [[$1 $2]]', $text); |
| 1421 | 1436 | $text = preg_replace( $rxYMD, '[[$1]] [[$3 $4]]', $text); |
| 1422 | | - $text = preg_replace ( "/$rxDM/i", '[[$2 $1]]', $text); |
| | 1437 | + $text = preg_replace ( $rxDM, '[[$2 $1]]', $text); |
| 1423 | 1438 | } |
| 1424 | 1439 | return $text; |
| 1425 | 1440 | } |