Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -2091,13 +2091,16 @@ |
2092 | 2092 | * save and then make a comparison. |
2093 | 2093 | */ |
2094 | 2094 | function showDiff() { |
| 2095 | + global $wgUser, $wgContLang, $wgParser; |
| 2096 | + |
2095 | 2097 | $oldtext = $this->mArticle->fetchContent(); |
2096 | 2098 | $newtext = $this->mArticle->replaceSection( |
2097 | 2099 | $this->section, $this->textbox1, $this->summary, $this->edittime ); |
2098 | 2100 | |
2099 | 2101 | wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) ); |
2100 | 2102 | |
2101 | | - $newtext = $this->mArticle->preSaveTransform( $newtext ); |
| 2103 | + $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); |
| 2104 | + $newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts ); |
2102 | 2105 | $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) ); |
2103 | 2106 | $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) ); |
2104 | 2107 | if ( $oldtext !== false || $newtext != '' ) { |
— | — | @@ -2296,10 +2299,25 @@ |
2297 | 2300 | * @return string |
2298 | 2301 | */ |
2299 | 2302 | function getPreviewText() { |
2300 | | - global $wgOut, $wgUser, $wgParser; |
| 2303 | + global $wgOut, $wgUser, $wgParser, $wgRawHtml; |
2301 | 2304 | |
2302 | 2305 | wfProfileIn( __METHOD__ ); |
2303 | 2306 | |
| 2307 | + if ( $wgRawHtml && !$this->mTokenOk ) { |
| 2308 | + // Could be an offsite preview attempt. This is very unsafe if |
| 2309 | + // HTML is enabled, as it could be an attack. |
| 2310 | + $parsedNote = ''; |
| 2311 | + if ( $this->textbox1 !== '' ) { |
| 2312 | + // Do not put big scary notice, if previewing the empty |
| 2313 | + // string, which happens when you initially edit |
| 2314 | + // a category page, due to automatic preview-on-open. |
| 2315 | + $parsedNote = $wgOut->parse( "<div class='previewnote'>" . |
| 2316 | + wfMsg( 'session_fail_preview_html' ) . "</div>", true, /* interface */true ); |
| 2317 | + } |
| 2318 | + wfProfileOut( __METHOD__ ); |
| 2319 | + return $parsedNote; |
| 2320 | + } |
| 2321 | + |
2304 | 2322 | if ( $this->mTriedSave && !$this->mTokenOk ) { |
2305 | 2323 | if ( $this->mTokenOkExceptSuffix ) { |
2306 | 2324 | $note = wfMsg( 'token_suffix_mismatch' ); |
— | — | @@ -2314,25 +2332,10 @@ |
2315 | 2333 | |
2316 | 2334 | $parserOptions = ParserOptions::newFromUser( $wgUser ); |
2317 | 2335 | $parserOptions->setEditSection( false ); |
| 2336 | + $parserOptions->setTidy( true ); |
2318 | 2337 | $parserOptions->setIsPreview( true ); |
2319 | 2338 | $parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' ); |
2320 | 2339 | |
2321 | | - global $wgRawHtml; |
2322 | | - if ( $wgRawHtml && !$this->mTokenOk ) { |
2323 | | - // Could be an offsite preview attempt. This is very unsafe if |
2324 | | - // HTML is enabled, as it could be an attack. |
2325 | | - $parsedNote = ''; |
2326 | | - if ( $this->textbox1 !== '' ) { |
2327 | | - // Do not put big scary notice, if previewing the empty |
2328 | | - // string, which happens when you initially edit |
2329 | | - // a category page, due to automatic preview-on-open. |
2330 | | - $parsedNote = $wgOut->parse( "<div class='previewnote'>" . |
2331 | | - wfMsg( 'session_fail_preview_html' ) . "</div>", true, /* interface */true ); |
2332 | | - } |
2333 | | - wfProfileOut( __METHOD__ ); |
2334 | | - return $parsedNote; |
2335 | | - } |
2336 | | - |
2337 | 2340 | # don't parse non-wikitext pages, show message about preview |
2338 | 2341 | # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago? |
2339 | 2342 | |
— | — | @@ -2359,7 +2362,6 @@ |
2360 | 2363 | } |
2361 | 2364 | } |
2362 | 2365 | |
2363 | | - $parserOptions->setTidy( true ); |
2364 | 2366 | $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions ); |
2365 | 2367 | $previewHTML = $parserOutput->mText; |
2366 | 2368 | $previewHTML .= "<pre class=\"$class\" dir=\"ltr\">\n" . htmlspecialchars( $this->textbox1 ) . "\n</pre>\n"; |
— | — | @@ -2378,11 +2380,11 @@ |
2379 | 2381 | |
2380 | 2382 | wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) ); |
2381 | 2383 | |
2382 | | - $parserOptions->setTidy( true ); |
2383 | 2384 | $parserOptions->enableLimitReport(); |
2384 | | - $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ), |
2385 | | - $this->mTitle, $parserOptions ); |
2386 | 2385 | |
| 2386 | + $toparse = $wgParser->preSaveTransform( $toparse, $this->mTitle, $wgUser, $parserOptions ); |
| 2387 | + $parserOutput = $wgParser->parse( $toparse, $this->mTitle, $parserOptions ); |
| 2388 | + |
2387 | 2389 | $previewHTML = $parserOutput->getText(); |
2388 | 2390 | $this->mParserOutput = $parserOutput; |
2389 | 2391 | $wgOut->addParserOutputNoText( $parserOutput ); |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1977,7 +1977,7 @@ |
1978 | 1978 | $edit = (object)array(); |
1979 | 1979 | $edit->revid = $revid; |
1980 | 1980 | $edit->newText = $text; |
1981 | | - $edit->pst = $this->preSaveTransform( $text, $user, $popts ); |
| 1981 | + $edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts ); |
1982 | 1982 | $edit->popts = $this->makeParserOptions( 'canonical' ); |
1983 | 1983 | $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid ); |
1984 | 1984 | $edit->oldText = $this->getRawText(); |
— | — | @@ -2131,6 +2131,7 @@ |
2132 | 2132 | * This function is called right before saving the wikitext, |
2133 | 2133 | * so we can do things like signatures and links-in-context. |
2134 | 2134 | * |
| 2135 | + * @deprecated in 1.19; use Parser::preSaveTransform() instead |
2135 | 2136 | * @param $text String article contents |
2136 | 2137 | * @param $user User object: user doing the edit |
2137 | 2138 | * @param $popts ParserOptions object: parser options, default options for |
— | — | @@ -2140,6 +2141,9 @@ |
2141 | 2142 | */ |
2142 | 2143 | public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) { |
2143 | 2144 | global $wgParser, $wgUser; |
| 2145 | + |
| 2146 | + wfDeprecated( __METHOD__ ); |
| 2147 | + |
2144 | 2148 | $user = is_null( $user ) ? $wgUser : $user; |
2145 | 2149 | |
2146 | 2150 | if ( $popts === null ) { |