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

Revision: 64851
Author:   philip
Date:     2010-04-10 05:46:01 +0000 (Sat, 10 Apr 2010)

Log Message:
-----------
Fix bug 23115 again. Follow up r64821, r64823 and r64827. Rewrite the converted 
title to HTML title if the HTML title haven't set by other messages.

Modified Paths:
--------------
    trunk/phase3/includes/OutputPage.php
    trunk/phase3/includes/parser/Parser.php
    trunk/phase3/languages/LanguageConverter.php

Modified: trunk/phase3/includes/OutputPage.php
===================================================================
--- trunk/phase3/includes/OutputPage.php        2010-04-10 04:31:43 UTC (rev 
64850)
+++ trunk/phase3/includes/OutputPage.php        2010-04-10 05:46:01 UTC (rev 
64851)
@@ -9,7 +9,7 @@
        var $mMetatags = array(), $mKeywords = array(), $mLinktags = array();
        var $mExtStyles = array();
        var $mPagetitle = '', $mBodytext = '', $mDebugtext = '';
-       var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false;
+       var $mHTMLtitle = '', $mHTMLtitleFromPagetitle = true, $mIsarticle = 
true, $mPrintable = false;
        var $mSubtitle = '', $mRedirect = '', $mStatusCode;
        var $mLastModified = '', $mETag = false;
        var $mCategoryLinks = array(), $mCategories = array(), $mLanguageLinks 
= array();
@@ -445,10 +445,19 @@
        }
 
        /**
-        * "HTML title" means the contents of <title>. It is stored as plain, 
unescaped text and will be run through htmlspecialchars in the skin file.
+        * "HTML title" means the contents of <title>.
+        * It is stored as plain, unescaped text and will be run through 
htmlspecialchars in the skin file.
+        * If $name is from page title, it can only override names which are 
also from page title,
+        * but if it is not from page title, it can override all other names.
         */
-       public function setHTMLTitle( $name ) {
-               $this->mHTMLtitle = $name;
+       public function setHTMLTitle( $name, $frompagetitle = false ) {
+               if ( $frompagetitle && $this->mHTMLtitleFromPagetitle ) {
+                       $this->mHTMLtitle = $name;
+               }
+               elseif ( $this->mHTMLtitleFromPagetitle ) {
+                       $this->mHTMLtitle = $name;
+                       $this->mHTMLtitleFromPagetitle = false;
+               }
        }
 
        /**
@@ -478,7 +487,7 @@
                }
 
                # change "<i>foo&amp;bar</i>" to "foo&bar"
-               $this->setHTMLTitle( wfMsg( 'pagetitle', 
Sanitizer::stripAllTags( $nameWithTags ) ) );
+               $this->setHTMLTitle( wfMsg( 'pagetitle', 
Sanitizer::stripAllTags( $nameWithTags ) ), true );
        }
 
        /**

Modified: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php     2010-04-10 04:31:43 UTC (rev 
64850)
+++ trunk/phase3/includes/parser/Parser.php     2010-04-10 05:46:01 UTC (rev 
64851)
@@ -303,7 +303,7 @@
                 * to internalParse() which does all the real work.
                 */
 
-               global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, 
$wgDisableLangConversion, $wgDisableTitleConversion, $wgUser, $wgRequest;
+               global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, 
$wgDisableLangConversion, $wgDisableTitleConversion, $wgUser, $wgRequest, 
$wgOut;
                $fname = __METHOD__.'-' . wfGetCaller();
                wfProfileIn( __METHOD__ );
                wfProfileIn( $fname );
@@ -386,7 +386,7 @@
                        if ( $convruletitle ) {
                                $this->mOutput->setTitleText( $convruletitle );
                        } else {
-                               $this->mOutput->setTitleText( 
$wgContLang->convert( $this->mOutput->getTitleText() ) );
+                               $wgOut->setPageTitle( $wgContLang->convert( 
$wgOut->getPageTitle(), true ) );
                        }
                }
 

Modified: trunk/phase3/languages/LanguageConverter.php
===================================================================
--- trunk/phase3/languages/LanguageConverter.php        2010-04-10 04:31:43 UTC 
(rev 64850)
+++ trunk/phase3/languages/LanguageConverter.php        2010-04-10 05:46:01 UTC 
(rev 64851)
@@ -547,12 +547,16 @@
         * @param $text String: text to be converted
         * @return String: converted text
         */
-       public function convert( $text ) {
+       public function convert( $text, $istitle = false ) {
                global $wgDisableLangConversion;
                if ( $wgDisableLangConversion ) return $text;
 
                $variant = $this->getPreferredVariant();
 
+               if( $istitle ) {
+                       $text = $this->convertNamespace( $text, $variant );
+               }
+
                return $this->recursiveConvertTopLevel( $text, $variant );
        }
 



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

Reply via email to