r7875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7874‎ | r7875 | r7876 >
Date:00:54, 26 March 2005
Author:zhengzhu
Status:old
Tags:
Comment:
(zh) strip   before parsing the -{}- tag; small code clean-up.
Modified paths:
  • /trunk/phase3/languages/LanguageZh.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageZh.php
@@ -347,23 +347,29 @@
348348 $text = $this->autoConvert($tfirst);
349349 foreach($tarray as $txt) {
350350 $marked = explode("}-", $txt);
351 - $choice = explode(";", $marked{0});
 351+
 352+ //strip   since it interferes with the parsing, plus,
 353+ //all spaces should be stripped in this tag anyway.
 354+ $marked[0] = str_replace(' ', '', $marked[0]);
 355+
 356+ $choice = explode(";", $marked[0]);
352357 /* see if this conversion is specifically for the
353 - article title
 358+ article title. the format is
 359+ -{T|zh-cn:foo;zh-tw:bar}-
354360 */
355361 $fortitle = false;
356 - $tt = explode("T|", $marked{0}, 2);
357 - if(sizeof($tt) == 2) {
 362+ $tt = explode("|", $marked[0], 2);
 363+ if(sizeof($tt) == 2 && trim($tt[0]) == 'T') {
358364 $choice = explode(";", $tt[1]);
359365 $fortitle = true;
360366 }
361367 else {
362 - $choice = explode(";", $marked{0});
 368+ $choice = explode(";", $marked[0]);
363369 }
364370 $disp = '';
365371 if(!array_key_exists(1, $choice)) {
366372 /* a single choice */
367 - $disp = $choice{0};
 373+ $disp = $choice[0];
368374 } else {
369375 $choice1=false;
370376 $choice2=false;
@@ -373,8 +379,8 @@
374380 //syntax error in the markup, give up
375381 break;
376382 }
377 - $code = trim($v{0});
378 - $content = trim($v{1});
 383+ $code = trim($v[0]);
 384+ $content = trim($v[1]);
379385 if($code == $plang) {
380386 $choice1 = $content;
381387 break;
@@ -387,7 +393,7 @@
388394 elseif ( $choice2 )
389395 $disp = $choice2;
390396 else
391 - $disp = $marked{0};
 397+ $disp = $marked[0];
392398 }
393399
394400 if($fortitle)
@@ -395,7 +401,7 @@
396402 else
397403 $text .= $disp;
398404 if(array_key_exists(1, $marked))
399 - $text .= $this->autoConvert($marked{1});
 405+ $text .= $this->autoConvert($marked[1]);
400406 }
401407
402408 return $text;

Status & tagging log