Revert r36161 -- these are pretty weird-looking hooks, which seem a bit arbitrary...
[lhc/web/wiklou.git] / includes / EditPage.php
index 04452a5..0c428ec 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
  * Contains the EditPage class
+ * @file
  */
 
 /**
@@ -388,6 +389,7 @@ class EditPage {
                }
 
                $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser);
+               
                if( !$this->mTitle->exists() ) {
                        $permErrors = array_merge( $permErrors,
                                wfArrayDiff2( $this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors ) );
@@ -413,10 +415,10 @@ class EditPage {
                        }
                }
                $permErrors = wfArrayDiff2( $permErrors, $remove );
-
+               
                if ( $permErrors ) {
                        wfDebug( __METHOD__.": User can't edit\n" );
-                       $this->readOnlyPage( $this->getContent(), true, $permErrors );
+                       $this->readOnlyPage( $this->getContent(), true, $permErrors, 'edit' );
                        wfProfileOut( __METHOD__ );
                        return;
                } else {
@@ -488,7 +490,7 @@ class EditPage {
         * Parameters are the same as OutputPage:readOnlyPage()
         * Redirect to the article page if redlink=1
         */
-       function readOnlyPage( $source = null, $protected = false, $reasons = array() ) {
+       function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
                global $wgRequest, $wgOut;
                if ( $wgRequest->getBool( 'redlink' ) ) {
                        // The edit page was reached via a red link.
@@ -496,7 +498,7 @@ class EditPage {
                        // they really want a permission error.
                        $wgOut->redirect( $this->mTitle->getFullUrl() );
                } else {
-                       $wgOut->readOnlyPage( $source, $protected, $reasons );
+                       $wgOut->readOnlyPage( $source, $protected, $reasons, $action );
                }
        }
 
@@ -869,7 +871,7 @@ class EditPage {
                                }
                        }
                }
-               $userid = $wgUser->getID();
+               $userid = $wgUser->getId();
 
                if ( $this->isConflict) {
                        wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
@@ -921,8 +923,11 @@ class EditPage {
                }
 
                # Handle the user preference to force summaries here, but not for null edits
-               if( $this->section != 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary')
-                       &&  0 != strcmp($oldtext, $text) && !Article::getRedirectAutosummary( $text )) {
+               if( $this->section != 'new' && !$this->allowBlankSummary &&  $wgUser->getOption( 'forceeditsummary') && 
+                       0 != strcmp($oldtext, $text) && 
+                       !is_object( Title::newFromRedirect( $text ) ) # check if it's not a redirect
+               ) {
+
                        if( md5( $this->summary ) == $this->autoSumm ) {
                                $this->missingSummary = true;
                                wfProfileOut( $fname );
@@ -1200,7 +1205,7 @@ class EditPage {
 
                if( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) {
                        # prepare toolbar for edit buttons
-                       $toolbar = $this->getEditToolbar();
+                       $toolbar = EditPage::getEditToolbar();
                } else {
                        $toolbar = '';
                }
@@ -1785,9 +1790,11 @@ END
        /**
         * Shows a bulletin board style toolbar for common editing functions.
         * It can be disabled in the user preferences.
-        * The necessary JavaScript code can be found in style/wikibits.js.
+        * The necessary JavaScript code can be found in skins/common/edit.js.
+        * 
+        * @return string
         */
-       function getEditToolbar() {
+       static function getEditToolbar() {
                global $wgStylePath, $wgContLang, $wgJsMimeType;
 
                /**