* Show custom editing introduction when editing existing pages, too
authorRob Church <robchurch@users.mediawiki.org>
Mon, 11 Jun 2007 11:57:20 +0000 (11:57 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 11 Jun 2007 11:57:20 +0000 (11:57 +0000)
* Clean up handling of editing introductions

[Based on a patch from ZJH]

RELEASE-NOTES
includes/EditPage.php

index 78ee12e..b1111a0 100644 (file)
@@ -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 ==
 
index a9a94d6..e0dcc75 100644 (file)
@@ -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;
                }
        }