r64755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64754‎ | r64755 | r64756 >
Date:20:19, 8 April 2010
Author:ashley
Status:ok
Tags:
Comment:
coding style tweaks (spacing, braces, etc.) to Language.php
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -13,18 +13,18 @@
1414
1515 # Read language names
1616 global $wgLanguageNames;
17 -require_once( dirname(__FILE__) . '/Names.php' ) ;
 17+require_once( dirname( __FILE__ ) . '/Names.php' );
1818
1919 global $wgInputEncoding, $wgOutputEncoding;
2020
2121 /**
2222 * These are always UTF-8, they exist only for backwards compatibility
2323 */
24 -$wgInputEncoding = "UTF-8";
25 -$wgOutputEncoding = "UTF-8";
 24+$wgInputEncoding = 'UTF-8';
 25+$wgOutputEncoding = 'UTF-8';
2626
2727 if( function_exists( 'mb_strtoupper' ) ) {
28 - mb_internal_encoding('UTF-8');
 28+ mb_internal_encoding( 'UTF-8' );
2929 }
3030
3131 /**
@@ -34,19 +34,19 @@
3535 */
3636 class FakeConverter {
3737 var $mLang;
38 - function FakeConverter($langobj) {$this->mLang = $langobj;}
39 - function autoConvertToAllVariants($text) {return $text;}
40 - function convert($t, $i) {return $t;}
 38+ function FakeConverter( $langobj ) { $this->mLang = $langobj; }
 39+ function autoConvertToAllVariants( $text ) { return $text; }
 40+ function convert( $t, $i ) { return $t; }
4141 function getVariants() { return array( $this->mLang->getCode() ); }
4242 function getPreferredVariant() { return $this->mLang->getCode(); }
4343 function getConvRuleTitle() { return false; }
44 - function findVariantLink(&$l, &$n, $ignoreOtherCond = false) {}
45 - function getExtraHashOptions() {return '';}
46 - function getParsedTitle() {return '';}
47 - function markNoConversion($text, $noParse=false) {return $text;}
48 - function convertCategoryKey( $key ) {return $key; }
49 - function convertLinkToAllVariants($text){ return array( $this->mLang->getCode() => $text); }
50 - function armourMath($text){ return $text; }
 44+ function findVariantLink( &$l, &$n, $ignoreOtherCond = false ) {}
 45+ function getExtraHashOptions() { return ''; }
 46+ function getParsedTitle() { return ''; }
 47+ function markNoConversion( $text, $noParse = false ) { return $text; }
 48+ function convertCategoryKey( $key ) { return $key; }
 49+ function convertLinkToAllVariants( $text ) { return array( $this->mLang->getCode() => $text ); }
 50+ function armourMath( $text ) { return $text; }
5151 }
5252
5353 /**
@@ -149,10 +149,10 @@
150150 $class = 'Language' . str_replace( '-', '_', ucfirst( $code ) );
151151 // Preload base classes to work around APC/PHP5 bug
152152 if ( file_exists( "$IP/languages/classes/$class.deps.php" ) ) {
153 - include_once("$IP/languages/classes/$class.deps.php");
 153+ include_once( "$IP/languages/classes/$class.deps.php" );
154154 }
155155 if ( file_exists( "$IP/languages/classes/$class.php" ) ) {
156 - include_once("$IP/languages/classes/$class.php");
 156+ include_once( "$IP/languages/classes/$class.php" );
157157 }
158158 }
159159
@@ -160,7 +160,7 @@
161161 throw new MWException( "Language fallback loop detected when creating class $class\n" );
162162 }
163163
164 - if( ! class_exists( $class ) ) {
 164+ if( !class_exists( $class ) ) {
165165 $fallback = Language::getFallbackFor( $code );
166166 ++$recursionLevel;
167167 $lang = Language::newFromCode( $fallback );
@@ -185,7 +185,7 @@
186186 }
187187
188188 function __construct() {
189 - $this->mConverter = new FakeConverter($this);
 189+ $this->mConverter = new FakeConverter( $this );
190190 // Set the code to the name of the descendant
191191 if ( get_class( $this ) == 'Language' ) {
192192 $this->mCode = 'en';
@@ -273,8 +273,8 @@
274274 */
275275 function getFormattedNamespaces() {
276276 $ns = $this->getNamespaces();
277 - foreach($ns as $k => $v) {
278 - $ns[$k] = strtr($v, '_', ' ');
 277+ foreach( $ns as $k => $v ) {
 278+ $ns[$k] = strtr( $v, '_', ' ' );
279279 }
280280 return $ns;
281281 }
@@ -303,7 +303,7 @@
304304 */
305305 function getFormattedNsText( $index ) {
306306 $ns = $this->getNsText( $index );
307 - return strtr($ns, '_', ' ');
 307+ return strtr( $ns, '_', ' ' );
308308 }
309309
310310 /**
@@ -315,7 +315,7 @@
316316 * @return mixed An integer if $text is a valid value otherwise false
317317 */
318318 function getLocalNsIndex( $text ) {
319 - $lctext = $this->lc($text);
 319+ $lctext = $this->lc( $text );
320320 $ids = $this->getNamespaceIds();
321321 return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
322322 }
@@ -348,14 +348,14 @@
349349 # class-specific fixup hasn't been done.
350350 $this->mNamespaceIds = array();
351351 foreach ( $this->getNamespaces() as $index => $name ) {
352 - $this->mNamespaceIds[$this->lc($name)] = $index;
 352+ $this->mNamespaceIds[$this->lc( $name )] = $index;
353353 }
354354 foreach ( $this->getNamespaceAliases() as $name => $index ) {
355 - $this->mNamespaceIds[$this->lc($name)] = $index;
 355+ $this->mNamespaceIds[$this->lc( $name )] = $index;
356356 }
357357 if ( $wgNamespaceAliases ) {
358358 foreach ( $wgNamespaceAliases as $name => $index ) {
359 - $this->mNamespaceIds[$this->lc($name)] = $index;
 359+ $this->mNamespaceIds[$this->lc( $name )] = $index;
360360 }
361361 }
362362 }
@@ -371,7 +371,7 @@
372372 * @return mixed An integer if $text is a valid value otherwise false
373373 */
374374 function getNsIndex( $text ) {
375 - $lctext = $this->lc($text);
 375+ $lctext = $this->lc( $text );
376376 if ( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) {
377377 return $ns;
378378 }
@@ -492,39 +492,39 @@
493493 }
494494
495495 function getMonthName( $key ) {
496 - return $this->getMessageFromDB( self::$mMonthMsgs[$key-1] );
 496+ return $this->getMessageFromDB( self::$mMonthMsgs[$key - 1] );
497497 }
498498
499499 function getMonthNameGen( $key ) {
500 - return $this->getMessageFromDB( self::$mMonthGenMsgs[$key-1] );
 500+ return $this->getMessageFromDB( self::$mMonthGenMsgs[$key - 1] );
501501 }
502502
503503 function getMonthAbbreviation( $key ) {
504 - return $this->getMessageFromDB( self::$mMonthAbbrevMsgs[$key-1] );
 504+ return $this->getMessageFromDB( self::$mMonthAbbrevMsgs[$key - 1] );
505505 }
506506
507507 function getWeekdayName( $key ) {
508 - return $this->getMessageFromDB( self::$mWeekdayMsgs[$key-1] );
 508+ return $this->getMessageFromDB( self::$mWeekdayMsgs[$key - 1] );
509509 }
510510
511511 function getWeekdayAbbreviation( $key ) {
512 - return $this->getMessageFromDB( self::$mWeekdayAbbrevMsgs[$key-1] );
 512+ return $this->getMessageFromDB( self::$mWeekdayAbbrevMsgs[$key - 1] );
513513 }
514514
515515 function getIranianCalendarMonthName( $key ) {
516 - return $this->getMessageFromDB( self::$mIranianCalendarMonthMsgs[$key-1] );
 516+ return $this->getMessageFromDB( self::$mIranianCalendarMonthMsgs[$key - 1] );
517517 }
518518
519519 function getHebrewCalendarMonthName( $key ) {
520 - return $this->getMessageFromDB( self::$mHebrewCalendarMonthMsgs[$key-1] );
 520+ return $this->getMessageFromDB( self::$mHebrewCalendarMonthMsgs[$key - 1] );
521521 }
522522
523523 function getHebrewCalendarMonthNameGen( $key ) {
524 - return $this->getMessageFromDB( self::$mHebrewCalendarMonthGenMsgs[$key-1] );
 524+ return $this->getMessageFromDB( self::$mHebrewCalendarMonthGenMsgs[$key - 1] );
525525 }
526526
527527 function getHijriCalendarMonthName( $key ) {
528 - return $this->getMessageFromDB( self::$mHijriCalendarMonthMsgs[$key-1] );
 528+ return $this->getMessageFromDB( self::$mHijriCalendarMonthMsgs[$key - 1] );
529529 }
530530
531531 /**
@@ -558,7 +558,9 @@
559559 $minDiff = 0;
560560 if ( $data[0] == 'System' || $tz == '' ) {
561561 # Global offset in minutes.
562 - if( isset($wgLocalTZoffset) ) $minDiff = $wgLocalTZoffset;
 562+ if( isset( $wgLocalTZoffset ) ) {
 563+ $minDiff = $wgLocalTZoffset;
 564+ }
563565 } else if ( $data[0] == 'Offset' ) {
564566 $minDiff = intval( $data[1] );
565567 } else {
@@ -567,14 +569,18 @@
568570 $data[0] = intval( $data[0] );
569571 $data[1] = intval( $data[1] );
570572 $minDiff = abs( $data[0] ) * 60 + $data[1];
571 - if ( $data[0] < 0 ) $minDiff = -$minDiff;
 573+ if ( $data[0] < 0 ) {
 574+ $minDiff = -$minDiff;
 575+ }
572576 } else {
573577 $minDiff = intval( $data[0] ) * 60;
574578 }
575579 }
576580
577581 # No difference ? Return time unchanged
578 - if ( 0 == $minDiff ) return $ts;
 582+ if ( 0 == $minDiff ) {
 583+ return $ts;
 584+ }
579585
580586 wfSuppressWarnings(); // E_STRICT system time bitching
581587 # Generate an adjusted date; take advantage of the fact that mktime
@@ -713,51 +719,73 @@
714720 $num = intval( substr( $ts, 6, 2 ) );
715721 break;
716722 case 'xij':
717 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 723+ if ( !$iranian ) {
 724+ $iranian = self::tsToIranian( $ts );
 725+ }
718726 $num = $iranian[2];
719727 break;
720728 case 'xmj':
721 - if ( !$hijri ) $hijri = self::tsToHijri( $ts );
 729+ if ( !$hijri ) {
 730+ $hijri = self::tsToHijri( $ts );
 731+ }
722732 $num = $hijri[2];
723733 break;
724734 case 'xjj':
725 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 735+ if ( !$hebrew ) {
 736+ $hebrew = self::tsToHebrew( $ts );
 737+ }
726738 $num = $hebrew[2];
727739 break;
728740 case 'l':
729 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 741+ if ( !$unix ) {
 742+ $unix = wfTimestamp( TS_UNIX, $ts );
 743+ }
730744 $s .= $this->getWeekdayName( gmdate( 'w', $unix ) + 1 );
731745 break;
732746 case 'N':
733 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 747+ if ( !$unix ) {
 748+ $unix = wfTimestamp( TS_UNIX, $ts );
 749+ }
734750 $w = gmdate( 'w', $unix );
735751 $num = $w ? $w : 7;
736752 break;
737753 case 'w':
738 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 754+ if ( !$unix ) {
 755+ $unix = wfTimestamp( TS_UNIX, $ts );
 756+ }
739757 $num = gmdate( 'w', $unix );
740758 break;
741759 case 'z':
742 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 760+ if ( !$unix ) {
 761+ $unix = wfTimestamp( TS_UNIX, $ts );
 762+ }
743763 $num = gmdate( 'z', $unix );
744764 break;
745765 case 'W':
746 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 766+ if ( !$unix ) {
 767+ $unix = wfTimestamp( TS_UNIX, $ts );
 768+ }
747769 $num = gmdate( 'W', $unix );
748770 break;
749771 case 'F':
750772 $s .= $this->getMonthName( substr( $ts, 4, 2 ) );
751773 break;
752774 case 'xiF':
753 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 775+ if ( !$iranian ) {
 776+ $iranian = self::tsToIranian( $ts );
 777+ }
754778 $s .= $this->getIranianCalendarMonthName( $iranian[1] );
755779 break;
756780 case 'xmF':
757 - if ( !$hijri ) $hijri = self::tsToHijri( $ts );
 781+ if ( !$hijri ) {
 782+ $hijri = self::tsToHijri( $ts );
 783+ }
758784 $s .= $this->getHijriCalendarMonthName( $hijri[1] );
759785 break;
760786 case 'xjF':
761 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 787+ if ( !$hebrew ) {
 788+ $hebrew = self::tsToHebrew( $ts );
 789+ }
762790 $s .= $this->getHebrewCalendarMonthName( $hebrew[1] );
763791 break;
764792 case 'm':
@@ -770,64 +798,91 @@
771799 $num = intval( substr( $ts, 4, 2 ) );
772800 break;
773801 case 'xin':
774 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 802+ if ( !$iranian ) {
 803+ $iranian = self::tsToIranian( $ts );
 804+ }
775805 $num = $iranian[1];
776806 break;
777807 case 'xmn':
778 - if ( !$hijri ) $hijri = self::tsToHijri ( $ts );
 808+ if ( !$hijri ) {
 809+ $hijri = self::tsToHijri ( $ts );
 810+ }
779811 $num = $hijri[1];
780812 break;
781813 case 'xjn':
782 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 814+ if ( !$hebrew ) {
 815+ $hebrew = self::tsToHebrew( $ts );
 816+ }
783817 $num = $hebrew[1];
784818 break;
785819 case 't':
786 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 820+ if ( !$unix ) {
 821+ $unix = wfTimestamp( TS_UNIX, $ts );
 822+ }
787823 $num = gmdate( 't', $unix );
788824 break;
789825 case 'xjt':
790 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 826+ if ( !$hebrew ) {
 827+ $hebrew = self::tsToHebrew( $ts );
 828+ }
791829 $num = $hebrew[3];
792830 break;
793831 case 'L':
794 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 832+ if ( !$unix ) {
 833+ $unix = wfTimestamp( TS_UNIX, $ts );
 834+ }
795835 $num = gmdate( 'L', $unix );
796836 break;
797837 # 'o' is supported since PHP 5.1.0
798838 # return literal if not supported
799839 # TODO: emulation for pre 5.1.0 versions
800840 case 'o':
801 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
802 - if ( version_compare(PHP_VERSION, '5.1.0') === 1 )
 841+ if ( !$unix ) {
 842+ $unix = wfTimestamp( TS_UNIX, $ts );
 843+ }
 844+ if ( version_compare( PHP_VERSION, '5.1.0' ) === 1 ) {
803845 $num = date( 'o', $unix );
804 - else
 846+ } else {
805847 $s .= 'o';
 848+ }
806849 break;
807850 case 'Y':
808851 $num = substr( $ts, 0, 4 );
809852 break;
810853 case 'xiY':
811 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 854+ if ( !$iranian ) {
 855+ $iranian = self::tsToIranian( $ts );
 856+ }
812857 $num = $iranian[0];
813858 break;
814859 case 'xmY':
815 - if ( !$hijri ) $hijri = self::tsToHijri( $ts );
 860+ if ( !$hijri ) {
 861+ $hijri = self::tsToHijri( $ts );
 862+ }
816863 $num = $hijri[0];
817864 break;
818865 case 'xjY':
819 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 866+ if ( !$hebrew ) {
 867+ $hebrew = self::tsToHebrew( $ts );
 868+ }
820869 $num = $hebrew[0];
821870 break;
822871 case 'xkY':
823 - if ( !$thai ) $thai = self::tsToYear( $ts, 'thai' );
 872+ if ( !$thai ) {
 873+ $thai = self::tsToYear( $ts, 'thai' );
 874+ }
824875 $num = $thai[0];
825876 break;
826877 case 'xoY':
827 - if ( !$minguo ) $minguo = self::tsToYear( $ts, 'minguo' );
 878+ if ( !$minguo ) {
 879+ $minguo = self::tsToYear( $ts, 'minguo' );
 880+ }
828881 $num = $minguo[0];
829882 break;
830883 case 'xtY':
831 - if ( !$tenno ) $tenno = self::tsToYear( $ts, 'tenno' );
 884+ if ( !$tenno ) {
 885+ $tenno = self::tsToYear( $ts, 'tenno' );
 886+ }
832887 $num = $tenno[0];
833888 break;
834889 case 'y':
@@ -860,15 +915,21 @@
861916 $num = substr( $ts, 12, 2 );
862917 break;
863918 case 'c':
864 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 919+ if ( !$unix ) {
 920+ $unix = wfTimestamp( TS_UNIX, $ts );
 921+ }
865922 $s .= gmdate( 'c', $unix );
866923 break;
867924 case 'r':
868 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 925+ if ( !$unix ) {
 926+ $unix = wfTimestamp( TS_UNIX, $ts );
 927+ }
869928 $s .= gmdate( 'r', $unix );
870929 break;
871930 case 'U':
872 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 931+ if ( !$unix ) {
 932+ $unix = wfTimestamp( TS_UNIX, $ts );
 933+ }
873934 $num = $unix;
874935 break;
875936 case '\\':
@@ -933,10 +994,10 @@
934995 $gd = substr( $ts, 6, 2 ) -1;
935996
936997 # Days passed from the beginning (including leap years)
937 - $gDayNo = 365*$gy
938 - + floor(($gy+3) / 4)
939 - - floor(($gy+99) / 100)
940 - + floor(($gy+399) / 400);
 998+ $gDayNo = 365 * $gy
 999+ + floor( ( $gy + 3 ) / 4 )
 1000+ - floor( ( $gy + 99 ) / 100 )
 1001+ + floor( ( $gy + 399 ) / 400 );
9411002
9421003
9431004 // Add days of the past months of this year
@@ -945,7 +1006,7 @@
9461007 }
9471008
9481009 // Leap years
949 - if ( $gm > 1 && (($gy%4===0 && $gy%100!==0 || ($gy%400==0)))) {
 1010+ if ( $gm > 1 && ( ( $gy%4 === 0 && $gy%100 !== 0 || ( $gy%400 == 0 ) ) ) ) {
9501011 $gDayNo++;
9511012 }
9521013
@@ -954,26 +1015,27 @@
9551016
9561017 $jDayNo = $gDayNo - 79;
9571018
958 - $jNp = floor($jDayNo / 12053);
 1019+ $jNp = floor( $jDayNo / 12053 );
9591020 $jDayNo %= 12053;
9601021
961 - $jy = 979 + 33*$jNp + 4*floor($jDayNo/1461);
 1022+ $jy = 979 + 33 * $jNp + 4 * floor( $jDayNo / 1461 );
9621023 $jDayNo %= 1461;
9631024
9641025 if ( $jDayNo >= 366 ) {
965 - $jy += floor(($jDayNo-1)/365);
966 - $jDayNo = floor(($jDayNo-1)%365);
 1026+ $jy += floor( ( $jDayNo - 1 ) / 365 );
 1027+ $jDayNo = floor( ( $jDayNo - 1 ) % 365 );
9671028 }
9681029
9691030 for ( $i = 0; $i < 11 && $jDayNo >= self::$IRANIAN_DAYS[$i]; $i++ ) {
9701031 $jDayNo -= self::$IRANIAN_DAYS[$i];
9711032 }
9721033
973 - $jm= $i+1;
974 - $jd= $jDayNo+1;
 1034+ $jm = $i + 1;
 1035+ $jd = $jDayNo + 1;
9751036
976 - return array($jy, $jm, $jd);
 1037+ return array( $jy, $jm, $jd );
9771038 }
 1039+
9781040 /**
9791041 * Converting Gregorian dates to Hijri dates.
9801042 *
@@ -981,39 +1043,40 @@
9821044 *
9831045 * @link http://phpnuke.org/modules.php?name=News&file=article&sid=8234&mode=thread&order=0&thold=0
9841046 */
985 - private static function tsToHijri ( $ts ) {
 1047+ private static function tsToHijri( $ts ) {
9861048 $year = substr( $ts, 0, 4 );
9871049 $month = substr( $ts, 4, 2 );
9881050 $day = substr( $ts, 6, 2 );
9891051
9901052 $zyr = $year;
991 - $zd=$day;
992 - $zm=$month;
993 - $zy=$zyr;
 1053+ $zd = $day;
 1054+ $zm = $month;
 1055+ $zy = $zyr;
9941056
 1057+ if (
 1058+ ( $zy > 1582 ) || ( ( $zy == 1582 ) && ( $zm > 10 ) ) ||
 1059+ ( ( $zy == 1582 ) && ( $zm == 10 ) && ( $zd > 14 ) )
 1060+ )
 1061+ {
 1062+ $zjd = (int)( ( 1461 * ( $zy + 4800 + (int)( ( $zm - 14 ) / 12 ) ) ) / 4 ) +
 1063+ (int)( ( 367 * ( $zm - 2 - 12 * ( (int)( ( $zm - 14 ) / 12 ) ) ) ) / 12 ) -
 1064+ (int)( ( 3 * (int)( ( ( $zy + 4900 + (int)( ( $zm - 14 ) / 12 ) ) / 100 ) ) ) / 4 ) +
 1065+ $zd - 32075;
 1066+ } else {
 1067+ $zjd = 367 * $zy - (int)( ( 7 * ( $zy + 5001 + (int)( ( $zm - 9 ) / 7 ) ) ) / 4 ) +
 1068+ (int)( ( 275 * $zm ) / 9 ) + $zd + 1729777;
 1069+ }
9951070
 1071+ $zl = $zjd-1948440 + 10632;
 1072+ $zn = (int)( ( $zl - 1 ) / 10631 );
 1073+ $zl = $zl - 10631 * $zn + 354;
 1074+ $zj = ( (int)( ( 10985 - $zl ) / 5316 ) ) * ((int)( ( 50 * $zl ) / 17719 ) ) + ( (int)( $zl / 5670 ) ) * ( (int)( ( 43 * $zl ) / 15238 ) );
 1075+ $zl = $zl - ( (int)( ( 30 - $zj ) / 15 ) ) * ((int)( ( 17719 * $zj ) / 50 ) ) - ( (int)( $zj / 16 ) ) * ( (int)( ( 15238 * $zj ) / 43 ) ) + 29;
 1076+ $zm = (int)( ( 24 * $zl ) / 709 );
 1077+ $zd = $zl - (int)( ( 709 * $zm ) / 24 );
 1078+ $zy = 30 * $zn + $zj - 30;
9961079
997 - if (($zy>1582)||(($zy==1582)&&($zm>10))||(($zy==1582)&&($zm==10)&&($zd>14)))
998 - {
999 -
1000 -
1001 - $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;
1002 - }
1003 - else
1004 - {
1005 - $zjd = 367*$zy-(int)((7*($zy+5001+(int)(($zm-9)/7)))/4)+(int)((275*$zm)/9)+$zd+1729777;
1006 - }
1007 -
1008 - $zl=$zjd-1948440+10632;
1009 - $zn=(int)(($zl-1)/10631);
1010 - $zl=$zl-10631*$zn+354;
1011 - $zj=((int)((10985-$zl)/5316))*((int)((50*$zl)/17719))+((int)($zl/5670))*((int)((43*$zl)/15238));
1012 - $zl=$zl-((int)((30-$zj)/15))*((int)((17719*$zj)/50))-((int)($zj/16))*((int)((15238*$zj)/43))+29;
1013 - $zm=(int)((24*$zl)/709);
1014 - $zd=$zl-(int)((709*$zm)/24);
1015 - $zy=30*$zn+$zj-30;
1016 -
1017 - return array ($zy, $zm, $zd);
 1080+ return array( $zy, $zm, $zd );
10181081 }
10191082
10201083 /**
@@ -1207,49 +1270,65 @@
12081271 $gm = substr( $ts, 4, 2 );
12091272 $gd = substr( $ts, 6, 2 );
12101273
1211 - if (!strcmp($cName,'thai')) {
 1274+ if ( !strcmp( $cName, 'thai' ) ) {
12121275 # Thai solar dates
12131276 # Add 543 years to the Gregorian calendar
12141277 # Months and days are identical
12151278 $gy_offset = $gy + 543;
1216 - } else if ((!strcmp($cName,'minguo')) || !strcmp($cName,'juche')) {
 1279+ } else if ( ( !strcmp( $cName, 'minguo' ) ) || !strcmp( $cName, 'juche' ) ) {
12171280 # Minguo dates
12181281 # Deduct 1911 years from the Gregorian calendar
12191282 # Months and days are identical
12201283 $gy_offset = $gy - 1911;
1221 - } else if (!strcmp($cName,'tenno')) {
 1284+ } else if ( !strcmp( $cName, 'tenno' ) ) {
12221285 # Nengō dates up to Meiji period
12231286 # Deduct years from the Gregorian calendar
12241287 # depending on the nengo periods
12251288 # Months and days are identical
1226 - if (($gy < 1912) || (($gy == 1912) && ($gm < 7)) || (($gy == 1912) && ($gm == 7) && ($gd < 31))) {
 1289+ if ( ( $gy < 1912 ) || ( ( $gy == 1912 ) && ( $gm < 7 ) ) || ( ( $gy == 1912 ) && ( $gm == 7 ) && ( $gd < 31 ) ) ) {
12271290 # Meiji period
12281291 $gy_gannen = $gy - 1868 + 1;
12291292 $gy_offset = $gy_gannen;
1230 - if ($gy_gannen == 1)
 1293+ if ( $gy_gannen == 1 ) {
12311294 $gy_offset = '元';
1232 - $gy_offset = '明治'.$gy_offset;
1233 - } else if ((($gy == 1912) && ($gm == 7) && ($gd == 31)) || (($gy == 1912) && ($gm >= 8)) || (($gy > 1912) && ($gy < 1926)) || (($gy == 1926) && ($gm < 12)) || (($gy == 1926) && ($gm == 12) && ($gd < 26))) {
 1295+ }
 1296+ $gy_offset = '明治' . $gy_offset;
 1297+ } else if (
 1298+ ( ( $gy == 1912 ) && ( $gm == 7 ) && ( $gd == 31 ) ) ||
 1299+ ( ( $gy == 1912 ) && ( $gm >= 8 ) ) ||
 1300+ ( ( $gy > 1912 ) && ( $gy < 1926 ) ) ||
 1301+ ( ( $gy == 1926 ) && ( $gm < 12 ) ) ||
 1302+ ( ( $gy == 1926 ) && ( $gm == 12 ) && ( $gd < 26 ) )
 1303+ )
 1304+ {
12341305 # Taishō period
12351306 $gy_gannen = $gy - 1912 + 1;
12361307 $gy_offset = $gy_gannen;
1237 - if ($gy_gannen == 1)
 1308+ if ( $gy_gannen == 1 ) {
12381309 $gy_offset = '元';
1239 - $gy_offset = '大正'.$gy_offset;
1240 - } else if ((($gy == 1926) && ($gm == 12) && ($gd >= 26)) || (($gy > 1926) && ($gy < 1989)) || (($gy == 1989) && ($gm == 1) && ($gd < 8))) {
 1310+ }
 1311+ $gy_offset = '大正' . $gy_offset;
 1312+ } else if (
 1313+ ( ( $gy == 1926 ) && ( $gm == 12 ) && ( $gd >= 26 ) ) ||
 1314+ ( ( $gy > 1926 ) && ( $gy < 1989 ) ) ||
 1315+ ( ( $gy == 1989 ) && ( $gm == 1 ) && ( $gd < 8 ) )
 1316+ )
 1317+ {
12411318 # Shōwa period
12421319 $gy_gannen = $gy - 1926 + 1;
12431320 $gy_offset = $gy_gannen;
1244 - if ($gy_gannen == 1)
 1321+ if ( $gy_gannen == 1 ) {
12451322 $gy_offset = '元';
1246 - $gy_offset = '昭和'.$gy_offset;
 1323+ }
 1324+ $gy_offset = '昭和' . $gy_offset;
12471325 } else {
12481326 # Heisei period
12491327 $gy_gannen = $gy - 1989 + 1;
12501328 $gy_offset = $gy_gannen;
1251 - if ($gy_gannen == 1)
 1329+ if ( $gy_gannen == 1 ) {
12521330 $gy_offset = '元';
1253 - $gy_offset = '平成'.$gy_offset;
 1331+ }
 1332+ $gy_offset = '平成' . $gy_offset;
12541333 }
12551334 } else {
12561335 $gy_offset = $gy;
@@ -1277,7 +1356,7 @@
12781357 $s = '';
12791358 for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) {
12801359 if ( $num >= $pow10 ) {
1281 - $s .= $table[$i][floor($num / $pow10)];
 1360+ $s .= $table[$i][floor( $num / $pow10 )];
12821361 }
12831362 $num = $num % $pow10;
12841363 }
@@ -1482,29 +1561,29 @@
14831562 }
14841563
14851564 // callback functions for uc(), lc(), ucwords(), ucwordbreaks()
1486 - function ucwordbreaksCallbackAscii($matches){
1487 - return $this->ucfirst($matches[1]);
 1565+ function ucwordbreaksCallbackAscii( $matches ) {
 1566+ return $this->ucfirst( $matches[1] );
14881567 }
14891568
1490 - function ucwordbreaksCallbackMB($matches){
1491 - return mb_strtoupper($matches[0]);
 1569+ function ucwordbreaksCallbackMB( $matches ) {
 1570+ return mb_strtoupper( $matches[0] );
14921571 }
14931572
1494 - function ucCallback($matches){
 1573+ function ucCallback( $matches ) {
14951574 list( $wikiUpperChars ) = self::getCaseMaps();
14961575 return strtr( $matches[1], $wikiUpperChars );
14971576 }
14981577
1499 - function lcCallback($matches){
 1578+ function lcCallback( $matches ) {
15001579 list( , $wikiLowerChars ) = self::getCaseMaps();
15011580 return strtr( $matches[1], $wikiLowerChars );
15021581 }
15031582
1504 - function ucwordsCallbackMB($matches){
1505 - return mb_strtoupper($matches[0]);
 1583+ function ucwordsCallbackMB( $matches ) {
 1584+ return mb_strtoupper( $matches[0] );
15061585 }
15071586
1508 - function ucwordsCallbackWiki($matches){
 1587+ function ucwordsCallbackWiki( $matches ) {
15091588 list( $wikiUpperChars ) = self::getCaseMaps();
15101589 return strtr( $matches[0], $wikiUpperChars );
15111590 }
@@ -1514,10 +1593,10 @@
15151594 if ( $o < 96 ) {
15161595 return $str;
15171596 } elseif ( $o < 128 ) {
1518 - return ucfirst($str);
 1597+ return ucfirst( $str );
15191598 } else {
15201599 // fall back to more complex logic in case of multibyte strings
1521 - return self::uc($str,true);
 1600+ return self::uc( $str, true );
15221601 }
15231602 }
15241603
@@ -1538,7 +1617,7 @@
15391618 $x = $first ? '^' : '';
15401619 return preg_replace_callback(
15411620 "/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/",
1542 - array($this,"ucCallback"),
 1621+ array( $this, 'ucCallback' ),
15431622 $str
15441623 );
15451624 } else {
@@ -1562,85 +1641,92 @@
15631642 }
15641643
15651644 function lc( $str, $first = false ) {
1566 - if ( function_exists( 'mb_strtolower' ) )
1567 - if ( $first )
1568 - if ( self::isMultibyte( $str ) )
 1645+ if ( function_exists( 'mb_strtolower' ) ) {
 1646+ if ( $first ) {
 1647+ if ( self::isMultibyte( $str ) ) {
15691648 return mb_strtolower( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
1570 - else
 1649+ } else {
15711650 return strtolower( substr( $str, 0, 1 ) ) . substr( $str, 1 );
1572 - else
 1651+ }
 1652+ } else {
15731653 return self::isMultibyte( $str ) ? mb_strtolower( $str ) : strtolower( $str );
1574 - else
 1654+ }
 1655+ } else {
15751656 if ( self::isMultibyte( $str ) ) {
15761657 list( , $wikiLowerChars ) = self::getCaseMaps();
15771658 $x = $first ? '^' : '';
15781659 return preg_replace_callback(
15791660 "/$x([A-Z]|[\\xc0-\\xff][\\x80-\\xbf]*)/",
1580 - array($this,"lcCallback"),
 1661+ array( $this, 'lcCallback' ),
15811662 $str
15821663 );
1583 - } else
 1664+ } else {
15841665 return $first ? strtolower( substr( $str, 0, 1 ) ) . substr( $str, 1 ) : strtolower( $str );
 1666+ }
 1667+ }
15851668 }
15861669
15871670 function isMultibyte( $str ) {
15881671 return (bool)preg_match( '/[\x80-\xff]/', $str );
15891672 }
15901673
1591 - function ucwords($str) {
 1674+ function ucwords( $str ) {
15921675 if ( self::isMultibyte( $str ) ) {
1593 - $str = self::lc($str);
 1676+ $str = self::lc( $str );
15941677
15951678 // regexp to find first letter in each word (i.e. after each space)
15961679 $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)| ([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/";
15971680
15981681 // function to use to capitalize a single char
1599 - if ( function_exists( 'mb_strtoupper' ) )
 1682+ if ( function_exists( 'mb_strtoupper' ) ) {
16001683 return preg_replace_callback(
16011684 $replaceRegexp,
1602 - array($this,"ucwordsCallbackMB"),
 1685+ array( $this, 'ucwordsCallbackMB' ),
16031686 $str
16041687 );
1605 - else
 1688+ } else {
16061689 return preg_replace_callback(
16071690 $replaceRegexp,
1608 - array($this,"ucwordsCallbackWiki"),
 1691+ array( $this, 'ucwordsCallbackWiki' ),
16091692 $str
16101693 );
 1694+ }
 1695+ } else {
 1696+ return ucwords( strtolower( $str ) );
16111697 }
1612 - else
1613 - return ucwords( strtolower( $str ) );
16141698 }
16151699
1616 - # capitalize words at word breaks
1617 - function ucwordbreaks($str){
1618 - if (self::isMultibyte( $str ) ) {
1619 - $str = self::lc($str);
 1700+ # capitalize words at word breaks
 1701+ function ucwordbreaks( $str ) {
 1702+ if ( self::isMultibyte( $str ) ) {
 1703+ $str = self::lc( $str );
16201704
16211705 // since \b doesn't work for UTF-8, we explicitely define word break chars
1622 - $breaks= "[ \-\(\)\}\{\.,\?!]";
 1706+ $breaks = "[ \-\(\)\}\{\.,\?!]";
16231707
16241708 // find first letter after word break
16251709 $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$breaks([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/";
16261710
1627 - if ( function_exists( 'mb_strtoupper' ) )
 1711+ if ( function_exists( 'mb_strtoupper' ) ) {
16281712 return preg_replace_callback(
16291713 $replaceRegexp,
1630 - array($this,"ucwordbreaksCallbackMB"),
 1714+ array( $this, 'ucwordbreaksCallbackMB' ),
16311715 $str
16321716 );
1633 - else
 1717+ } else {
16341718 return preg_replace_callback(
16351719 $replaceRegexp,
1636 - array($this,"ucwordsCallbackWiki"),
 1720+ array( $this, 'ucwordsCallbackWiki' ),
16371721 $str
16381722 );
 1723+ }
 1724+ } else {
 1725+ return preg_replace_callback(
 1726+ '/\b([\w\x80-\xff]+)\b/',
 1727+ array( $this, 'ucwordbreaksCallbackAscii' ),
 1728+ $str
 1729+ );
16391730 }
1640 - else
1641 - return preg_replace_callback(
1642 - '/\b([\w\x80-\xff]+)\b/',
1643 - array($this,"ucwordbreaksCallbackAscii"),
1644 - $str );
16451731 }
16461732
16471733 /**
@@ -1664,13 +1750,17 @@
16651751 }
16661752 # Check for non-UTF-8 URLs
16671753 $ishigh = preg_match( '/[\x80-\xff]/', $s);
1668 - if(!$ishigh) return $s;
 1754+ if( !$ishigh ) {
 1755+ return $s;
 1756+ }
16691757
16701758 $isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
16711759 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
1672 - if( $isutf8 ) return $s;
 1760+ if( $isutf8 ) {
 1761+ return $s;
 1762+ }
16731763
1674 - return $this->iconv( $this->fallback8bitEncoding(), "utf-8", $s );
 1764+ return $this->iconv( $this->fallback8bitEncoding(), 'utf-8', $s );
16751765 }
16761766
16771767 function fallback8bitEncoding() {
@@ -1686,11 +1776,11 @@
16871777 function hasWordBreaks() {
16881778 return true;
16891779 }
1690 -
 1780+
16911781 /**
16921782 * Some languages such as Chinese require word segmentation,
16931783 * Specify such segmentation when overridden in derived class.
1694 - *
 1784+ *
16951785 * @param $string String
16961786 * @return String
16971787 */
@@ -1748,8 +1838,12 @@
17491839 */
17501840 function firstChar( $s ) {
17511841 $matches = array();
1752 - preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
1753 - '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/', $s, $matches);
 1842+ preg_match(
 1843+ '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
 1844+ '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/',
 1845+ $s,
 1846+ $matches
 1847+ );
17541848
17551849 if ( isset( $matches[1] ) ) {
17561850 if ( strlen( $matches[1] ) != 3 ) {
@@ -1758,7 +1852,7 @@
17591853
17601854 // Break down Hangul syllables to grab the first jamo
17611855 $code = utf8ToCodepoint( $matches[1] );
1762 - if ( $code < 0xac00 || 0xd7a4 <= $code) {
 1856+ if ( $code < 0xac00 || 0xd7a4 <= $code ) {
17631857 return $matches[1];
17641858 } elseif ( $code < 0xb098 ) {
17651859 return "\xe3\x84\xb1";
@@ -1790,7 +1884,7 @@
17911885 return "\xe3\x85\x8e";
17921886 }
17931887 } else {
1794 - return "";
 1888+ return '';
17951889 }
17961890 }
17971891
@@ -1809,8 +1903,7 @@
18101904 # wgInputEncoding, this text will be further converted
18111905 # to wgOutputEncoding.
18121906 global $wgEditEncoding;
1813 - if( $wgEditEncoding == '' or
1814 - $wgEditEncoding == 'UTF-8' ) {
 1907+ if( $wgEditEncoding == '' || $wgEditEncoding == 'UTF-8' ) {
18151908 return $s;
18161909 } else {
18171910 return $this->iconv( 'UTF-8', $wgEditEncoding, $s );
@@ -1820,7 +1913,7 @@
18211914 function recodeInput( $s ) {
18221915 # Take the previous into account.
18231916 global $wgEditEncoding;
1824 - if($wgEditEncoding != "") {
 1917+ if( $wgEditEncoding != '' ) {
18251918 $enc = $wgEditEncoding;
18261919 } else {
18271920 $enc = 'UTF-8';
@@ -1855,7 +1948,7 @@
18561949 if ( !isset( $this->transformData[$file] ) ) {
18571950 $data = wfGetPrecompiledData( $file );
18581951 if ( $data === false ) {
1859 - throw new MWException( __METHOD__.": The transformation file $file is missing" );
 1952+ throw new MWException( __METHOD__ . ": The transformation file $file is missing" );
18601953 }
18611954 $this->transformData[$file] = new ReplacementArray( $data );
18621955 }
@@ -2039,15 +2132,19 @@
20402133 */
20412134 function formatNum( $number, $nocommafy = false ) {
20422135 global $wgTranslateNumerals;
2043 - if (!$nocommafy) {
2044 - $number = $this->commafy($number);
 2136+ if ( !$nocommafy ) {
 2137+ $number = $this->commafy( $number );
20452138 $s = $this->separatorTransformTable();
2046 - if ($s) { $number = strtr($number, $s); }
 2139+ if ( $s ) {
 2140+ $number = strtr( $number, $s );
 2141+ }
20472142 }
20482143
2049 - if ($wgTranslateNumerals) {
 2144+ if ( $wgTranslateNumerals ) {
20502145 $s = $this->digitTransformTable();
2051 - if ($s) { $number = strtr($number, $s); }
 2146+ if ( $s ) {
 2147+ $number = strtr( $number, $s );
 2148+ }
20522149 }
20532150
20542151 return $number;
@@ -2055,12 +2152,16 @@
20562153
20572154 function parseFormattedNumber( $number ) {
20582155 $s = $this->digitTransformTable();
2059 - if ($s) { $number = strtr($number, array_flip($s)); }
 2156+ if ( $s ) {
 2157+ $number = strtr( $number, array_flip( $s ) );
 2158+ }
20602159
20612160 $s = $this->separatorTransformTable();
2062 - if ($s) { $number = strtr($number, array_flip($s)); }
 2161+ if ( $s ) {
 2162+ $number = strtr( $number, array_flip( $s ) );
 2163+ }
20632164
2064 - $number = strtr( $number, array (',' => '') );
 2165+ $number = strtr( $number, array( ',' => '' ) );
20652166 return $number;
20662167 }
20672168
@@ -2071,7 +2172,7 @@
20722173 * @return string
20732174 */
20742175 function commafy($_) {
2075 - return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
 2176+ return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
20762177 }
20772178
20782179 function digitTransformTable() {
@@ -2082,7 +2183,6 @@
20832184 return self::$dataCache->getItem( $this->mCode, 'separatorTransformTable' );
20842185 }
20852186
2086 -
20872187 /**
20882188 * Take a list of strings and build a locale-friendly comma-separated
20892189 * list, using the local comma-separator message.
@@ -2096,8 +2196,7 @@
20972197 $m = count( $l ) - 1;
20982198 if( $m == 1 ) {
20992199 return $l[0] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $l[1];
2100 - }
2101 - else {
 2200+ } else {
21022201 for ( $i = $m; $i >= 0; $i-- ) {
21032202 if ( $i == $m ) {
21042203 $s = $l[$i];
@@ -2120,7 +2219,11 @@
21212220 function commaList( $list ) {
21222221 return implode(
21232222 $list,
2124 - wfMsgExt( 'comma-separator', array( 'parsemag', 'escapenoentities', 'language' => $this ) ) );
 2223+ wfMsgExt(
 2224+ 'comma-separator',
 2225+ array( 'parsemag', 'escapenoentities', 'language' => $this )
 2226+ )
 2227+ );
21252228 }
21262229
21272230 /**
@@ -2132,7 +2235,11 @@
21332236 function semicolonList( $list ) {
21342237 return implode(
21352238 $list,
2136 - wfMsgExt( 'semicolon-separator', array( 'parsemag', 'escapenoentities', 'language' => $this ) ) );
 2239+ wfMsgExt(
 2240+ 'semicolon-separator',
 2241+ array( 'parsemag', 'escapenoentities', 'language' => $this )
 2242+ )
 2243+ );
21372244 }
21382245
21392246 /**
@@ -2143,7 +2250,11 @@
21442251 function pipeList( $list ) {
21452252 return implode(
21462253 $list,
2147 - wfMsgExt( 'pipe-separator', array( 'escapenoentities', 'language' => $this ) ) );
 2254+ wfMsgExt(
 2255+ 'pipe-separator',
 2256+ array( 'escapenoentities', 'language' => $this )
 2257+ )
 2258+ );
21482259 }
21492260
21502261 /**
@@ -2251,7 +2362,7 @@
22522363 # Check if there is no need to truncate
22532364 if ( $length <= 0 ) {
22542365 return $ellipsis; // no text shown, nothing to format
2255 - } elseif ( strlen($text) <= $length ) {
 2366+ } elseif ( strlen( $text ) <= $length ) {
22562367 return $text; // string short enough even *with* HTML
22572368 }
22582369 $text = MWTidy::tidy( $text ); // fix tags
@@ -2265,7 +2376,7 @@
22662377 $textLen = strlen($text);
22672378 for( $pos = 0; $pos < $textLen; ++$pos ) {
22682379 $ch = $text[$pos];
2269 - $lastCh = $pos ? $text[$pos-1] : '';
 2380+ $lastCh = $pos ? $text[$pos - 1] : '';
22702381 $ret .= $ch; // add to result string
22712382 if ( $ch == '<' ) {
22722383 $this->truncate_endBracket( $tag, $tagType, $lastCh, $openTags ); // for bad HTML
@@ -2318,7 +2429,7 @@
23192430 # the ellipsis actually makes the string longer.
23202431 $pOpenTags = $openTags; // save state
23212432 $pRet = $ret; // save state
2322 - } elseif ( $displayLen > ($length + strlen($ellipsis)) ) {
 2433+ } elseif ( $displayLen > ( $length + strlen( $ellipsis ) ) ) {
23232434 # Ellipsis won't make string longer/equal, the truncation point was OK.
23242435 $openTags = $pOpenTags; // reload state
23252436 $ret = $this->removeBadCharLast( $pRet ); // reload state, multi-byte char fix
@@ -2330,7 +2441,7 @@
23312442 if ( $displayLen == 0 ) {
23322443 return ''; // no text shown, nothing to format
23332444 }
2334 - $this->truncate_endBracket( $tag, $text[$textLen-1], $tagType, $openTags ); // for bad HTML
 2445+ $this->truncate_endBracket( $tag, $text[$textLen - 1], $tagType, $openTags ); // for bad HTML
23352446 while ( count( $openTags ) > 0 ) {
23362447 $ret .= '</' . array_pop( $openTags ) . '>'; // close open tags
23372448 }
@@ -2341,7 +2452,7 @@
23422453 // like strcspn() but adds the skipped chars to $ret
23432454 private function truncate_skip( &$ret, $text, $search, $start, $len = -1 ) {
23442455 $skipCount = 0;
2345 - if( $start < strlen($text) ) {
 2456+ if( $start < strlen( $text ) ) {
23462457 $skipCount = strcspn( $text, $search, $start, $len );
23472458 $ret .= substr( $text, $start, $skipCount );
23482459 }
@@ -2357,7 +2468,7 @@
23582469 if( $tagType == 0 && $lastCh != '/' ) {
23592470 $openTags[] = $tag; // tag opened (didn't close itself)
23602471 } else if( $tagType == 1 ) {
2361 - if( $openTags && $tag == $openTags[count($openTags)-1] ) {
 2472+ if( $openTags && $tag == $openTags[count( $openTags ) - 1] ) {
23622473 array_pop( $openTags ); // tag closed
23632474 }
23642475 }
@@ -2375,7 +2486,7 @@
23762487 */
23772488 function convertGrammar( $word, $case ) {
23782489 global $wgGrammarForms;
2379 - if ( isset($wgGrammarForms[$this->getCode()][$case][$word]) ) {
 2490+ if ( isset( $wgGrammarForms[$this->getCode()][$case][$word] ) ) {
23802491 return $wgGrammarForms[$this->getCode()][$case][$word];
23812492 }
23822493 return $word;
@@ -2390,11 +2501,17 @@
23912502 * These details may be overriden per language.
23922503 */
23932504 function gender( $gender, $forms ) {
2394 - if ( !count($forms) ) { return ''; }
 2505+ if ( !count( $forms ) ) {
 2506+ return '';
 2507+ }
23952508 $forms = $this->preConvertPlural( $forms, 2 );
2396 - if ( $gender === 'male' ) return $forms[0];
2397 - if ( $gender === 'female' ) return $forms[1];
2398 - return isset($forms[2]) ? $forms[2] : $forms[0];
 2509+ if ( $gender === 'male' ) {
 2510+ return $forms[0];
 2511+ }
 2512+ if ( $gender === 'female' ) {
 2513+ return $forms[1];
 2514+ }
 2515+ return isset( $forms[2] ) ? $forms[2] : $forms[0];
23992516 }
24002517
24012518 /**
@@ -2413,7 +2530,9 @@
24142531 * @return string Correct form of plural for $count in this language
24152532 */
24162533 function convertPlural( $count, $forms ) {
2417 - if ( !count($forms) ) { return ''; }
 2534+ if ( !count( $forms ) ) {
 2535+ return '';
 2536+ }
24182537 $forms = $this->preConvertPlural( $forms, 2 );
24192538
24202539 return ( $count == 1 ) ? $forms[0] : $forms[1];
@@ -2428,31 +2547,31 @@
24292548 * @return array Padded array of forms or an exception if not an array
24302549 */
24312550 protected function preConvertPlural( /* Array */ $forms, $count ) {
2432 - while ( count($forms) < $count ) {
2433 - $forms[] = $forms[count($forms)-1];
 2551+ while ( count( $forms ) < $count ) {
 2552+ $forms[] = $forms[count( $forms ) - 1];
24342553 }
24352554 return $forms;
24362555 }
24372556
24382557 /**
2439 - * For translaing of expiry times
 2558+ * For translating of expiry times
24402559 * @param $str String: the validated block time in English
24412560 * @return Somehow translated block time
24422561 * @see LanguageFi.php for example implementation
24432562 */
24442563 function translateBlockExpiry( $str ) {
2445 -
24462564 $scBlockExpiryOptions = $this->getMessageFromDB( 'ipboptions' );
24472565
2448 - if ( $scBlockExpiryOptions == '-') {
 2566+ if ( $scBlockExpiryOptions == '-' ) {
24492567 return $str;
24502568 }
24512569
2452 - foreach (explode(',', $scBlockExpiryOptions) as $option) {
2453 - if ( strpos($option, ":") === false )
 2570+ foreach ( explode( ',', $scBlockExpiryOptions) as $option ) {
 2571+ if ( strpos( $option, ':' ) === false ) {
24542572 continue;
2455 - list($show, $value) = explode(":", $option);
2456 - if ( strcmp ( $str, $value) == 0 ) {
 2573+ }
 2574+ list( $show, $value ) = explode( ':', $option );
 2575+ if ( strcmp( $str, $value ) == 0 ) {
24572576 return htmlspecialchars( trim( $show ) );
24582577 }
24592578 }
@@ -2482,26 +2601,25 @@
24832602 }
24842603
24852604 # convert text to all supported variants
2486 - function autoConvertToAllVariants($text) {
2487 - return $this->mConverter->autoConvertToAllVariants($text);
 2605+ function autoConvertToAllVariants( $text ) {
 2606+ return $this->mConverter->autoConvertToAllVariants( $text );
24882607 }
24892608
24902609 # convert text to different variants of a language.
2491 - function convert( $text, $isTitle = false) {
2492 - return $this->mConverter->convert($text, $isTitle);
 2610+ function convert( $text, $isTitle = false ) {
 2611+ return $this->mConverter->convert( $text, $isTitle );
24932612 }
24942613
24952614 # Check if this is a language with variants
2496 - function hasVariants(){
2497 - return sizeof($this->getVariants())>1;
 2615+ function hasVariants() {
 2616+ return sizeof( $this->getVariants() ) > 1;
24982617 }
24992618
25002619 # Put custom tags (e.g. -{ }-) around math to prevent conversion
2501 - function armourMath($text){
2502 - return $this->mConverter->armourMath($text);
 2620+ function armourMath( $text ) {
 2621+ return $this->mConverter->armourMath( $text );
25032622 }
25042623
2505 -
25062624 /**
25072625 * Perform output conversion on a string, and encode for safe HTML output.
25082626 * @param $text String text to be converted
@@ -2518,7 +2636,7 @@
25192637 }
25202638
25212639 /**
2522 - * get the list of variants supported by this langauge
 2640+ * Get the list of variants supported by this langauge
25232641 * see sample implementation in LanguageZh.php
25242642 *
25252643 * @return array an array of language codes
@@ -2527,13 +2645,12 @@
25282646 return $this->mConverter->getVariants();
25292647 }
25302648
2531 -
25322649 function getPreferredVariant( $fromUser = true, $fromHeader = false ) {
25332650 return $this->mConverter->getPreferredVariant( $fromUser, $fromHeader );
25342651 }
25352652
25362653 /**
2537 - * if a language supports multiple variants, it is
 2654+ * If a language supports multiple variants, it is
25382655 * possible that non-existing link in one variant
25392656 * actually exists in another variant. this function
25402657 * tries to find it. See e.g. LanguageZh.php
@@ -2553,11 +2670,10 @@
25542671 * into an array of all possible variants of the text:
25552672 * 'variant' => text in that variant
25562673 */
2557 - function convertLinkToAllVariants($text){
2558 - return $this->mConverter->convertLinkToAllVariants($text);
 2674+ function convertLinkToAllVariants( $text ) {
 2675+ return $this->mConverter->convertLinkToAllVariants( $text );
25592676 }
25602677
2561 -
25622678 /**
25632679 * returns language specific options used by User::getPageRenderHash()
25642680 * for example, the preferred language variant
@@ -2569,7 +2685,7 @@
25702686 }
25712687
25722688 /**
2573 - * for languages that support multiple variants, the title of an
 2689+ * For languages that support multiple variants, the title of an
25742690 * article may be displayed differently in different variants. this
25752691 * function returns the apporiate title defined in the body of the article.
25762692 *
@@ -2587,7 +2703,7 @@
25882704 * @param $noParse
25892705 * @return string the tagged text
25902706 */
2591 - function markNoConversion( $text, $noParse=false ) {
 2707+ function markNoConversion( $text, $noParse = false ) {
25922708 return $this->mConverter->markNoConversion( $text, $noParse );
25932709 }
25942710
@@ -2682,7 +2798,9 @@
26832799 }
26842800
26852801 function fixVariableInNamespace( $talk ) {
2686 - if ( strpos( $talk, '$1' ) === false ) return $talk;
 2802+ if ( strpos( $talk, '$1' ) === false ) {
 2803+ return $talk;
 2804+ }
26872805
26882806 global $wgMetaNamespace;
26892807 $talk = str_replace( '$1', $wgMetaNamespace, $talk );

Status & tagging log