From: Rob Church Date: Mon, 11 Jun 2007 11:57:20 +0000 (+0000) Subject: * Show custom editing introduction when editing existing pages, too X-Git-Tag: 1.31.0-rc.0~52583 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=97645af9fa29695253d80d101596787e6437e8f3;p=lhc%2Fweb%2Fwiklou.git * Show custom editing introduction when editing existing pages, too * Clean up handling of editing introductions [Based on a patch from ZJH] --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 78ee12e2a6..b1111a0cb3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -161,6 +161,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 6743) Don't link broken image links to the upload form when uploads are disabled * (bug 9679) Improve documentation for $wgSiteNotice +* Show custom editing introduction when editing existing pages == API changes since 1.10 == diff --git a/includes/EditPage.php b/includes/EditPage.php index a9a94d6ae3..e0dcc7554d 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -410,9 +410,10 @@ class EditPage { } } - if(!$this->mTitle->getArticleID() && ('initial' == $this->formtype || $this->firsttime )) { # new article + # Show applicable editing introductions + if( $this->formtype == 'initial' || $this->firsttime ) $this->showIntro(); - } + if( $this->mTitle->isTalkPage() ) { $wgOut->addWikiText( wfMsg( 'talkpagetext' ) ); } @@ -585,27 +586,38 @@ class EditPage { return $this->mTokenOk; } - /** */ - function showIntro() { + /** + * Show all applicable editing introductions + */ + private function showIntro() { global $wgOut, $wgUser; - $addstandardintro=true; - if($this->editintro) { - $introtitle=Title::newFromText($this->editintro); - if(isset($introtitle) && $introtitle->userCanRead()) { - $rev=Revision::newFromTitle($introtitle); - if($rev) { - $wgOut->addSecondaryWikiText($rev->getText()); - $addstandardintro=false; - } - } - } - if($addstandardintro) { - if ( $wgUser->isLoggedIn() ) + if( !$this->showCustomIntro() && !$this->mTitle->exists() ) { + if( $wgUser->isLoggedIn() ) { $wgOut->addWikiText( wfMsg( 'newarticletext' ) ); - else + } else { $wgOut->addWikiText( wfMsg( 'newarticletextanon' ) ); - # Let the user know about previous deletions if applicable $this->showDeletionLog( $wgOut ); + } + } + } + + /** + * Attempt to show a custom editing introduction, if supplied + * + * @return bool + */ + private function showCustomIntro() { + if( $this->editintro ) { + $title = Title::newFromText( $this->editintro ); + if( $title instanceof Title && $title->exists() && $title->userCanRead() ) { + $revision = Revision::newFromTitle( $title ); + $wgOut->addSecondaryWikiText( $revision->getText() ); + return true; + } else { + return false; + } + } else { + return false; } }