00001 <?php 00009 require_once( dirname(__FILE__) . '/Maintenance.php' ); 00010 00011 class Undelete extends Maintenance { 00012 public function __construct() { 00013 parent::__construct(); 00014 $this->mDescription = "Undelete a page"; 00015 $this->addOption( 'u', 'The user to perform the undeletion', false, true ); 00016 $this->addOption( 'r', 'The reason to undelete', false, true ); 00017 $this->addArg( 'pagename', 'Page to undelete' ); 00018 } 00019 00020 public function execute() { 00021 global $wgUser; 00022 00023 $user = $this->getOption( 'u', 'Command line script' ); 00024 $reason = $this->getOption( 'r', '' ); 00025 $pageName = $this->getArg(); 00026 00027 $title = Title::newFromText( $pageName ); 00028 if ( !$title ) { 00029 $this->error( "Invalid title", true ); 00030 } 00031 $wgUser = User::newFromName( $user ); 00032 $archive = new PageArchive( $title ); 00033 $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' ); 00034 $archive->undelete( array(), $reason ); 00035 $this->output( "done\n" ); 00036 } 00037 } 00038 00039 $maintClass = "Undelete"; 00040 require_once( DO_MAINTENANCE );