3 $basePath = getenv( 'MW_INSTALL_PATH' ) !== false ?
getenv( 'MW_INSTALL_PATH' ) : __DIR__
. '/..';
5 require_once $basePath . '/maintenance/Maintenance.php';
8 * Maintenance script for importing site definitions from XML into the sites table.
12 * @license GNU GPL v2+
13 * @author Daniel Kinzler
15 class ImportSites
extends Maintenance
{
17 public function __construct() {
18 $this->mDescription
= 'Imports site definitions from XML into the sites table.';
20 $this->addArg( 'file', 'An XML file containing site definitions (see docs/sitelist.txt). Use "php://stdin" to read from stdin.', true );
22 parent
::__construct();
29 public function execute() {
30 $file = $this->getArg( 0 );
32 $importer = new SiteImporter( SiteSQLStore
::newInstance() );
33 $importer->setExceptionCallback( array( $this, 'reportException' ) );
35 $importer->importFromFile( $file );
37 $this->output( "Done.\n" );
41 * Outputs a message via the output() method.
43 * @param Exception $ex
45 public function reportException( Exception
$ex ) {
46 $msg = $ex->getMessage();
47 $this->output( "$msg\n" );
51 $maintClass = 'ImportSites';
52 require_once( RUN_MAINTENANCE_IF_MAIN
);