MediaWiki  1.23.13
getText.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/Maintenance.php';
27 
33 class GetTextMaint extends Maintenance {
34  public function __construct() {
35  parent::__construct();
36  $this->mDescription = 'Outputs page text to stdout';
37  $this->addOption( 'show-private', 'Show the text even if it\'s not available to the public' );
38  $this->addArg( 'title', 'Page title' );
39  }
40 
41  public function execute() {
42  $this->db = wfGetDB( DB_SLAVE );
43 
44  $titleText = $this->getArg( 0 );
45  $title = Title::newFromText( $titleText );
46  if ( !$title ) {
47  $this->error( "$titleText is not a valid title.\n", true );
48  }
49 
51  if ( !$rev ) {
52  $titleText = $title->getPrefixedText();
53  $this->error( "Page $titleText does not exist.\n", true );
54  }
55  $content = $rev->getContent( $this->hasOption( 'show-private' ) ? Revision::RAW : Revision::FOR_PUBLIC );
56  if ( $content === false ) {
57  $titleText = $title->getPrefixedText();
58  $this->error( "Couldn't extract the text from $titleText.\n", true );
59  }
60  $this->output( $content->serialize() );
61  }
62 }
63 
64 $maintClass = "GetTextMaint";
65 require_once RUN_MAINTENANCE_IF_MAIN;
Revision\FOR_PUBLIC
const FOR_PUBLIC
Definition: Revision.php:72
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
$maintClass
$maintClass
Definition: getText.php:64
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3706
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
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
GetTextMaint\__construct
__construct()
Default constructor.
Definition: getText.php:34
GetTextMaint
Maintenance script that outputs page text to stdout.
Definition: getText.php:33
GetTextMaint\execute
execute()
Do the actual work.
Definition: getText.php:41
Revision\newFromTitle
static newFromTitle( $title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
Definition: Revision.php:106
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
Revision\RAW
const RAW
Definition: Revision.php:74
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1337
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:207
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\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:246