Merge "Add mediawiki.org to default $wgNoFollowDomainExceptions"
[lhc/web/wiklou.git] / includes / EditPage.php
index 530e267..c0e7ed2 100644 (file)
@@ -457,9 +457,9 @@ class EditPage {
                # Ignore some permissions errors when a user is just previewing/viewing diffs
                $remove = array();
                foreach ( $permErrors as $error ) {
-                       if ( ( $this->preview || $this->diff ) &&
-                               ( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' ) )
-                       {
+                       if ( ( $this->preview || $this->diff )
+                               && ( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' )
+                       {
                                $remove[] = $error;
                        }
                }
@@ -567,10 +567,10 @@ class EditPage {
                } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
                        // Standard preference behavior
                        return true;
-               } elseif ( !$this->mTitle->exists() &&
-                       isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) &&
-                       $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
-               {
+               } elseif ( !$this->mTitle->exists()
+                       && isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
+                       && $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()]
+               {
                        // Categories are special
                        return true;
                } else {
@@ -728,9 +728,9 @@ class EditPage {
                        $this->watchthis = $request->getCheck( 'wpWatchthis' );
 
                        # Don't force edit summaries when a user is editing their own user or talk page
-                       if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK ) &&
-                               $this->mTitle->getText() == $wgUser->getName() )
-                       {
+                       if ( ( $this->mTitle->mNamespace == NS_USER || $this->mTitle->mNamespace == NS_USER_TALK )
+                               && $this->mTitle->getText() == $wgUser->getName()
+                       {
                                $this->allowBlankSummary = true;
                        } else {
                                $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary' );
@@ -1204,13 +1204,29 @@ class EditPage {
         * @throws UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
         * @return bool false if output is done, true if the rest of the form should be displayed
         */
-       function attemptSave() {
-               global $wgUser, $wgOut;
+       public function attemptSave() {
+               global $wgUser;
 
                $resultDetails = false;
                # Allow bots to exempt some edits from bot flagging
                $bot = $wgUser->isAllowed( 'bot' ) && $this->bot;
                $status = $this->internalAttemptSave( $resultDetails, $bot );
+
+               return $this->handleStatus( $status, $resultDetails );
+       }
+
+       /**
+        * Handle status, such as after attempt save
+        *
+        * @param Status $status
+        * @param array|bool $resultDetails
+        *
+        * @throws ErrorPageError
+        * return bool false, if output is done, true if rest of the form should be displayed
+        */
+       private function handleStatus( Status $status, $resultDetails ) {
+               global $wgUser, $wgOut;
+
                // FIXME: once the interface for internalAttemptSave() is made nicer, this should use the message in $status
                if ( $status->value == self::AS_SUCCESS_UPDATE || $status->value == self::AS_SUCCESS_NEW_ARTICLE ) {
                        $this->didSave = true;
@@ -1776,9 +1792,9 @@ class EditPage {
                        // Show the edit conflict page for certain recognized errors from doEdit(),
                        // but don't show it for errors from extension hooks
                        $errors = $doEditStatus->getErrorsArray();
-                       if ( in_array( $errors[0][0], array( 'edit-gone-missing', 'edit-conflict',
-                               'edit-already-exists' ) ) )
-                       {
+                       if ( in_array( $errors[0][0],
+                                       array( 'edit-gone-missing', 'edit-conflict', 'edit-already-exists' ) )
+                       {
                                $this->isConflict = true;
                                // Destroys data doEdit() put in $status->value but who cares
                                $doEditStatus->value = self::AS_END;
@@ -2937,7 +2953,7 @@ HTML
 
                foreach ( $output->getLimitReportData() as $key => $value ) {
                        if ( wfRunHooks( 'ParserLimitReportFormat',
-                               array( $key, $value, &$limitReport, true, true )
+                               array( $key, &$value, &$limitReport, true, true )
                        ) ) {
                                $keyMsg = wfMessage( $key );
                                $valueMsg = wfMessage( array( "$key-value-html", "$key-value" ) );
@@ -3155,6 +3171,10 @@ HTML
                                return $previewHTML;
                        }
 
+                       # provide a anchor link to the editform
+                       $continueEditing = '<span class="mw-continue-editing">' .
+                               '[[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' .
+                               wfMessage( 'continue-editing' )->text() . ']]</span>';
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
                                        $note = wfMessage( 'token_suffix_mismatch' )->plain();
@@ -3165,8 +3185,7 @@ HTML
                        } elseif ( $this->incompleteForm ) {
                                $note = wfMessage( 'edit_form_incomplete' )->plain();
                        } else {
-                               $note = wfMessage( 'previewnote' )->plain() .
-                                       ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text() . ']]';
+                               $note = wfMessage( 'previewnote' )->plain() . ' ' . $continueEditing;
                        }
 
                        $parserOptions = $this->mArticle->makeParserOptions( $this->mArticle->getContext() );
@@ -3195,7 +3214,9 @@ HTML
                                # Used messages to make sure grep find them:
                                # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
                                if ( $level && $format ) {
-                                       $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage( "{$level}{$format}preview" )->text() . "</div>";
+                                       $note = "<div id='mw-{$level}{$format}preview'>" .
+                                               wfMessage( "{$level}{$format}preview" )->text() .
+                                               ' ' . $continueEditing . "</div>";
                                }
                        }
 
@@ -3622,29 +3643,6 @@ HTML
                $wgOut->returnToMain( false, $this->mTitle );
        }
 
-       /**
-        * Produce the stock "your edit contains spam" page
-        *
-        * @param string|bool $match Text which triggered one or more filters
-        * @deprecated since 1.17 Use method spamPageWithContent() instead
-        */
-       static function spamPage( $match = false ) {
-               wfDeprecated( __METHOD__, '1.17' );
-
-               global $wgOut, $wgTitle;
-
-               $wgOut->prepareErrorPage( wfMessage( 'spamprotectiontitle' ) );
-
-               $wgOut->addHTML( '<div id="spamprotected">' );
-               $wgOut->addWikiMsg( 'spamprotectiontext' );
-               if ( $match ) {
-                       $wgOut->addWikiMsg( 'spamprotectionmatch', wfEscapeWikiText( $match ) );
-               }
-               $wgOut->addHTML( '</div>' );
-
-               $wgOut->returnToMain( false, $wgTitle );
-       }
-
        /**
         * Show "your edit contains spam" page with your diff and text
         *