Add a function that returns a list of categories the page is a member of
[lhc/web/wiklou.git] / includes / EditPage.php
index c97431a..1b59430 100644 (file)
@@ -521,6 +521,8 @@ class EditPage {
                $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ),
                        Linker::formatTemplates( $this->getTemplates() ) ) );
 
+               $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' );
+
                if ( $this->mTitle->exists() ) {
                        $wgOut->returnToMain( null, $this->mTitle );
                }
@@ -935,7 +937,19 @@ class EditPage {
                                                        # If we just undid one rev, use an autosummary
                                                        $firstrev = $oldrev->getNext();
                                                        if ( $firstrev && $firstrev->getId() == $undo ) {
-                                                               $undoSummary = wfMessage( 'undo-summary', $undo, $undorev->getUserText() )->inContentLanguage()->text();
+                                                               $userText = $undorev->getUserText();
+                                                               if ( $userText === '' ) {
+                                                                       $undoSummary = wfMessage(
+                                                                               'undo-summary-username-hidden',
+                                                                               $undo
+                                                                       )->inContentLanguage()->text();
+                                                               } else {
+                                                                       $undoSummary = wfMessage(
+                                                                               'undo-summary',
+                                                                               $undo,
+                                                                               $userText
+                                                                       )->inContentLanguage()->text();
+                                                               }
                                                                if ( $this->summary === '' ) {
                                                                        $this->summary = $undoSummary;
                                                                } else {
@@ -1388,6 +1402,13 @@ class EditPage {
 
                # Check for spam
                $match = self::matchSummarySpamRegex( $this->summary );
+               if ( $match === false && $this->section == 'new' ) {
+                       if ( $this->sectiontitle !== '' ) {
+                               $match = self::matchSpamRegex( $this->sectiontitle );
+                       } else {
+                               $match = self::matchSpamRegex( $this->summary );
+                       }
+               }
                if ( $match === false ) {
                        $match = self::matchSpamRegex( $this->textbox1 );
                }
@@ -1495,8 +1516,17 @@ class EditPage {
                                return $status;
                        }
 
-                       # Don't save a new article if it's blank.
-                       if ( $this->textbox1 == '' ) {
+                       // Don't save a new page if it's blank or if it's a MediaWiki:
+                       // message with content equivalent to default (allow empty pages
+                       // in this case to disable messages, see bug 50124)
+                       $defaultMessageText = $this->mTitle->getDefaultMessageText();
+                       if( $this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false ) {
+                               $defaultText = $defaultMessageText;
+                       } else {
+                               $defaultText = '';
+                       }
+
+                       if ( $this->textbox1 === $defaultText ) {
                                $status->setResult( false, self::AS_BLANK_ARTICLE );
                                wfProfileOut( __METHOD__ );
                                return $status;
@@ -1743,7 +1773,9 @@ class EditPage {
        protected function updateWatchlist() {
                global $wgUser;
 
-               if ( $wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched( $this->mTitle ) ) {
+               if ( $wgUser->isLoggedIn()
+                       && $this->watchthis != $wgUser->isWatched( $this->mTitle, WatchedItem::IGNORE_USER_RIGHTS )
+               ) {
                        $fname = __METHOD__;
                        $title = $this->mTitle;
                        $watch = $this->watchthis;
@@ -1752,11 +1784,7 @@ class EditPage {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->onTransactionIdle( function() use ( $dbw, $title, $watch, $wgUser, $fname ) {
                                $dbw->begin( $fname );
-                               if ( $watch ) {
-                                       WatchAction::doWatch( $title, $wgUser );
-                               } else {
-                                       WatchAction::doUnwatch( $title, $wgUser );
-                               }
+                               WatchAction::doWatchOrUnwatch( $watch, $title, $wgUser );
                                $dbw->commit( $fname );
                        } );
                }
@@ -2138,7 +2166,7 @@ class EditPage {
                        }
                }
 
-               //@todo: add EditForm plugin interface and use it here!
+               // @todo add EditForm plugin interface and use it here!
                //       search for textarea1 and textares2, and allow EditForm to override all uses.
                $wgOut->addHTML( Html::openElement( 'form', array( 'id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID,
                        'method' => 'post', 'action' => $this->getActionURL( $this->getContextTitle() ),
@@ -2251,6 +2279,8 @@ class EditPage {
                $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'hiddencats' ),
                        Linker::formatHiddenCategories( $this->mArticle->getHiddenCategories() ) ) );
 
+               $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' );
+
                if ( $this->isConflict ) {
                        try {
                                $this->showConflict();
@@ -2294,7 +2324,7 @@ class EditPage {
                }
 
                // Add edit notices
-               $wgOut->addHTML( implode( "\n", $this->mTitle->getEditNotices() ) );
+               $wgOut->addHTML( implode( "\n", $this->mTitle->getEditNotices( $this->oldid ) ) );
 
                if ( $this->isConflict ) {
                        $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );