$preload = $wgRequest->getVal( 'preload',
// Custom preload text for new sections
$this->section === 'new' ? 'MediaWiki:addsection-preload' : '' );
+ $params = $wgRequest->getArray( 'preloadparams', array() );
- $content = $this->getPreloadedContent( $preload );
+ $content = $this->getPreloadedContent( $preload, $params );
}
// For existing pages, get text based on "undo" or section parameters.
} else {
* an earlier setPreloadText() or by loading the given page.
*
* @param string $preload representing the title to preload from.
+ * @param Array $params Parameters to use (interface-message style) in the preloaded text
*
* @return Content
*
* @since 1.21
*/
- protected function getPreloadedContent( $preload ) {
+ protected function getPreloadedContent( $preload, $params = array() ) {
global $wgUser;
if ( !empty( $this->mPreloadContent ) ) {
$content = $converted;
}
- return $content->preloadTransform( $title, $parserOptions );
+ return $content->preloadTransform( $title, $parserOptions, $params );
}
/**
*
* @see Content::preloadTransform
*/
- public function preloadTransform( Title $title, ParserOptions $popts ) {
+ public function preloadTransform( Title $title, ParserOptions $popts, $params = array() ) {
return $this;
}
*
* @param Title $title
* @param ParserOptions $parserOptions
+ * @param array $params
*
* @return Content
*/
- public function preloadTransform( Title $title, ParserOptions $parserOptions );
+ public function preloadTransform( Title $title, ParserOptions $parserOptions, $params = array() );
/**
* Prepare Content for saving. Called before Content is saved by WikiPage::doEditContent() and in
*
* @param Title $title
* @param ParserOptions $popts
+ * @param array $params
*
* @return Content
*/
- public function preloadTransform( Title $title, ParserOptions $popts ) {
+ public function preloadTransform( Title $title, ParserOptions $popts, $params = array() ) {
global $wgParser;
$text = $this->getNativeData();
- $plt = $wgParser->getPreloadText( $text, $title, $popts );
+ $plt = $wgParser->getPreloadText( $text, $title, $popts, $params );
return new WikitextContent( $plt );
}
* @param $text String
* @param $title Title
* @param $options ParserOptions
+ * @param $params Array
* @return String
*/
- public function getPreloadText( $text, Title $title, ParserOptions $options ) {
+ public function getPreloadText( $text, Title $title, ParserOptions $options, $params = array() ) {
+ $msg = new RawMessage( $text );
+ $text = $msg->params( $params )->plain();
+
# Parser (re)initialisation
$this->startParse( $title, $options, self::OT_PLAIN, true );