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

Revision: 65393
Author:   tstarling
Date:     2010-04-21 14:51:15 +0000 (Wed, 21 Apr 2010)

Log Message:
-----------
MFT r64876 and followups r64892, r64918, 64934: fix various language 
converter-related title issues.

Modified Paths:
--------------
    branches/REL1_16/phase3/RELEASE-NOTES
    branches/REL1_16/phase3/includes/Article.php
    branches/REL1_16/phase3/includes/OutputPage.php
    branches/REL1_16/phase3/includes/parser/Parser.php
    branches/REL1_16/phase3/languages/Language.php
    branches/REL1_16/phase3/languages/LanguageConverter.php

Property Changed:
----------------
    branches/REL1_16/phase3/
    branches/REL1_16/phase3/includes/
    branches/REL1_16/phase3/includes/Article.php
    branches/REL1_16/phase3/includes/OutputPage.php


Property changes on: branches/REL1_16/phase3
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/phase3:63545-63546,63549,63643,63764,63897-63901
   + /trunk/phase3:63545-63546,63549,63643,63764,63897-63901,64876

Modified: branches/REL1_16/phase3/RELEASE-NOTES
===================================================================
--- branches/REL1_16/phase3/RELEASE-NOTES       2010-04-21 14:22:55 UTC (rev 
65392)
+++ branches/REL1_16/phase3/RELEASE-NOTES       2010-04-21 14:51:15 UTC (rev 
65393)
@@ -51,6 +51,8 @@
 * Fixed a bug in the Vector skin where personal tools display behind the logo
 * (bug 23139) Fixed a bug in edit conflict resolution, where both textboxes 
   showed the same text.
+* (bug 23115, bug 23124) Fixed various problems with <title> and <h1> elements
+  in page views and previews when the language converter is enabled.
 
 === Changes since 1.16 beta 1 ===
 


Property changes on: branches/REL1_16/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/includes:51646
/branches/sqlite/includes:58211-58321
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:63549,63764,63897-63901,64881
   + /branches/REL1_15/phase3/includes:51646
/branches/sqlite/includes:58211-58321
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:63549,63764,63897-63901,64876,64881

Modified: branches/REL1_16/phase3/includes/Article.php
===================================================================
--- branches/REL1_16/phase3/includes/Article.php        2010-04-21 14:22:55 UTC 
(rev 65392)
+++ branches/REL1_16/phase3/includes/Article.php        2010-04-21 14:51:15 UTC 
(rev 65393)
@@ -799,15 +799,6 @@
                        wfIncrStats( 'pcache_miss_stub' );
                }
 
-               # For the main page, overwrite the <title> element with the con-
-               # tents of 'pagetitle-view-mainpage' instead of the default (if
-               # that's not empty).
-               if ( $this->mTitle->equals( Title::newMainPage() )
-                       && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) 
) !== '' )
-               {
-                       $wgOut->setHTMLTitle( $m );
-               }
-
                $wasRedirected = $this->showRedirectedFromHeader();
                $this->showNamespaceHeader();
 
@@ -815,6 +806,7 @@
                # Keep going until $outputDone is set, or we run out of things 
to do.
                $pass = 0;
                $outputDone = false;
+               $this->mParserOutput = false;
                while ( !$outputDone && ++$pass ) {
                        switch( $pass ) {
                                case 1:
@@ -923,6 +915,23 @@
                        }
                }
 
+               # Adjust the title if it was set by displaytitle, -{T|}- or 
language conversion
+               if ( $this->mParserOutput ) {
+                       $titleText = $this->mParserOutput->getTitleText();
+                       if ( strval( $titleText ) !== '' ) {
+                               $wgOut->setPageTitle( $titleText );
+                       }
+               }
+
+               # For the main page, overwrite the <title> element with the con-
+               # tents of 'pagetitle-view-mainpage' instead of the default (if
+               # that's not empty).
+               if ( $this->mTitle->equals( Title::newMainPage() )
+                       && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) 
) !== '' )
+               {
+                       $wgOut->setHTMLTitle( $m );
+               }
+
                # Now that we've filled $this->mParserOutput, we know whether
                # there are any __NOINDEX__ tags on the page
                $policy = $this->getRobotPolicy( 'view' );


