* ( bug 18264 ) upload-by-url form was still disabled in non-js2 form output
[lhc/web/wiklou.git] / includes / specials / SpecialMergeHistory.php
index 0460c20..1b4ef30 100644 (file)
@@ -67,7 +67,7 @@ class MergehistoryForm {
        }
 
        function execute() {
-               global $wgOut, $wgUser;
+               global $wgOut;
 
                $wgOut->setPagetitle( wfMsgHtml( "mergehistory" ) );
 
@@ -96,8 +96,10 @@ class MergehistoryForm {
                                wfEscapeWikiText( $this->mDestObj->getPrefixedText() )
                        );
                }
-
-               // TODO: warn about target = dest?
+               
+               if ( $this->mTargetObj && $this->mDestObj && $this->mTargetObj->equals( $this->mDestObj ) ) {
+                       $errors[] = wfMsgExt( 'mergehistory-same-destination', array( 'parse' ) );
+               }
 
                if ( count( $errors ) ) {
                        $this->showMergeForm();
@@ -113,7 +115,7 @@ class MergehistoryForm {
 
                $wgOut->addWikiMsg( 'mergehistory-header' );
 
-               $wgOut->addHtml(
+               $wgOut->addHTML(
                        Xml::openElement( 'form', array(
                                'method' => 'get',
                                'action' => $wgScript ) ) .
@@ -140,7 +142,7 @@ class MergehistoryForm {
        }
 
        private function showHistory() {
-               global $wgLang, $wgContLang, $wgUser, $wgOut;
+               global $wgLang, $wgUser, $wgOut;
 
                $this->sk = $wgUser->getSkin();
 
@@ -153,42 +155,37 @@ class MergehistoryForm {
                $haveRevisions = $revisions && $revisions->getNumRows() > 0;
 
                $titleObj = SpecialPage::getTitleFor( "Mergehistory" );
-               $action = $titleObj->getLocalURL( "action=submit" );
+               $action = $titleObj->getLocalURL( array( 'action' => 'submit' ) );
                # Start the form here
                $top = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'merge' ) );
-               $wgOut->addHtml( $top );
+               $wgOut->addHTML( $top );
 
                if( $haveRevisions ) {
                        # Format the user-visible controls (comment field, submission button)
                        # in a nice little table
-                       $align = $wgContLang->isRtl() ? 'left' : 'right';
                        $table =
                                Xml::openElement( 'fieldset' ) .
-                               Xml::openElement( 'table' ) .
+                               wfMsgExt( 'mergehistory-merge', array('parseinline'),
+                                       $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText() ) .
+                               Xml::openElement( 'table', array( 'id' => 'mw-mergehistory-table' ) ) .
                                        "<tr>
-                                               <td colspan='2'>" .
-                                                       wfMsgExt( 'mergehistory-merge', array('parseinline'),
-                                                               $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText() ) .
-                                               "</td>
-                                       </tr>
-                                       <tr>
-                                               <td align='$align'>" .
-                                                       Xml::label( wfMsg( 'undeletecomment' ), 'wpComment' ) .
+                                               <td class='mw-label'>" .
+                                                       Xml::label( wfMsg( 'mergehistory-reason' ), 'wpComment' ) .
                                                "</td>
-                                               <td>" .
-                                                       Xml::input( 'wpComment', 50, $this->mComment ) .
+                                               <td class='mw-input'>" .
+                                                       Xml::input( 'wpComment', 50, $this->mComment, array('id' => 'wpComment') ) .
                                                "</td>
                                        </tr>
                                        <tr>
                                                <td>&nbsp;</td>
-                                               <td>" .
+                                               <td class='mw-submit'>" .
                                                        Xml::submitButton( wfMsg( 'mergehistory-submit' ), array( 'name' => 'merge', 'id' => 'mw-merge-submit' ) ) .
                                                "</td>
                                        </tr>" .
                                Xml::closeElement( 'table' ) .
                                Xml::closeElement( 'fieldset' );
 
-                       $wgOut->addHtml( $table );
+                       $wgOut->addHTML( $table );
                }
 
                $wgOut->addHTML( "<h2 id=\"mw-mergehistory\">" . wfMsgHtml( "mergehistory-list" ) . "</h2>\n" );
@@ -215,13 +212,13 @@ class MergehistoryForm {
                $misc .= Xml::hidden( 'dest', $this->mDest );
                $misc .= Xml::hidden( 'wpEditToken', $wgUser->editToken() );
                $misc .= Xml::closeElement( 'form' );
-               $wgOut->addHtml( $misc );
+               $wgOut->addHTML( $misc );
 
                return true;
        }
 
        function formatRevisionRow( $row ) {
-               global $wgUser, $wgLang;
+               global $wgLang;
 
                $rev = new Revision( $row );
 
@@ -229,10 +226,14 @@ class MergehistoryForm {
                $last = $this->message['last'];
 
                $ts = wfTimestamp( TS_MW, $row->rev_timestamp );
-               $checkBox = wfRadio( "mergepoint", $ts, false );
+               $checkBox = Xml::radio( "mergepoint", $ts, false );
 
-               $pageLink = $this->sk->makeKnownLinkObj( $rev->getTitle(),
-                       htmlspecialchars( $wgLang->timeanddate( $ts ) ), 'oldid=' . $rev->getId() );
+               $pageLink = $this->sk->linkKnown(
+                       $rev->getTitle(),
+                       htmlspecialchars( $wgLang->timeanddate( $ts ) ),
+                       array(),
+                       array( 'oldid' => $rev->getId() )
+               );
                if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
                        $pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
                }
@@ -241,8 +242,15 @@ class MergehistoryForm {
                if( !$rev->userCan( Revision::DELETED_TEXT ) )
                        $last = $this->message['last'];
                else if( isset($this->prevId[$row->rev_id]) )
-                       $last = $this->sk->makeKnownLinkObj( $rev->getTitle(), $this->message['last'],
-                               "diff=" . $row->rev_id . "&oldid=" . $this->prevId[$row->rev_id] );
+                       $last = $this->sk->linkKnown(
+                               $rev->getTitle(),
+                               $this->message['last'],
+                               array(),
+                               array(
+                                       'diff' => $row->rev_id,
+                                       'oldid' => $this->prevId[$row->rev_id]
+                               )
+                       );
 
                $userLink = $this->sk->revUserTools( $rev );
 
@@ -264,8 +272,15 @@ class MergehistoryForm {
                if( !$this->userCan($row, Revision::DELETED_TEXT) ) {
                        return '<span class="history-deleted">' . $wgLang->timeanddate( $ts, true ) . '</span>';
                } else {
-                       $link = $this->sk->makeKnownLinkObj( $titleObj,
-                               $wgLang->timeanddate( $ts, true ), "target=$target&timestamp=$ts" );
+                       $link = $this->sk->linkKnown(
+                               $titleObj,
+                               $wgLang->timeanddate( $ts, true ),
+                               array(),
+                               array(
+                                       'target' => $target,
+                                       'timestamp' => $ts
+                               )
+                       );
                        if( $this->isDeleted($row, Revision::DELETED_TEXT) )
                                $link = '<span class="history-deleted">' . $link . '</span>';
                        return $link;
@@ -273,7 +288,7 @@ class MergehistoryForm {
        }
 
        function merge() {
-               global $wgOut, $wgUser;
+               global $wgOut;
                # Get the titles directly from the IDs, in case the target page params
                # were spoofed. The queries are done based on the IDs, so it's best to
                # keep it consistent...
@@ -370,7 +385,7 @@ class MergehistoryForm {
                $log->addEntry( 'merge', $targetTitle, $this->mComment,
                        array($destTitle->getPrefixedText(),$TimestampLimit) );
 
-               $wgOut->addHtml( wfMsgExt( 'mergehistory-success', array('parseinline'),
+               $wgOut->addHTML( wfMsgExt( 'mergehistory-success', array('parseinline'),
                        $targetTitle->getPrefixedText(), $destTitle->getPrefixedText(), $count ) );
 
                wfRunHooks( 'ArticleMergeComplete', array( $targetTitle, $destTitle ) );
@@ -432,12 +447,12 @@ class MergeHistoryPager extends ReverseChronologicalPager {
        function getQueryInfo() {
                $conds = $this->mConds;
                $conds['rev_page'] = $this->articleID;
+               $conds[] = 'page_id = rev_page';
                $conds[] = "rev_timestamp < {$this->maxTimestamp}";
-
                return array(
-                       'tables' => array('revision'),
+                       'tables' => array('revision','page'),
                        'fields' => array( 'rev_minor_edit', 'rev_timestamp', 'rev_user', 'rev_user_text', 'rev_comment',
-                                'rev_id', 'rev_page', 'rev_text_id', 'rev_len', 'rev_deleted' ),
+                                'rev_id', 'rev_page', 'rev_parent_id', 'rev_text_id', 'rev_len', 'rev_deleted' ),
                        'conds' => $conds
                );
        }