Index: trunk/phase3/includes/ParserOutput.php |
— | — | @@ -17,11 +17,14 @@ |
18 | 18 | $mTemplateIds, # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. |
19 | 19 | $mImages, # DB keys of the images used, in the array key only |
20 | 20 | $mExternalLinks, # External link URLs, in the key only |
21 | | - $mHTMLtitle, # Display HTML title |
22 | | - $mSubtitle, # Additional subtitle |
23 | 21 | $mNewSection, # Show a new section link? |
24 | 22 | $mNoGallery, # No gallery on category page? (__NOGALLERY__) |
25 | 23 | $mHeadItems; # Items to put in the <head> section |
| 24 | + |
| 25 | + /** |
| 26 | + * Overridden title for display |
| 27 | + */ |
| 28 | + private $displayTitle = false; |
26 | 29 | |
27 | 30 | function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(), |
28 | 31 | $containsOldMagic = false, $titletext = '' ) |
— | — | @@ -37,8 +40,6 @@ |
38 | 41 | $this->mTemplates = array(); |
39 | 42 | $this->mImages = array(); |
40 | 43 | $this->mExternalLinks = array(); |
41 | | - $this->mHTMLtitle = "" ; |
42 | | - $this->mSubtitle = "" ; |
43 | 44 | $this->mNewSection = false; |
44 | 45 | $this->mNoGallery = false; |
45 | 46 | $this->mHeadItems = array(); |
— | — | @@ -65,7 +66,6 @@ |
66 | 67 | function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); } |
67 | 68 | function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); } |
68 | 69 | function setTitleText( $t ) { return wfSetVar($this->mTitleText, $t); } |
69 | | - function setSubtitle( $st ) { return wfSetVar( $this->mSubtitle, $st ); } |
70 | 70 | |
71 | 71 | function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; } |
72 | 72 | function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; } |
— | — | @@ -137,6 +137,27 @@ |
138 | 138 | $this->mHeadItems[] = $section; |
139 | 139 | } |
140 | 140 | } |
| 141 | + |
| 142 | + /** |
| 143 | + * Override the title to be used for display |
| 144 | + * -- this is assumed to have been validated |
| 145 | + * (check equal normalisation, etc.) |
| 146 | + * |
| 147 | + * @param string $text Desired title text |
| 148 | + */ |
| 149 | + public function setDisplayTitle( $text ) { |
| 150 | + $this->displayTitle = $text; |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Get the title to be used for display |
| 155 | + * |
| 156 | + * @return string |
| 157 | + */ |
| 158 | + public function getDisplayTitle() { |
| 159 | + return $this->displayTitle; |
| 160 | + } |
| 161 | + |
141 | 162 | } |
142 | 163 | |
143 | 164 | ?> |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | * changes in an incompatible way, so the parser cache |
14 | 14 | * can automatically discard old data. |
15 | 15 | */ |
16 | | -define( 'MW_PARSER_VERSION', '1.6.1' ); |
| 16 | +define( 'MW_PARSER_VERSION', '1.6.2' ); |
17 | 17 | |
18 | 18 | define( 'RLH_FOR_UPDATE', 1 ); |
19 | 19 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -381,17 +381,15 @@ |
382 | 382 | if ( $parserOutput->getCacheTime() == -1 ) { |
383 | 383 | $this->enableClientCache( false ); |
384 | 384 | } |
385 | | - if ( $parserOutput->mHTMLtitle != "" ) { |
386 | | - $this->mPagetitle = $parserOutput->mHTMLtitle ; |
387 | | - } |
388 | | - if ( $parserOutput->mSubtitle != '' ) { |
389 | | - $this->mSubtitle .= $parserOutput->mSubtitle ; |
390 | | - } |
391 | 385 | $this->mNoGallery = $parserOutput->getNoGallery(); |
392 | 386 | $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems ); |
393 | 387 | // Versioning... |
394 | 388 | $this->mTemplateIds += (array)$parserOutput->mTemplateIds; |
395 | 389 | |
| 390 | + # Display title |
| 391 | + if( ( $dt = $parserOutput->getDisplayTitle() ) !== false ) |
| 392 | + $this->setPageTitle( $dt ); |
| 393 | + |
396 | 394 | wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) ); |
397 | 395 | } |
398 | 396 | |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2539,7 +2539,7 @@ |
2540 | 2540 | /** |
2541 | 2541 | * Allow DISPLAYTITLE to change title display |
2542 | 2542 | */ |
2543 | | -$wgAllowDisplayTitle = false ; |
| 2543 | +$wgAllowDisplayTitle = true; |
2544 | 2544 | |
2545 | 2545 | /** |
2546 | 2546 | * Array of usernames which may not be registered or logged in from |
Index: trunk/phase3/includes/CoreParserFunctions.php |
— | — | @@ -97,15 +97,20 @@ |
98 | 98 | return $parser->getFunctionLang()->convertPlural( $text, $arg0, $arg1, $arg2, $arg3, $arg4 ); |
99 | 99 | } |
100 | 100 | |
101 | | - static function displaytitle( $parser, $param = '' ) { |
102 | | - $parserOptions = new ParserOptions; |
103 | | - $local_parser = clone $parser; |
104 | | - $t2 = $local_parser->parse ( $param, $parser->mTitle, $parserOptions, false ); |
105 | | - $parser->mOutput->mHTMLtitle = $t2->GetText(); |
106 | | - |
107 | | - # Add subtitle |
108 | | - $t = $parser->mTitle->getPrefixedText(); |
109 | | - $parser->mOutput->mSubtitle .= wfMsg('displaytitle', $t); |
| 101 | + /** |
| 102 | + * Override the title of the page when viewed, |
| 103 | + * provided we've been given a title which |
| 104 | + * will normalise to the canonical title |
| 105 | + * |
| 106 | + * @param Parser $parser Parent parser |
| 107 | + * @param string $text Desired title text |
| 108 | + * @return string |
| 109 | + */ |
| 110 | + static function displaytitle( $parser, $text = '' ) { |
| 111 | + $text = trim( $text ); |
| 112 | + $title = Title::newFromText( $text ); |
| 113 | + if( $title instanceof Title && $title->equals( $parser->mTitle ) ) |
| 114 | + $parser->mOutput->setDisplayTitle( $text ); |
110 | 115 | return ''; |
111 | 116 | } |
112 | 117 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -102,8 +102,9 @@ |
103 | 103 | * Added option to install to MyISAM |
104 | 104 | * (bug 9250) Remove hardcoded minimum image name length of three characters |
105 | 105 | * (bug 10338) Enforce signature length limit in Unicode characters instead of bytes |
| 106 | +* Fixed DISPLAYTITLE behaviour to reject titles which don't normalise to the |
| 107 | + same title as the current page, and enabled per default |
106 | 108 | |
107 | | - |
108 | 109 | == Bugfixes since 1.10 == |
109 | 110 | |
110 | 111 | * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi |