5 require_once( "commandLine.inc" );
6 require_once( "rebuildInterwiki.inc" );
7 require_once( "languages/Names.php" );
8 if ( count( $args ) != 3 ) {
9 die( "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;
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";
28 $dbw->query( "SET table_type=Innodb" );
29 $dbw->query( "CREATE DATABASE $dbName" );
30 $dbw->selectDB( $dbName );
32 print "Initialising tables\n";
33 dbsource( "$maintenance/tables.sql", $dbw );
34 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
35 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
37 $wgTitle = Title
::newMainPage();
38 $wgArticle = new Article( $wgTitle );
39 $ucsite = ucfirst( $site );
41 $wgArticle->insertNewArticle( "
42 ==This subdomain is reserved for the creation of a $ucsite in '''[[:en:{$name}|{$name}]]''' language==
44 If you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.
46 Go ahead. Translate this page and start working on your encyclopedia.
48 For help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.
51 [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]
53 See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
161 ", '', false, false );
163 print "Adding to dblists\n";
166 $file = fopen( "$common/all.dblist", "a" );
167 fwrite( $file, "$dbName\n" );
170 # Update the sublists
171 system("cd $common && ./refresh-dblist");
173 print "Constructing interwiki SQL\n";
174 # Rebuild interwiki tables
175 $sql = getRebuildInterwikiSQL();
176 $tempname = tempnam( '/tmp', 'addwiki' );
177 $file = fopen( $tempname, 'w' );
179 die( "Error, unable to open temporary file $tempname\n" );
181 fwrite( $file, $sql );
183 print "Sourcing interwiki SQL\n";
184 dbsource( $tempname, $dbw );
187 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";