r37499 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37498‎ | r37499 | r37500 >
Date:13:56, 10 July 2008
Author:shinjiman
Status:old
Tags:
Comment:
some tweaks for the Language Converter
patch by fdcn
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -42,6 +42,7 @@
4343 * @param array $variantfallback the fallback language of each variant
4444 * @param array $markup array defining the markup used for manual conversion
4545 * @param array $flags array defining the custom strings that maps to the flags
 46+ * @param array $manualLevel limit for supported variants
4647 * @public
4748 */
4849 function __construct($langobj, $maincode,
@@ -323,15 +324,14 @@
324325 $this->mTitleDisplay = $title;
325326 }
326327
327 - //add manual conversion table to global table
 328+ //apply manual conversion table to global table
328329 $convTable = $convRule->getConvTable();
329 - $isAdd = $convRule->getRulesAction()=="add";
330 - $isRemove = $convRule->getRulesAction()=="remove";
 330+ $action = $convRule->getRulesAction();
331331 foreach($convTable as $v=>$t) {
332332 if( !in_array($v,$this->mVariants) )continue;
333 - if( $isAdd )
 333+ if( $action=="add" )
334334 $this->mTables[$v]->mergeArray($t);
335 - elseif ( $isRemove )
 335+ elseif ( $action=="remove" )
336336 $this->mTables[$v]->removeArray($t);
337337 }
338338 }
@@ -841,14 +841,6 @@
842842 $rules = $text;
843843 }
844844
845 - if( !in_array('R',$flags) ){
846 - //FIXME: may cause trouble here...
847 - //strip   since it interferes with the parsing, plus,
848 - //all spaces should be stripped in this tag anyway.
849 - $rules = str_replace(' ', '', $rules);
850 - $rules = str_replace('=>','=>',$rules);
851 - }
852 -
853845 //check flags
854846 if( in_array('R',$flags) ){
855847 $flags = array('R');// remove other flags
@@ -976,7 +968,6 @@
977969 * @private
978970 */
979971 function generateConvTable(){
980 - //$rules = $this->mRules;
981972 $flags = $this->mFlags;
982973 $bidtable = $this->mBidtable;
983974 $unidtable = $this->mUnidtable;
@@ -1027,10 +1018,19 @@
10281019 if(!$variant) $variant = $this->mConverter->getPreferredVariant();
10291020
10301021 $this->parseFlags();
1031 - $this->parseRules();
 1022+ $flags = $this->mFlags;
10321023
 1024+ if( !in_array('R',$flags) || !in_array('N',$flags) ){
 1025+ //FIXME: may cause trouble here...
 1026+ //strip   since it interferes with the parsing, plus,
 1027+ //all spaces should be stripped in this tag anyway.
 1028+ $this->mRules = str_replace(' ', '', $this->mRules);
 1029+ // decode => HTML entities modified by Sanitizer::removeHTMLtags
 1030+ $this->mRules = str_replace('=>','=>',$this->mRules);
 1031+
 1032+ $this->parseRules();
 1033+ }
10331034 $rules = $this->mRules;
1034 - $flags = $this->mFlags;
10351035
10361036 if(count($this->mBidtable)==0 && count($this->mUnidtable)==0){
10371037 if(in_array('+',$flags) || in_array('-',$flags))
@@ -1059,7 +1059,7 @@
10601060 } else {
10611061 $this->mRuleDisplay= $this->mManualCodeError;
10621062 }
1063 - // proces T flag : output nothing
 1063+ // proces T flag
10641064 if ( in_array('T',$flags) ) {
10651065 $this->mRuleTitle = $this->getRuleConvertedStr($variant,
10661066 $this->mConverter->mDoTitleConvert);
@@ -1082,7 +1082,6 @@
10831083
10841084 /**
10851085 * get display text on markup -{...}-
1086 - * @param string $variant the current variant
10871086 * @public
10881087 */
10891088 function getDisplay(){
@@ -1090,7 +1089,6 @@
10911090 }
10921091 /**
10931092 * get converted title
1094 - * @param string $variant the current variant
10951093 * @public
10961094 */
10971095 function getTitle(){

Follow-up revisions

RevisionCommit summaryAuthorDate
r61233In LanguageConverter:...tstarling02:36, 19 January 2010

Status & tagging log