r60921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60920‎ | r60921 | r60922 >
Date:04:23, 11 January 2010
Author:mah
Status:ok
Tags:
Comment:
trailing whitespace fixup before I fix(??) a bug.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -116,7 +116,7 @@
117117 'hebrew-calendar-m10-gen', 'hebrew-calendar-m11-gen', 'hebrew-calendar-m12-gen',
118118 'hebrew-calendar-m6a-gen', 'hebrew-calendar-m6b-gen'
119119 );
120 -
 120+
121121 static public $mHijriCalendarMonthMsgs = array(
122122 'hijri-calendar-m1', 'hijri-calendar-m2', 'hijri-calendar-m3',
123123 'hijri-calendar-m4', 'hijri-calendar-m5', 'hijri-calendar-m6',
@@ -159,7 +159,7 @@
160160
161161 if ( $recursionLevel > 5 ) {
162162 throw new MWException( "Language fallback loop detected when creating class $class\n" );
163 - }
 163+ }
164164
165165 if( ! class_exists( $class ) ) {
166166 $fallback = Language::getFallbackFor( $code );
@@ -242,7 +242,7 @@
243243 function getNamespaces() {
244244 if ( is_null( $this->namespaceNames ) ) {
245245 global $wgExtraNamespaces, $wgMetaNamespace, $wgMetaNamespaceTalk;
246 -
 246+
247247 $this->namespaceNames = self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
248248 if ( $wgExtraNamespaces ) {
249249 $this->namespaceNames = $wgExtraNamespaces + $this->namespaceNames;
@@ -256,7 +256,7 @@
257257 $this->namespaceNames[NS_PROJECT_TALK] =
258258 $this->fixVariableInNamespace( $talk );
259259 }
260 -
 260+
261261 # The above mixing may leave namespaces out of canonical order.
262262 # Re-order by namespace ID number...
263263 ksort( $this->namespaceNames );
@@ -344,7 +344,7 @@
345345 if ( is_null( $this->mNamespaceIds ) ) {
346346 global $wgNamespaceAliases;
347347 # Put namespace names and aliases into a hashtable.
348 - # If this is too slow, then we should arrange it so that it is done
 348+ # If this is too slow, then we should arrange it so that it is done
349349 # before caching. The catch is that at pre-cache time, the above
350350 # class-specific fixup hasn't been done.
351351 $this->mNamespaceIds = array();
@@ -415,7 +415,7 @@
416416 function getDatePreferences() {
417417 return self::$dataCache->getItem( $this->mCode, 'datePreferences' );
418418 }
419 -
 419+
420420 function getDateFormats() {
421421 return self::$dataCache->getItem( $this->mCode, 'dateFormats' );
422422 }
@@ -460,7 +460,7 @@
461461 if ( !$customisedOnly ) {
462462 return $allNames;
463463 }
464 -
 464+
465465 global $IP;
466466 $names = array();
467467 $dir = opendir( "$IP/languages/messages" );
@@ -523,11 +523,11 @@
524524 function getHebrewCalendarMonthNameGen( $key ) {
525525 return $this->getMessageFromDB( self::$mHebrewCalendarMonthGenMsgs[$key-1] );
526526 }
527 -
 527+
528528 function getHijriCalendarMonthName( $key ) {
529529 return $this->getMessageFromDB( self::$mHijriCalendarMonthMsgs[$key-1] );
530530 }
531 -
 531+
532532 /**
533533 * Used by date() and time() to adjust the time output.
534534 *
@@ -579,7 +579,7 @@
580580
581581 wfSuppressWarnings(); // E_STRICT system time bitching
582582 # Generate an adjusted date; take advantage of the fact that mktime
583 - # will normalize out-of-range values so we don't have to split $minDiff
 583+ # will normalize out-of-range values so we don't have to split $minDiff
584584 # into hours and minutes.
585585 $t = mktime( (
586586 (int)substr( $ts, 8, 2) ), # Hours
@@ -588,19 +588,19 @@
589589 (int)substr( $ts, 4, 2 ), # Month
590590 (int)substr( $ts, 6, 2 ), # Day
591591 (int)substr( $ts, 0, 4 ) ); #Year
592 -
 592+
593593 $date = date( 'YmdHis', $t );
594594 wfRestoreWarnings();
595 -
 595+
596596 return $date;
597597 }
598598
599599 /**
600600 * This is a workalike of PHP's date() function, but with better
601 - * internationalisation, a reduced set of format characters, and a better
 601+ * internationalisation, a reduced set of format characters, and a better
602602 * escaping format.
603603 *
604 - * Supported format characters are dDjlNwzWFmMntLoYyaAgGhHiscrU. See the
 604+ * Supported format characters are dDjlNwzWFmMntLoYyaAgGhHiscrU. See the
605605 * PHP manual for definitions. "o" format character is supported since
606606 * PHP 5.1.0, previous versions return literal o.
607607 * There are a number of extensions, which start with "x":
@@ -648,7 +648,7 @@
649649 *
650650 * Input timestamp is assumed to be pre-normalized to the desired local
651651 * time zone, if any.
652 - *
 652+ *
653653 * @param $format String
654654 * @param $ts String: 14-character timestamp
655655 * YYYYMMDDHHMMSS
@@ -850,7 +850,7 @@
851851 case 'h':
852852 $h = substr( $ts, 8, 2 );
853853 $num = sprintf( '%02d', $h % 12 ? $h % 12 : 12 );
854 - break;
 854+ break;
855855 case 'H':
856856 $num = substr( $ts, 8, 2 );
857857 break;
@@ -921,11 +921,11 @@
922922 private static $GREG_DAYS = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
923923 private static $IRANIAN_DAYS = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 );
924924 /**
925 - * Algorithm by Roozbeh Pournader and Mohammad Toossi to convert
 925+ * Algorithm by Roozbeh Pournader and Mohammad Toossi to convert
926926 * Gregorian dates to Iranian dates. Originally written in C, it
927927 * is released under the terms of GNU Lesser General Public
928928 * License. Conversion to PHP was performed by Niklas Laxström.
929 - *
 929+ *
930930 * Link: http://www.farsiweb.info/jalali/jalali.c
931931 */
932932 private static function tsToIranian( $ts ) {
@@ -952,7 +952,7 @@
953953
954954 // Days passed in current month
955955 $gDayNo += $gd;
956 -
 956+
957957 $jDayNo = $gDayNo - 79;
958958
959959 $jNp = floor($jDayNo / 12053);
@@ -986,7 +986,7 @@
987987 $year = substr( $ts, 0, 4 );
988988 $month = substr( $ts, 4, 2 );
989989 $day = substr( $ts, 6, 2 );
990 -
 990+
991991 $zyr = $year;
992992 $zd=$day;
993993 $zm=$month;
@@ -996,15 +996,15 @@
997997
998998 if (($zy>1582)||(($zy==1582)&&($zm>10))||(($zy==1582)&&($zm==10)&&($zd>14)))
999999 {
1000 -
1001 -
 1000+
 1001+
10021002 $zjd=(int)((1461*($zy + 4800 + (int)( ($zm-14) /12) ))/4) + (int)((367*($zm-2-12*((int)(($zm-14)/12))))/12)-(int)((3*(int)(( ($zy+4900+(int)(($zm-14)/12))/100)))/4)+$zd-32075;
10031003 }
10041004 else
10051005 {
10061006 $zjd = 367*$zy-(int)((7*($zy+5001+(int)(($zm-9)/7)))/4)+(int)((275*$zm)/9)+$zd+1729777;
10071007 }
1008 -
 1008+
10091009 $zl=$zjd-1948440+10632;
10101010 $zn=(int)(($zl-1)/10631);
10111011 $zl=$zl-10631*$zn+354;
@@ -1268,7 +1268,7 @@
12691269 array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ),
12701270 array( '', 'M', 'MM', 'MMM' )
12711271 );
1272 -
 1272+
12731273 $num = intval( $num );
12741274 if ( $num > 3000 || $num <= 0 ) {
12751275 return $num;
@@ -1378,7 +1378,7 @@
13791379 if( $datePreference == '' ) {
13801380 return 'default';
13811381 }
1382 -
 1382+
13831383 return $datePreference;
13841384 }
13851385
@@ -1415,8 +1415,8 @@
14161416 * @return string
14171417 */
14181418 function date( $ts, $adj = false, $format = true, $timecorrection = false ) {
1419 - if ( $adj ) {
1420 - $ts = $this->userAdjust( $ts, $timecorrection );
 1419+ if ( $adj ) {
 1420+ $ts = $this->userAdjust( $ts, $timecorrection );
14211421 }
14221422 $df = $this->getDateFormatString( 'date', $this->dateFormat( $format ) );
14231423 return $this->sprintfDate( $df, $ts );
@@ -1433,8 +1433,8 @@
14341434 * @return string
14351435 */
14361436 function time( $ts, $adj = false, $format = true, $timecorrection = false ) {
1437 - if ( $adj ) {
1438 - $ts = $this->userAdjust( $ts, $timecorrection );
 1437+ if ( $adj ) {
 1438+ $ts = $this->userAdjust( $ts, $timecorrection );
14391439 }
14401440 $df = $this->getDateFormatString( 'time', $this->dateFormat( $format ) );
14411441 return $this->sprintfDate( $df, $ts );
@@ -1453,8 +1453,8 @@
14541454 */
14551455 function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
14561456 $ts = wfTimestamp( TS_MW, $ts );
1457 - if ( $adj ) {
1458 - $ts = $this->userAdjust( $ts, $timecorrection );
 1457+ if ( $adj ) {
 1458+ $ts = $this->userAdjust( $ts, $timecorrection );
14591459 }
14601460 $df = $this->getDateFormatString( 'both', $this->dateFormat( $format ) );
14611461 return $this->sprintfDate( $df, $ts );
@@ -1486,25 +1486,25 @@
14871487 function ucwordbreaksCallbackAscii($matches){
14881488 return $this->ucfirst($matches[1]);
14891489 }
1490 -
 1490+
14911491 function ucwordbreaksCallbackMB($matches){
14921492 return mb_strtoupper($matches[0]);
14931493 }
1494 -
 1494+
14951495 function ucCallback($matches){
14961496 list( $wikiUpperChars ) = self::getCaseMaps();
14971497 return strtr( $matches[1], $wikiUpperChars );
14981498 }
1499 -
 1499+
15001500 function lcCallback($matches){
15011501 list( , $wikiLowerChars ) = self::getCaseMaps();
15021502 return strtr( $matches[1], $wikiLowerChars );
15031503 }
1504 -
 1504+
15051505 function ucwordsCallbackMB($matches){
15061506 return mb_strtoupper($matches[0]);
15071507 }
1508 -
 1508+
15091509 function ucwordsCallbackWiki($matches){
15101510 list( $wikiUpperChars ) = self::getCaseMaps();
15111511 return strtr( $matches[0], $wikiUpperChars );
@@ -1518,7 +1518,7 @@
15191519 return ucfirst($str);
15201520 } else {
15211521 // fall back to more complex logic in case of multibyte strings
1522 - return self::uc($str,true);
 1522+ return self::uc($str,true);
15231523 }
15241524 }
15251525
@@ -1547,7 +1547,7 @@
15481548 }
15491549 }
15501550 }
1551 -
 1551+
15521552 function lcfirst( $str ) {
15531553 $o = ord( $str );
15541554 if ( !$o ) {
@@ -1602,7 +1602,7 @@
16031603 array($this,"ucwordsCallbackMB"),
16041604 $str
16051605 );
1606 - else
 1606+ else
16071607 return preg_replace_callback(
16081608 $replaceRegexp,
16091609 array($this,"ucwordsCallbackWiki"),
@@ -1630,7 +1630,7 @@
16311631 array($this,"ucwordbreaksCallbackMB"),
16321632 $str
16331633 );
1634 - else
 1634+ else
16351635 return preg_replace_callback(
16361636 $replaceRegexp,
16371637 array($this,"ucwordsCallbackWiki"),
@@ -1647,7 +1647,7 @@
16481648 /**
16491649 * Return a case-folded representation of $s
16501650 *
1651 - * This is a representation such that caseFold($s1)==caseFold($s2) if $s1
 1651+ * This is a representation such that caseFold($s1)==caseFold($s2) if $s1
16521652 * and $s2 are the same except for the case of their characters. It is not
16531653 * necessary for the value returned to make sense when displayed.
16541654 *
@@ -1677,7 +1677,7 @@
16781678 function fallback8bitEncoding() {
16791679 return self::$dataCache->getItem( $this->mCode, 'fallback8bitEncoding' );
16801680 }
1681 -
 1681+
16821682 /**
16831683 * Most writing systems use whitespace to break up words.
16841684 * Some languages such as Chinese don't conventionally do this,
@@ -1687,7 +1687,7 @@
16881688 function hasWordBreaks() {
16891689 return true;
16901690 }
1691 -
 1691+
16921692 /**
16931693 * Some languages have special punctuation to strip out
16941694 * or characters which need to be converted for MySQL's
@@ -1703,14 +1703,14 @@
17041704 }
17051705
17061706 wfProfileIn( __METHOD__ );
1707 -
 1707+
17081708 // MySQL fulltext index doesn't grok utf-8, so we
17091709 // need to fold cases and convert to hex
17101710 $out = preg_replace_callback(
17111711 "/([\\xc0-\\xff][\\x80-\\xbf]*)/",
17121712 array( $this, 'stripForSearchCallback' ),
17131713 $this->lc( $string ) );
1714 -
 1714+
17151715 // And to add insult to injury, the default indexing
17161716 // ignores short words... Pad them so we can pass them
17171717 // through without reconfiguring the server...
@@ -1722,7 +1722,7 @@
17231723 "$1u800",
17241724 $out );
17251725 }
1726 -
 1726+
17271727 // Periods within things like hostnames and IP addresses
17281728 // are also important -- we want a search for "example.com"
17291729 // or "192.168.1.1" to work sanely.
@@ -1733,11 +1733,11 @@
17341734 "/(\w)\.(\w|\*)/u",
17351735 "$1u82e$2",
17361736 $out );
1737 -
 1737+
17381738 wfProfileOut( __METHOD__ );
17391739 return $out;
17401740 }
1741 -
 1741+
17421742 /**
17431743 * Armor a case-folded UTF-8 string to get through MySQL's
17441744 * fulltext search without being mucked up by funny charset
@@ -1746,7 +1746,7 @@
17471747 protected function stripForSearchCallback( $matches ) {
17481748 return 'u8' . bin2hex( $matches[1] );
17491749 }
1750 -
 1750+
17511751 /**
17521752 * Check MySQL server's ft_min_word_len setting so we know
17531753 * if we need to pad short words...
@@ -1758,7 +1758,7 @@
17591759 $result = $dbr->query( $sql );
17601760 $row = $result->fetchObject();
17611761 $result->free();
1762 -
 1762+
17631763 if( $row && $row->Variable_name == 'ft_min_word_len' ) {
17641764 $this->minSearchLength = intval( $row->Value );
17651765 } else {
@@ -1791,7 +1791,7 @@
17921792 }
17931793
17941794 /**
1795 - * Get the first character of a string.
 1795+ * Get the first character of a string.
17961796 *
17971797 * @param $s string
17981798 * @return string
@@ -1805,7 +1805,7 @@
18061806 if ( strlen( $matches[1] ) != 3 ) {
18071807 return $matches[1];
18081808 }
1809 -
 1809+
18101810 // Break down Hangul syllables to grab the first jamo
18111811 $code = utf8ToCodepoint( $matches[1] );
18121812 if ( $code < 0xac00 || 0xd7a4 <= $code) {
@@ -1884,7 +1884,7 @@
18851885
18861886 /**
18871887 * Convert a UTF-8 string to normal form C. In Malayalam and Arabic, this
1888 - * also cleans up certain backwards-compatible sequences, converting them
 1888+ * also cleans up certain backwards-compatible sequences, converting them
18891889 * to the modern Unicode equivalent.
18901890 *
18911891 * This is language-specific for performance reasons only.
@@ -1896,9 +1896,9 @@
18971897 /**
18981898 * Transform a string using serialized data stored in the given file (which
18991899 * must be in the serialized subdirectory of $IP). The file contains pairs
1900 - * mapping source characters to destination characters.
 1900+ * mapping source characters to destination characters.
19011901 *
1902 - * The data is cached in process memory. This will go faster if you have the
 1902+ * The data is cached in process memory. This will go faster if you have the
19031903 * FastStringSearch extension.
19041904 */
19051905 function transformUsingPairFile( $file, $string ) {
@@ -1917,10 +1917,10 @@
19181918 *
19191919 * @return bool
19201920 */
1921 - function isRTL() {
 1921+ function isRTL() {
19221922 return self::$dataCache->getItem( $this->mCode, 'rtl' );
19231923 }
1924 -
 1924+
19251925 /**
19261926 * Return the correct HTML 'dir' attribute value for this language.
19271927 * @return String
@@ -1928,7 +1928,7 @@
19291929 function getDir() {
19301930 return $this->isRTL() ? 'rtl' : 'ltr';
19311931 }
1932 -
 1932+
19331933 /**
19341934 * Return 'left' or 'right' as appropriate alignment for line-start
19351935 * for this language's text direction.
@@ -1940,7 +1940,7 @@
19411941 function alignStart() {
19421942 return $this->isRTL() ? 'right' : 'left';
19431943 }
1944 -
 1944+
19451945 /**
19461946 * Return 'right' or 'left' as appropriate alignment for line-end
19471947 * for this language's text direction.
@@ -2044,7 +2044,7 @@
20452045 // Cache aliases because it may be slow to load them
20462046 if ( is_null( $this->mExtendedSpecialPageAliases ) ) {
20472047 // Initialise array
2048 - $this->mExtendedSpecialPageAliases =
 2048+ $this->mExtendedSpecialPageAliases =
20492049 self::$dataCache->getItem( $this->mCode, 'specialPageAliases' );
20502050 wfRunHooks( 'LanguageGetSpecialPageAliases',
20512051 array( &$this->mExtendedSpecialPageAliases, $this->getCode() ) );
@@ -2205,7 +2205,7 @@
22062206 * are included, otherwise broken characters can be passed to the user
22072207 *
22082208 * If $length is negative, the string will be truncated from the beginning
2209 - *
 2209+ *
22102210 * @param $string String to truncate
22112211 * @param $length Int: maximum length (excluding ellipses)
22122212 * @param $ellipsis String to append to the truncated text
@@ -2380,7 +2380,7 @@
23812381 }
23822382
23832383 # Put custom tags (e.g. -{ }-) around math to prevent conversion
2384 - function armourMath($text){
 2384+ function armourMath($text){
23852385 return $this->mConverter->armourMath($text);
23862386 }
23872387
@@ -2509,7 +2509,7 @@
25102510 static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) {
25112511 return $prefix . str_replace( '-', '_', ucfirst( $code ) ) . $suffix;
25122512 }
2513 -
 2513+
25142514 /**
25152515 * Get the language code from a file name. Inverse of getFileName()
25162516 * @param $filename string $prefix . $languageCode . $suffix
@@ -2536,7 +2536,7 @@
25372537 global $IP;
25382538 return self::getFileName( "$IP/languages/classes/Language", $code, '.php' );
25392539 }
2540 -
 2540+
25412541 /**
25422542 * Get the fallback for a given language
25432543 */
@@ -2549,7 +2549,7 @@
25502550 }
25512551 }
25522552
2553 - /**
 2553+ /**
25542554 * Get all messages for a given language
25552555 * WARNING: this may take a long time
25562556 */
@@ -2557,7 +2557,7 @@
25582558 return self::getLocalisationCache()->getItem( $code, 'messages' );
25592559 }
25602560
2561 - /**
 2561+ /**
25622562 * Get a message for a given language
25632563 */
25642564 static function getMessageFor( $key, $code ) {
@@ -2571,10 +2571,10 @@
25722572 $talk = str_replace( '$1', $wgMetaNamespace, $talk );
25732573
25742574 # Allow grammar transformations
2575 - # Allowing full message-style parsing would make simple requests
2576 - # such as action=raw much more expensive than they need to be.
 2575+ # Allowing full message-style parsing would make simple requests
 2576+ # such as action=raw much more expensive than they need to be.
25772577 # This will hopefully cover most cases.
2578 - $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
 2578+ $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
25792579 array( &$this, 'replaceGrammarInNamespace' ), $talk );
25802580 return str_replace( ' ', '_', $talk );
25812581 }
@@ -2592,7 +2592,7 @@
25932593 wfProfileIn( __METHOD__ );
25942594 $arr = wfGetPrecompiledData( 'Utf8Case.ser' );
25952595 if ( $arr === false ) {
2596 - throw new MWException(
 2596+ throw new MWException(
25972597 "Utf8Case.ser is missing, please run \"make\" in the serialized directory\n" );
25982598 }
25992599 extract( $arr );
@@ -2606,13 +2606,13 @@
26072607 } elseif ( $seconds < 60 ) {
26082608 return $this->formatNum( round( $seconds ) ) . wfMsg( 'seconds-abbrev' );
26092609 } elseif ( $seconds < 3600 ) {
2610 - return $this->formatNum( floor( $seconds / 60 ) ) . wfMsg( 'minutes-abbrev' ) .
 2610+ return $this->formatNum( floor( $seconds / 60 ) ) . wfMsg( 'minutes-abbrev' ) .
26112611 $this->formatNum( round( fmod( $seconds, 60 ) ) ) . wfMsg( 'seconds-abbrev' );
26122612 } else {
26132613 $hours = floor( $seconds / 3600 );
26142614 $minutes = floor( ( $seconds - $hours * 3600 ) / 60 );
26152615 $secondsPart = round( $seconds - $hours * 3600 - $minutes * 60 );
2616 - return $this->formatNum( $hours ) . wfMsg( 'hours-abbrev' ) .
 2616+ return $this->formatNum( $hours ) . wfMsg( 'hours-abbrev' ) .
26172617 $this->formatNum( $minutes ) . wfMsg( 'minutes-abbrev' ) .
26182618 $this->formatNum( $secondsPart ) . wfMsg( 'seconds-abbrev' );
26192619 }

Status & tagging log