* Fixing the caching issue by using -{T|xxx}- syntax (only applies on wiki with Langu...
authorShinjiman <shinjiman@users.mediawiki.org>
Sat, 10 Jan 2009 16:13:44 +0000 (16:13 +0000)
committerShinjiman <shinjiman@users.mediawiki.org>
Sat, 10 Jan 2009 16:13:44 +0000 (16:13 +0000)
* Improving the efficiency by using -{A|xxx}- syntax (only applies on wiki with LanguageConverter class)
  patches by PhiLiP

RELEASE-NOTES
includes/OutputPage.php
includes/parser/Parser.php
languages/LanguageConverter.php
languages/messages/MessagesZh_hans.php

index 25bba2c..8622878 100644 (file)
@@ -33,7 +33,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   for the current page for a given action
   
 === Bug fixes in 1.15 ===
-
+* Fixing the caching issue by using -{T|xxx}- syntax (only applies on wiki with LanguageConverter class)
+* Improving the efficiency by using -{A|xxx}- syntax (only applies on wiki with LanguageConverter class)
 
 === Languages updated in 1.15 ===
 
index f8dba71..b3e727c 100644 (file)
@@ -511,6 +511,7 @@ class OutputPage {
                $this->mLanguageLinks += $parserOutput->getLanguageLinks();
                $this->addCategoryLinks( $parserOutput->getCategories() );
                $this->mNewSectionLink = $parserOutput->getNewSection();
+               $this->setPageTitle($parserOutput->mTitleText);
 
                if( is_null( $wgExemptFromUserRobotsControl ) ) {
                        $bannedNamespaces = $wgContentNamespaces;
index 1a4901c..3114bf8 100644 (file)
@@ -3304,6 +3304,7 @@ class Parser
                                                throw new MWException( '<html> extension tag encountered unexpectedly' );
                                        }
                                case 'nowiki':
+                                       $content = strtr($content, array('-{' => '-&#123;', '}-' => '&#125;-'));
                                        $output = Xml::escapeTagsOnly( $content );
                                        break;
                                case 'math':
index dd69e82..56e5e42 100644 (file)
@@ -13,7 +13,7 @@
  * @ingroup Language
  *
  * @author Zhengzhu Feng <zhengzhu@gmail.com>
- * @maintainers fdcn <fdcn64@gmail.com>, shinjiman <shinjiman@gmail.com>
+ * @maintainers fdcn <fdcn64@gmail.com>, shinjiman <shinjiman@gmail.com>, PhiLiP <philip.npc@gmail.com>
  */
 class LanguageConverter {
        var $mPreferredVariant='';
@@ -21,6 +21,8 @@ class LanguageConverter {
        var $mVariants, $mVariantFallbacks, $mVariantNames;
        var $mTablesLoaded = false;
        var $mTables;
+       var $mManualAddTables;
+       var $mManualRemoveTables;
        var $mTitleDisplay='';
        var $mDoTitleConvert=true, $mDoContentConvert=true;
        var $mManualLevel; // 'bidirectional' 'unidirectional' 'disable' for each variants
@@ -81,10 +83,13 @@ class LanguageConverter {
                        'N'=>'N'        // current variant name
                );
                $this->mFlags = array_merge($f, $flags);
-               foreach( $this->mVariants as $v)
+               foreach( $this->mVariants as $v) {
                        $this->mManualLevel[$v]=array_key_exists($v,$manualLevel)
                                                                ?$manualLevel[$v]
                                                                :'bidirectional';
+                       $this->mManualAddTables[$v] = array();
+                       $this->mManualRemoveTables[$v] = array();
+               }
        }
 
        /**
@@ -323,13 +328,12 @@ class LanguageConverter {
 
                return $ret;
        }
-
-
+       
        /**
-        * apply manual conversion
+        * prepare manual conversion table
         * @private
         */
-       function applyManualConv($convRule){
+       function prepareManualConv($convRule){
                // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
                $title = $convRule->getTitle();
                if($title){
@@ -342,10 +346,29 @@ class LanguageConverter {
                $action = $convRule->getRulesAction();
                foreach($convTable as $v=>$t) {
                        if( !in_array($v,$this->mVariants) )continue;
-                       if( $action=="add" )
-                               $this->mTables[$v]->mergeArray($t);
+                       if( $action=="add" ) {
+                               foreach($t as $from=>$to) {
+                                       // more efficient than array_merge(), about 2.5 times.
+                                       $this->mManualAddTables[$v][$from] = $to;
+                               }
+                       }
                        elseif ( $action=="remove" )
-                               $this->mTables[$v]->removeArray($t);
+                               $this->mManualRemoveTables[$v] = array_merge($this->mManualRemoveTables[$v], $t);
+               }
+       }
+
+       /**
+        * apply manual conversion from $this->mManualAddTables and $this->mManualRemoveTables
+        * @private
+        */
+       function applyManualConv(){
+               //apply manual conversion table to global table
+               foreach($this->mVariants as $v) {
+                       if (count($this->mManualAddTables[$v]) > 0) {
+                               $this->mTables[$v]->mergeArray($this->mManualAddTables[$v]);
+                       }
+                       if (count($this->mManualRemoveTables[$v]) > 0)
+                               $this->mTables[$v]->removeArray($this->mManualRemoveTables[$v]);
                }
        }
 
@@ -438,32 +461,26 @@ class LanguageConverter {
                $plang = $this->getPreferredVariant();
                $tarray = StringUtils::explode($this->mMarkup['end'], $text);
                $text = '';
-               $lastDelim = false;
+
+               $marks = array();
                foreach($tarray as $txt) {
                        $marked = explode($this->mMarkup['begin'], $txt, 2);
-
-                       if( $this->mDoContentConvert )
-                               $text .= $this->autoConvert($marked[0],$plang);
-                       else
-                               $text .= $marked[0];
-
-                       if(array_key_exists(1, $marked)){
-                               // strip the flags from syntax like -{T| ... }-
+                       if (array_key_exists(1, $marked)) {
                                $crule = new ConverterRule($marked[1], $this);
                                $crule->parse($plang);
-
-                               $text .= $crule->getDisplay();
-                               $this->applyManualConv($crule);
-                               $lastDelim = false;
-                       } else {
-                               // Reinsert the }- which wasn't part of anything
-                               $text .= $this->mMarkup['end'];
-                               $lastDelim = true;
+                               $marked[1] = $crule->getDisplay();
+                               $this->prepareManualConv($crule);
                        }
+                       array_push($marks, $marked);
                }
-               if ( $lastDelim ) {
-                       // Remove the last delimiter (wasn't real)
-                       $text = substr( $text, 0, -strlen( $this->mMarkup['end'] ) );
+               $this->applyManualConv();
+               foreach ($marks as $marked) {
+                       if( $this->mDoContentConvert )
+                               $text .= $this->autoConvert($marked[0],$plang);
+                       else
+                               $text .= $marked[0];
+                       if( array_key_exists(1, $marked) )
+                               $text .= $marked[1];
                }
 
                return $text;
@@ -800,6 +817,7 @@ class LanguageConverter {
  * @ingroup Language
  * @author  fdcn <fdcn64@gmail.com>
  */
+
 class ConverterRule {
        var $mText; // original text in -{text}-
        var $mConverter; // LanguageConverter object 
index 40eed49..075c81b 100644 (file)
@@ -67,6 +67,7 @@ $specialPageAliases = array(
        'Preferences'               => array( '参数设置' ),
        'Watchlist'                 => array( '监视列表' ),
        'Recentchanges'             => array( '最近更改' ),
+       'Recentchangeslinked'       => array( '链出更改' ),
        'Upload'                    => array( '上传文件' ),
        'Listfiles'                 => array( '文件列表' ),
        'Newimages'                 => array( '新建文件' ),
@@ -79,7 +80,7 @@ $specialPageAliases = array(
        'Uncategorizedcategories'   => array( '未归类分类' ),
        'Uncategorizedimages'       => array( '未归类文件' ),
        'Uncategorizedtemplates'    => array( '未归类模版' ),
-       'Unusedcategories'          => array( '未使用的模板' ),
+       'Unusedcategories'          => array( '未使用分类' ),
        'Unusedimages'              => array( '未使用文件' ),
        'Wantedpages'               => array( '待撰页面' ),
        'Wantedcategories'          => array( '待撰分类' ),