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.
This commit is contained in:
parent
d81ad1041f
commit
fedceb4bcd
2 changed files with 36 additions and 4 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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() ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue