Followup r80122, protected, just incase it's needed..
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index e9d01bb..e613725 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 /**
+ * Implements Special:Undelete
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
  * Used to show archived pages and eventually restore them.
+ *
  * @ingroup SpecialPage
  */
 class PageArchive {
@@ -487,7 +492,7 @@ class PageArchive {
                $revision = null;
                $restored = 0;
 
-               while( $row = $ret->fetchObject() ) {
+               foreach ( $ret as $row ) {
                        // Check for key dupes due to shitty archive integrity.
                        if( $row->ar_rev_id ) {
                                $exists = $dbw->selectField( 'revision', '1', array('rev_id' => $row->ar_rev_id), __METHOD__ );
@@ -556,7 +561,7 @@ class PageArchive {
  *
  * @ingroup SpecialPage
  */
-class UndeleteForm extends SpecialPage {
+class SpecialUndelete extends SpecialPage {
        var $mAction, $mTarget, $mTimestamp, $mRestore, $mInvert, $mTargetObj;
        var $mTargetTimestamp, $mAllowed, $mCanView, $mComment, $mToken, $mRequest;
 
@@ -644,6 +649,7 @@ class UndeleteForm extends SpecialPage {
                }
                if ( $this->mTarget !== '' ) {
                        $this->mTargetObj = Title::newFromURL( $this->mTarget );
+                       $wgUser->getSkin()->setRelevantTitle( $this->mTargetObj );
                } else {
                        $this->mTargetObj = null;
                }
@@ -709,7 +715,7 @@ class UndeleteForm extends SpecialPage {
                                'method' => 'get',
                                'action' => $wgScript ) ) .
                        Xml::fieldset( wfMsg( 'undelete-search-box' ) ) .
-                       Xml::hidden( 'title',
+                       Html::hidden( 'title',
                                $this->getTitle()->getPrefixedDbKey() ) .
                        Xml::inputLabel( wfMsg( 'undelete-search-prefix' ),
                                'prefix', 'prefix', 20,
@@ -734,7 +740,7 @@ class UndeleteForm extends SpecialPage {
                $sk = $wgUser->getSkin();
                $undelete = $this->getTitle();
                $wgOut->addHTML( "<ul>\n" );
-               while( $row = $result->fetchObject() ) {
+               foreach ( $result as $row ) {
                        $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
                        $link = $sk->linkKnown(
                                $undelete,
@@ -1054,7 +1060,7 @@ class UndeleteForm extends SpecialPage {
                # Batch existence check on user and talk pages
                if( $haveRevisions ) {
                        $batch = new LinkBatch();
-                       while( $row = $revisions->fetchObject() ) {
+                       foreach ( $revisions as $row ) {
                                $batch->addObj( Title::makeTitleSafe( NS_USER, $row->ar_user_text ) );
                                $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->ar_user_text ) );
                        }
@@ -1063,7 +1069,7 @@ class UndeleteForm extends SpecialPage {
                }
                if( $haveFiles ) {
                        $batch = new LinkBatch();
-                       while( $row = $files->fetchObject() ) {
+                       foreach ( $files as $row ) {
                                $batch->addObj( Title::makeTitleSafe( NS_USER, $row->fa_user_text ) );
                                $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->fa_user_text ) );
                        }
@@ -1138,11 +1144,10 @@ class UndeleteForm extends SpecialPage {
                if( $haveRevisions ) {
                        # The page's stored (deleted) history:
                        $wgOut->addHTML("<ul>");
-                       $target = urlencode( $this->mTarget );
                        $remaining = $revisions->numRows();
                        $earliestLiveTime = $this->mTargetObj->getEarliestRevTime();
 
-                       while( $row = $revisions->fetchObject() ) {
+                       foreach ( $revisions as $row ) {
                                $remaining--;
                                $wgOut->addHTML( $this->formatRevisionRow( $row, $earliestLiveTime, $remaining, $sk ) );
                        }
@@ -1155,7 +1160,7 @@ class UndeleteForm extends SpecialPage {
                if( $haveFiles ) {
                        $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'filehist' ) ) . "\n" );
                        $wgOut->addHTML( "<ul>" );
-                       while( $row = $files->fetchObject() ) {
+                       foreach ( $files as $row ) {
                                $wgOut->addHTML( $this->formatFileRow( $row, $sk ) );
                        }
                        $files->free();
@@ -1164,8 +1169,8 @@ class UndeleteForm extends SpecialPage {
 
                if ( $this->mAllowed ) {
                        # Slip in the hidden controls here
-                       $misc  = Xml::hidden( 'target', $this->mTarget );
-                       $misc .= Xml::hidden( 'wpEditToken', $wgUser->editToken() );
+                       $misc  = Html::hidden( 'target', $this->mTarget );
+                       $misc .= Html::hidden( 'wpEditToken', $wgUser->editToken() );
                        $misc .= Xml::closeElement( 'form' );
                        $wgOut->addHTML( $misc );
                }
@@ -1258,7 +1263,6 @@ class UndeleteForm extends SpecialPage {
                if( $this->mAllowed && $row->fa_storage_key ) {
                        $checkBox = Xml::check( "fileid" . $row->fa_id );
                        $key = urlencode( $row->fa_storage_key );
-                       $target = urlencode( $this->mTarget );
                        $pageLink = $this->getFileLink( $file, $this->getTitle(), $ts, $key, $sk );
                } else {
                        $checkBox = '';