http://www.mediawiki.org/wiki/Special:Code/MediaWiki/58275

Revision: 58275
Author:   philip
Date:     2009-10-28 19:09:38 +0000 (Wed, 28 Oct 2009)

Log Message:
-----------
(bug 20884) Try to fix the magic word __NOTC__ which use to prevent 
title-conversion. Now it should work AGAIN.

Modified Paths:
--------------
    trunk/phase3/languages/LanguageConverter.php

Modified: trunk/phase3/languages/LanguageConverter.php
===================================================================
--- trunk/phase3/languages/LanguageConverter.php        2009-10-28 19:05:17 UTC 
(rev 58274)
+++ trunk/phase3/languages/LanguageConverter.php        2009-10-28 19:09:38 UTC 
(rev 58275)
@@ -22,7 +22,6 @@
        var $mTablesLoaded = false;
        var $mTables;
        var $mNamespaceTables;
-       var $mTitleDisplay='';
        var $mDoTitleConvert=true, $mDoContentConvert=true;
        var $mManualLevel; // 'bidirectional' 'unidirectional' 'disable' for 
each variants
        var $mTitleFromFlag = false;
@@ -32,6 +31,8 @@
        var $mFlags;
        var $mDescCodeSep = ':',$mDescVarSep = ';';
        var $mUcfirst = false;
+       var $mTitleOriginal = '';
+       var $mTitleDisplay = '';
 
        const CACHE_VERSION_KEY = 'VERSION 6';
 
@@ -439,8 +440,9 @@
 
                $text = $this->convert( $text );
 
-               if ( $this->mTitleFromFlag )
-                       $parser->mOutput->setTitleText( $this->mTitleDisplay );
+               $this->convertTitle();
+               $parser->mOutput->setTitleText( $this->mTitleDisplay );
+
                return $text;
        }
        
@@ -461,35 +463,37 @@
        }
 
        /**
+        * Pre convert title. Store the original title $this->mTitleOrginal;
+        * store the default converted title to $this->mTitleDisplay.
+        * @private
+        */
+       function preConvertTitle( $text, $variant ){
+               $this->mTitleOriginal = $text;
+               
+               $text = $this->convertNamespace( $text, $variant );
+               $this->mTitleDisplay = $this->convert( $text );
+       }
+
+       /**
         * convert title
         * @private
         */
-       function convertTitle( $text, $variant ){
-               global $wgDisableTitleConversion, $wgUser;
-
-               // check for global param and __NOTC__ tag
-               if( $wgDisableTitleConversion || !$this->mDoTitleConvert || 
$wgUser->getOption('noconvertlink') == 1 ) {
-                       $this->mTitleDisplay = $text;
-                       return $text;
-               }
-
-               // use the title from the T flag if any
-               if( $this->mTitleFromFlag ){
-                       $this->mTitleFromFlag = false;
-                       return $this->mTitleDisplay;
-               }
-
-               global $wgRequest;
+       function convertTitle(){
+               global $wgDisableTitleConversion, $wgUser, $wgRequest;
                $isredir = $wgRequest->getText( 'redirect', 'yes' );
                $action = $wgRequest->getText( 'action' );
                $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
-               if ( $isredir == 'no' || $action == 'edit' || $action == 
'submit' || $linkconvert == 'no' ) {
-                       return $text;
-               } else {
-                       $text = $this->convertNamespace( $text, $variant );
-                       $this->mTitleDisplay = $this->convert( $text );
-                       return $this->mTitleDisplay;
+
+               // check for the global variable, __NOTC__ magic word, and user 
setting
+               if( $wgDisableTitleConversion || !$this->mDoTitleConvert ||
+                   $wgUser->getOption('noconvertlink') == 1 ) {
+                       $this->mTitleDisplay = $this->mTitleOriginal;
                }
+               
+               // check for GET params
+               elseif  ( $isredir == 'no' || $action == 'edit' || $linkconvert 
== 'no' ) {
+                       $this->mTitleDisplay = $this->mTitleOriginal;
+               }
        }
 
        /**
@@ -526,7 +530,10 @@
                $plang = $this->getPreferredVariant();
 
                // for title convertion
-               if ( $isTitle ) return $this->convertTitle( $text, $plang );
+               if ( $isTitle ) {
+                       $this->preConvertTitle( $text, $plang );
+                       return $text;
+               }
 
                $tarray = StringUtils::explode( $this->mMarkup['end'], $text );
                $text = '';



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to