5 require_once( "commandLine.inc" );
6 require_once( "rebuildInterwiki.inc" );
7 require_once( "languages/Names.php" );
8 if ( count( $args ) != 3 ) {
9 wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
12 addWiki( $args[0], $args[1], $args[2] );
14 # -----------------------------------------------------------------
16 function addWiki( $lang, $site, $dbName )
18 global $IP, $wgLanguageNames, $wgDefaultExternalStore;
20 $name = $wgLanguageNames[$lang];
22 $dbw =& wfGetDB( DB_WRITE
);
23 $common = "/home/wikipedia/common";
24 $maintenance = "$IP/maintenance";
26 print "Creating database $dbName for $lang.$site\n";
29 $dbw->query( "SET table_type=Innodb" );
30 $dbw->query( "CREATE DATABASE $dbName" );
31 $dbw->selectDB( $dbName );
33 print "Initialising tables\n";
34 dbsource( "$maintenance/tables.sql", $dbw );
35 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
36 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
38 # Initialise external storage
39 if ( $wgDefaultExternalStore && preg_match( '!^DB://(.*)$!', $wgDefaultExternalStore, $m ) ) {
40 print "Initialising external storage...\n";
41 require_once( 'ExternalStoreDB.php' );
42 global $wgDBuser, $wgDBpassword, $wgExternalServers;
46 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
47 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
49 $store = new ExternalStoreDB
;
50 $extdb =& $store->getMaster( $cluster );
51 $extdb->query( "SET table_type=InnoDB" );
52 $extdb->query( "CREATE DATABASE $dbName" );
53 $extdb->selectDB( $dbName );
54 dbsource( "$maintenance/storage/blobs.sql", $extdb );
55 $extdb->immediateCommit();
58 $wgTitle = Title
::newMainPage();
59 $wgArticle = new Article( $wgTitle );
60 $ucsite = ucfirst( $site );
62 $wgArticle->insertNewArticle( "
63 ==This subdomain is reserved for the creation of a $ucsite in '''[[:en:{$name}|{$name}]]''' language==
65 If you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.
67 Go ahead. Translate this page and start working on your encyclopedia.
69 For help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.
72 [http://meta.wikipedia.org Meta-Wikipedia] | [http://www.wiktionary.org Wikitonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource]
74 See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
182 ", '', false, false );
184 print "Adding to dblists\n";
187 $file = fopen( "$common/all.dblist", "a" );
188 fwrite( $file, "$dbName\n" );
191 # Update the sublists
192 system("cd $common && ./refresh-dblist");
194 print "Constructing interwiki SQL\n";
195 # Rebuild interwiki tables
196 $sql = getRebuildInterwikiSQL();
197 $tempname = tempnam( '/tmp', 'addwiki' );
198 $file = fopen( $tempname, 'w' );
200 wfDie( "Error, unable to open temporary file $tempname\n" );
202 fwrite( $file, $sql );
204 print "Sourcing interwiki SQL\n";
205 dbsource( $tempname, $dbw );
208 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";