r60650 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60649‎ | r60650 | r60651 >
Date:09:07, 5 January 2010
Author:mah
Status:ok (Comments)
Tags:
Comment:
Coding Convention cleanup, removed extraneous references to $_SERVER
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -9,27 +9,28 @@
1010 */
1111
1212 /**
13 - * base class for language convert
 13+ * Base class for language conversion.
1414 * @ingroup Language
1515 *
1616 * @author Zhengzhu Feng <zhengzhu@gmail.com>
1717 * @maintainers fdcn <fdcn64@gmail.com>, shinjiman <shinjiman@gmail.com>, PhiLiP <philip.npc@gmail.com>
1818 */
1919 class LanguageConverter {
20 - var $mPreferredVariant='';
 20+ var $mPreferredVariant = '';
2121 var $mMainLanguageCode;
2222 var $mVariants, $mVariantFallbacks, $mVariantNames;
2323 var $mTablesLoaded = false;
2424 var $mTables;
2525 var $mNamespaceTables;
26 - var $mDoTitleConvert=true, $mDoContentConvert=true;
27 - var $mManualLevel; // 'bidirectional' 'unidirectional' 'disable' for each variants
 26+ var $mDoTitleConvert = true, $mDoContentConvert = true;
 27+ // 'bidirectional' 'unidirectional' 'disable' for each variant
 28+ var $mManualLevel;
2829 var $mTitleFromFlag = false;
2930 var $mCacheKey;
3031 var $mLangObj;
3132 var $mMarkup;
3233 var $mFlags;
33 - var $mDescCodeSep = ':',$mDescVarSep = ';';
 34+ var $mDescCodeSep = ':', $mDescVarSep = ';';
3435 var $mUcfirst = false;
3536 var $mTitleOriginal = '';
3637 var $mTitleDisplay = '';
@@ -39,18 +40,20 @@
4041 /**
4142 * Constructor
4243 *
 44+ * @param $langobj The Language Object
4345 * @param string $maincode the main language code of this language
4446 * @param array $variants the supported variants of this language
4547 * @param array $variantfallback the fallback language of each variant
4648 * @param array $markup array defining the markup used for manual conversion
47 - * @param array $flags array defining the custom strings that maps to the flags
 49+ * @param array $flags array defining the custom strings that maps to the
 50+ * flags
4851 * @param array $manualLevel limit for supported variants
4952 * @public
5053 */
5154 function __construct( $langobj, $maincode,
52 - $variants=array(),
53 - $variantfallbacks=array(),
54 - $markup=array(),
 55+ $variants = array(),
 56+ $variantfallbacks = array(),
 57+ $markup = array(),
5558 $flags = array(),
5659 $manualLevel = array() ) {
5760 $this->mLangObj = $langobj;
@@ -58,41 +61,45 @@
5962
6063 global $wgDisabledVariants;
6164 $this->mVariants = array();
62 - foreach( $variants as $variant ) {
63 - if( !in_array( $variant, $wgDisabledVariants ) )
 65+ foreach ( $variants as $variant ) {
 66+ if ( !in_array( $variant, $wgDisabledVariants ) ) {
6467 $this->mVariants[] = $variant;
 68+ }
6569 }
6670 $this->mVariantFallbacks = $variantfallbacks;
6771 global $wgLanguageNames;
6872 $this->mVariantNames = $wgLanguageNames;
6973 $this->mCacheKey = wfMemcKey( 'conversiontables', $maincode );
7074 $m = array(
71 - 'begin'=>'-{',
72 - 'flagsep'=>'|',
73 - 'unidsep'=>'=>', //for unidirectional conversion
74 - 'codesep'=>':',
75 - 'varsep'=>';',
76 - 'end'=>'}-'
 75+ 'begin' => '-{',
 76+ 'flagsep' => '|',
 77+ 'unidsep' => '=>', // for unidirectional conversion
 78+ 'codesep' => ':',
 79+ 'varsep' => ';',
 80+ 'end' => '}-'
7781 );
78 - $this->mMarkup = array_merge($m, $markup);
79 - $f = array(
 82+ $this->mMarkup = array_merge( $m, $markup );
 83+ $f = array(
8084 // 'S' show converted text
8185 // '+' add rules for alltext
8286 // 'E' the gave flags is error
8387 // these flags above are reserved for program
84 - 'A'=>'A', // add rule for convert code (all text convert)
85 - 'T'=>'T', // title convert
86 - 'R'=>'R', // raw content
87 - 'D'=>'D', // convert description (subclass implement)
88 - '-'=>'-', // remove convert (not implement)
89 - 'H'=>'H', // add rule for convert code (but no display in placed code )
90 - 'N'=>'N' // current variant name
 88+ 'A' => 'A', // add rule for convert code (all text convert)
 89+ 'T' => 'T', // title convert
 90+ 'R' => 'R', // raw content
 91+ 'D' => 'D', // convert description (subclass implement)
 92+ '-' => '-', // remove convert (not implement)
 93+ 'H' => 'H', // add rule for convert code
 94+ // (but no display in placed code )
 95+ 'N' => 'N' // current variant name
9196 );
92 - $this->mFlags = array_merge($f, $flags);
93 - foreach( $this->mVariants as $v) {
94 - $this->mManualLevel[$v]=array_key_exists($v,$manualLevel)
95 - ?$manualLevel[$v]
96 - :'bidirectional';
 97+ $this->mFlags = array_merge( $f, $flags );
 98+ foreach ( $this->mVariants as $v ) {
 99+ if ( array_key_exists( $v, $manualLevel ) ) {
 100+ $this->mManualLevel[$v] = $manualLevel[$v];
 101+ } else {
 102+ $this->mManualLevel[$v] = 'bidirectional';
 103+ }
97104 $this->mNamespaceTables[$v] = array();
98105 $this->mFlags[$v] = $v;
99106 }
@@ -106,127 +113,128 @@
107114 }
108115
109116 /**
110 - * in case some variant is not defined in the markup, we need
111 - * to have some fallback. for example, in zh, normally people
 117+ * In case some variant is not defined in the markup, we need
 118+ * to have some fallback. For example, in zh, normally people
112119 * will define zh-hans and zh-hant, but less so for zh-sg or zh-hk.
113120 * when zh-sg is preferred but not defined, we will pick zh-hans
114 - * in this case. right now this is only used by zh.
 121+ * in this case. Right now this is only used by zh.
115122 *
116 - * @param string $v the language code of the variant
117 - * @return string array the code of the fallback language or false if there is no fallback
 123+ * @param string $v The language code of the variant
 124+ * @return string array The code of the fallback language or false if there
 125+ * is no fallback
118126 * @public
119127 */
120 - function getVariantFallbacks($v) {
121 - if( isset( $this->mVariantFallbacks[$v] ) ) {
 128+ function getVariantFallbacks( $v ) {
 129+ if ( isset( $this->mVariantFallbacks[$v] ) ) {
122130 return $this->mVariantFallbacks[$v];
123131 }
124132 return $this->mMainLanguageCode;
125133 }
126134
127135 /**
128 - * get preferred language variants.
 136+ * Get preferred language variants.
129137 * @param boolean $fromUser Get it from $wgUser's preferences
130138 * @param boolean $fromHeader Get it from Accept-Language
131139 * @return string the preferred language code
132140 * @public
133141 */
134142 function getPreferredVariant( $fromUser = true, $fromHeader = false ) {
135 - global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant, $wgOut;
 143+ global $wgUser, $wgRequest, $wgVariantArticlePath,
 144+ $wgDefaultLanguageVariant, $wgOut;
136145
137146 // bug 21974, don't return $this->mPreferredVariant if $fromUser = false
138 - if( $fromUser && $this->mPreferredVariant )
 147+ if ( $fromUser && $this->mPreferredVariant ) {
139148 return $this->mPreferredVariant;
 149+ }
140150
141 - // figure out user lang without constructing wgLang to avoid infinite recursion
142 - if( $fromUser )
 151+ // figure out user lang without constructing wgLang to avoid
 152+ // infinite recursion
 153+ if ( $fromUser ) {
143154 $defaultUserLang = $wgUser->getOption( 'language' );
144 - else
 155+ } else {
145156 $defaultUserLang = $this->mMainLanguageCode;
 157+ }
 158+
146159 $userLang = $wgRequest->getVal( 'uselang', $defaultUserLang );
147 - // see if interface language is same as content, if not, prevent conversion
148 - if( ! in_array( $userLang, $this->mVariants ) ){
149 - $this->mPreferredVariant = $this->mMainLanguageCode; // no conversion
 160+ // see if interface language is same as content, if not, prevent
 161+ // conversion
 162+
 163+ if ( ! in_array( $userLang, $this->mVariants ) ) {
 164+ // no conversion
 165+ $this->mPreferredVariant = $this->mMainLanguageCode;
150166 return $this->mPreferredVariant;
151167 }
152168
153169 // see if the preference is set in the request
154170 $req = $wgRequest->getText( 'variant' );
155 - if( in_array( $req, $this->mVariants ) ) {
 171+ if ( in_array( $req, $this->mVariants ) ) {
156172 $this->mPreferredVariant = $req;
157 - return $req;
 173+ return $this->mPreferredVariant;
158174 }
159175
160 - // check the syntax /code/ArticleTitle
161 - if($wgVariantArticlePath!=false && isset($_SERVER['SCRIPT_NAME'])){
162 - // Note: SCRIPT_NAME probably won't hold the correct value if PHP is run as CGI
163 - // (it will hold path to php.cgi binary), and might not exist on some very old PHP installations
164 - $scriptBase = basename( $_SERVER['SCRIPT_NAME'] );
165 - if(in_array($scriptBase,$this->mVariants)){
166 - $this->mPreferredVariant = $scriptBase;
167 - return $this->mPreferredVariant;
168 - }
169 - }
170 -
171176 // get language variant preference from logged in users
172177 // Don't call this on stub objects because that causes infinite
173178 // recursion during initialisation
174 - if( $fromUser && $wgUser->isLoggedIn() ) {
175 - $this->mPreferredVariant = $wgUser->getOption('variant');
 179+ if ( $fromUser && $wgUser->isLoggedIn() ) {
 180+ $this->mPreferredVariant = $wgUser->getOption( 'variant' );
176181 return $this->mPreferredVariant;
177182 }
178183
179184 // see if default variant is globaly set
180 - if($wgDefaultLanguageVariant != false && in_array( $wgDefaultLanguageVariant, $this->mVariants )){
 185+ if ( $wgDefaultLanguageVariant != false
 186+ && in_array( $wgDefaultLanguageVariant, $this->mVariants ) ) {
181187 $this->mPreferredVariant = $wgDefaultLanguageVariant;
182188 return $this->mPreferredVariant;
183189 }
184190
185 - if( !$this->mPreferredVariant ) {
 191+ if ( !$this->mPreferredVariant ) {
186192 // see if some supported language variant is set in the
187193 // http header, but we don't set the mPreferredVariant
188194 // variable in case this is called before the user's
189195 // preference is loaded
190 - if( $fromHeader && array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) {
191 - $acceptLanguage = strtolower( $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
 196+
 197+ $acceptLanguage = $wgRequest->getHeader( 'Accept-Language' );
 198+ if ( $fromHeader && $acceptLanguage ) {
192199 // explode by comma
193 - $result = explode(',', $acceptLanguage);
 200+ $result = explode( ',', strtolower( $acceptLanguage ) );
194201
195202 $languages = array();
196203
197 - foreach( $result as $elem ) {
 204+ foreach ( $result as $elem ) {
198205 // if $elem likes 'zh-cn;q=0.9'
199 - if(($posi = strpos( $elem, ';' )) !== false ) {
 206+ if ( ( $posi = strpos( $elem, ';' ) ) !== false ) {
200207 // get the real language code likes 'zh-cn'
201208 $languages[] = substr( $elem, 0, $posi );
202 - }
203 - else {
 209+ } else {
204210 $languages[] = $elem;
205211 }
206212 }
207213
208214 $fallback_languages = array();
209 - foreach( $languages as $language ) {
 215+ foreach ( $languages as $language ) {
210216 // strip whitespace
211217 $language = trim( $language );
212 - if( in_array( $language, $this->mVariants ) ) {
 218+ if ( in_array( $language, $this->mVariants ) ) {
213219 return $language;
214 - }
215 - else {
 220+ } else {
216221 // To see if there are fallbacks of current language.
217222 // We record these fallback variants, and process
218223 // them later.
219224 $fallbacks = $this->getVariantFallbacks( $language );
220 - if( is_string( $fallbacks ) )
 225+ if ( is_string( $fallbacks ) ) {
221226 $fallback_languages[] = $fallbacks;
222 - elseif( is_array( $fallbacks ) )
223 - $fallback_languages = array_merge( $fallback_languages, $fallbacks );
 227+ } elseif ( is_array( $fallbacks ) ) {
 228+ $fallback_languages =
 229+ array_merge( $fallback_languages,
 230+ $fallbacks );
 231+ }
224232 }
225233 }
226234
227235 // process fallback languages now
228236 $fallback_languages = array_unique( $fallback_languages );
229 - foreach( $fallback_languages as $language ) {
230 - if( in_array( $language, $this->mVariants ) ) {
 237+ foreach ( $fallback_languages as $language ) {
 238+ if ( in_array( $language, $this->mVariants ) ) {
231239 return $language;
232240 }
233241 }
@@ -236,9 +244,9 @@
237245 }
238246
239247 /**
240 - * caption convert, base on preg_replace_callback
 248+ * Caption convert, base on preg_replace_callback.
241249 *
242 - * to convert text in "title" or "alt", like '<img alt="text" ... '
 250+ * To convert text in "title" or "alt", like '<img alt="text" ... '
243251 * or '<span title="text" ... '
244252 *
245253 * @return string like ' alt="yyyy"' or ' title="yyyy"'
@@ -249,31 +257,35 @@
250258 $title = $matches[1];
251259 $text = $matches[2];
252260 // we convert captions except URL
253 - if( !strpos( $text, '://' ) )
254 - $text = $this->translate($text, $toVariant);
 261+ if ( !strpos( $text, '://' ) ) {
 262+ $text = $this->translate( $text, $toVariant );
 263+ }
255264 return " $title=\"$text\"";
256265 }
257266
258267 /**
259 - * dictionary-based conversion
 268+ * Dictionary-based conversion.
260269 *
261270 * @param string $text the text to be converted
262271 * @param string $toVariant the target language code
263272 * @return string the converted text
264273 * @private
265274 */
266 - function autoConvert($text, $toVariant=false) {
267 - $fname="LanguageConverter::autoConvert";
 275+ function autoConvert( $text, $toVariant = false ) {
 276+ $fname = 'LanguageConverter::autoConvert';
268277
269278 wfProfileIn( $fname );
270279
271 - if(!$this->mTablesLoaded)
 280+ if ( !$this->mTablesLoaded ) {
272281 $this->loadTables();
 282+ }
273283
274 - if(!$toVariant)
 284+ if ( !$toVariant ) {
275285 $toVariant = $this->getPreferredVariant();
276 - if(!in_array($toVariant, $this->mVariants))
 286+ }
 287+ if ( !in_array( $toVariant, $this->mVariants ) ) {
277288 return $text;
 289+ }
278290
279291 /* we convert everything except:
280292 1. html markups (anything between < and >)
@@ -281,10 +293,11 @@
282294 3. place holders created by the parser
283295 */
284296 global $wgParser;
285 - if (isset($wgParser) && $wgParser->UniqPrefix()!=''){
 297+ if ( isset( $wgParser ) && $wgParser->UniqPrefix() != '' ) {
286298 $marker = '|' . $wgParser->UniqPrefix() . '[\-a-zA-Z0-9]+';
287 - } else
288 - $marker = "";
 299+ } else {
 300+ $marker = '';
 301+ }
289302
290303 // this one is needed when the text is inside an html markup
291304 $htmlfix = '|<[^>]+$|^[^<>]*>';
@@ -296,35 +309,39 @@
297310 // disable conversion of <pre xxxx> ... </pre>
298311 $prefix = '<pre.*?>.*?<\/pre>|';
299312
300 - $reg = '/'.$codefix . $scriptfix . $prefix . '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s';
 313+ $reg = '/' . $codefix . $scriptfix . $prefix .
 314+ '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s';
301315
302 - $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
 316+ $matches = preg_split( $reg, $text, - 1, PREG_SPLIT_OFFSET_CAPTURE );
303317
304 - $m = array_shift($matches);
 318+ $m = array_shift( $matches );
305319
306 - $ret = $this->translate($m[0], $toVariant);
307 - $mstart = $m[1]+strlen($m[0]);
 320+ $ret = $this->translate( $m[0], $toVariant );
 321+ $mstart = $m[1] + strlen( $m[0] );
308322
309 - // enable convertsion of '<img alt="xxxx" ... ' or '<span title="xxxx" ... '
310 - $captionpattern = '/\s(title|alt)\s*=\s*"([\s\S]*?)"/';
 323+ // enable convertsion of '<img alt="xxxx" ... '
 324+ // or '<span title="xxxx" ... '
 325+ $captionpattern = '/\s(title|alt)\s*=\s*"([\s\S]*?)"/';
311326
312327 $trtext = '';
313328 $trtextmark = "\0";
314329 $notrtext = array();
315 - foreach($matches as $m) {
316 - $mark = substr($text, $mstart, $m[1]-$mstart);
317 - $mark = preg_replace_callback($captionpattern, array(&$this, 'captionConvert'), $mark);
 330+ foreach ( $matches as $m ) {
 331+ $mark = substr( $text, $mstart, $m[1] - $mstart );
 332+ $mark = preg_replace_callback( $captionpattern,
 333+ array( &$this, 'captionConvert' ),
 334+ $mark );
318335 // Let's convert the trtext only once,
319336 // it would give us more performance improvement
320337 $notrtext[] = $mark;
321338 $trtext .= $m[0] . $trtextmark;
322 - $mstart = $m[1] + strlen($m[0]);
 339+ $mstart = $m[1] + strlen( $m[0] );
323340 }
324341 $notrtext[] = '';
325342 $trtext = $this->translate( $trtext, $toVariant );
326343 $trtext = StringUtils::explode( $trtextmark, $trtext );
327 - foreach( $trtext as $t ) {
328 - $ret .= array_shift($notrtext);
 344+ foreach ( $trtext as $t ) {
 345+ $ret .= array_shift( $notrtext );
329346 $ret .= $t;
330347 }
331348 wfProfileOut( $fname );
@@ -332,8 +349,9 @@
333350 }
334351
335352 /**
336 - * Translate a string to a variant
337 - * Doesn't process markup or do any of that other stuff, for that use convert()
 353+ * Translate a string to a variant.
 354+ * Doesn't process markup or do any of that other stuff, for that use
 355+ * convert().
338356 *
339357 * @param string $text Text to convert
340358 * @param string $variant Variant language code
@@ -344,31 +362,33 @@
345363 wfProfileIn( __METHOD__ );
346364 // If $text is empty or only includes spaces, do nothing
347365 // Otherwise translate it
348 - if( trim($text) ) {
349 - if( !$this->mTablesLoaded )
 366+ if ( trim( $text ) ) {
 367+ if ( !$this->mTablesLoaded ) {
350368 $this->loadTables();
351 - $text = $this->mTables[$variant]->replace( $text );
 369+ }
 370+ $text = $this->mTables[$variant]->replace( $text );
352371 }
353372 wfProfileOut( __METHOD__ );
354373 return $text;
355374 }
356375
357376 /**
358 - * convert text to all supported variants
 377+ * Convert text to all supported variants.
359378 *
360379 * @param string $text the text to be converted
361380 * @return array of string
362381 * @public
363382 */
364 - function autoConvertToAllVariants($text) {
365 - $fname="LanguageConverter::autoConvertToAllVariants";
 383+ function autoConvertToAllVariants( $text ) {
 384+ $fname = 'LanguageConverter::autoConvertToAllVariants';
366385 wfProfileIn( $fname );
367 - if( !$this->mTablesLoaded )
 386+ if ( !$this->mTablesLoaded ) {
368387 $this->loadTables();
 388+ }
369389
370390 $ret = array();
371 - foreach($this->mVariants as $variant) {
372 - $ret[$variant] = $this->translate($text, $variant);
 391+ foreach ( $this->mVariants as $variant ) {
 392+ $ret[$variant] = $this->translate( $text, $variant );
373393 }
374394
375395 wfProfileOut( $fname );
@@ -376,30 +396,34 @@
377397 }
378398
379399 /**
380 - * convert link text to all supported variants
 400+ * Convert link text to all supported variants.
381401 *
382402 * @param string $text the text to be converted
383403 * @return array of string
384404 * @public
385405 */
386 - function convertLinkToAllVariants($text) {
387 - if( !$this->mTablesLoaded )
 406+ function convertLinkToAllVariants( $text ) {
 407+ if ( !$this->mTablesLoaded ) {
388408 $this->loadTables();
 409+ }
389410
390411 $ret = array();
391 - $tarray = explode($this->mMarkup['begin'], $text);
392 - $tfirst = array_shift($tarray);
 412+ $tarray = explode( $this->mMarkup['begin'], $text );
 413+ $tfirst = array_shift( $tarray );
393414
394 - foreach($this->mVariants as $variant)
395 - $ret[$variant] = $this->translate($tfirst,$variant);
 415+ foreach ( $this->mVariants as $variant ) {
 416+ $ret[$variant] = $this->translate( $tfirst, $variant );
 417+ }
396418
397 - foreach($tarray as $txt) {
398 - $marked = explode($this->mMarkup['end'], $txt, 2);
 419+ foreach ( $tarray as $txt ) {
 420+ $marked = explode( $this->mMarkup['end'], $txt, 2 );
399421
400 - foreach($this->mVariants as $variant){
401 - $ret[$variant] .= $this->mMarkup['begin'].$marked[0].$this->mMarkup['end'];
402 - if(array_key_exists(1, $marked))
403 - $ret[$variant] .= $this->translate($marked[1],$variant);
 422+ foreach ( $this->mVariants as $variant ) {
 423+ $ret[$variant] .= $this->mMarkup['begin'] . $marked[0] .
 424+ $this->mMarkup['end'];
 425+ if ( array_key_exists( 1, $marked ) ) {
 426+ $ret[$variant] .= $this->translate( $marked[1], $variant );
 427+ }
404428 }
405429
406430 }
@@ -408,52 +432,57 @@
409433 }
410434
411435 /**
412 - * prepare manual conversion table
 436+ * Prepare manual conversion table.
413437 * @private
414438 */
415 - function applyManualConv( $convRule ){
416 - // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
 439+ function applyManualConv( $convRule ) {
 440+ // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom
 441+ // conversion in title
417442 $title = $convRule->getTitle();
418 - if( $title ){
 443+ if ( $title ) {
419444 $this->mTitleFromFlag = true;
420 - $this->mTitleDisplay = $title;
 445+ $this->mTitleDisplay = $title;
421446 }
422447
423 - //apply manual conversion table to global table
 448+ // apply manual conversion table to global table
424449 $convTable = $convRule->getConvTable();
425450 $action = $convRule->getRulesAction();
426 - foreach( $convTable as $variant => $pair ) {
427 - if( !in_array( $variant, $this->mVariants ) )continue;
428 - if( $action == 'add' ) {
429 - foreach( $pair as $from => $to ) {
 451+ foreach ( $convTable as $variant => $pair ) {
 452+ if ( !in_array( $variant, $this->mVariants ) ) {
 453+ continue;
 454+ }
 455+
 456+ if ( $action == 'add' ) {
 457+ foreach ( $pair as $from => $to ) {
430458 // to ensure that $from and $to not be left blank
431459 // so $this->translate() could always return a string
432 - if ( $from || $to )
 460+ if ( $from || $to ) {
433461 // more efficient than array_merge(), about 2.5 times.
434462 $this->mTables[$variant]->setPair( $from, $to );
 463+ }
435464 }
436 - }
437 - elseif ( $action == 'remove' ) {
 465+ } elseif ( $action == 'remove' ) {
438466 $this->mTables[$variant]->removeArray( $pair );
439467 }
440468 }
441469 }
442470
443471 /**
444 - * Convert text using a parser object for context
 472+ * Convert text using a parser object for context.
445473 * @public
446474 */
447475 function parserConvert( $text, &$parser ) {
448476 global $wgDisableLangConversion;
449477 /* don't do anything if this is the conversion table */
450 - if ( $parser->getTitle()->getNamespace() == NS_MEDIAWIKI &&
451 - strpos($parser->mTitle->getText(), "Conversiontable") !== false )
452 - {
 478+ if ( $parser->getTitle()->getNamespace() == NS_MEDIAWIKI
 479+ && strpos( $parser->mTitle->getText(),
 480+ 'Conversiontable' ) !== false ) {
453481 return $text;
454482 }
455483
456 - if ( $wgDisableLangConversion )
 484+ if ( $wgDisableLangConversion ) {
457485 return $text;
 486+ }
458487
459488 $text = $this->convert( $text );
460489
@@ -464,18 +493,20 @@
465494 }
466495
467496 /**
468 - * convert namespace
 497+ * Convert namespace.
469498 * @param string $title the title included namespace
470499 * @return array of string
471500 * @private
472501 */
473502 function convertNamespace( $title, $variant ) {
474503 $splittitle = explode( ':', $title );
475 - if (count($splittitle) < 2)
 504+ if ( count( $splittitle ) < 2 ) {
476505 return $title;
477 - if ( isset( $this->mNamespaceTables[$variant][$splittitle[0]] ) )
 506+ }
 507+ if ( isset( $this->mNamespaceTables[$variant][$splittitle[0]] ) ) {
478508 $splittitle[0] = $this->mNamespaceTables[$variant][$splittitle[0]];
479 - $ret = implode(':', $splittitle );
 509+ }
 510+ $ret = implode( ':', $splittitle );
480511 return $ret;
481512 }
482513
@@ -484,7 +515,7 @@
485516 * store the default converted title to $this->mTitleDisplay.
486517 * @private
487518 */
488 - function preConvertTitle( $text, $variant ){
 519+ function preConvertTitle( $text, $variant ) {
489520 $this->mTitleOriginal = $text;
490521
491522 $text = $this->convertNamespace( $text, $variant );
@@ -492,34 +523,34 @@
493524 }
494525
495526 /**
496 - * convert title
 527+ * Convert title.
497528 * @private
498529 */
499 - function convertTitle(){
 530+ function convertTitle() {
500531 global $wgDisableTitleConversion, $wgUser, $wgRequest;
501532 $isredir = $wgRequest->getText( 'redirect', 'yes' );
502533 $action = $wgRequest->getText( 'action' );
503534 $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
504535
505536 // check for the global variable, __NOTC__ magic word, and user setting
506 - if( $wgDisableTitleConversion || !$this->mDoTitleConvert ||
507 - $wgUser->getOption('noconvertlink') == 1 ) {
 537+ if ( $wgDisableTitleConversion || !$this->mDoTitleConvert ||
 538+ $wgUser->getOption( 'noconvertlink' ) == 1 ) {
508539 $this->mTitleDisplay = $this->mTitleOriginal;
509 - }
510 -
511 - // check for GET params
512 - elseif ( $isredir == 'no' || $action == 'edit' || $linkconvert == 'no' ) {
 540+ } elseif ( $isredir == 'no'
 541+ || $action == 'edit'
 542+ || $linkconvert == 'no' ) {
 543+ // check for GET params
513544 $this->mTitleDisplay = $this->mTitleOriginal;
514545 }
515546 }
516547
517548 /**
518 - * convert text to different variants of a language. the automatic
519 - * conversion is done in autoConvert(). here we parse the text
 549+ * Convert text to different variants of a language. The automatic
 550+ * conversion is done in autoConvert(). Here we parse the text
520551 * marked with -{}-, which specifies special conversions of the
521 - * text that can not be accomplished in autoConvert()
 552+ * text that can not be accomplished in autoConvert().
522553 *
523 - * syntax of the markup:
 554+ * Syntax of the markup:
524555 * -{code1:text1;code2:text2;...}- or
525556 * -{flags|code1:text1;code2:text2;...}- or
526557 * -{text}- in which case no conversion should take place for text
@@ -532,17 +563,19 @@
533564 function convert( $text, $isTitle = false ) {
534565
535566 $mw =& MagicWord::get( 'notitleconvert' );
536 - if( $mw->matchAndRemove( $text ) )
 567+ if ( $mw->matchAndRemove( $text ) ) {
537568 $this->mDoTitleConvert = false;
 569+ }
538570 $mw =& MagicWord::get( 'nocontentconvert' );
539 - if( $mw->matchAndRemove( $text ) ) {
 571+ if ( $mw->matchAndRemove( $text ) ) {
540572 $this->mDoContentConvert = false;
541573 }
542574
543575 // no conversion if redirecting
544576 $mw =& MagicWord::get( 'redirect' );
545 - if( $mw->matchStart( $text ) )
 577+ if ( $mw->matchStart( $text ) ) {
546578 return $text;
 579+ }
547580
548581 $plang = $this->getPreferredVariant();
549582
@@ -559,75 +592,87 @@
560593
561594 $marked = explode( $this->mMarkup['begin'], $txt, 2 );
562595
563 - if( $this->mDoContentConvert )
564 - // Bug 19620: should convert a string immediately after a new rule added.
 596+ if ( $this->mDoContentConvert ) {
 597+ // Bug 19620: should convert a string immediately after a
 598+ // new rule added.
565599 $text .= $this->autoConvert( $marked[0], $plang );
566 - else
 600+ } else {
567601 $text .= $marked[0];
 602+ }
568603
569604 if ( array_key_exists( 1, $marked ) ) {
570 - $crule = new ConverterRule($marked[1], $this);
 605+ $crule = new ConverterRule( $marked[1], $this );
571606 $crule->parse( $plang );
572607 $text .= $crule->getDisplay();
573608 $this->applyManualConv( $crule );
 609+ } else {
 610+ $text .= $this->mMarkup['end'];
574611 }
575 - else
576 - $text .= $this->mMarkup['end'];
577 -
578612 }
579613
580614 // Remove the last delimiter (wasn't real)
581 - $text = substr( $text, 0, -strlen( $this->mMarkup['end'] ) );
 615+ $text = substr( $text, 0, - strlen( $this->mMarkup['end'] ) );
582616 return $text;
583617 }
584618
585619 /**
586 - * if a language supports multiple variants, it is
 620+ * If a language supports multiple variants, it is
587621 * possible that non-existing link in one variant
588 - * actually exists in another variant. this function
 622+ * actually exists in another variant. This function
589623 * tries to find it. See e.g. LanguageZh.php
590624 *
591625 * @param string $link the name of the link
592626 * @param mixed $nt the title object of the link
593627 * @param boolean $ignoreOtherCond: to disable other conditions when
594 - * we need to transclude a template or update a category's link
 628+ * we need to transclude a template or update a category's link
595629 * @return null the input parameters may be modified upon return
596630 * @public
597631 */
598632 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
599633 # If the article has already existed, there is no need to
600634 # check it again, otherwise it may cause a fault.
601 - if ( is_object( $nt ) && $nt->exists() )
 635+ if ( is_object( $nt ) && $nt->exists() ) {
602636 return;
 637+ }
603638
604 - global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser;
 639+ global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest,
 640+ $wgUser;
605641 $isredir = $wgRequest->getText( 'redirect', 'yes' );
606642 $action = $wgRequest->getText( 'action' );
607643 $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
608 - $disableLinkConversion = $wgDisableLangConversion || $wgDisableTitleConversion;
 644+ $disableLinkConversion = $wgDisableLangConversion
 645+ || $wgDisableTitleConversion;
609646 $linkBatch = new LinkBatch();
610647
611 - $ns=NS_MAIN;
 648+ $ns = NS_MAIN;
612649
613 - if ( $disableLinkConversion || ( !$ignoreOtherCond && ( $isredir == 'no' || $action == 'edit'
614 - || $action == 'submit' || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) ) )
 650+ if ( $disableLinkConversion ||
 651+ ( !$ignoreOtherCond &&
 652+ ( $isredir == 'no'
 653+ || $action == 'edit'
 654+ || $action == 'submit'
 655+ || $linkconvert == 'no'
 656+ || $wgUser->getOption( 'noconvertlink' ) == 1 ) ) ) {
615657 return;
 658+ }
616659
617 - if ( is_object( $nt ) )
 660+ if ( is_object( $nt ) ) {
618661 $ns = $nt->getNamespace();
 662+ }
619663
620 - $variants = $this->autoConvertToAllVariants($link);
621 - if($variants == false) //give up
 664+ $variants = $this->autoConvertToAllVariants( $link );
 665+ if ( $variants == false ) { // give up
622666 return;
 667+ }
623668
624669 $titles = array();
625670
626 - foreach( $variants as $v ) {
627 - if($v != $link){
 671+ foreach ( $variants as $v ) {
 672+ if ( $v != $link ) {
628673 $varnt = Title::newFromText( $v, $ns );
629 - if(!is_null($varnt)){
630 - $linkBatch->addObj($varnt);
631 - $titles[]=$varnt;
 674+ if ( !is_null( $varnt ) ) {
 675+ $linkBatch->addObj( $varnt );
 676+ $titles[] = $varnt;
632677 }
633678 }
634679 }
@@ -635,8 +680,8 @@
636681 // fetch all variants in single query
637682 $linkBatch->execute();
638683
639 - foreach( $titles as $varnt ) {
640 - if( $varnt->getArticleID() > 0 ) {
 684+ foreach ( $titles as $varnt ) {
 685+ if ( $varnt->getArticleID() > 0 ) {
641686 $nt = $varnt;
642687 $link = $varnt->getText();
643688 break;
@@ -645,7 +690,7 @@
646691 }
647692
648693 /**
649 - * returns language specific hash options
 694+ * Returns language specific hash options.
650695 *
651696 * @public
652697 */
@@ -655,7 +700,7 @@
656701 }
657702
658703 /**
659 - * get title text as defined in the body of the article text
 704+ * Get title text as defined in the body of the article text.
660705 *
661706 * @public
662707 */
@@ -664,103 +709,109 @@
665710 }
666711
667712 /**
668 - * Load default conversion tables
669 - * This method must be implemented in derived class
 713+ * Load default conversion tables.
 714+ * This method must be implemented in derived class.
670715 *
671716 * @private
672717 */
673718 function loadDefaultTables() {
674 - $name = get_class($this);
675 - wfDie("Must implement loadDefaultTables() method in class $name");
 719+ $name = get_class( $this );
 720+ wfDie( "Must implement loadDefaultTables() method in class $name" );
676721 }
677722
678723 /**
679 - * load conversion tables either from the cache or the disk
 724+ * Load conversion tables either from the cache or the disk.
680725 * @private
681726 */
682 - function loadTables($fromcache=true) {
 727+ function loadTables( $fromcache = true ) {
683728 global $wgMemc;
684 - if( $this->mTablesLoaded )
 729+ if ( $this->mTablesLoaded ) {
685730 return;
 731+ }
686732 wfProfileIn( __METHOD__ );
687733 $this->mTablesLoaded = true;
688734 $this->mTables = false;
689 - if($fromcache) {
690 - wfProfileIn( __METHOD__.'-cache' );
 735+ if ( $fromcache ) {
 736+ wfProfileIn( __METHOD__ . '-cache' );
691737 $this->mTables = $wgMemc->get( $this->mCacheKey );
692 - wfProfileOut( __METHOD__.'-cache' );
 738+ wfProfileOut( __METHOD__ . '-cache' );
693739 }
694 - if ( !$this->mTables || !isset( $this->mTables[self::CACHE_VERSION_KEY] ) ) {
695 - wfProfileIn( __METHOD__.'-recache' );
 740+ if ( !$this->mTables
 741+ || !isset( $this->mTables[self::CACHE_VERSION_KEY] ) ) {
 742+ wfProfileIn( __METHOD__ . '-recache' );
696743 // not in cache, or we need a fresh reload.
697744 // we will first load the default tables
698745 // then update them using things in MediaWiki:Zhconversiontable/*
699746 $this->loadDefaultTables();
700 - foreach($this->mVariants as $var) {
701 - $cached = $this->parseCachedTable($var);
702 - $this->mTables[$var]->mergeArray($cached);
 747+ foreach ( $this->mVariants as $var ) {
 748+ $cached = $this->parseCachedTable( $var );
 749+ $this->mTables[$var]->mergeArray( $cached );
703750 }
704751
705752 $this->postLoadTables();
706753 $this->mTables[self::CACHE_VERSION_KEY] = true;
707754
708 - $wgMemc->set($this->mCacheKey, $this->mTables, 43200);
709 - wfProfileOut( __METHOD__.'-recache' );
 755+ $wgMemc->set( $this->mCacheKey, $this->mTables, 43200 );
 756+ wfProfileOut( __METHOD__ . '-recache' );
710757 }
711758 wfProfileOut( __METHOD__ );
712759 }
713760
714761 /**
715 - * Hook for post processig after conversion tables are loaded
 762+ * Hook for post processig after conversion tables are loaded.
716763 *
717764 */
718 - function postLoadTables() {}
 765+ function postLoadTables() { }
719766
720767 /**
721 - * Reload the conversion tables
 768+ * Reload the conversion tables.
722769 *
723770 * @private
724771 */
725772 function reloadTables() {
726 - if($this->mTables)
727 - unset($this->mTables);
 773+ if ( $this->mTables ) {
 774+ unset( $this->mTables );
 775+ }
728776 $this->mTablesLoaded = false;
729 - $this->loadTables(false);
 777+ $this->loadTables( false );
730778 }
731779
732780
733781 /**
734 - * parse the conversion table stored in the cache
 782+ * Parse the conversion table stored in the cache.
735783 *
736 - * the tables should be in blocks of the following form:
 784+ * The tables should be in blocks of the following form:
737785 * -{
738786 * word => word ;
739787 * word => word ;
740788 * ...
741789 * }-
742790 *
743 - * to make the tables more manageable, subpages are allowed
744 - * and will be parsed recursively if $recursive=true
 791+ * To make the tables more manageable, subpages are allowed
 792+ * and will be parsed recursively if $recursive == true.
745793 *
746794 */
747 - function parseCachedTable($code, $subpage='', $recursive=true) {
 795+ function parseCachedTable( $code, $subpage = '', $recursive = true ) {
748796 global $wgMessageCache;
749797 static $parsed = array();
750798
751 - if(!is_object($wgMessageCache))
 799+ if ( !is_object( $wgMessageCache ) ) {
752800 return array();
 801+ }
753802
754 - $key = 'Conversiontable/'.$code;
755 - if($subpage)
 803+ $key = 'Conversiontable/' . $code;
 804+ if ( $subpage ) {
756805 $key .= '/' . $subpage;
757 -
758 - if(array_key_exists($key, $parsed))
 806+ }
 807+ if ( array_key_exists( $key, $parsed ) ) {
759808 return array();
 809+ }
760810
761811 if ( strpos( $code, '/' ) === false ) {
762812 $txt = $wgMessageCache->get( 'Conversiontable', true, $code );
763813 } else {
764 - $title = Title::makeTitleSafe( NS_MEDIAWIKI, "Conversiontable/$code" );
 814+ $title = Title::makeTitleSafe( NS_MEDIAWIKI,
 815+ "Conversiontable/$code" );
765816 if ( $title && $title->exists() ) {
766817 $article = new Article( $title );
767818 $txt = $article->getContents();
@@ -771,57 +822,61 @@
772823
773824 // get all subpage links of the form
774825 // [[MediaWiki:conversiontable/zh-xx/...|...]]
775 - $linkhead = $this->mLangObj->getNsText(NS_MEDIAWIKI) . ':Conversiontable';
776 - $subs = explode('[[', $txt);
 826+ $linkhead = $this->mLangObj->getNsText( NS_MEDIAWIKI ) .
 827+ ':Conversiontable';
 828+ $subs = explode( '[[', $txt );
777829 $sublinks = array();
778 - foreach( $subs as $sub ) {
779 - $link = explode(']]', $sub, 2);
780 - if(count($link) != 2)
 830+ foreach ( $subs as $sub ) {
 831+ $link = explode( ']]', $sub, 2 );
 832+ if ( count( $link ) != 2 ) {
781833 continue;
782 - $b = explode('|', $link[0]);
783 - $b = explode('/', trim($b[0]), 3);
784 - if(count($b)==3)
 834+ }
 835+ $b = explode( '|', $link[0] );
 836+ $b = explode( '/', trim( $b[0] ), 3 );
 837+ if ( count( $b ) == 3 ) {
785838 $sublink = $b[2];
786 - else
 839+ } else {
787840 $sublink = '';
 841+ }
788842
789 - if($b[0] == $linkhead && $b[1] == $code) {
 843+ if ( $b[0] == $linkhead && $b[1] == $code ) {
790844 $sublinks[] = $sublink;
791845 }
792846 }
793847
794848
795849 // parse the mappings in this page
796 - $blocks = explode($this->mMarkup['begin'], $txt);
797 - array_shift($blocks);
 850+ $blocks = explode( $this->mMarkup['begin'], $txt );
 851+ array_shift( $blocks );
798852 $ret = array();
799 - foreach($blocks as $block) {
800 - $mappings = explode($this->mMarkup['end'], $block, 2);
801 - $stripped = str_replace(array("'", '"', '*','#'), '', $mappings[0]);
 853+ foreach ( $blocks as $block ) {
 854+ $mappings = explode( $this->mMarkup['end'], $block, 2 );
 855+ $stripped = str_replace( array( "'", '"', '*', '#' ), '',
 856+ $mappings[0] );
802857 $table = explode( ';', $stripped );
803 - foreach( $table as $t ) {
 858+ foreach ( $table as $t ) {
804859 $m = explode( '=>', $t );
805 - if( count( $m ) != 2)
 860+ if ( count( $m ) != 2 )
806861 continue;
807862 // trim any trailling comments starting with '//'
808 - $tt = explode('//', $m[1], 2);
809 - $ret[trim($m[0])] = trim($tt[0]);
 863+ $tt = explode( '//', $m[1], 2 );
 864+ $ret[trim( $m[0] )] = trim( $tt[0] );
810865 }
811866 }
812867 $parsed[$key] = true;
813868
814869
815870 // recursively parse the subpages
816 - if($recursive) {
817 - foreach($sublinks as $link) {
818 - $s = $this->parseCachedTable($code, $link, $recursive);
819 - $ret = array_merge($ret, $s);
 871+ if ( $recursive ) {
 872+ foreach ( $sublinks as $link ) {
 873+ $s = $this->parseCachedTable( $code, $link, $recursive );
 874+ $ret = array_merge( $ret, $s );
820875 }
821876 }
822877
823 - if ($this->mUcfirst) {
824 - foreach ($ret as $k => $v) {
825 - $ret[Language::ucfirst($k)] = Language::ucfirst($v);
 878+ if ( $this->mUcfirst ) {
 879+ foreach ( $ret as $k => $v ) {
 880+ $ret[Language::ucfirst( $k )] = Language::ucfirst( $v );
826881 }
827882 }
828883 return $ret;
@@ -829,42 +884,45 @@
830885
831886 /**
832887 * Enclose a string with the "no conversion" tag. This is used by
833 - * various functions in the Parser
 888+ * various functions in the Parser.
834889 *
835890 * @param string $text text to be tagged for no conversion
836891 * @return string the tagged text
837892 * @public
838893 */
839 - function markNoConversion($text, $noParse=false) {
 894+ function markNoConversion( $text, $noParse = false ) {
840895 # don't mark if already marked
841 - if(strpos($text, $this->mMarkup['begin']) ||
842 - strpos($text, $this->mMarkup['end']))
 896+ if ( strpos( $text, $this->mMarkup['begin'] )
 897+ || strpos( $text, $this->mMarkup['end'] ) ) {
843898 return $text;
 899+ }
844900
845 - $ret = $this->mMarkup['begin'] .'R|'. $text . $this->mMarkup['end'];
 901+ $ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end'];
846902 return $ret;
847903 }
848904
849905 /**
850 - * convert the sorting key for category links. this should make different
851 - * keys that are variants of each other map to the same key
 906+ * Convert the sorting key for category links. This should make different
 907+ * keys that are variants of each other map to the same key.
852908 */
853909 function convertCategoryKey( $key ) {
854910 return $key;
855911 }
 912+
856913 /**
857 - * hook to refresh the cache of conversion tables when
858 - * MediaWiki:conversiontable* is updated
 914+ * Hook to refresh the cache of conversion tables when
 915+ * MediaWiki:conversiontable* is updated.
859916 * @private
860917 */
861 - function OnArticleSaveComplete($article, $user, $text, $summary, $isminor, $iswatch, $section, $flags, $revision) {
 918+ function OnArticleSaveComplete( $article, $user, $text, $summary, $isminor,
 919+ $iswatch, $section, $flags, $revision ) {
862920 $titleobj = $article->getTitle();
863 - if($titleobj->getNamespace() == NS_MEDIAWIKI) {
 921+ if ( $titleobj->getNamespace() == NS_MEDIAWIKI ) {
864922 $title = $titleobj->getDBkey();
865 - $t = explode('/', $title, 3);
866 - $c = count($t);
867 - if( $c > 1 && $t[0] == 'Conversiontable' ) {
868 - if(in_array($t[1], $this->mVariants)) {
 923+ $t = explode( '/', $title, 3 );
 924+ $c = count( $t );
 925+ if ( $c > 1 && $t[0] == 'Conversiontable' ) {
 926+ if ( in_array( $t[1], $this->mVariants ) ) {
869927 $this->reloadTables();
870928 }
871929 }
@@ -873,21 +931,21 @@
874932 }
875933
876934 /**
877 - * Armour rendered math against conversion
878 - * Wrap math into rawoutput -{R| math }- syntax
 935+ * Armour rendered math against conversion.
 936+ * Wrap math into rawoutput -{R| math }- syntax.
879937 * @public
880938 */
881 - function armourMath($text){
882 - // we need to convert '-{' and '}-' to '-&#123;' and '&#125;-'
883 - // to avoid a unwanted '}-' appeared after the math-image.
884 - $text = strtr( $text, array('-{' => '-&#123;', '}-' => '&#125;-') );
 939+ function armourMath( $text ) {
 940+ // we need to convert '-{' and '}-' to '-&#123;' and '&#125;-'
 941+ // to avoid a unwanted '}-' appeared after the math-image.
 942+ $text = strtr( $text, array( '-{' => '-&#123;', '}-' => '&#125;-' ) );
885943 $ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end'];
886944 return $ret;
887945 }
888946 }
889947
890948 /**
891 - * parser for rules of language conversion , parse rules in -{ }- tag
 949+ * Parser for rules of language conversion , parse rules in -{ }- tag.
892950 * @ingroup Language
893951 * @author fdcn <fdcn64@gmail.com>, PhiLiP <philip.npc@gmail.com>
894952 */
@@ -911,26 +969,30 @@
912970 * @param object $converter a LanguageConverter object
913971 * @access public
914972 */
915 - function __construct( $text, $converter ){
 973+ function __construct( $text, $converter ) {
916974 $this->mText = $text;
917975 $this->mConverter = $converter;
918 - foreach( $converter->mVariants as $v ){
 976+ foreach ( $converter->mVariants as $v ) {
919977 $this->mConvTable[$v] = array();
920978 }
921979 }
922980
923981 /**
924 - * check if variants array in convert array
 982+ * Check if variants array in convert array.
925983 *
926984 * @param string $variant Variant language code
927985 * @return string Translated text
928986 * @public
929987 */
930 - function getTextInBidtable( $variants ){
931 - if( is_string( $variants ) ){ $variants = array( $variants ); }
932 - if( !is_array( $variants ) ) return false;
933 - foreach( $variants as $variant ){
934 - if( array_key_exists( $variant, $this->mBidtable ) ){
 988+ function getTextInBidtable( $variants ) {
 989+ if ( is_string( $variants ) ) {
 990+ $variants = array( $variants );
 991+ }
 992+ if ( !is_array( $variants ) ) {
 993+ return false;
 994+ }
 995+ foreach ( $variants as $variant ) {
 996+ if ( array_key_exists( $variant, $this->mBidtable ) ) {
935997 return $this->mBidtable[$variant];
936998 }
937999 }
@@ -941,9 +1003,9 @@
9421004 * Parse flags with syntax -{FLAG| ... }-
9431005 * @private
9441006 */
945 - function parseFlags(){
 1007+ function parseFlags() {
9461008 $text = $this->mText;
947 - if(strlen($text) < 2 ) {
 1009+ if ( strlen( $text ) < 2 ) {
9481010 $this->mFlags = array( 'R' );
9491011 $this->mRules = $text;
9501012 return;
@@ -954,60 +1016,68 @@
9551017 $validFlags = $this->mConverter->mFlags;
9561018 $variants = $this->mConverter->mVariants;
9571019
958 - $tt = explode($markup['flagsep'], $text, 2);
959 - if(count($tt) == 2) {
960 - $f = explode($markup['varsep'], $tt[0]);
961 - foreach($f as $ff) {
962 - $ff = trim($ff);
963 - if(array_key_exists($ff, $validFlags) &&
964 - !in_array($validFlags[$ff], $flags))
 1020+ $tt = explode( $markup['flagsep'], $text, 2 );
 1021+ if ( count( $tt ) == 2 ) {
 1022+ $f = explode( $markup['varsep'], $tt[0] );
 1023+ foreach ( $f as $ff ) {
 1024+ $ff = trim( $ff );
 1025+ if ( array_key_exists( $ff, $validFlags )
 1026+ && !in_array( $validFlags[$ff], $flags ) ) {
9651027 $flags[] = $validFlags[$ff];
 1028+ }
9661029 }
9671030 $rules = $tt[1];
9681031 } else {
9691032 $rules = $text;
9701033 }
9711034
972 - //check flags
973 - if( in_array('R',$flags) ){
974 - $flags = array('R');// remove other flags
975 - } elseif ( in_array('N',$flags) ){
976 - $flags = array('N');// remove other flags
977 - } elseif ( in_array('-',$flags) ){
978 - $flags = array('-');// remove other flags
979 - } elseif (count($flags)==1 && $flags[0]=='T'){
980 - $flags[]='H';
981 - } elseif ( in_array('H',$flags) ){
 1035+ // check flags
 1036+ if ( in_array( 'R', $flags ) ) {
 1037+ $flags = array( 'R' );// remove other flags
 1038+ } elseif ( in_array( 'N', $flags ) ) {
 1039+ $flags = array( 'N' );// remove other flags
 1040+ } elseif ( in_array( '-', $flags ) ) {
 1041+ $flags = array( '-' );// remove other flags
 1042+ } elseif ( count( $flags ) == 1 && $flags[0] == 'T' ) {
 1043+ $flags[] = 'H';
 1044+ } elseif ( in_array( 'H', $flags ) ) {
9821045 // replace A flag, and remove other flags except T
983 - $temp=array('+','H');
984 - if(in_array('T',$flags)) $temp[] = 'T';
985 - if(in_array('D',$flags)) $temp[] = 'D';
 1046+ $temp = array( '+', 'H' );
 1047+ if ( in_array( 'T', $flags ) ) {
 1048+ $temp[] = 'T';
 1049+ }
 1050+ if ( in_array( 'D', $flags ) ) {
 1051+ $temp[] = 'D';
 1052+ }
9861053 $flags = $temp;
9871054 } else {
988 - if ( in_array('A',$flags) ) {
989 - $flags[]='+';
990 - $flags[]='S';
 1055+ if ( in_array( 'A', $flags ) ) {
 1056+ $flags[] = '+';
 1057+ $flags[] = 'S';
9911058 }
992 - if ( in_array('D',$flags) )
993 - $flags=array_diff($flags,array('S'));
 1059+ if ( in_array( 'D', $flags ) ) {
 1060+ $flags = array_diff( $flags, array( 'S' ) );
 1061+ }
9941062 $flags_temp = array();
995 - foreach ($variants as $variant) {
 1063+ foreach ( $variants as $variant ) {
9961064 // try to find flags like "zh-hans", "zh-hant"
9971065 // allow syntaxes like "-{zh-hans;zh-hant|XXXX}-"
998 - if ( in_array($variant, $flags) )
 1066+ if ( in_array( $variant, $flags ) )
9991067 $flags_temp[] = $variant;
10001068 }
1001 - if ( count($flags_temp) !== 0 )
 1069+ if ( count( $flags_temp ) !== 0 ) {
10021070 $flags = $flags_temp;
 1071+ }
10031072 }
1004 - if ( count($flags) == 0 )
1005 - $flags = array('S');
1006 - $this->mRules=$rules;
1007 - $this->mFlags=$flags;
 1073+ if ( count( $flags ) == 0 ) {
 1074+ $flags = array( 'S' );
 1075+ }
 1076+ $this->mRules = $rules;
 1077+ $this->mFlags = $flags;
10081078 }
10091079
10101080 /**
1011 - * generate conversion table
 1081+ * Generate conversion table.
10121082 * @private
10131083 */
10141084 function parseRules() {
@@ -1021,44 +1091,52 @@
10221092 // varsep_pattern for preg_split:
10231093 // text should be splited by ";" only if a valid variant
10241094 // name exist after the markup, for example:
1025 - // -{zh-hans:<span style="font-size:120%;">xxx</span>;zh-hant:<span style="font-size:120%;">yyy</span>;}-
 1095+ // -{zh-hans:<span style="font-size:120%;">xxx</span>;zh-hant:\
 1096+ // <span style="font-size:120%;">yyy</span>;}-
10261097 // we should split it as:
10271098 // array(
1028 - // [0] => 'zh-hans:<span style="font-size:120%;">xxx</span>'
1029 - // [1] => 'zh-hant:<span style="font-size:120%;">yyy</span>'
1030 - // [2] => ''
1031 - // )
 1099+ // [0] => 'zh-hans:<span style="font-size:120%;">xxx</span>'
 1100+ // [1] => 'zh-hant:<span style="font-size:120%;">yyy</span>'
 1101+ // [2] => ''
 1102+ // )
10321103 $varsep_pattern = '/' . $markup['varsep'] . '\s*' . '(?=';
1033 - foreach( $variants as $variant ) {
1034 - $varsep_pattern .= $variant . '\s*' . $markup['codesep'] . '|'; // zh-hans:xxx;zh-hant:yyy
 1104+ foreach ( $variants as $variant ) {
 1105+ // zh-hans:xxx;zh-hant:yyy
 1106+ $varsep_pattern .= $variant . '\s*' . $markup['codesep'] . '|';
 1107+ // xxx=>zh-hans:yyy; xxx=>zh-hant:zzz
10351108 $varsep_pattern .= '[^;]*?' . $markup['unidsep'] . '\s*' . $variant
1036 - . '\s*' . $markup['codesep'] . '|'; // xxx=>zh-hans:yyy; xxx=>zh-hant:zzz
 1109+ . '\s*' . $markup['codesep'] . '|';
10371110 }
10381111 $varsep_pattern .= '\s*$)/';
10391112
1040 - $choice = preg_split($varsep_pattern, $rules);
 1113+ $choice = preg_split( $varsep_pattern, $rules );
10411114
1042 - foreach( $choice as $c ) {
1043 - $v = explode($markup['codesep'], $c, 2);
1044 - if( count($v) != 2 )
1045 - continue;// syntax error, skip
1046 - $to = trim($v[1]);
1047 - $v = trim($v[0]);
1048 - $u = explode($markup['unidsep'], $v, 2);
 1115+ foreach ( $choice as $c ) {
 1116+ $v = explode( $markup['codesep'], $c, 2 );
 1117+ if ( count( $v ) != 2 ) {
 1118+ // syntax error, skip
 1119+ continue;
 1120+ }
 1121+ $to = trim( $v[1] );
 1122+ $v = trim( $v[0] );
 1123+ $u = explode( $markup['unidsep'], $v, 2 );
10491124 // if $to is empty, strtr() could return a wrong result
1050 - if( count($u) == 1 && $to && in_array( $v, $variants ) ) {
 1125+ if ( count( $u ) == 1 && $to && in_array( $v, $variants ) ) {
10511126 $bidtable[$v] = $to;
1052 - } else if(count($u) == 2){
1053 - $from = trim($u[0]);
1054 - $v = trim($u[1]);
1055 - if( array_key_exists( $v, $unidtable ) && !is_array( $unidtable[$v] )
1056 - && $to && in_array( $v, $variants ) )
1057 - $unidtable[$v] = array( $from=>$to );
1058 - elseif ( $to && in_array( $v, $variants ) )
 1127+ } elseif ( count( $u ) == 2 ) {
 1128+ $from = trim( $u[0] );
 1129+ $v = trim( $u[1] );
 1130+ if ( array_key_exists( $v, $unidtable )
 1131+ && !is_array( $unidtable[$v] )
 1132+ && $to
 1133+ && in_array( $v, $variants ) ) {
 1134+ $unidtable[$v] = array( $from => $to );
 1135+ } elseif ( $to && in_array( $v, $variants ) ) {
10591136 $unidtable[$v][$from] = $to;
 1137+ }
10601138 }
10611139 // syntax error, pass
1062 - if ( !array_key_exists( $v, $this->mConverter->mVariantNames ) ){
 1140+ if ( !array_key_exists( $v, $this->mConverter->mVariantNames ) ) {
10631141 $bidtable = array();
10641142 $unidtable = array();
10651143 break;
@@ -1071,111 +1149,121 @@
10721150 /**
10731151 * @private
10741152 */
1075 - function getRulesDesc(){
 1153+ function getRulesDesc() {
10761154 $codesep = $this->mConverter->mDescCodeSep;
10771155 $varsep = $this->mConverter->mDescVarSep;
1078 - $text='';
1079 - foreach($this->mBidtable as $k => $v)
1080 - $text .= $this->mConverter->mVariantNames[$k]."$codesep$v$varsep";
1081 - foreach($this->mUnidtable as $k => $a)
1082 - foreach($a as $from=>$to)
1083 - $text.=$from.'⇒'.$this->mConverter->mVariantNames[$k]."$codesep$to$varsep";
 1156+ $text = '';
 1157+ foreach ( $this->mBidtable as $k => $v ) {
 1158+ $text .= $this->mConverter->mVariantNames[$k] . "$codesep$v$varsep";
 1159+ }
 1160+ foreach ( $this->mUnidtable as $k => $a ) {
 1161+ foreach ( $a as $from => $to ) {
 1162+ $text .= $from . '⇒' . $this->mConverter->mVariantNames[$k] .
 1163+ "$codesep$to$varsep";
 1164+ }
 1165+ }
10841166 return $text;
10851167 }
10861168
10871169 /**
1088 - * Parse rules conversion
 1170+ * Parse rules conversion.
10891171 * @private
10901172 */
1091 - function getRuleConvertedStr( $variant, $doConvert ){
 1173+ function getRuleConvertedStr( $variant, $doConvert ) {
10921174 $bidtable = $this->mBidtable;
10931175 $unidtable = $this->mUnidtable;
10941176
1095 - if( count($bidtable) + count($unidtable) == 0 ){
 1177+ if ( count( $bidtable ) + count( $unidtable ) == 0 ) {
10961178 return $this->mRules;
1097 - } elseif ( $doConvert ){// the text converted
 1179+ } elseif ( $doConvert ) { // the text converted
10981180 // display current variant in bidirectional array
1099 - $disp = $this->getTextInBidtable($variant);
 1181+ $disp = $this->getTextInBidtable( $variant );
11001182 // or display current variant in fallbacks
1101 - if(!$disp)
 1183+ if ( !$disp ) {
11021184 $disp = $this->getTextInBidtable(
1103 - $this->mConverter->getVariantFallbacks($variant));
 1185+ $this->mConverter->getVariantFallbacks( $variant ) );
 1186+ }
11041187 // or display current variant in unidirectional array
1105 - if(!$disp && array_key_exists($variant,$unidtable)){
1106 - $disp = array_values($unidtable[$variant]);
 1188+ if ( !$disp && array_key_exists( $variant, $unidtable ) ) {
 1189+ $disp = array_values( $unidtable[$variant] );
11071190 $disp = $disp[0];
11081191 }
11091192 // or display frist text under disable manual convert
1110 - if(!$disp && $this->mConverter->mManualLevel[$variant]=='disable') {
1111 - if(count($bidtable)>0){
1112 - $disp = array_values($bidtable);
 1193+ if ( !$disp
 1194+ && $this->mConverter->mManualLevel[$variant] == 'disable' ) {
 1195+ if ( count( $bidtable ) > 0 ) {
 1196+ $disp = array_values( $bidtable );
11131197 $disp = $disp[0];
11141198 } else {
1115 - $disp = array_values($unidtable);
1116 - $disp = array_values($disp[0]);
 1199+ $disp = array_values( $unidtable );
 1200+ $disp = array_values( $disp[0] );
11171201 $disp = $disp[0];
11181202 }
11191203 }
11201204 return $disp;
1121 - } else {// no convert
 1205+ } else { // no convert
11221206 return $this->mRules;
11231207 }
11241208 }
11251209
11261210 /**
1127 - * generate conversion table for all text
 1211+ * Generate conversion table for all text.
11281212 * @private
11291213 */
1130 - function generateConvTable(){
 1214+ function generateConvTable() {
11311215 $flags = $this->mFlags;
11321216 $bidtable = $this->mBidtable;
11331217 $unidtable = $this->mUnidtable;
11341218 $manLevel = $this->mConverter->mManualLevel;
11351219
1136 - $vmarked=array();
1137 - foreach($this->mConverter->mVariants as $v) {
 1220+ $vmarked = array();
 1221+ foreach ( $this->mConverter->mVariants as $v ) {
11381222 /* for bidirectional array
11391223 fill in the missing variants, if any,
11401224 with fallbacks */
1141 - if(!array_key_exists($v, $bidtable)) {
1142 - $variantFallbacks = $this->mConverter->getVariantFallbacks($v);
1143 - $vf = $this->getTextInBidtable($variantFallbacks);
1144 - if($vf) $bidtable[$v] = $vf;
 1225+ if ( !array_key_exists( $v, $bidtable ) ) {
 1226+ $variantFallbacks =
 1227+ $this->mConverter->getVariantFallbacks( $v );
 1228+ $vf = $this->getTextInBidtable( $variantFallbacks );
 1229+ if ( $vf ) {
 1230+ $bidtable[$v] = $vf;
 1231+ }
11451232 }
11461233
1147 - if(array_key_exists($v,$bidtable)){
1148 - foreach($vmarked as $vo){
 1234+ if ( array_key_exists( $v, $bidtable ) ) {
 1235+ foreach ( $vmarked as $vo ) {
11491236 // use syntax: -{A|zh:WordZh;zh-tw:WordTw}-
1150 - // or -{H|zh:WordZh;zh-tw:WordTw}- or -{-|zh:WordZh;zh-tw:WordTw}-
 1237+ // or -{H|zh:WordZh;zh-tw:WordTw}-
 1238+ // or -{-|zh:WordZh;zh-tw:WordTw}-
11511239 // to introduce a custom mapping between
11521240 // words WordZh and WordTw in the whole text
1153 - if($manLevel[$v]=='bidirectional'){
1154 - $this->mConvTable[$v][$bidtable[$vo]]=$bidtable[$v];
 1241+ if ( $manLevel[$v] == 'bidirectional' ) {
 1242+ $this->mConvTable[$v][$bidtable[$vo]] = $bidtable[$v];
11551243 }
1156 - if($manLevel[$vo]=='bidirectional'){
1157 - $this->mConvTable[$vo][$bidtable[$v]]=$bidtable[$vo];
 1244+ if ( $manLevel[$vo] == 'bidirectional' ) {
 1245+ $this->mConvTable[$vo][$bidtable[$v]] = $bidtable[$vo];
11581246 }
11591247 }
1160 - $vmarked[]=$v;
 1248+ $vmarked[] = $v;
11611249 }
1162 - /*for unidirectional array
1163 - fill to convert tables */
1164 - $allow_unid = $manLevel[$v]=='bidirectional'
1165 - || $manLevel[$v]=='unidirectional';
1166 - if( $allow_unid && array_key_exists( $v, $unidtable ) ){
 1250+ /*for unidirectional array fill to convert tables */
 1251+ if ( ( $manLevel[$v] == 'bidirectional'
 1252+ || $manLevel[$v] == 'unidirectional' )
 1253+ && array_key_exists( $v, $unidtable ) ) {
11671254 $ct = $this->mConvTable[$v];
1168 - $this->mConvTable[$v] = array_merge($ct, $unidtable[$v]);
 1255+ $this->mConvTable[$v] = array_merge( $ct, $unidtable[$v] );
11691256 }
11701257 }
11711258 }
11721259
11731260 /**
1174 - * Parse rules and flags
 1261+ * Parse rules and flags.
11751262 * @public
11761263 */
1177 - function parse($variant){
1178 - if(!$variant)
 1264+ function parse( $variant = NULL ) {
 1265+ if ( !$variant ) {
11791266 $variant = $this->mConverter->getPreferredVariant();
 1267+ }
11801268
11811269 $variants = $this->mConverter->mVariants;
11821270 $this->parseFlags();
@@ -1183,70 +1271,82 @@
11841272
11851273 // convert to specified variant
11861274 // syntax: -{zh-hans;zh-hant[;...]|<text to convert>}-
1187 - if( count( array_diff( $flags, $variants ) ) == 0 and count( $flags ) != 0 ) {
1188 - if ( in_array( $variant, $flags ) ) // check if current variant in flags
 1275+ if ( count( array_diff( $flags, $variants ) ) == 0
 1276+ and count( $flags ) != 0 ) {
 1277+ // check if current variant in flags
 1278+ if ( in_array( $variant, $flags ) ) {
11891279 // then convert <text to convert> to current language
1190 - $this->mRules = $this->mConverter->autoConvert( $this->mRules, $variant );
1191 - else { // if current variant no in flags,
 1280+ $this->mRules = $this->mConverter->autoConvert( $this->mRules,
 1281+ $variant );
 1282+ } else { // if current variant no in flags,
11921283 // then we check its fallback variants.
1193 - $variantFallbacks = $this->mConverter->getVariantFallbacks($variant);
 1284+ $variantFallbacks =
 1285+ $this->mConverter->getVariantFallbacks( $variant );
11941286 foreach ( $variantFallbacks as $variantFallback ) {
11951287 // if current variant's fallback exist in flags
11961288 if ( in_array( $variantFallback, $flags ) ) {
11971289 // then convert <text to convert> to fallback language
1198 - $this->mRules = $this->mConverter->autoConvert( $this->mRules, $variantFallback );
 1290+ $this->mRules =
 1291+ $this->mConverter->autoConvert( $this->mRules,
 1292+ $variantFallback );
11991293 break;
12001294 }
12011295 }
12021296 }
1203 - $this->mFlags = $flags = array('R');
 1297+ $this->mFlags = $flags = array( 'R' );
12041298 }
12051299
1206 - if( !in_array( 'R', $flags ) || !in_array( 'N', $flags ) ) {
 1300+ if ( !in_array( 'R', $flags ) || !in_array( 'N', $flags ) ) {
12071301 // decode => HTML entities modified by Sanitizer::removeHTMLtags
1208 - $this->mRules = str_replace('=&gt;','=>',$this->mRules);
 1302+ $this->mRules = str_replace( '=&gt;', '=>', $this->mRules );
12091303
12101304 $this->parseRules();
12111305 }
12121306 $rules = $this->mRules;
12131307
1214 - if( count( $this->mBidtable ) == 0 && count( $this->mUnidtable ) == 0 ){
1215 - if(in_array('+',$flags) || in_array('-',$flags))
 1308+ if ( count( $this->mBidtable ) == 0
 1309+ && count( $this->mUnidtable ) == 0 ) {
 1310+ if ( in_array( '+', $flags ) || in_array( '-', $flags ) ) {
12161311 // fill all variants if text in -{A/H/-|text} without rules
1217 - foreach($this->mConverter->mVariants as $v)
 1312+ foreach ( $this->mConverter->mVariants as $v ) {
12181313 $this->mBidtable[$v] = $rules;
1219 - elseif (!in_array('N',$flags) && !in_array('T',$flags) )
1220 - $this->mFlags = $flags = array('R');
 1314+ }
 1315+ } elseif ( !in_array( 'N', $flags ) && !in_array( 'T', $flags ) ) {
 1316+ $this->mFlags = $flags = array( 'R' );
 1317+ }
12211318 }
12221319
1223 - if( in_array('R',$flags) ) {
 1320+ if ( in_array( 'R', $flags ) ) {
12241321 // if we don't do content convert, still strip the -{}- tags
12251322 $this->mRuleDisplay = $rules;
1226 - } elseif ( in_array('N',$flags) ){
 1323+ } elseif ( in_array( 'N', $flags ) ) {
12271324 // proces N flag: output current variant name
1228 - $this->mRuleDisplay = $this->mConverter->mVariantNames[trim($rules)];
1229 - } elseif ( in_array('D',$flags) ){
 1325+ $this->mRuleDisplay =
 1326+ $this->mConverter->mVariantNames[ trim( $rules ) ];
 1327+ } elseif ( in_array( 'D', $flags ) ) {
12301328 // proces D flag: output rules description
12311329 $this->mRuleDisplay = $this->getRulesDesc();
1232 - } elseif ( in_array('H',$flags) || in_array('-',$flags) ) {
 1330+ } elseif ( in_array( 'H', $flags ) || in_array( '-', $flags ) ) {
12331331 // proces H,- flag or T only: output nothing
12341332 $this->mRuleDisplay = '';
1235 - } elseif ( in_array('S',$flags) ){
1236 - $this->mRuleDisplay = $this->getRuleConvertedStr($variant,
1237 - $this->mConverter->mDoContentConvert);
 1333+ } elseif ( in_array( 'S', $flags ) ) {
 1334+ $this->mRuleDisplay = $this->getRuleConvertedStr( $variant,
 1335+ $this->mConverter->mDoContentConvert );
12381336 } else {
1239 - $this->mRuleDisplay= $this->mManualCodeError;
 1337+ $this->mRuleDisplay = $this->mManualCodeError;
12401338 }
12411339 // proces T flag
1242 - if ( in_array('T',$flags) ) {
1243 - $this->mRuleTitle = $this->getRuleConvertedStr($variant,
1244 - $this->mConverter->mDoTitleConvert);
 1340+ if ( in_array( 'T', $flags ) ) {
 1341+ $this->mRuleTitle = $this->getRuleConvertedStr( $variant,
 1342+ $this->mConverter->mDoTitleConvert );
12451343 }
12461344
1247 - if (in_array('-', $flags))
1248 - $this->mRulesAction='remove';
1249 - if (in_array('+', $flags))
1250 - $this->mRulesAction='add';
 1345+ if ( in_array( '-', $flags ) ) {
 1346+ $this->mRulesAction = 'remove';
 1347+ }
 1348+ if ( in_array( '+', $flags ) ) {
 1349+ $this->mRulesAction = 'add';
 1350+ }
12511351
12521352 $this->generateConvTable();
12531353 }
@@ -1254,54 +1354,56 @@
12551355 /**
12561356 * @public
12571357 */
1258 - function hasRules(){
 1358+ function hasRules() {
12591359 // TODO:
12601360 }
12611361
12621362 /**
1263 - * get display text on markup -{...}-
 1363+ * Get display text on markup -{...}-
12641364 * @public
12651365 */
1266 - function getDisplay(){
 1366+ function getDisplay() {
12671367 return $this->mRuleDisplay;
12681368 }
 1369+
12691370 /**
1270 - * get converted title
 1371+ * Get converted title.
12711372 * @public
12721373 */
1273 - function getTitle(){
 1374+ function getTitle() {
12741375 return $this->mRuleTitle;
12751376 }
12761377
12771378 /**
1278 - * return how deal with conversion rules
 1379+ * Return how deal with conversion rules.
12791380 * @public
12801381 */
1281 - function getRulesAction(){
 1382+ function getRulesAction() {
12821383 return $this->mRulesAction;
12831384 }
12841385
12851386 /**
1286 - * get conversion table ( bidirectional and unidirectional conversion table )
 1387+ * Get conversion table. ( bidirectional and unidirectional
 1388+ * conversion table )
12871389 * @public
12881390 */
1289 - function getConvTable(){
 1391+ function getConvTable() {
12901392 return $this->mConvTable;
12911393 }
12921394
12931395 /**
1294 - * get conversion rules string
 1396+ * Get conversion rules string.
12951397 * @public
12961398 */
1297 - function getRules(){
 1399+ function getRules() {
12981400 return $this->mRules;
12991401 }
13001402
13011403 /**
1302 - * get conversion flags
 1404+ * Get conversion flags.
13031405 * @public
13041406 */
1305 - function getFlags(){
 1407+ function getFlags() {
13061408 return $this->mFlags;
13071409 }
13081410 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r60651Follow-up r60650: run stylize.php and remove trailing whitespacesiebrand09:34, 5 January 2010

Comments

#Comment by Siebrand (talk | contribs)   09:31, 5 January 2010

Hey Mark. Please have a look at trunk/tools/code-utils/stylize.php. Running that on PHP files before manually scanning them may save you a lot of time (assuming you do not yet know this toy and do not have other means to automagically change add coding convertion changes in).

#Comment by MarkAHershberger (talk | contribs)   18:53, 5 January 2010

I did use stylize.php for the initial pass, but I guess I should have run it again to get rid of the trailing white space after my edits.

Status & tagging log