Make the instantiation tests actually work.
[lhc/web/wiklou.git] / includes / EditPage.php
index bb325b8..db32c4b 100644 (file)
@@ -121,6 +121,7 @@ class EditPage {
 
        /**
         * Fetch initial editing page content.
+        * @returns mixed string on success, $def_text for invalid sections
         * @private
         */
        function getContent( $def_text = '' ) {
@@ -204,6 +205,7 @@ class EditPage {
                                if ( $section == 'new' ) {
                                        $text = $this->getPreloadedText( $preload );
                                } else {
+                                       // Get section edit text (returns $def_text for invalid sections)
                                        $text = $wgParser->getSection( $text, $section, $def_text );
                                }
                        }
@@ -403,7 +405,7 @@ class EditPage {
                $permErrors = $this->getEditPermissionErrors();
                if ( $permErrors ) {
                        wfDebug( __METHOD__ . ": User can't edit\n" );
-                       $this->readOnlyPage( $this->getContent(), true, $permErrors, 'edit' );
+                       $this->readOnlyPage( $this->getContent( false ), true, $permErrors, 'edit' );
                        wfProfileOut( __METHOD__ );
                        return;
                } else {
@@ -1183,6 +1185,7 @@ class EditPage {
        /**
         * Initialise form fields in the object
         * Called on the first invocation, e.g. when a user clicks an edit link
+        * @returns bool -- if the requested section is valid
         */
        function initialiseForm() {
                global $wgUser;
@@ -1399,7 +1402,7 @@ HTML
        }
        
        protected function showHeader() {
-               global $wgOut, $wgParser, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
+               global $wgOut, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
                if ( $this->isConflict ) {
                        $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1</div>", 'explainconflict' );
                        $this->edittime = $this->mArticle->getTimestamp();
@@ -1506,7 +1509,11 @@ HTML
                        $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', $cascadeSourcesCount ) );
                }
                if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) {
-                       $wgOut->wrapWikiMsg( "<div class=\"mw-titleprotectedwarning\">\n$1</div>", 'titleprotectedwarning' );
+                       LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '',
+                               array(  'lim' => 1,
+                                       'showIfEmpty' => false,
+                                       'msgKey' => array( 'titleprotectedwarning' ),
+                                       'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ) );
                }
 
                if ( $this->kblength === false ) {
@@ -1684,12 +1691,6 @@ INPUTS
                                $classes[] = $attribs['class'];
                        $attribs['class'] = implode( ' ', $classes );
                }
-
-               # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
-               if ( !$this->preview && !$this->diff ) {
-                       global $wgOut;
-                       $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus();' );
-               }
                
                $this->showTextbox( isset($textoverride) ? $textoverride : $this->textbox1, 'wpTextbox1', $attribs );
        }
@@ -2052,14 +2053,17 @@ INPUTS
         * they have attempted to edit a nonexistent section.
         */
        function noSuchSectionPage() {
-               global $wgOut, $wgTitle;
+               global $wgOut;
 
                $wgOut->setPageTitle( wfMsg( 'nosuchsectiontitle' ) );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->setArticleRelated( false );
 
-               $wgOut->addWikiMsg( 'nosuchsectiontext', $this->section );
-               $wgOut->returnToMain( false, $wgTitle );
+               $res = wfMsgExt( 'nosuchsectiontext', 'parse', $this->section );
+               wfRunHooks( 'EditPageNoSuchSection', array( &$this, &$res ) );
+               $wgOut->addHTML( $res );
+
+               $wgOut->returnToMain( false, $this->mTitle );
        }
 
        /**
@@ -2691,5 +2695,5 @@ INPUTS
                } else {
                        return $this->mBaseRevision;
                }
-       }
+       }       
 }