From fedceb4bcdae9a67b692eabfe259d78d39ffcab0 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Sat, 2 Jul 2005 14:38:15 +0000 Subject: [PATCH] Add two new parameters for editing new pages: &preload=Page_name => Content of [[Page name]] will be loaded into the textarea. &&editintro=Page_name => Content of [[Page name]] will be used instead of [[MediaWiki:Newarticletext]]. Respects read permissions. Primary purpose: Customizing of edit pages for newbies, use of custom page templates. Possible future changes: Make preload work with §ion=new, make editintro work with any edit. --- includes/Article.php | 22 ++++++++++++++++++++-- includes/EditPage.php | 18 ++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 57a1fe0bde..9b86e9192d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -86,16 +86,34 @@ class Article { # Get variables from query string :P $action = $wgRequest->getText( 'action', 'view' ); $section = $wgRequest->getText( 'section' ); + $preload = $wgRequest->getText( 'preload' ); + $newpagetext = $wgRequest->getText('newpagetext'); $fname = 'Article::getContent'; wfProfileIn( $fname ); if ( 0 == $this->getID() ) { if ( 'edit' == $action ) { - wfProfileOut( $fname ); - return ''; # was "newarticletext", now moved above the box) + wfProfileOut( $fname ); + # Should we put something in the textarea? + # if &preload=Pagename is set, we try to get + # the revision text and put it in. + if($preload) { + $preloadTitle=Title::newFromText($preload); + if($preloadTitle->userCanRead()) { + $rev=Revision::newFromTitle($preloadTitle); + if($rev) { + return $rev->getText(); + } + } + } + # Don't preload anything. + # We used to put MediaWiki:Newarticletext here. + # This is now shown above the edit box instead. + return ''; } wfProfileOut( $fname ); + return wfMsg( 'noarticletext' ); } else { $this->loadContent( $noredir ); diff --git a/includes/EditPage.php b/includes/EditPage.php index a97558f73b..8729b94788 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -298,7 +298,7 @@ class EditPage { function editForm( $formtype, $firsttime = false ) { global $wgOut, $wgUser; global $wgLang, $wgContLang, $wgParser, $wgTitle; - global $wgAllowAnonymousMinor; + global $wgAllowAnonymousMinor, $wgRequest; global $wgSpamRegex, $wgFilterCallback; $sk = $wgUser->getSkin(); @@ -308,7 +308,21 @@ class EditPage { if(!$this->mTitle->getArticleID()) { # new article - $wgOut->addWikiText(wfmsg('newarticletext')); + $editintro = $wgRequest->getText( 'editintro' ); + $addstandardintro=true; + if($editintro) { + $introtitle=Title::newFromText($editintro); + if($introtitle->userCanRead()) { + $rev=Revision::newFromTitle($introtitle); + if($rev) { + $wgOut->addWikiText($rev->getText()); + $addstandardintro=false; + } + } + } + if($addstandardintro) { + $wgOut->addWikiText(wfmsg('newarticletext')); + } } if( $this->mTitle->isTalkPage() ) { -- 2.20.1