Fix typos identified by Nick Jenkins with his magic tool o' doom
[mediawiki.git] / maintenance / addwiki.php
blob253033a3daeedf324c94c2086322b19265aaa7f5
1 <?php
3 $wgNoDBParam = true;
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";
28 # Set up the database
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;
43 $cluster = $m[1];
45 # Hack
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]]'''.
71 ==Sister projects==
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.
76 [[aa:]]
77 [[af:]]
78 [[als:]]
79 [[ar:]]
80 [[de:]]
81 [[en:]]
82 [[as:]]
83 [[ast:]]
84 [[ay:]]
85 [[az:]]
86 [[be:]]
87 [[bg:]]
88 [[bn:]]
89 [[bo:]]
90 [[bs:]]
91 [[cs:]]
92 [[co:]]
93 [[cs:]]
94 [[cy:]]
95 [[da:]]
96 [[el:]]
97 [[eo:]]
98 [[es:]]
99 [[et:]]
100 [[eu:]]
101 [[fa:]]
102 [[fi:]]
103 [[fr:]]
104 [[fy:]]
105 [[ga:]]
106 [[gl:]]
107 [[gn:]]
108 [[gu:]]
109 [[he:]]
110 [[hi:]]
111 [[hr:]]
112 [[hy:]]
113 [[ia:]]
114 [[id:]]
115 [[is:]]
116 [[it:]]
117 [[ja:]]
118 [[ka:]]
119 [[kk:]]
120 [[km:]]
121 [[kn:]]
122 [[ko:]]
123 [[ks:]]
124 [[ku:]]
125 [[ky:]]
126 [[la:]]
127 [[ln:]]
128 [[lo:]]
129 [[lt:]]
130 [[lv:]]
131 [[hu:]]
132 [[mi:]]
133 [[mk:]]
134 [[ml:]]
135 [[mn:]]
136 [[mr:]]
137 [[ms:]]
138 [[mt:]]
139 [[my:]]
140 [[na:]]
141 [[nah:]]
142 [[nds:]]
143 [[ne:]]
144 [[nl:]]
145 [[no:]]
146 [[oc:]]
147 [[om:]]
148 [[pa:]]
149 [[pl:]]
150 [[ps:]]
151 [[pt:]]
152 [[qu:]]
153 [[ro:]]
154 [[ru:]]
155 [[sa:]]
156 [[si:]]
157 [[sk:]]
158 [[sl:]]
159 [[sq:]]
160 [[sr:]]
161 [[sv:]]
162 [[sw:]]
163 [[ta:]]
164 [[te:]]
165 [[tg:]]
166 [[th:]]
167 [[tk:]]
168 [[tl:]]
169 [[tr:]]
170 [[tt:]]
171 [[ug:]]
172 [[uk:]]
173 [[ur:]]
174 [[uz:]]
175 [[vi:]]
176 [[vo:]]
177 [[xh:]]
178 [[yo:]]
179 [[za:]]
180 [[zh:]]
181 [[zu:]]
182 ", '', false, false );
184 print "Adding to dblists\n";
186 # Add to dblist
187 $file = fopen( "$common/all.dblist", "a" );
188 fwrite( $file, "$dbName\n" );
189 fclose( $file );
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' );
199 if ( !$file ) {
200 wfDie( "Error, unable to open temporary file $tempname\n" );
202 fwrite( $file, $sql );
203 fclose( $file );
204 print "Sourcing interwiki SQL\n";
205 dbsource( $tempname, $dbw );
206 unlink( $tempname );
208 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";