API: Fix list=deletedrevs paging bug pointed out by Splarka on IRC
[lhc/web/wiklou.git] / includes / EditPage.php
index 9abb776..16230f5 100644 (file)
@@ -352,7 +352,7 @@ class EditPage {
         * the newly-edited page.
         */
        function edit() {
-               global $wgOut, $wgUser, $wgRequest;
+               global $wgOut, $wgRequest;
                // Allow extensions to modify/prevent this form or submission
                if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) {
                        return;
@@ -426,7 +426,6 @@ class EditPage {
 
                # Optional notices on a per-namespace and per-page basis
                $editnotice_ns   = 'editnotice-'.$this->mTitle->getNamespace();
-               $editnotice_page = $editnotice_ns.'-'.$this->mTitle->getDBkey();
                if ( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) {
                        $wgOut->addWikiText( wfMsgForContent( $editnotice_ns )  );
                }
@@ -439,8 +438,6 @@ class EditPage {
                                        $wgOut->addWikiText( wfMsgForContent( $editnotice_base )  );
                                }
                        }
-               } else if ( !wfEmptyMsg( $editnotice_page, wfMsgForContent( $editnotice_page ) ) ) {
-                       $wgOut->addWikiText( wfMsgForContent( $editnotice_page ) );
                }
 
                # Attempt submission here.  This will check for edit conflicts,
@@ -710,9 +707,9 @@ class EditPage {
                                $wgOut->wrapWikiMsg( '<div class="mw-newarticletextanon">$1</div>', 'newarticletextanon' );
                        }
                }
-               # Give a notice if the user is editing a deleted page...
+               # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
-                       $this->showDeletionLog( $wgOut );
+                       $this->showLogs( $wgOut );
                }
        }
 
@@ -1166,7 +1163,7 @@ class EditPage {
                $wgOut->setArticleRelated( true );
 
                if ( $this->isConflict ) {
-                       $wgOut->addWikiMsg( 'explainconflict' );
+                       $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1</div>", 'explainconflict' );
 
                        $this->textbox2 = $this->textbox1;
                        $this->textbox1 = $this->getContent();
@@ -1366,13 +1363,14 @@ class EditPage {
                if ( $this->section == 'new' ) {
                        $commentsubject = '';
                        if ( !$wgRequest->getBool( 'nosummary' ) ) {
-                               # Add an ID if 'missingsummary' is triggered to allow styling of the summary line
-                               $summaryMissedID = $this->missingSummary ? ' mw-summarymissed' : '';
+                               # Add a class if 'missingsummary' is triggered to allow styling of the summary line
+                               $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
 
                                $commentsubject =
                                        Xml::tags( 'label', array( 'for' => 'wpSummary' ), $subject );
                                $commentsubject =
-                                       Xml::tags( 'span', array( 'id' => "wpSummaryLabel$summaryMissedID" ), $commentsubject );
+                                       Xml::tags( 'span', array( 'class' => $summaryClass, 'id' => "wpSummaryLabel" ),
+                                               $commentsubject );
                                $commentsubject .= '&nbsp;';
                                $commentsubject .= Xml::input( 'wpSummary',
                                                                        60,
@@ -1391,11 +1389,12 @@ class EditPage {
                } else {
                        $commentsubject = '';
 
-                       # Add an ID if 'missingsummary' is triggered to allow styling of the summary line
-                       $summaryMissedID = $this->missingSummary ? ' mw-summarymissed' : '';
+                       # Add a class if 'missingsummary' is triggered to allow styling of the summary line
+                       $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
 
                        $editsummary = Xml::tags( 'label', array( 'for' => 'wpSummary' ), $summary );
-                       $editsummary = Xml::tags( 'span', array( 'id' => "wpSummaryLabel$summaryMissedID" ), $editsummary ) . ' ';
+                       $editsummary = Xml::tags( 'span',  array( 'class' => $summaryClass, 'id' => "wpSummaryLabel" ),
+                                       $editsummary ) . ' ';
 
                        $editsummary .= Xml::input( 'wpSummary',
                                60,
@@ -1687,7 +1686,7 @@ END
                $wgOut->addHTML( '</div>' );
        }
 
-       function getLastDelete() {
+       protected function getLastDelete() {
                $dbr = wfGetDB( DB_SLAVE );
                $data = $dbr->selectRow(
                        array( 'logging', 'user' ),
@@ -1699,15 +1698,23 @@ END
                               'log_title',
                               'log_comment',
                               'log_params',
-                              'user_name', ),
+                                  'log_deleted',
+                              'user_name' ),
                        array( 'log_namespace' => $this->mTitle->getNamespace(),
                               'log_title' => $this->mTitle->getDBkey(),
                               'log_type' => 'delete',
                               'log_action' => 'delete',
                               'user_id=log_user' ),
                        __METHOD__,
-                       array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ) );
-
+                       array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' )
+               );
+               // Quick paranoid permission checks...
+               if( is_object($data) ) {
+                       if( $data->log_deleted & LogPage::DELETED_USER )
+                               $data->user_name = wfMsgHtml('rev-deleted-user');
+                       if( $data->log_deleted & LogPage::DELETED_COMMENT )
+                               $data->log_comment = wfMsgHtml('rev-deleted-comment');
+               }
                return $data;
        }
 
@@ -2428,20 +2435,20 @@ END
        }
 
        /**
-        * If there are rows in the deletion log for this page, show them,
+        * If there are rows in the deletion/move log for this page, show them,
         * along with a nice little note for the user
         *
         * @param OutputPage $out
         */
-       protected function showDeletionLog( $out ) {
+       protected function showLogs( $out ) {
                global $wgUser;
                $loglist = new LogEventsList( $wgUser->getSkin(), $out );
-               $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
+               $pager = new LogPager( $loglist, array('move', 'delete'), false, $this->mTitle->getPrefixedText() );
                $count = $pager->getNumRows();
                if ( $count > 0 ) {
                        $pager->mLimit = 10;
                        $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
-                       $out->addWikiMsg( 'recreate-deleted-warn' );
+                       $out->addWikiMsg( 'recreate-moveddeleted-warn' );
                        $out->addHTML(
                                $loglist->beginLogEventsList() .
                                $pager->getBody() .
@@ -2450,11 +2457,9 @@ END
                        if($count > 10){
                                $out->addHTML( $wgUser->getSkin()->link(
                                        SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'deletelog-fulllog' ),
+                                       wfMsgHtml( 'log-fulllog' ),
                                        array(),
-                                       array(
-                                               'type' => 'delete',
-                                               'page' => $this->mTitle->getPrefixedText() ) ) );
+                                       array( 'page' => $this->mTitle->getPrefixedText() ) ) );
                        }
                        $out->addHTML( '</div>' );
                        return true;