(Bug 19725) Do not include suppressed edits in the "View X deleted edits" message...
[lhc/web/wiklou.git] / includes / EditPage.php
index fad212c..a17b4b1 100644 (file)
@@ -244,7 +244,7 @@ class EditPage {
                                        // was created, or we may simply have got bogus input.
                                        $this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-norev">' . wfMsgNoTrans( 'undo-norev' ) . '</div>' );
                                }
-                       } else if ( $section != '' ) {
+                       } elseif ( $section != '' ) {
                                if ( $section == 'new' ) {
                                        $text = $this->getPreloadedText( $preload );
                                } else {
@@ -411,9 +411,9 @@ class EditPage {
                } else {
                        if ( $this->save ) {
                                $this->formtype = 'save';
-                       } else if ( $this->preview ) {
+                       } elseif ( $this->preview ) {
                                $this->formtype = 'preview';
-                       } else if ( $this->diff ) {
+                       } elseif ( $this->diff ) {
                                $this->formtype = 'diff';
                        } else { # First time through
                                $this->firsttime = true;
@@ -553,7 +553,7 @@ class EditPage {
                } elseif ( $wgRequest->getVal( 'preview' ) == 'no' ) {
                        // Explicit override from request
                        return false;
-               } elseif ( $this->section == 'new' ) { 
+               } elseif ( $this->section == 'new' ) {
                        // Nothing *to* preview for new sections
                        return false;
                } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
@@ -662,7 +662,7 @@ class EditPage {
                                        # The unmarked state will be assumed to be a save,
                                        # if the form seems otherwise complete.
                                        wfDebug( __METHOD__ . ": Passed token check.\n" );
-                               } else if ( $this->diff ) {
+                               } elseif ( $this->diff ) {
                                        # Failed token check, but only requested "Show Changes".
                                        wfDebug( __METHOD__ . ": Failed token check; Show Changes requested.\n" );
                                } else {
@@ -792,8 +792,8 @@ class EditPage {
                        $ip = User::isIP( $username );
                        if ( !$user->isLoggedIn() && !$ip ) { # User does not exist
                                $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
-                                       array( 'userpage-userdoesnotexist', $username ) );
-                       } else if ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
+                                       array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) );
+                       } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
                                LogEventsList::showLogExtract(
                                        $wgOut,
                                        'block',
@@ -1003,7 +1003,7 @@ class EditPage {
                        }
 
                        $text = $this->textbox1;
-                       if ( $this->section == 'new' && $this->summary != '' ) { 
+                       if ( $this->section == 'new' && $this->summary != '' ) {
                                $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text;
                        }
 
@@ -1053,7 +1053,7 @@ class EditPage {
                                wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" );
                                $this->isConflict = true;
                                $text = $this->textbox1; // do not try to merge here!
-                       } else if ( $this->isConflict ) {
+                       } elseif ( $this->isConflict ) {
                                # Attempt merge
                                if ( $this->mergeChangesInto( $text ) ) {
                                        // Successful merge! Maybe we should tell the user the good news?
@@ -1085,7 +1085,7 @@ class EditPage {
                        }
 
                        # Handle the user preference to force summaries here, but not for null edits
-                       if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text ) 
+                       if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text )
                                && !Title::newFromRedirect( $text ) ) # check if it's not a redirect
                        {
                                if ( md5( $this->summary ) == $this->autoSumm ) {
@@ -1096,7 +1096,7 @@ class EditPage {
                        }
 
                        # And a similar thing for new sections
-                       if ( $this->section == 'new' && !$this->allowBlankSummary ) { 
+                       if ( $this->section == 'new' && !$this->allowBlankSummary ) {
                                if ( trim( $this->summary ) == '' ) {
                                        $this->missingSummary = true;
                                        wfProfileOut( __METHOD__ );
@@ -1107,7 +1107,7 @@ class EditPage {
                        # All's well
                        wfProfileIn( __METHOD__ . '-sectionanchor' );
                        $sectionanchor = '';
-                       if ( $this->section == 'new' ) { 
+                       if ( $this->section == 'new' ) {
                                if ( $this->textbox1 == '' ) {
                                        $this->missingComment = true;
                                        wfProfileOut( __METHOD__ . '-sectionanchor' );
@@ -1176,13 +1176,14 @@ class EditPage {
         * Commit the change of watch status
         */
        protected function commitWatch() {
+               global $wgUser;
                if ( $this->watchthis xor $this->mTitle->userIsWatching() ) {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->begin();
                        if ( $this->watchthis ) {
-                               Action::factory( 'watch', $this->mArticle )->execute();
+                               WatchAction::doWatch( $this->mTitle, $wgUser );
                        } else {
-                               Action::factory( 'unwatch', $this->mArticle )->execute();
+                               WatchAction::doUnwatch( $this->mTitle, $wgUser );
                        }
                        $dbw->commit();
                }
@@ -1334,7 +1335,7 @@ class EditPage {
                        $previewOutput = $this->getPreviewText();
                }
 
-               wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) );
+               wfRunHooks( 'EditPage::showEditForm:initial', array( &$this, &$formCallback ) );
 
                $this->setHeaders();
 
@@ -1434,7 +1435,7 @@ HTML
                }
 
                $wgOut->addHTML( $this->editFormTextBeforeContent );
-               
+
                $wgOut->addHTML( $toolbar );
 
                if ( $this->isConflict ) {
@@ -1535,7 +1536,7 @@ HTML
 
                                if ( !$this->mArticle->mRevision->userCan( Revision::DELETED_TEXT ) ) {
                                        $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
-                               } else if ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
+                               } elseif ( $this->mArticle->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
                                        $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
                                }
 
@@ -1633,7 +1634,6 @@ HTML
         * @return array An array in the format array( $label, $input )
         */
        function getSummaryInput($summary = "", $labelText = null, $inputAttrs = null, $spanLabelAttrs = null) {
-               global $wgUser;
                //Note: the maxlength is overriden in JS to 250 and to make it use UTF-8 bytes, not characters.
                $inputAttrs = ( is_array($inputAttrs) ? $inputAttrs : array() ) + array(
                        'id' => 'wpSummary',
@@ -1641,7 +1641,7 @@ HTML
                        'tabindex' => '1',
                        'size' => 60,
                        'spellcheck' => 'true',
-               ) + $wgUser->getSkin()->tooltipAndAccessKeyAttribs( 'summary' );
+               ) + Linker::tooltipAndAccesskeyAttribs( 'summary' );
 
                $spanLabelAttrs = ( is_array($spanLabelAttrs) ? $spanLabelAttrs : array() ) + array(
                        'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
@@ -1814,6 +1814,10 @@ HTML
                        'style' => '' // avoid php notices when appending preferences (appending allows customAttribs['style'] to still work
                );
 
+               $pageLang = $this->mTitle->getPageLanguage();
+               $attribs['lang'] = $pageLang->getCode();
+               $attribs['dir'] = $pageLang->getDir();
+
                $wgOut->addHTML( Html::textarea( $name, $wikitext, $attribs ) );
        }
 
@@ -1996,7 +2000,7 @@ HTML
                        } else {
                                $note = wfMsg( 'session_fail_preview' );
                        }
-               } else if ( $this->incompleteForm ) {
+               } elseif ( $this->incompleteForm ) {
                        $note = wfMsg( 'edit_form_incomplete' );
                } else {
                        $note = wfMsg( 'previewnote' );
@@ -2011,8 +2015,14 @@ HTML
                if ( $wgRawHtml && !$this->mTokenOk ) {
                        // Could be an offsite preview attempt. This is very unsafe if
                        // HTML is enabled, as it could be an attack.
-                       $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
-                               wfMsg( 'session_fail_preview_html' ) . "</div>" );
+                       $parsedNote = '';
+                       if ( $this->textbox1 !== '' ) {
+                               // Do not put big scary notice, if previewing the empty
+                               // string, which happens when you initially edit
+                               // a category page, due to automatic preview-on-open.
+                               $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
+                                       wfMsg( 'session_fail_preview_html' ) . "</div>" );
+                       }
                        wfProfileOut( __METHOD__ );
                        return $parsedNote;
                }
@@ -2057,13 +2067,6 @@ HTML
 
                                wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
 
-                               // Parse mediawiki messages with correct target language
-                               if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                                       list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->mTitle->getText() );
-                                       $obj = wfGetLangObj( $lang );
-                                       $parserOptions->setTargetLanguage( $obj );
-                               }
-
                                $parserOptions->setTidy( true );
                                $parserOptions->enableLimitReport();
                                $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ),
@@ -2089,6 +2092,11 @@ HTML
                        '<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" .
                        $wgOut->parse( $note ) . $conflict . "</div>\n";
 
+               $pageLang = $this->mTitle->getPageLanguage();
+               $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
+                       'class' => 'mw-content-'.$pageLang->getDir() );
+               $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML );
+
                wfProfileOut( __METHOD__ );
                return $previewhead . $previewHTML . $this->previewTextAfterContent;
        }