Add class to EditPage text area when editing an old revision
authorcenarium <cenarium.sysop@gmail.com>
Wed, 20 Jan 2016 20:43:47 +0000 (21:43 +0100)
committerChad <chadh@wikimedia.org>
Tue, 25 Oct 2016 19:36:54 +0000 (19:36 +0000)
This adds a class 'mw-textarea-oldrev' to the editing area when an old
page revision is edited. It seems that the warning MediaWiki:Editingold
is not sufficient for some users and some css tweaks might be
appreciated, as is already done for protected pages.

Bug: T124226
Change-Id: Ifc53af0f827a5cebfd9cc220b0aa247210e8dcfc

includes/EditPage.php

index 770a74e..e8ea20f 100644 (file)
@@ -408,6 +408,11 @@ class EditPage {
         */
        protected $context;
 
+       /**
+        * @var bool Whether an old revision is edited
+        */
+       private $isOldRev = false;
+
        /**
         * @param Article $article
         */
@@ -2968,6 +2973,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 +3284,10 @@ HTML
                                        $classes[] = 'mw-textarea-cprotected';
                                }
                        }
+                       # Is an old revision being edited?
+                       if ( $this->isOldRev ) {
+                               $classes[] = 'mw-textarea-oldrev';
+                       }
 
                        $attribs = [ 'tabindex' => 1 ];