Follow up r64936. Even better, provide the bug number and imagemagick doc page.
[lhc/web/wiklou.git] / includes / specials / SpecialMergeHistory.php
index 300157e..275690a 100644 (file)
@@ -3,32 +3,18 @@
  * Special page allowing users with the appropriate permissions to
  * merge article histories, with some restrictions
  *
- * @file
  * @ingroup SpecialPage
  */
-
-/**
- * Constructor
- */
-function wfSpecialMergehistory( $par ) {
-       global $wgRequest;
-
-       $form = new MergehistoryForm( $wgRequest, $par );
-       $form->execute();
-}
-
-/**
- * The HTML form for Special:MergeHistory, which allows users with the appropriate
- * permissions to view and restore deleted content.
- * @ingroup SpecialPage
- */
-class MergehistoryForm {
+class SpecialMergeHistory extends SpecialPage {
        var $mAction, $mTarget, $mDest, $mTimestamp, $mTargetID, $mDestID, $mComment;
        var $mTargetObj, $mDestObj;
 
-       function MergehistoryForm( $request, $par = "" ) {
-               global $wgUser;
+       public function __construct() {
+               parent::__construct( 'MergeHistory', 'mergehistory' );
+       }
 
+       private function loadRequestParams( $request ) {
+               global $wgUser;
                $this->mAction = $request->getVal( 'action' );
                $this->mTarget = $request->getVal( 'target' );
                $this->mDest = $request->getVal( 'dest' );
@@ -51,7 +37,6 @@ class MergehistoryForm {
                        $this->mTargetObj = null;
                        $this->mDestObj = null;
                }
-
                $this->preCacheMessages();
        }
 
@@ -62,14 +47,27 @@ class MergehistoryForm {
        function preCacheMessages() {
                // Precache various messages
                if( !isset( $this->message ) ) {
-                       $this->message['last'] = wfMsgExt( 'last', array( 'escape') );
+                       $this->message['last'] = wfMsgExt( 'last', array( 'escape' ) );
                }
        }
 
-       function execute() {
-               global $wgOut, $wgUser;
+       function execute( $par ) {
+               global $wgOut, $wgRequest, $wgUser;
 
-               $wgOut->setPagetitle( wfMsgHtml( "mergehistory" ) );
+               if ( wfReadOnly() ) {
+                       $wgOut->readOnlyPage();
+                       return;
+               }
+
+               if( !$this->userCanExecute( $wgUser ) ) {
+                       $this->displayRestrictionError();
+                       return;
+               }
+
+               $this->loadRequestParams( $wgRequest );
+
+               $this->setHeaders();
+               $this->outputHeader();
 
                if( $this->mTargetID && $this->mDestID && $this->mAction=="submit" && $this->mMerge ) {
                        return $this->merge();
@@ -97,7 +95,7 @@ class MergehistoryForm {
                        );
                }
                
-               if ( empty($errors) && $this->mTargetObj->equals( $this->mDestObj ) ) {
+               if ( $this->mTargetObj && $this->mDestObj && $this->mTargetObj->equals( $this->mDestObj ) ) {
                        $errors[] = wfMsgExt( 'mergehistory-same-destination', array( 'parse' ) );
                }
 
@@ -122,8 +120,7 @@ class MergehistoryForm {
                        '<fieldset>' .
                        Xml::element( 'legend', array(),
                                wfMsg( 'mergehistory-box' ) ) .
-                       Xml::hidden( 'title',
-                               SpecialPage::getTitleFor( 'Mergehistory' )->getPrefixedDbKey() ) .
+                       Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
                        Xml::hidden( 'submitted', '1' ) .
                        Xml::hidden( 'mergepoint', $this->mTimestamp ) .
                        Xml::openElement( 'table' ) .
@@ -154,8 +151,8 @@ class MergehistoryForm {
                $revisions = new MergeHistoryPager( $this, array(), $this->mTargetObj, $this->mDestObj );
                $haveRevisions = $revisions && $revisions->getNumRows() > 0;
 
-               $titleObj = SpecialPage::getTitleFor( "Mergehistory" );
-               $action = $titleObj->getLocalURL( "action=submit" );
+               $titleObj = $this->getTitle();
+               $action = $titleObj->getLocalURL( array( 'action' => 'submit' ) );
                # Start the form here
                $top = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'merge' ) );
                $wgOut->addHTML( $top );
@@ -218,7 +215,7 @@ class MergehistoryForm {
        }
 
        function formatRevisionRow( $row ) {
-               global $wgUser, $wgLang;
+               global $wgLang;
 
                $rev = new Revision( $row );
 
@@ -228,8 +225,12 @@ class MergehistoryForm {
                $ts = wfTimestamp( TS_MW, $row->rev_timestamp );
                $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>';
                }
@@ -238,8 +239,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 );
 
@@ -261,8 +269,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;
@@ -270,7 +285,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...