[search] Remove unused SpecialSearch functions
[lhc/web/wiklou.git] / includes / EditPage.php
index 770a74e..9c5c91a 100644 (file)
@@ -408,6 +408,11 @@ class EditPage {
         */
        protected $context;
 
+       /**
+        * @var bool Whether an old revision is edited
+        */
+       private $isOldRev = false;
+
        /**
         * @param Article $article
         */
@@ -1039,7 +1044,6 @@ class EditPage {
 
                // Allow extensions to modify form data
                Hooks::run( 'EditPage::importFormData', [ $this, $request ] );
-
        }
 
        /**
@@ -1641,7 +1645,7 @@ class EditPage {
                                // being set. This is used by ConfirmEdit to display a captcha
                                // without any error message cruft.
                        } else {
-                               $this->hookError = $this->formatStatusErrors( $status );
+                               $this->hookError = $status->getWikiText();
                        }
                        // Use the existing $status->value if the hook set it
                        if ( !$status->value ) {
@@ -1651,7 +1655,7 @@ class EditPage {
                } elseif ( !$status->isOK() ) {
                        # ...or the hook could be expecting us to produce an error
                        // FIXME this sucks, we should just use the Status object throughout
-                       $this->hookError = $this->formatStatusErrors( $status );
+                       $this->hookError = $status->getWikiText();
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR_EXPECTED;
                        return false;
@@ -1660,26 +1664,6 @@ class EditPage {
                return true;
        }
 
-       /**
-        * Wrap status errors in an errorbox for increased visiblity
-        *
-        * @param Status $status
-        * @return string
-        */
-       private function formatStatusErrors( Status $status ) {
-               $errmsg = $status->getHTML(
-                       'edit-error-short',
-                       'edit-error-long',
-                       $this->context->getLanguage()
-               );
-               return <<<ERROR
-<div class="errorbox">
-{$errmsg}
-</div>
-<br clear="all" />
-ERROR;
-       }
-
        /**
         * Return the summary to be used for a new section.
         *
@@ -2252,7 +2236,6 @@ ERROR;
         * @return bool
         */
        private function mergeChangesIntoContent( &$editContent ) {
-
                $db = wfGetDB( DB_MASTER );
 
                // This is the revision the editor started from
@@ -2828,7 +2811,6 @@ ERROR;
                if ( !$wgUser->getOption( 'previewontop' ) ) {
                        $this->displayPreviewArea( $previewOutput, false );
                }
-
        }
 
        /**
@@ -2854,7 +2836,6 @@ ERROR;
                return Html::rawElement( 'div', [ 'class' => 'templatesUsed' ],
                        $templateListFormatter->format( $templates, $type )
                );
-
        }
 
        /**
@@ -2880,24 +2861,9 @@ ERROR;
                global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
                global $wgAllowUserCss, $wgAllowUserJs;
 
-               if ( $this->mTitle->isTalkPage() ) {
-                       $wgOut->addWikiMsg( 'talkpagetext' );
-               }
+               $this->addTalkPageText();
 
-               // Add edit notices
-               $editNotices = $this->mTitle->getEditNotices( $this->oldid );
-               if ( count( $editNotices ) ) {
-                       $wgOut->addHTML( implode( "\n", $editNotices ) );
-               } else {
-                       $msg = $this->context->msg( 'editnotice-notext' );
-                       if ( !$msg->isDisabled() ) {
-                               $wgOut->addHTML(
-                                       '<div class="mw-editnotice-notext">'
-                                       . $msg->parseAsBlock()
-                                       . '</div>'
-                               );
-                       }
-               }
+               $this->addEditNotices();
 
                if ( $this->isConflict ) {
                        $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
@@ -2968,6 +2934,7 @@ ERROR;
                                        if ( !$revision->isCurrent() ) {
                                                $this->mArticle->setOldSubtitle( $revision->getId() );
                                                $wgOut->addWikiMsg( 'editingold' );
+                                               $this->isOldRev = true;
                                        }
                                } elseif ( $this->mTitle->exists() ) {
                                        // Something went wrong
@@ -3278,6 +3245,10 @@ HTML
                                        $classes[] = 'mw-textarea-cprotected';
                                }
                        }
+                       # Is an old revision being edited?
+                       if ( $this->isOldRev ) {
+                               $classes[] = 'mw-textarea-oldrev';
+                       }
 
                        $attribs = [ 'tabindex' => 1 ];
 
@@ -4425,4 +4396,36 @@ HTML
                // reverse the transform that we made for reversibility reasons.
                return strtr( $result, [ "&#x0" => "&#x" ] );
        }
+
+       /**
+        * @since 1.29
+        */
+       protected function addEditNotices() {
+               global $wgOut;
+
+               $editNotices = $this->mTitle->getEditNotices( $this->oldid );
+               if ( count( $editNotices ) ) {
+                       $wgOut->addHTML( implode( "\n", $editNotices ) );
+               } else {
+                       $msg = $this->context->msg( 'editnotice-notext' );
+                       if ( !$msg->isDisabled() ) {
+                               $wgOut->addHTML(
+                                       '<div class="mw-editnotice-notext">'
+                                       . $msg->parseAsBlock()
+                                       . '</div>'
+                               );
+                       }
+               }
+       }
+
+       /**
+        * @since 1.29
+        */
+       protected function addTalkPageText() {
+               global $wgOut;
+
+               if ( $this->mTitle->isTalkPage() ) {
+                       $wgOut->addWikiMsg( 'talkpagetext' );
+               }
+       }
 }