Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | <div id="content"> |
117 | 117 | <a name="top" id="top"></a> |
118 | 118 | <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?> |
119 | | - <h1 class="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1> |
| 119 | + <h1 class="firstHeading"><?php $this->html('title'); ?></h1> |
120 | 120 | <div id="bodyContent"> |
121 | 121 | <h3 id="siteSub"><?php $this->msg('tagline') ?></h3> |
122 | 122 | <div id="contentSub"><?php $this->html('subtitle') ?></div> |
— | — | @@ -371,3 +371,4 @@ |
372 | 372 | } // end of class |
373 | 373 | |
374 | 374 | |
| 375 | + |
Index: trunk/phase3/skins/Modern.php |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>"> |
104 | 104 | |
105 | 105 | <!-- heading --> |
106 | | - <div id="mw_header"><h1 id="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1></div> |
| 106 | + <div id="mw_header"><h1 id="firstHeading"><?php $this->html('title') ?></h1></div> |
107 | 107 | |
108 | 108 | <div id="mw_main"> |
109 | 109 | <div id="mw_contentwrapper"> |
Index: trunk/phase3/includes/parser/ParserOutput.php |
— | — | @@ -29,7 +29,8 @@ |
30 | 30 | /** |
31 | 31 | * Overridden title for display |
32 | 32 | */ |
33 | | - private $displayTitle = false; |
| 33 | + private $displayTitle = false; #for use in the <title> tag |
| 34 | + private $displayTitleH1 = false; #for use in the <h1> tag, may contain further HTML tags |
34 | 35 | |
35 | 36 | function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(), |
36 | 37 | $containsOldMagic = false, $titletext = '' ) |
— | — | @@ -145,6 +146,15 @@ |
146 | 147 | } |
147 | 148 | |
148 | 149 | /** |
| 150 | + * Get the title to be used for display |
| 151 | + * |
| 152 | + * @return string |
| 153 | + */ |
| 154 | + public function getDisplayTitle() { |
| 155 | + return $this->displayTitle; |
| 156 | + } |
| 157 | + |
| 158 | + /** |
149 | 159 | * Override the title to be used for display |
150 | 160 | * -- this is assumed to have been validated |
151 | 161 | * (check equal normalisation, etc.) |
— | — | @@ -154,15 +164,14 @@ |
155 | 165 | public function setDisplayTitle( $text ) { |
156 | 166 | $this->displayTitle = $text; |
157 | 167 | } |
158 | | - |
159 | | - /** |
160 | | - * Get the title to be used for display |
161 | | - * |
162 | | - * @return string |
163 | | - */ |
164 | | - public function getDisplayTitle() { |
165 | | - return $this->displayTitle; |
| 168 | + |
| 169 | + public function getDisplayTitleH1() { |
| 170 | + return $this->displayTitleH1; |
166 | 171 | } |
| 172 | + |
| 173 | + public function setDisplayTitleH1( $html ) { |
| 174 | + $this->displayTitleH1 = $html; |
| 175 | + } |
167 | 176 | |
168 | 177 | /** |
169 | 178 | * Fairly generic flag setter thingy. |
Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -168,17 +168,24 @@ |
169 | 169 | * @param string $text Desired title text |
170 | 170 | * @return string |
171 | 171 | */ |
172 | | - static function displaytitle( $parser, $text = '' ) { |
| 172 | + static function displaytitle( $parser, $displayTitleH1 = '' ) { |
173 | 173 | global $wgRestrictDisplayTitle; |
174 | | - $text = trim( Sanitizer::decodeCharReferences( $text ) ); |
175 | | - |
| 174 | + |
| 175 | + $titleHTML = Sanitizer::removeHTMLtags( $displayTitleH1 ); #escape the bad tags |
| 176 | + $titleText = trim( Sanitizer::stripAllTags( $titleHTML ) ); #remove the good tags, leaving the bad tags escaped, and trim it to make sure it comes out pretty |
| 177 | + |
176 | 178 | if ( !$wgRestrictDisplayTitle ) { |
177 | | - $parser->mOutput->setDisplayTitle( $text ); |
| 179 | + $parser->mOutput->setDisplayTitleH1( $titleHTML ); |
| 180 | + $parser->mOutput->setDisplayTitle( $titleText ); |
178 | 181 | } else { |
179 | | - $title = Title::newFromText( $text ); |
180 | | - if( $title instanceof Title && $title->getFragment() == '' && $title->equals( $parser->mTitle ) ) |
181 | | - $parser->mOutput->setDisplayTitle( $text ); |
| 182 | + # Only requested titles that normalize to the actual title are allowed through |
| 183 | + $title = Title::newFromText( $titleText ); |
| 184 | + if ( $title != null && $title->getFragment() == '' && $title->equals( $parser->mTitle ) ) { |
| 185 | + $parser->mOutput->setDisplayTitleH1( $titleHTML ); |
| 186 | + $parser->mOutput->setDisplayTitle( $titleText ); #put the stripped contents of <h1> into <title> |
| 187 | + } |
182 | 188 | } |
| 189 | + |
183 | 190 | return ''; |
184 | 191 | } |
185 | 192 | |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -1085,12 +1085,14 @@ |
1086 | 1086 | } else { |
1087 | 1087 | # Use the title defined by DISPLAYTITLE magic word when present |
1088 | 1088 | if ( isset( $this->mParserOutput ) |
1089 | | - && ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) { |
1090 | | - $title = $dt; |
| 1089 | + && ( $displayTitle = $this->mParserOutput->getDisplayTitle() ) !== false ) |
| 1090 | + { |
| 1091 | + $wgOut->setPageTitle( wfMsg( 'editing', $this->mParserOutput->getDisplayTitleH1() ) ); |
| 1092 | + # Override the HTML that setPageTitle slated for inclusion in the <title> |
| 1093 | + $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'editing', $displayTitle ) ) ); |
1091 | 1094 | } else { |
1092 | | - $title = $wgTitle->getPrefixedText(); |
| 1095 | + $wgOut->setPageTitle( wfMsg( 'editing', $wgTitle->getPrefixedText() ) ); |
1093 | 1096 | } |
1094 | | - $wgOut->setPageTitle( wfMsg( 'editing', $title ) ); |
1095 | 1097 | } |
1096 | 1098 | } |
1097 | 1099 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -309,7 +309,10 @@ |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | | - public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; } |
| 313 | + # "HTML title" means <title> |
| 314 | + public function setHTMLTitle( $name ) { $this->mHTMLtitle = $name; } |
| 315 | + |
| 316 | + # "Page title" means <h1> |
314 | 317 | public function setPageTitle( $name ) { |
315 | 318 | global $action, $wgContLang; |
316 | 319 | $name = $wgContLang->convert($name, true); |
— | — | @@ -320,7 +323,7 @@ |
321 | 324 | $name .= ' - '.$taction; |
322 | 325 | } |
323 | 326 | } |
324 | | - |
| 327 | + |
325 | 328 | $this->setHTMLTitle( wfMsg( 'pagetitle', $name ) ); |
326 | 329 | } |
327 | 330 | public function getHTMLTitle() { return $this->mHTMLtitle; } |
— | — | @@ -539,8 +542,10 @@ |
540 | 543 | } |
541 | 544 | } |
542 | 545 | // Display title |
543 | | - if( ( $dt = $parserOutput->getDisplayTitle() ) !== false ) |
544 | | - $this->setPageTitle( $dt ); |
| 546 | + if( ( $displayTitleText = $parserOutput->getDisplayTitle() ) !== false ) { |
| 547 | + $this->setPageTitle( $parserOutput->getDisplayTitleH1() ); |
| 548 | + $this->setHTMLTitle( wfMsg( 'pagetitle', $displayTitleText ) ); #override the HTML that setPageTitle slated for inclusion in the <title> |
| 549 | + } |
545 | 550 | |
546 | 551 | // Hooks registered in the object |
547 | 552 | global $wgParserOutputHooks; |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -1018,7 +1018,7 @@ |
1019 | 1019 | |
1020 | 1020 | function pageTitle() { |
1021 | 1021 | global $wgOut; |
1022 | | - $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>'; |
| 1022 | + $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>'; |
1023 | 1023 | return $s; |
1024 | 1024 | } |
1025 | 1025 | |