MediaWiki  1.23.2
undelete.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Maintenance.php';
25 
26 class Undelete extends Maintenance {
27  public function __construct() {
28  parent::__construct();
29  $this->mDescription = "Undelete a page";
30  $this->addOption( 'user', 'The user to perform the undeletion', false, true, 'u' );
31  $this->addOption( 'reason', 'The reason to undelete', false, true, 'r' );
32  $this->addArg( 'pagename', 'Page to undelete' );
33  }
34 
35  public function execute() {
37 
38  $user = $this->getOption( 'user', 'Command line script' );
39  $reason = $this->getOption( 'reason', '' );
40  $pageName = $this->getArg();
41 
42  $title = Title::newFromText( $pageName );
43  if ( !$title ) {
44  $this->error( "Invalid title", true );
45  }
46  $wgUser = User::newFromName( $user );
47  if ( !$wgUser ) {
48  $this->error( "Invalid username", true );
49  }
50  $archive = new PageArchive( $title );
51  $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' );
52  $archive->undelete( array(), $reason );
53  $this->output( "done\n" );
54  }
55 }
56 
57 $maintClass = "Undelete";
58 require_once RUN_MAINTENANCE_IF_MAIN;
$wgUser
$wgUser
Definition: Setup.php:552
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PageArchive
Used to show archived pages and eventually restore them.
Definition: SpecialUndelete.php:29
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:388
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
Undelete
Definition: undelete.php:26
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$maintClass
$maintClass
Definition: undelete.php:57
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
Undelete\__construct
__construct()
Default constructor.
Definition: undelete.php:27
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:207
Undelete\execute
execute()
Do the actual work.
Definition: undelete.php:35
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:246