Merge "+Test for Status->CleanParams with a callback"
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index d4aed11..0dd5a0c 100644 (file)
@@ -124,6 +124,8 @@ class PageArchive {
 
                $dbr = wfGetDB( DB_SLAVE );
 
+               $tables = array( 'archive' );
+
                $fields = array(
                        'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text',
                        'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1',
@@ -134,12 +136,28 @@ class PageArchive {
                        $fields[] = 'ar_content_model';
                }
 
-               $res = $dbr->select( 'archive',
+               $conds = array( 'ar_namespace' => $this->title->getNamespace(),
+                               'ar_title' => $this->title->getDBkey() );
+
+               $options = array( 'ORDER BY' => 'ar_timestamp DESC' );
+
+               $join_conds = array();
+
+               ChangeTags::modifyDisplayQuery(
+                       $tables,
                        $fields,
-                       array( 'ar_namespace' => $this->title->getNamespace(),
-                               'ar_title' => $this->title->getDBkey() ),
+                       $conds,
+                       $join_conds,
+                       $options
+               );
+
+               $res = $dbr->select( $tables,
+                       $fields,
+                       $conds,
                        __METHOD__,
-                       array( 'ORDER BY' => 'ar_timestamp DESC' ) );
+                       $options,
+                       $join_conds
+               );
 
                return $dbr->resultObject( $res );
        }
@@ -791,7 +809,7 @@ class SpecialUndelete extends SpecialPage {
                $out->addHTML(
                        Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
                                Xml::fieldset( $this->msg( 'undelete-search-box' )->text() ) .
-                               Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
+                               Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) .
                                Html::rawElement(
                                        'label',
                                        array( 'for' => 'prefix' ),
@@ -831,7 +849,7 @@ class SpecialUndelete extends SpecialPage {
 
                $out->addWikiMsg( 'undeletepagetext', $this->getLanguage()->formatNum( $result->numRows() ) );
 
-               $undelete = $this->getTitle();
+               $undelete = $this->getPageTitle();
                $out->addHTML( "<ul>\n" );
                foreach ( $result as $row ) {
                        $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
@@ -914,7 +932,7 @@ class SpecialUndelete extends SpecialPage {
                }
 
                $link = Linker::linkKnown(
-                       $this->getTitle( $this->mTargetObj->getPrefixedDBkey() ),
+                       $this->getPageTitle( $this->mTargetObj->getPrefixedDBkey() ),
                        htmlspecialchars( $this->mTargetObj->getPrefixedText() )
                );
 
@@ -997,7 +1015,7 @@ class SpecialUndelete extends SpecialPage {
                                        'style' => 'clear: both' ) ) .
                                Xml::openElement( 'form', array(
                                        'method' => 'post',
-                                       'action' => $this->getTitle()->getLocalURL( array( 'action' => 'submit' ) ) ) ) .
+                                       'action' => $this->getPageTitle()->getLocalURL( array( 'action' => 'submit' ) ) ) ) .
                                Xml::element( 'input', array(
                                        'type' => 'hidden',
                                        'name' => 'target',
@@ -1032,26 +1050,19 @@ class SpecialUndelete extends SpecialPage {
 
                $diffEngine = $currentRev->getContentHandler()->createDifferenceEngine( $diffContext );
                $diffEngine->showDiffStyle();
-               $this->getOutput()->addHTML( "<div>" .
-                       "<table style='width: 98%;' cellpadding='0' cellspacing='4' class='diff'>" .
-                       "<col class='diff-marker' />" .
-                       "<col class='diff-content' />" .
-                       "<col class='diff-marker' />" .
-                       "<col class='diff-content' />" .
-                       "<tr>" .
-                       "<td colspan='2' style='width: 50%; text-align: center' class='diff-otitle'>" .
-                       $this->diffHeader( $previousRev, 'o' ) .
-                       "</td>\n" .
-                       "<td colspan='2' style='width: 50%;  text-align: center' class='diff-ntitle'>" .
-                       $this->diffHeader( $currentRev, 'n' ) .
-                       "</td>\n" .
-                       "</tr>" .
-                       $diffEngine->generateContentDiffBody(
-                               $previousRev->getContent( Revision::FOR_THIS_USER, $this->getUser() ),
-                               $currentRev->getContent( Revision::FOR_THIS_USER, $this->getUser() ) ) .
-                       "</table>" .
-                       "</div>\n"
+
+               $formattedDiff = $diffEngine->generateContentDiffBody(
+                       $previousRev->getContent( Revision::FOR_THIS_USER, $this->getUser() ),
+                       $currentRev->getContent( Revision::FOR_THIS_USER, $this->getUser() )
                );
+
+               $formattedDiff = $diffEngine->addHeader(
+                       $formattedDiff,
+                       $this->diffHeader( $previousRev, 'o' ),
+                       $this->diffHeader( $currentRev, 'n' )
+               );
+
+               $this->getOutput()->addHTML( "<div>$formattedDiff</div>\n" );
        }
 
        /**
@@ -1063,7 +1074,7 @@ class SpecialUndelete extends SpecialPage {
                $isDeleted = !( $rev->getId() && $rev->getTitle() );
                if ( $isDeleted ) {
                        /// @todo FIXME: $rev->getTitle() is null for deleted revs...?
-                       $targetPage = $this->getTitle();
+                       $targetPage = $this->getPageTitle();
                        $targetQuery = array(
                                'target' => $this->mTargetObj->getPrefixedText(),
                                'timestamp' => wfTimestamp( TS_MW, $rev->getTimestamp() )
@@ -1083,6 +1094,18 @@ class SpecialUndelete extends SpecialPage {
                        $rdel = " $rdel";
                }
 
+               $minor = $rev->isMinor() ? ChangesList::flag( 'minor' ) : '';
+
+               $tags = wfGetDB( DB_SLAVE )->selectField(
+                       'tag_summary',
+                       'ts_tags',
+                       array( 'ts_rev_id' => $rev->getId() ),
+                       __METHOD__
+               );
+               $tagSummary = ChangeTags::formatSummaryRow( $tags, 'deleteddiff' );
+
+               // FIXME This is reimplementing DifferenceEngine#getRevisionHeader
+               // and partially #showDiffPage, but worse
                return '<div id="mw-diff-' . $prefix . 'title1"><strong>' .
                        Linker::link(
                                $targetPage,
@@ -1100,7 +1123,10 @@ class SpecialUndelete extends SpecialPage {
                        Linker::revUserTools( $rev ) . '<br />' .
                        '</div>' .
                        '<div id="mw-diff-' . $prefix . 'title3">' .
-                       Linker::revComment( $rev ) . $rdel . '<br />' .
+                       $minor . Linker::revComment( $rev ) . $rdel . '<br />' .
+                       '</div>' .
+                       '<div id="mw-diff-' . $prefix . 'title5">' .
+                       $tagSummary[0] . '<br />' .
                        '</div>';
        }
 
@@ -1119,7 +1145,7 @@ class SpecialUndelete extends SpecialPage {
                $out->addHTML(
                        Xml::openElement( 'form', array(
                                        'method' => 'POST',
-                                       'action' => $this->getTitle()->getLocalURL( array(
+                                       'action' => $this->getPageTitle()->getLocalURL( array(
                                                'target' => $this->mTarget,
                                                'file' => $key,
                                                'token' => $user->getEditToken( $key ),
@@ -1207,7 +1233,7 @@ class SpecialUndelete extends SpecialPage {
                }
 
                if ( $this->mAllowed ) {
-                       $action = $this->getTitle()->getLocalURL( array( 'action' => 'submit' ) );
+                       $action = $this->getPageTitle()->getLocalURL( array( 'action' => 'submit' ) );
                        # Start the form here
                        $top = Xml::openElement(
                                'form',
@@ -1338,7 +1364,7 @@ class SpecialUndelete extends SpecialPage {
                // Build page & diff links...
                $user = $this->getUser();
                if ( $this->mCanView ) {
-                       $titleObj = $this->getTitle();
+                       $titleObj = $this->getPageTitle();
                        # Last link
                        if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
                                $pageLink = htmlspecialchars( $this->getLanguage()->userTimeAndDate( $ts, $user ) );
@@ -1367,6 +1393,9 @@ class SpecialUndelete extends SpecialPage {
                // User links
                $userLink = Linker::revUserTools( $rev );
 
+               // Minor edit
+               $minor = $rev->isMinor() ? ChangesList::flag( 'minor' ) : '';
+
                // Revision text size
                $size = $row->ar_len;
                if ( !is_null( $size ) ) {
@@ -1376,14 +1405,21 @@ class SpecialUndelete extends SpecialPage {
                // Edit summary
                $comment = Linker::revComment( $rev );
 
+               // Tags
+               $attribs = array();
+               list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'deletedhistory' );
+               if ( $classes ) {
+                       $attribs['class'] = implode( ' ', $classes );
+               }
+
                // Revision delete links
                $revdlink = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj );
 
-               $revisionRow = $this->msg( 'undelete-revisionrow' )
-                       ->rawParams( $checkBox, $revdlink, $last, $pageLink, $userLink, $revTextSize, $comment )
+               $revisionRow = $this->msg( 'undelete-revision-row' )
+                       ->rawParams( $checkBox, $revdlink, $last, $pageLink, $userLink, $minor, $revTextSize, $comment, $tagSummary )
                        ->escaped();
 
-               return "<li>$revisionRow</li>";
+               return Xml::tags( 'li', $attribs, $revisionRow ) . "\n";
        }
 
        private function formatFileRow( $row ) {
@@ -1394,7 +1430,7 @@ class SpecialUndelete extends SpecialPage {
                if ( $this->mAllowed && $row->fa_storage_key ) {
                        $checkBox = Xml::check( 'fileid' . $row->fa_id );
                        $key = urlencode( $row->fa_storage_key );
-                       $pageLink = $this->getFileLink( $file, $this->getTitle(), $ts, $key );
+                       $pageLink = $this->getFileLink( $file, $this->getPageTitle(), $ts, $key );
                } else {
                        $checkBox = '';
                        $pageLink = $this->getLanguage()->userTimeAndDate( $ts, $user );