MediaWiki  REL1_24
pageExists.php
Go to the documentation of this file.
00001 <?php
00022 require_once __DIR__ . '/Maintenance.php';
00023 
00027 class PageExists extends Maintenance {
00028     public function __construct() {
00029         parent::__construct();
00030         $this->mDescription = "Report whether a specific page exists";
00031         $this->addArg( 'title', 'Page title to check whether it exists' );
00032     }
00033 
00034     public function execute() {
00035         $titleArg = $this->getArg();
00036         $title = Title::newFromText( $titleArg );
00037         $pageExists = $title && $title->exists();
00038 
00039         $text = '';
00040         $code = 0;
00041         if ( $pageExists ) {
00042             $text = "{$title} exists.";
00043         } else {
00044             $text = "{$titleArg} doesn't exist.";
00045             $code = 1;
00046         }
00047         $this->output( $text );
00048         $this->error( '', $code );
00049     }
00050 }
00051 
00052 $maintClass = "PageExists";
00053 require_once RUN_MAINTENANCE_IF_MAIN;
00054