Property changes on: branches/REL1_16/phase3/includes/Article.php
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/REL1_15/phase3/includes/Article.php:51646
/branches/sqlite/includes/Article.php:58211-58321
/branches/wmf-deployment/includes/Article.php:53381
/trunk/phase3/includes/Article.php:63549,63764,63897-63901,64918,64934

Modified: branches/REL1_16/phase3/includes/OutputPage.php
===================================================================
--- branches/REL1_16/phase3/includes/OutputPage.php     2010-04-21 14:22:55 UTC 
(rev 65392)
+++ branches/REL1_16/phase3/includes/OutputPage.php     2010-04-21 14:51:15 UTC 
(rev 65393)
@@ -477,7 +477,7 @@
                }
 
                # change "<i>foo&amp;bar</i>" to "foo&bar"
-               $this->setHTMLTitle( wfMsg( 'pagetitle', 
Sanitizer::stripAllTags( $nameWithTags ) ), true );
+               $this->setHTMLTitle( wfMsg( 'pagetitle', 
Sanitizer::stripAllTags( $nameWithTags ) ) );
        }
 
        /**


Property changes on: branches/REL1_16/phase3/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/includes/OutputPage.php:51646
/branches/wmf-deployment/includes/OutputPage.php:53381,57468
/trunk/phase3/includes/OutputPage.php:63549,63764,63897-63901,64881
   + /branches/REL1_15/phase3/includes/OutputPage.php:51646
/branches/wmf-deployment/includes/OutputPage.php:53381,57468
/trunk/phase3/includes/OutputPage.php:63549,63764,63897-63901,64881,64892,64918

Modified: branches/REL1_16/phase3/includes/parser/Parser.php
===================================================================
--- branches/REL1_16/phase3/includes/parser/Parser.php  2010-04-21 14:22:55 UTC 
(rev 65392)
+++ branches/REL1_16/phase3/includes/parser/Parser.php  2010-04-21 14:51:15 UTC 
(rev 65393)
@@ -305,7 +305,7 @@
                 * to internalParse() which does all the real work.
                 */
 
-               global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, 
$wgDisableLangConversion, $wgUser, $wgRequest, $wgDisableTitleConversion;
+               global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, 
$wgDisableLangConversion, $wgDisableTitleConversion;
                $fname = __METHOD__.'-' . wfGetCaller();
                wfProfileIn( __METHOD__ );
                wfProfileIn( $fname );
@@ -379,16 +379,16 @@
                 */
                if ( !( $wgDisableLangConversion
                                || $wgDisableTitleConversion
-                               || $wgRequest->getText( 'redirect', 'yes' ) == 
'no'
-                               || $wgRequest->getText( 'linkconvert', 'yes' ) 
== 'no'
                                || isset( 
$this->mDoubleUnderscores['nocontentconvert'] )
                                || isset( 
$this->mDoubleUnderscores['notitleconvert'] )
-                               || $wgUser->getOption( 'noconvertlink' ) == 1 ) 
) {
+                               || $this->mOutput->getDisplayTitle() !== false 
) ) 
+               {
                        $convruletitle = $wgContLang->getConvRuleTitle();
                        if ( $convruletitle ) {
                                $this->mOutput->setTitleText( $convruletitle );
                        } else {
-                               $this->mOutput->setTitleText( 
$wgContLang->convert( $title->getPrefixedText(), true ) );
+                               $titleText = $wgContLang->convertTitle( $title 
);
+                               $this->mOutput->setTitleText( $titleText );
                        }
                }
 

