* @ingroup Wikimedia
*/
-require_once( dirname(__FILE__) . '/Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class AddWiki extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = "Add a new wiki to the family. Wikimedia specific!";
- $this->addArg( 'language', 'Language code of new site' );
- $this->addArg( 'site', 'Type of site' );
- $this->addArg( 'dbname', 'Name of database to create' );
+ $this->addArg( 'language', 'Language code of new site, e.g. en' );
+ $this->addArg( 'site', 'Type of site, e.g. wikipedia' );
+ $this->addArg( 'dbname', 'Name of database to create, e.g. enwiki' );
+ $this->addArg( 'domain', 'Domain name of the wiki, e.g. en.wikipedia.org' );
}
public function getDbType() {
}
public function execute() {
- global $IP, $wgLanguageNames, $wgDefaultExternalStore, $wgNoDBParam;
+ global $IP, $wgDefaultExternalStore, $wgNoDBParam;
$wgNoDBParam = true;
- $lang = $this->getArg(0);
- $site = $this->getArg(1);
- $dbName = $this->getArg(2);
+ $lang = $this->getArg( 0 );
+ $site = $this->getArg( 1 );
+ $dbName = $this->getArg( 2 );
+ $domain = $this->getArg( 3 );
+ $languageNames = Language::getLanguageNames();
- if ( !isset( $wgLanguageNames[$lang] ) ) {
+ if ( !isset( $languageNames[$lang] ) ) {
$this->error( "Language $lang not found in \$wgLanguageNames", true );
}
- $name = $wgLanguageNames[$lang];
+ $name = $languageNames[$lang];
$dbw = wfGetDB( DB_MASTER );
$common = "/home/wikipedia/common";
$dbw->sourceFile( "$IP/extensions/UsabilityInitiative/ClickTracking/ClickTrackingEvents.sql" );
$dbw->sourceFile( "$IP/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql" );
$dbw->sourceFile( "$IP/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql" );
+ $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/OptIn/OptIn.sql" );
$dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
# Initialise external storage
if ( is_array( $wgDefaultExternalStore ) ) {
$stores = $wgDefaultExternalStore;
- } elseif ( $stores ) {
+ } elseif ( $wgDefaultExternalStore ) {
$stores = array( $wgDefaultExternalStore );
} else {
$stores = array();
fclose( $file );
# Update the sublists
- shell_exec("cd $common && ./refresh-dblist");
+ shell_exec( "cd $common && ./refresh-dblist" );
- #print "Constructing interwiki SQL\n";
+ # print "Constructing interwiki SQL\n";
# Rebuild interwiki tables
- #passthru( '/home/wikipedia/conf/interwiki/update' );
+ # passthru( '/home/wikipedia/conf/interwiki/update' );
+
+ $time = wfTimestamp( TS_RFC2822 );
+ // These arguments need to be escaped twice: once for echo and once for at
+ $escDbName = wfEscapeShellArg( wfEscapeShellArg( $dbName ) );
+ $escTime = wfEscapeShellArg( wfEscapeShellArg( $time ) );
+ $escUcsite = wfEscapeShellArg( wfEscapeShellArg( $ucsite ) );
+ $escName = wfEscapeShellArg( wfEscapeShellArg( $name ) );
+ $escLang = wfEscapeShellArg( wfEscapeShellArg( $lang ) );
+ $escDomain = wfEscapeShellArg( wfEscapeShellArg( $domain ) );
+ shell_exec( "echo notifyNewProjects $escDbName $escTime $escUcsite $escName $escLang $escDomain | at now + 15 minutes" );
$this->output( "Script ended. You still have to:
* Add any required settings in InitialiseSettings.php
* Run /home/wikipedia/conf/interwiki/update
" );
}
-
+
private function getFirstArticle( $ucsite, $name ) {
return <<<EOT
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
}
$maintClass = "AddWiki";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );