From: Alexandre Emsenhuber Date: Wed, 4 Feb 2009 19:01:14 +0000 (+0000) Subject: * (bug 17231) Transcluding special pages on wikis using language conversion no longer... X-Git-Tag: 1.31.0-rc.0~43049 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=ed5a6072afcadb5c84aed4582e856f796f47d782;p=lhc%2Fweb%2Fwiklou.git * (bug 17231) Transcluding special pages on wikis using language conversion no longer affects the page title * Whitespaces tweaks in LanguageConverter.php Please feel free to correct this if it's not the correct solution ;) --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e91e38303f..09f618440e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -137,6 +137,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 17283) Remove double URL escaping in show/hide links for log entries and RevisionDeleteForm::__construct * (bug 17105) Numeric table sorting broken +* (bug 17231) Transcluding special pages on wikis using language conversion no + longer affects the page title == API changes in 1.15 == * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 698baec11e..701381ab49 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -357,10 +357,10 @@ class LanguageConverter { * prepare manual conversion table * @private */ - function prepareManualConv($convRule){ + function prepareManualConv( $convRule ){ // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title $title = $convRule->getTitle(); - if($title){ + if( $title ){ $this->mTitleFromFlag = true; $this->mTitleDisplay = $title; } @@ -368,20 +368,20 @@ class LanguageConverter { //apply manual conversion table to global table $convTable = $convRule->getConvTable(); $action = $convRule->getRulesAction(); - foreach($convTable as $v=>$t) { - if( !in_array($v,$this->mVariants) )continue; + foreach( $convTable as $v => $t ) { + if( !in_array( $v, $this->mVariants ) )continue; if( $action=="add" ) { - foreach($t as $from=>$to) { + foreach( $t as $from => $to ) { // to ensure that $from and $to not be left blank // so $this->translate() could always return a string - if ($from || $to) + if ( $from || $to ) // more efficient than array_merge(), about 2.5 times. $this->mManualAddTables[$v][$from] = $to; } } - elseif ( $action=="remove" ) { - foreach($t as $from=>$to) { - if ($from || $to) + elseif ( $action == "remove" ) { + foreach ( $t as $from=>$to ) { + if ( $from || $to ) $this->mManualRemoveTables[$v][$from] = $to; } } @@ -416,11 +416,13 @@ class LanguageConverter { return $text; } - if($wgDisableLangConversion) + if ( $wgDisableLangConversion ) return $text; $text = $this->convert( $text ); - $parser->mOutput->setTitleText( $this->mTitleDisplay ); + + if ( $this->mTitleFromFlag ) + $parser->mOutput->setTitleText( $this->mTitleDisplay ); return $text; } @@ -428,7 +430,7 @@ class LanguageConverter { * convert title * @private */ - function convertTitle($text){ + function convertTitle( $text ){ global $wgDisableTitleConversion, $wgUser; // check for global param and __NOTC__ tag @@ -438,7 +440,7 @@ class LanguageConverter { } // use the title from the T flag if any - if($this->mTitleFromFlag){ + if( $this->mTitleFromFlag ){ $this->mTitleFromFlag = false; return $this->mTitleDisplay; } @@ -471,7 +473,7 @@ class LanguageConverter { * @return string converted text * @public */ - function convert( $text , $isTitle=false) { + function convert( $text, $isTitle = false ) { $mw =& MagicWord::get( 'notitleconvert' ); if( $mw->matchAndRemove( $text ) ) @@ -483,36 +485,36 @@ class LanguageConverter { // no conversion if redirecting $mw =& MagicWord::get( 'redirect' ); - if( $mw->matchStart( $text )) + if( $mw->matchStart( $text ) ) return $text; // for title convertion - if ($isTitle) return $this->convertTitle($text); + if ( $isTitle ) return $this->convertTitle( $text ); $plang = $this->getPreferredVariant(); - $tarray = StringUtils::explode($this->mMarkup['end'], $text); + $tarray = StringUtils::explode( $this->mMarkup['end'], $text ); $text = ''; $marks = array(); - foreach($tarray as $txt) { - $marked = explode($this->mMarkup['begin'], $txt, 2); - if (array_key_exists(1, $marked)) { + foreach ( $tarray as $txt ) { + $marked = explode( $this->mMarkup['begin'], $txt, 2 ); + if ( array_key_exists( 1, $marked ) ) { $crule = new ConverterRule($marked[1], $this); - $crule->parse($plang); + $crule->parse( $plang ); $marked[1] = $crule->getDisplay(); - $this->prepareManualConv($crule); + $this->prepareManualConv( $crule ); } else $marked[0] .= $this->mMarkup['end']; - array_push($marks, $marked); + array_push( $marks, $marked ); } $this->applyManualConv(); - foreach ($marks as $marked) { + foreach ( $marks as $marked ) { if( $this->mDoContentConvert ) - $text .= $this->autoConvert($marked[0],$plang); + $text .= $this->autoConvert( $marked[0], $plang ); else $text .= $marked[0]; - if( array_key_exists(1, $marked) ) + if( array_key_exists( 1, $marked ) ) $text .= $marked[1]; } // Remove the last delimiter (wasn't real)