Modified: branches/REL1_16/phase3/languages/Language.php
===================================================================
--- branches/REL1_16/phase3/languages/Language.php      2010-04-21 14:22:55 UTC 
(rev 65392)
+++ branches/REL1_16/phase3/languages/Language.php      2010-04-21 14:51:15 UTC 
(rev 65393)
@@ -34,9 +34,10 @@
  */
 class FakeConverter {
        var $mLang;
-       function FakeConverter($langobj) {$this->mLang = $langobj;}
-       function autoConvertToAllVariants($text) {return $text;}
-       function convert($t, $i) {return $t;}
+       function FakeConverter( $langobj ) { $this->mLang = $langobj; }
+       function autoConvertToAllVariants( $text ) { return $text; }
+       function convert( $t ) { return $t; }
+       function convertTitle( $t ) { return $t->getPrefixedText(); }
        function getVariants() { return array( $this->mLang->getCode() ); }
        function getPreferredVariant() { return $this->mLang->getCode(); }
        function getConvRuleTitle() { return false; }
@@ -2319,10 +2320,15 @@
        }
 
        # convert text to different variants of a language.
-       function convert( $text, $isTitle = false) {
-               return $this->mConverter->convert($text, $isTitle);
+       function convert( $text ) {
+               return $this->mConverter->convert( $text );
        }
 
+       # Convert a Title object to a string in the preferred variant
+       function convertTitle( $title ) {
+               return $this->mConverter->convertTitle( $title );
+       }
+
        # Check if this is a language with variants
        function hasVariants(){
                return sizeof($this->getVariants())>1;

Modified: branches/REL1_16/phase3/languages/LanguageConverter.php
===================================================================
--- branches/REL1_16/phase3/languages/LanguageConverter.php     2010-04-21 
14:22:55 UTC (rev 65392)
+++ branches/REL1_16/phase3/languages/LanguageConverter.php     2010-04-21 
14:51:15 UTC (rev 65393)
@@ -520,24 +520,6 @@
        }
 
        /**
-        * Convert namespace.
-        * @param $title String: the title included namespace
-        * @return Array of string
-        * @private
-        */
-       function convertNamespace( $title, $variant ) {
-               $splittitle = explode( ':', $title, 2 );
-               if ( count( $splittitle ) < 2 ) {
-                       return $title;
-               }
-               if ( isset( $this->mNamespaceTables[$variant][$splittitle[0]] ) 
) {
-                       $splittitle[0] = 
$this->mNamespaceTables[$variant][$splittitle[0]];
-               }
-               $ret = implode( ':', $splittitle );
-               return $ret;
-       }
-
-       /**
         * Convert text to different variants of a language. The automatic
         * conversion is done in autoConvert(). Here we parse the text
         * marked with -{}-, which specifies special conversions of the
@@ -551,19 +533,34 @@
         * @param $text String: text to be converted
         * @return String: converted text
         */
-       public function convert( $text, $istitle = false ) {
+       public function convert( $text ) {
                global $wgDisableLangConversion;
                if ( $wgDisableLangConversion ) return $text;
 
                $variant = $this->getPreferredVariant();
 
-               if( $istitle ) {
-                       $text = $this->convertNamespace( $text, $variant );
-               }
-
                return $this->recursiveConvertTopLevel( $text, $variant );
        }
 
+       /**
+        * Convert a Title object to a readable string in the preferred variant
+        */
+       public function convertTitle( $title ) {
+               $variant = $this->getPreferredVariant();
+               if ( $title->getNamespace() === NS_MAIN ) {
+                       $text = '';
+               } else {
+                       $text = $title->getNsText();
+                       if ( isset( $this->mNamespaceTables[$variant][$text] ) 
) {
+                               $text = 
$this->mNamespaceTables[$variant][$text];
+                       }
+                       $text .= ':';
+               }
+               $text .= $title->getText();
+               $text = $this->autoConvert( $text, $variant );
+               return $text;
+       }
+
        protected function recursiveConvertTopLevel( $text, $variant, $depth = 
0 ) {
                $startPos = 0;
                $out = '';



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to