From 0c136554ef475d2e18a4af9e36f4be7656dd7c7e Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Fri, 12 Jan 2007 07:26:32 +0000 Subject: [PATCH] For the "languages/" directory : * removing unused global declarations. * adding one or two if/else braces. * adding one or two array declarations. --- languages/Language.php | 25 +++++++++++++++---------- languages/LanguageConverter.php | 7 +++---- languages/classes/LanguageKo.php | 1 + 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index 7176391ba8..f523b9554a 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -316,6 +316,7 @@ class Language { $messageFiles = glob( "$IP/languages/messages/Messages*.php" ); $names = array(); foreach ( $messageFiles as $file ) { + $m = array(); if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $file, $m ) ) { $code = str_replace( '_', '-', strtolower( $m[1] ) ); if ( isset( $wgLanguageNames[$code] ) ) { @@ -803,15 +804,17 @@ class Language { } function uc( $str, $first = false ) { - if ( function_exists( 'mb_strtoupper' ) ) - if ( $first ) - if ( self::isMultibyte( $str ) ) + if ( function_exists( 'mb_strtoupper' ) ) { + if ( $first ) { + if ( self::isMultibyte( $str ) ) { return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 ); - else + } else { return ucfirst( $str ); - else + } + } else { return self::isMultibyte( $str ) ? mb_strtoupper( $str ) : strtoupper( $str ); - else + } + } else { if ( self::isMultibyte( $str ) ) { list( $wikiUpperChars ) = $this->getCaseMaps(); $x = $first ? '^' : ''; @@ -820,8 +823,10 @@ class Language { array($this,"ucCallback"), $str ); - } else + } else { return $first ? ucfirst( $str ) : strtoupper( $str ); + } + } } function lcfirst( $str ) { @@ -992,6 +997,7 @@ class Language { * @return string */ function firstChar( $s ) { + $matches = array(); preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/', $s, $matches); @@ -1241,6 +1247,7 @@ class Language { if( $length > 0 ) { $string = substr( $string, 0, $length ); $char = ord( $string[strlen( $string ) - 1] ); + $m = array(); if ($char >= 0xc0) { # We got the first byte only of a multibyte char; remove it. $string = substr( $string, 0, -1 ); @@ -1537,11 +1544,9 @@ class Language { $memcKey = wfMemcKey('localisation', $code ); $cache = $wgMemc->get( $memcKey ); if ( $cache ) { - $expired = false; # Check file modification times foreach ( $cache['deps'] as $file => $mtime ) { if ( !file_exists( $file ) || filemtime( $file ) > $mtime ) { - $expired = true; break; } } @@ -1701,7 +1706,7 @@ class Language { * Do any necessary post-cache-load settings adjustment */ function fixUpSettings() { - global $wgExtraNamespaces, $wgMetaNamespace, $wgMetaNamespaceTalk, $wgMessageCache, + global $wgExtraNamespaces, $wgMetaNamespace, $wgMetaNamespaceTalk, $wgNamespaceAliases, $wgAmericanDates; wfProfileIn( __METHOD__ ); if ( $wgExtraNamespaces ) { diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 316bcb12a2..4c0b5622e7 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -36,7 +36,6 @@ class LanguageConverter { $variantfallbacks=array(), $markup=array(), $flags = array()) { - global $wgLegalTitleChars; $this->mLangObj = $langobj; $this->mMainLanguageCode = $maincode; $this->mVariants = $variants; @@ -408,10 +407,11 @@ class LanguageConverter { $carray = $this->parseManualRule($rules, $flags); $disp = ''; - if(array_key_exists($plang, $carray)) + if(array_key_exists($plang, $carray)) { $disp = $carray[$plang]; - else if(array_key_exists($fallback, $carray)) + } else if(array_key_exists($fallback, $carray)) { $disp = $carray[$fallback]; + } } else{ // if we don't do content convert, still strip the -{}- tags $disp = $rules; @@ -621,7 +621,6 @@ class LanguageConverter { // not in cache, or we need a fresh reload. // we will first load the default tables // then update them using things in MediaWiki:Zhconversiontable/* - global $wgMessageCache; $this->loadDefaultTables(); foreach($this->mVariants as $var) { $cached = $this->parseCachedTable($var); diff --git a/languages/classes/LanguageKo.php b/languages/classes/LanguageKo.php index 55d2811763..b71b133b33 100644 --- a/languages/classes/LanguageKo.php +++ b/languages/classes/LanguageKo.php @@ -7,6 +7,7 @@ class LanguageKo extends Language { function firstChar( $s ) { + $matches = array(); preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/', $s, $matches); -- 2.20.1