Merge "mw.htmlform: Fix hiding of the textbox for 'selectorother' fields on page...
[lhc/web/wiklou.git] / includes / specials / SpecialMergeHistory.php
index 0cefb38..f122db8 100644 (file)
@@ -126,7 +126,7 @@ class SpecialMergeHistory extends SpecialPage {
                        return;
                }
 
-               $errors = array();
+               $errors = [];
                if ( !$this->mTargetObj instanceof Title ) {
                        $errors[] = $this->msg( 'mergehistory-invalid-source' )->parseAsBlock();
                } elseif ( !$this->mTargetObj->exists() ) {
@@ -160,11 +160,11 @@ class SpecialMergeHistory extends SpecialPage {
                $out->addWikiMsg( 'mergehistory-header' );
 
                $out->addHTML(
-                       Xml::openElement( 'form', array(
+                       Xml::openElement( 'form', [
                                'method' => 'get',
-                               'action' => wfScript() ) ) .
+                               'action' => wfScript() ] ) .
                                '<fieldset>' .
-                               Xml::element( 'legend', array(),
+                               Xml::element( 'legend', [],
                                        $this->msg( 'mergehistory-box' )->text() ) .
                                Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) .
                                Html::hidden( 'submitted', '1' ) .
@@ -172,10 +172,10 @@ class SpecialMergeHistory extends SpecialPage {
                                Xml::openElement( 'table' ) .
                                '<tr>
                                <td>' . Xml::label( $this->msg( 'mergehistory-from' )->text(), 'target' ) . '</td>
-                               <td>' . Xml::input( 'target', 30, $this->mTarget, array( 'id' => 'target' ) ) . '</td>
+                               <td>' . Xml::input( 'target', 30, $this->mTarget, [ 'id' => 'target' ] ) . '</td>
                        </tr><tr>
                                <td>' . Xml::label( $this->msg( 'mergehistory-into' )->text(), 'dest' ) . '</td>
-                               <td>' . Xml::input( 'dest', 30, $this->mDest, array( 'id' => 'dest' ) ) . '</td>
+                               <td>' . Xml::input( 'dest', 30, $this->mDest, [ 'id' => 'dest' ] ) . '</td>
                        </tr><tr><td>' .
                                Xml::submitButton( $this->msg( 'mergehistory-go' )->text() ) .
                                '</td></tr>' .
@@ -192,21 +192,21 @@ class SpecialMergeHistory extends SpecialPage {
 
                # List all stored revisions
                $revisions = new MergeHistoryPager(
-                       $this, array(), $this->mTargetObj, $this->mDestObj
+                       $this, [], $this->mTargetObj, $this->mDestObj
                );
                $haveRevisions = $revisions && $revisions->getNumRows() > 0;
 
                $out = $this->getOutput();
                $titleObj = $this->getPageTitle();
-               $action = $titleObj->getLocalURL( array( 'action' => 'submit' ) );
+               $action = $titleObj->getLocalURL( [ 'action' => 'submit' ] );
                # Start the form here
                $top = Xml::openElement(
                        'form',
-                       array(
+                       [
                                'method' => 'post',
                                'action' => $action,
                                'id' => 'merge'
-                       )
+                       ]
                );
                $out->addHTML( $top );
 
@@ -217,13 +217,13 @@ class SpecialMergeHistory extends SpecialPage {
                                Xml::openElement( 'fieldset' ) .
                                        $this->msg( 'mergehistory-merge', $this->mTargetObj->getPrefixedText(),
                                                $this->mDestObj->getPrefixedText() )->parse() .
-                                       Xml::openElement( 'table', array( 'id' => 'mw-mergehistory-table' ) ) .
+                                       Xml::openElement( 'table', [ 'id' => 'mw-mergehistory-table' ] ) .
                                        '<tr>
                                                <td class="mw-label">' .
                                        Xml::label( $this->msg( 'mergehistory-reason' )->text(), 'wpComment' ) .
                                        '</td>
                                        <td class="mw-input">' .
-                                       Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment' ) ) .
+                                       Xml::input( 'wpComment', 50, $this->mComment, [ 'id' => 'wpComment' ] ) .
                                        '</td>
                                        </tr>
                                        <tr>
@@ -231,7 +231,7 @@ class SpecialMergeHistory extends SpecialPage {
                                                <td class="mw-submit">' .
                                        Xml::submitButton(
                                                $this->msg( 'mergehistory-submit' )->text(),
-                                               array( 'name' => 'merge', 'id' => 'mw-merge-submit' )
+                                               [ 'name' => 'merge', 'id' => 'mw-merge-submit' ]
                                        ) .
                                        '</td>
                                        </tr>' .
@@ -277,6 +277,8 @@ class SpecialMergeHistory extends SpecialPage {
        function formatRevisionRow( $row ) {
                $rev = new Revision( $row );
 
+               $linkRenderer = $this->getLinkRenderer();
+
                $stxt = '';
                $last = $this->msg( 'last' )->escaped();
 
@@ -285,11 +287,11 @@ class SpecialMergeHistory extends SpecialPage {
 
                $user = $this->getUser();
 
-               $pageLink = Linker::linkKnown(
+               $pageLink = $linkRenderer->makeKnownLink(
                        $rev->getTitle(),
-                       htmlspecialchars( $this->getLanguage()->userTimeAndDate( $ts, $user ) ),
-                       array(),
-                       array( 'oldid' => $rev->getId() )
+                       $this->getLanguage()->userTimeAndDate( $ts, $user ),
+                       [],
+                       [ 'oldid' => $rev->getId() ]
                );
                if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
                        $pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
@@ -299,14 +301,14 @@ class SpecialMergeHistory extends SpecialPage {
                if ( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
                        $last = $this->msg( 'last' )->escaped();
                } elseif ( isset( $this->prevId[$row->rev_id] ) ) {
-                       $last = Linker::linkKnown(
+                       $last = $linkRenderer->makeKnownLink(
                                $rev->getTitle(),
-                               $this->msg( 'last' )->escaped(),
-                               array(),
-                               array(
+                               $this->msg( 'last' )->text(),
+                               [],
+                               [
                                        'diff' => $row->rev_id,
                                        'oldid' => $this->prevId[$row->rev_id]
-                               )
+                               ]
                        );
                }
 
@@ -318,7 +320,7 @@ class SpecialMergeHistory extends SpecialPage {
                }
                $comment = Linker::revComment( $rev );
 
-               return Html::rawElement( 'li', array(),
+               return Html::rawElement( 'li', [],
                        $this->msg( 'mergehistory-revisionrow' )
                                ->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() );
        }
@@ -359,11 +361,13 @@ class SpecialMergeHistory extends SpecialPage {
                        return false;
                }
 
-               $targetLink = Linker::link(
+               $linkRenderer = $this->getLinkRenderer();
+
+               $targetLink = $linkRenderer->makeLink(
                        $targetTitle,
                        null,
-                       array(),
-                       array( 'redirect' => 'no' )
+                       [],
+                       [ 'redirect' => 'no' ]
                );
 
                $this->getOutput()->addWikiMsg( $this->msg( 'mergehistory-done' )
@@ -379,78 +383,3 @@ class SpecialMergeHistory extends SpecialPage {
                return 'pagetools';
        }
 }
-
-class MergeHistoryPager extends ReverseChronologicalPager {
-       /** @var SpecialMergeHistory */
-       public $mForm;
-
-       /** @var array */
-       public $mConds;
-
-       function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
-               $this->mForm = $form;
-               $this->mConds = $conds;
-               $this->title = $source;
-               $this->articleID = $source->getArticleID();
-
-               $dbr = wfGetDB( DB_SLAVE );
-               $maxtimestamp = $dbr->selectField(
-                       'revision',
-                       'MIN(rev_timestamp)',
-                       array( 'rev_page' => $dest->getArticleID() ),
-                       __METHOD__
-               );
-               $this->maxTimestamp = $maxtimestamp;
-
-               parent::__construct( $form->getContext() );
-       }
-
-       function getStartBody() {
-               # Do a link batch query
-               $this->mResult->seek( 0 );
-               $batch = new LinkBatch();
-               # Give some pointers to make (last) links
-               $this->mForm->prevId = array();
-               foreach ( $this->mResult as $row ) {
-                       $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
-                       $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
-
-                       $rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id;
-                       if ( $rev_id > $row->rev_id ) {
-                               $this->mForm->prevId[$rev_id] = $row->rev_id;
-                       } elseif ( $rev_id < $row->rev_id ) {
-                               $this->mForm->prevId[$row->rev_id] = $rev_id;
-                       }
-
-                       $rev_id = $row->rev_id;
-               }
-
-               $batch->execute();
-               $this->mResult->seek( 0 );
-
-               return '';
-       }
-
-       function formatRow( $row ) {
-               return $this->mForm->formatRevisionRow( $row );
-       }
-
-       function getQueryInfo() {
-               $conds = $this->mConds;
-               $conds['rev_page'] = $this->articleID;
-               $conds[] = "rev_timestamp < " . $this->mDb->addQuotes( $this->maxTimestamp );
-
-               return array(
-                       'tables' => array( 'revision', 'page', 'user' ),
-                       'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
-                       'conds' => $conds,
-                       'join_conds' => array(
-                               'page' => Revision::pageJoinCond(),
-                               'user' => Revision::userJoinCond() )
-               );
-       }
-
-       function getIndexField() {
-               return 'rev_timestamp';
-       }
-}