Standardise wording of verbs relating to revision deletion
[lhc/web/wiklou.git] / includes / EditPage.php
index 17a1946..12cd4b3 100644 (file)
@@ -666,6 +666,11 @@ class EditPage {
                        $this->edittime = $request->getVal( 'wpEdittime' );
                        $this->starttime = $request->getVal( 'wpStarttime' );
 
+                       $undidRev = $request->getInt( 'wpUndidRevision' );
+                       if ( $undidRev ) {
+                               $this->undidRev = $undidRev;
+                       }
+
                        $this->scrolltop = $request->getIntOrNull( 'wpScrolltop' );
 
                        if ( $this->textbox1 === '' && $request->getVal( 'wpTextbox1' ) === null ) {
@@ -967,6 +972,7 @@ class EditPage {
                                                $undoMsg = 'norev';
                                        }
 
+                                       // Messages: undo-success, undo-failure, undo-norev
                                        $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
                                        $this->editFormPageTop .= $wgOut->parse( "<div class=\"{$class}\">" .
                                                wfMessage( 'undo-' . $undoMsg )->plain() . '</div>', true, /* interface */true );
@@ -1403,9 +1409,14 @@ class EditPage {
                # Check for spam
                $match = self::matchSummarySpamRegex( $this->summary );
                if ( $match === false && $this->section == 'new' ) {
+                       # $wgSpamRegex is enforced on this new heading/summary because, unlike
+                       # regular summaries, it is added to the actual wikitext.
                        if ( $this->sectiontitle !== '' ) {
+                               # This branch is taken when the API is used with the 'sectiontitle' parameter.
                                $match = self::matchSpamRegex( $this->sectiontitle );
                        } else {
+                               # This branch is taken when the "Add Topic" user interface is used, or the API
+                               # is used with the 'summary' parameter.
                                $match = self::matchSpamRegex( $this->summary );
                        }
                }
@@ -1482,7 +1493,7 @@ class EditPage {
                        wfProfileOut( __METHOD__ );
                        return $status;
                }
-               if ( $wgUser->pingLimiter() ) {
+               if ( $wgUser->pingLimiter() || $wgUser->pingLimiter( 'linkpurge', 0 ) ) {
                        $status->fatal( 'actionthrottledtext' );
                        $status->value = self::AS_RATE_LIMITED;
                        wfProfileOut( __METHOD__ . '-checks' );
@@ -1520,7 +1531,7 @@ class EditPage {
                        // 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 ) {
+                       if ( $this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false ) {
                                $defaultText = $defaultMessageText;
                        } else {
                                $defaultText = '';
@@ -1603,8 +1614,7 @@ class EditPage {
                                }
                        }
 
-                       // If sectiontitle is set, use it, otherwise use the summary as the section title (for
-                       // backwards compatibility with old forms/bots).
+                       // If sectiontitle is set, use it, otherwise use the summary as the section title.
                        if ( $this->sectiontitle !== '' ) {
                                $sectionTitle = $this->sectiontitle;
                        } else {
@@ -1761,6 +1771,10 @@ class EditPage {
                }
 
                $result['nullEdit'] = $doEditStatus->hasMessage( 'edit-no-change' );
+               if ( $result['nullEdit'] ) {
+                       // We don't know if it was a null edit until now, so increment here
+                       $wgUser->pingLimiter( 'linkpurge' );
+               }
                $result['redirect'] = $content->isRedirect();
                $this->updateWatchlist();
                wfProfileOut( __METHOD__ );
@@ -1889,11 +1903,11 @@ class EditPage {
        }
 
        /**
-        * Check given input text against $wgSpamRegex, and return the text of the first match.
+        * Check given input text against $wgSummarySpamRegex, and return the text of the first match.
         *
         * @param $text string
         *
-        * @return string|bool  matching string or false
+        * @return string|bool matching string or false
         */
        public static function matchSummarySpamRegex( $text ) {
                global $wgSummarySpamRegex;
@@ -1920,6 +1934,7 @@ class EditPage {
                global $wgOut, $wgUser;
 
                $wgOut->addModules( 'mediawiki.action.edit' );
+               $wgOut->addModuleStyles( 'mediawiki.action.edit.styles' );
 
                if ( $wgUser->getOption( 'uselivepreview', false ) ) {
                        $wgOut->addModules( 'mediawiki.action.edit.preview' );
@@ -2279,6 +2294,9 @@ class EditPage {
                $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'hiddencats' ),
                        Linker::formatHiddenCategories( $this->mArticle->getHiddenCategories() ) ) );
 
+               $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'limitreport' ),
+                       self::getPreviewLimitReport( $this->mParserOutput ) ) );
+
                $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' );
 
                if ( $this->isConflict ) {
@@ -2551,7 +2569,7 @@ class EditPage {
                global $wgParser;
 
                if ( $isSubjectPreview ) {
-                       $summary = wfMessage( 'newsectionsummary', $wgParser->stripSectionName( $summary ) )
+                       $summary = wfMessage( 'newsectionsummary' )->rawParams( $wgParser->stripSectionName( $summary ) )
                                ->inContentLanguage()->text();
                }
 
@@ -2858,6 +2876,59 @@ HTML
                        call_user_func_array( 'wfMessage', $copywarnMsg )->plain() . "\n</div>";
        }
 
+       /**
+        * Get the Limit report for page previews
+        *
+        * @since 1.22
+        * @param ParserOutput $output ParserOutput object from the parse
+        * @return string HTML
+        */
+       public static function getPreviewLimitReport( $output ) {
+               if ( !$output || !$output->getLimitReportData() ) {
+                       return '';
+               }
+
+               wfProfileIn( __METHOD__ );
+
+               $limitReport = Html::rawElement( 'div', array( 'class' => 'mw-limitReportExplanation' ),
+                       wfMessage( 'limitreport-title' )->parseAsBlock()
+               );
+
+               // Show/hide animation doesn't work correctly on a table, so wrap it in a div.
+               $limitReport .= Html::openElement( 'div', array( 'class' => 'preview-limit-report-wrapper' ) );
+
+               $limitReport .= Html::openElement( 'table', array(
+                       'class' => 'preview-limit-report wikitable'
+               ) ) .
+                       Html::openElement( 'tbody' );
+
+               foreach ( $output->getLimitReportData() as $key => $value ) {
+                       if ( wfRunHooks( 'ParserLimitReportFormat',
+                               array( $key, $value, &$limitReport, true, true )
+                       ) ) {
+                               $keyMsg = wfMessage( $key );
+                               $valueMsg = wfMessage( array( "$key-value-html", "$key-value" ) );
+                               if ( !$valueMsg->exists() ) {
+                                       $valueMsg = new RawMessage( '$1' );
+                               }
+                               if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) {
+                                       $limitReport .= Html::openElement( 'tr' ) .
+                                               Html::rawElement( 'th', null, $keyMsg->parse() ) .
+                                               Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) .
+                                               Html::closeElement( 'tr' );
+                               }
+                       }
+               }
+
+               $limitReport .= Html::closeElement( 'tbody' ) .
+                       Html::closeElement( 'table' ) .
+                       Html::closeElement( 'div' );
+
+               wfProfileOut( __METHOD__ );
+
+               return $limitReport;
+       }
+
        protected function showStandardInputs( &$tabindex = 2 ) {
                global $wgOut;
                $wgOut->addHTML( "<div class='editOptions'>\n" );
@@ -2880,7 +2951,9 @@ HTML
 
                $cancel = $this->getCancelLink();
                if ( $cancel !== '' ) {
-                       $cancel .= wfMessage( 'pipe-separator' )->text();
+                       $cancel .= Html::element( 'span',
+                               array( 'class' => 'mw-editButtons-pipe-separator' ),
+                               wfMessage( 'pipe-separator' )->text() );
                }
                $edithelpurl = Skin::makeInternalOrExternalUrl( wfMessage( 'edithelppage' )->inContentLanguage()->text() );
                $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .