* save and then make a comparison.
*/
function showDiff() {
+ global $wgUser, $wgContLang, $wgParser;
+
$oldtext = $this->mArticle->fetchContent();
$newtext = $this->mArticle->replaceSection(
$this->section, $this->textbox1, $this->summary, $this->edittime );
wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) );
- $newtext = $this->mArticle->preSaveTransform( $newtext );
+ $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
+ $newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts );
$oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) );
$newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) );
if ( $oldtext !== false || $newtext != '' ) {
* @return string
*/
function getPreviewText() {
- global $wgOut, $wgUser, $wgParser;
+ global $wgOut, $wgUser, $wgParser, $wgRawHtml;
wfProfileIn( __METHOD__ );
+ if ( $wgRawHtml && !$this->mTokenOk ) {
+ // Could be an offsite preview attempt. This is very unsafe if
+ // HTML is enabled, as it could be an attack.
+ $parsedNote = '';
+ if ( $this->textbox1 !== '' ) {
+ // Do not put big scary notice, if previewing the empty
+ // string, which happens when you initially edit
+ // a category page, due to automatic preview-on-open.
+ $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
+ wfMsg( 'session_fail_preview_html' ) . "</div>", true, /* interface */true );
+ }
+ wfProfileOut( __METHOD__ );
+ return $parsedNote;
+ }
+
if ( $this->mTriedSave && !$this->mTokenOk ) {
if ( $this->mTokenOkExceptSuffix ) {
$note = wfMsg( 'token_suffix_mismatch' );
$parserOptions = ParserOptions::newFromUser( $wgUser );
$parserOptions->setEditSection( false );
+ $parserOptions->setTidy( true );
$parserOptions->setIsPreview( true );
$parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' );
- global $wgRawHtml;
- if ( $wgRawHtml && !$this->mTokenOk ) {
- // Could be an offsite preview attempt. This is very unsafe if
- // HTML is enabled, as it could be an attack.
- $parsedNote = '';
- if ( $this->textbox1 !== '' ) {
- // Do not put big scary notice, if previewing the empty
- // string, which happens when you initially edit
- // a category page, due to automatic preview-on-open.
- $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
- wfMsg( 'session_fail_preview_html' ) . "</div>", true, /* interface */true );
- }
- wfProfileOut( __METHOD__ );
- return $parsedNote;
- }
-
# don't parse non-wikitext pages, show message about preview
# 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?
}
}
- $parserOptions->setTidy( true );
$parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
$previewHTML = $parserOutput->mText;
$previewHTML .= "<pre class=\"$class\" dir=\"ltr\">\n" . htmlspecialchars( $this->textbox1 ) . "\n</pre>\n";
wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
- $parserOptions->setTidy( true );
$parserOptions->enableLimitReport();
- $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
- $this->mTitle, $parserOptions );
+
+ $toparse = $wgParser->preSaveTransform( $toparse, $this->mTitle, $wgUser, $parserOptions );
+ $parserOutput = $wgParser->parse( $toparse, $this->mTitle, $parserOptions );
$previewHTML = $parserOutput->getText();
$this->mParserOutput = $parserOutput;
$edit = (object)array();
$edit->revid = $revid;
$edit->newText = $text;
- $edit->pst = $this->preSaveTransform( $text, $user, $popts );
+ $edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts );
$edit->popts = $this->makeParserOptions( 'canonical' );
$edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
$edit->oldText = $this->getRawText();
* This function is called right before saving the wikitext,
* so we can do things like signatures and links-in-context.
*
+ * @deprecated in 1.19; use Parser::preSaveTransform() instead
* @param $text String article contents
* @param $user User object: user doing the edit
* @param $popts ParserOptions object: parser options, default options for
*/
public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) {
global $wgParser, $wgUser;
+
+ wfDeprecated( __METHOD__ );
+
$user = is_null( $user ) ? $wgUser : $user;
if ( $popts === null ) {