* Moved the responsibility for calling $wgOut->setPageTitle() from OutputPage::addParserOutputNoText() to the OutputPage/Parser caller. Previously, every call to $wgOut->addWikiText() (or any other message parsing function) was resulting in the title being reset to a converted version of $wgTitle, producing bug 23124. Moving responsibility to the caller seems to work fairly well, since there are apparently only two callers that really want {{DISPLAYTITLE}} etc. to work (EditPage and Article::view).
* Reverted data flow obfuscation in OutputPage::setHTMLTitle() from r64851, replaced by the above. The caller decides what overrides what.
* Reverted inappropriate, cache-polluting references to $wgUser and $wgRequest in Parser::parse(), introduced in r64819.
* Reverted incomprehensible boolean parameter to Language::convert() from r64851, reintroduced Language::convertTitle() instead. Gave it a simpler implementation than before.
* Fixed broken {{DISPLAYTITLE}} feature, was being unconditionally overwritten by the ParserOutput::setTitleText() call in Parser::parse(). Give {{DISPLAYTITLE}} precedence over autoconverted title, like we do for -{T|...}-.
* Tested extensively (perhaps not exhaustively)
}
}
+ # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
+ $titleText = $this->mParserOutput->getTitleText();
+ if ( strval( $titleText ) !== '' ) {
+ $wgOut->setPageTitle( $titleText );
+ }
+
# Now that we've filled $this->mParserOutput, we know whether
# there are any __NOINDEX__ tags on the page
$policy = $this->getRobotPolicy( 'view' );
var $mMetatags = array(), $mKeywords = array(), $mLinktags = array();
var $mExtStyles = array();
var $mPagetitle = '', $mBodytext = '', $mDebugtext = '';
- var $mHTMLtitle = '', $mHTMLtitleFromPagetitle = true, $mIsarticle = true, $mPrintable = false;
+ var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false;
var $mSubtitle = '', $mRedirect = '', $mStatusCode;
var $mLastModified = '', $mETag = false;
var $mCategoryLinks = array(), $mCategories = array(), $mLanguageLinks = array();
/**
* "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, $frompagetitle = false ) {
- if ( $frompagetitle && $this->mHTMLtitleFromPagetitle ) {
- $this->mHTMLtitle = $name;
- }
- elseif ( $this->mHTMLtitleFromPagetitle ) {
- $this->mHTMLtitle = $name;
- $this->mHTMLtitleFromPagetitle = false;
- }
+ public function setHTMLTitle( $name ) {
+ $this->mHTMLtitle = $name;
}
/**
$this->mTemplateIds[$ns] = $dbks;
}
}
- // Page title
- $title = $parserOutput->getTitleText();
- if ( $title != '' ) {
- $this->setPageTitle( $title );
- }
// Hooks registered in the object
global $wgParserOutputHooks;
* to internalParse() which does all the real work.
*/
- global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion, $wgUser, $wgRequest;
+ global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
$fname = __METHOD__.'-' . wfGetCaller();
wfProfileIn( __METHOD__ );
wfProfileIn( $fname );
*/
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 );
}
}
var $mLang;
function FakeConverter( $langobj ) { $this->mLang = $langobj; }
function autoConvertToAllVariants( $text ) { return $text; }
- function convert( $t, $i ) { return $t; }
+ 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; }
}
# 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
}
}
- /**
- * 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
* @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 = '';