From 221f00408ad66fac0b42466f218249218f7102e3 Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Sat, 10 Apr 2010 05:46:01 +0000 Subject: [PATCH] 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. --- includes/OutputPage.php | 19 ++++++++++++++----- includes/parser/Parser.php | 4 ++-- languages/LanguageConverter.php | 6 +++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 38b3ef3baa..33753c0f81 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -9,7 +9,7 @@ class OutputPage { 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 @@ class OutputPage { } /** - * "HTML title" means the contents of . 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 @@ class OutputPage { } # change "<i>foo&bar</i>" to "foo&bar" - $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) ); + $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ), true ); } /** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8fd03961ed..6a2f29b31a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -303,7 +303,7 @@ class Parser { * 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 @@ class Parser { if ( $convruletitle ) { $this->mOutput->setTitleText( $convruletitle ); } else { - $this->mOutput->setTitleText( $wgContLang->convert( $this->mOutput->getTitleText() ) ); + $wgOut->setPageTitle( $wgContLang->convert( $wgOut->getPageTitle(), true ) ); } } diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 9e188cebc9..9a0eac9a8a 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -547,12 +547,16 @@ class LanguageConverter { * @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 ); } -- 2.20.1