if ( $this->mTriedSave && !$this->mTokenOk ) {
if ( $this->mTokenOkExceptSuffix ) {
- $msg = 'token_suffix_mismatch';
+ $note = wfMsg( 'token_suffix_mismatch' );
} else {
- $msg = 'session_fail_preview';
+ $note = wfMsg( 'session_fail_preview' );
}
} else {
- $msg = 'previewnote';
- }
- $previewhead = '<h2>' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>\n" .
- "<div class='previewnote'>" . $wgOut->parse( wfMsg( $msg ) ) . "</div>\n";
- if ( $this->isConflict ) {
- $previewhead.='<h2>' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n";
+ $note = wfMsg( 'previewnote' );
}
$parserOptions = ParserOptions::newFromUser( $wgUser );
$parserOptions->setTidy(true);
$parserOutput = $wgParser->parse( $previewtext , $this->mTitle, $parserOptions );
$wgOut->addHTML( $parserOutput->mText );
- wfProfileOut( $fname );
- return $previewhead;
+ $previewHTML = '';
} else {
$toparse = $this->textbox1;
foreach ( array_keys( $template ) as $dbk)
$this->mPreviewTemplates[] = Title::makeTitle($ns, $dbk);
- wfProfileOut( $fname );
- return $previewhead . $previewHTML;
+ if ( count( $parserOutput->getWarnings() ) ) {
+ $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
+ }
}
+
+ $previewhead = '<h2>' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>\n" .
+ "<div class='previewnote'>" . $wgOut->parse( $note ) . "</div>\n";
+ if ( $this->isConflict ) {
+ $previewhead.='<h2>' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n";
+ }
+
+ wfProfileOut( $fname );
+ return $previewhead . $previewHTML;
}
/**
var $mNewSectionLink = false;
var $mNoGallery = false;
var $mPageTitleActionText = '';
+ var $mParseWarnings = array();
/**
* Constructor
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->mNewSectionLink = $parserOutput->getNewSection();
$this->addKeywords( $parserOutput );
+ $this->mParseWarnings = $parserOutput->getWarnings();
if ( $parserOutput->getCacheTime() == -1 ) {
$this->enableClientCache( false );
}
$this->addHtml( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
}
}
-
+
}
*/
class PPFrame {
var $parser, $title;
+ var $titleCache;
const NO_ARGS = 1;
const NO_TEMPLATES = 2;
function __construct( $parser ) {
$this->parser = $parser;
$this->title = $parser->mTitle;
+ $this->titleCache = array( $this->title->getPrefixedDBkey() );
}
/**
function __toString() {
return 'frame{}';
}
+
+ function getPDBK( $level = false ) {
+ if ( $level === false ) {
+ return $this->title->getPrefixedDBkey();
+ } else {
+ return isset( $this->titleCache[$level] ) ? $this->titleCache[$level] : false;
+ }
+ }
}
/**
* Expansion frame with template arguments
*/
class PPTemplateFrame extends PPFrame {
- public $parser, $args, $parent, $serial;
+ var $parser, $args, $parent;
+ var $titleCache;
function __construct( $parser, $parent = false, $args = array(), $title = false ) {
$this->parser = $parser;
$this->parent = $parent;
$this->args = $args;
$this->title = $title;
+ $this->titleCache = $parent->titleCache;
+ $this->titleCache[] = $title->getPrefixedDBkey();
}
function __toString() {
$mNewSection, # Show a new section link?
$mNoGallery, # No gallery on category page? (__NOGALLERY__)
$mHeadItems, # Items to put in the <head> section
- $mOutputHooks; # Hook tags as per $wgParserOutputHooks
+ $mOutputHooks, # Hook tags as per $wgParserOutputHooks
+ $mWarnings; # Warning text to be returned to the user. Wikitext formatted.
/**
* Overridden title for display
$this->mHeadItems = array();
$this->mTemplateIds = array();
$this->mOutputHooks = array();
+ $this->mWarnings = array();
}
function getText() { return $this->mText; }
function getNoGallery() { return $this->mNoGallery; }
function getSubtitle() { return $this->mSubtitle; }
function getOutputHooks() { return (array)$this->mOutputHooks; }
+ function getWarnings() { return isset( $this->mWarnings ) ? $this->mWarnings : array(); }
function containsOldMagic() { return $this->mContainsOldMagic; }
function setText( $text ) { return wfSetVar( $this->mText, $text ); }
function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
function addExternalLink( $url ) { $this->mExternalLinks[$url] = 1; }
+ function addWarning( $s ) { $this->mWarnings[] = $s; }
function addOutputHook( $hook, $data = false ) {
$this->mOutputHooks[] = array( $hook, $data );