some tweaks, by brion
[lhc/web/wiklou.git] / maintenance / addwiki.php
1 <?php
2
3 $wgNoDBParam = true;
4
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" );
10 }
11
12 addWiki( $args[0], $args[1], $args[2] );
13
14 # -----------------------------------------------------------------
15
16 function addWiki( $lang, $site, $dbName )
17 {
18 global $IP, $wgLanguageNames;
19
20 $name = $wgLanguageNames[$lang];
21
22 $dbw =& wfGetDB( DB_WRITE );
23 $common = "/home/wikipedia/common";
24 $maintenance = "$IP/maintenance";
25
26 print "Creating database $dbName for $lang.$site\n";
27 # Set up the database
28 $dbw->query( "SET table_type=Innodb" );
29 $dbw->query( "CREATE DATABASE $dbName" );
30 $dbw->selectDB( $dbName );
31
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)" );
36
37 $wgTitle = Title::newMainPage();
38 $wgArticle = new Article( $wgTitle );
39 $ucsite = ucfirst( $site );
40
41 $wgArticle->insertNewArticle( "
42 ==This subdomain is reserved for the creation of a $ucsite in '''[[:en:{$name}|{$name}]]''' language==
43
44 If you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.
45
46 Go ahead. Translate this page and start working on your encyclopedia.
47
48 For help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.
49
50 ==Sister projects==
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]
52
53 See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
54
55 [[aa:]]
56 [[af:]]
57 [[als:]]
58 [[ar:]]
59 [[de:]]
60 [[en:]]
61 [[as:]]
62 [[ast:]]
63 [[ay:]]
64 [[az:]]
65 [[be:]]
66 [[bg:]]
67 [[bn:]]
68 [[bo:]]
69 [[bs:]]
70 [[cs:]]
71 [[co:]]
72 [[cs:]]
73 [[cy:]]
74 [[da:]]
75 [[el:]]
76 [[eo:]]
77 [[es:]]
78 [[et:]]
79 [[eu:]]
80 [[fa:]]
81 [[fi:]]
82 [[fr:]]
83 [[fy:]]
84 [[ga:]]
85 [[gl:]]
86 [[gn:]]
87 [[gu:]]
88 [[he:]]
89 [[hi:]]
90 [[hr:]]
91 [[hy:]]
92 [[ia:]]
93 [[id:]]
94 [[is:]]
95 [[it:]]
96 [[ja:]]
97 [[ka:]]
98 [[kk:]]
99 [[km:]]
100 [[kn:]]
101 [[ko:]]
102 [[ks:]]
103 [[ku:]]
104 [[ky:]]
105 [[la:]]
106 [[ln:]]
107 [[lo:]]
108 [[lt:]]
109 [[lv:]]
110 [[hu:]]
111 [[mi:]]
112 [[mk:]]
113 [[ml:]]
114 [[mn:]]
115 [[mr:]]
116 [[ms:]]
117 [[mt:]]
118 [[my:]]
119 [[na:]]
120 [[nah:]]
121 [[nds:]]
122 [[ne:]]
123 [[nl:]]
124 [[no:]]
125 [[oc:]]
126 [[om:]]
127 [[pa:]]
128 [[pl:]]
129 [[ps:]]
130 [[pt:]]
131 [[qu:]]
132 [[ro:]]
133 [[ru:]]
134 [[sa:]]
135 [[si:]]
136 [[sk:]]
137 [[sl:]]
138 [[sq:]]
139 [[sr:]]
140 [[sv:]]
141 [[sw:]]
142 [[ta:]]
143 [[te:]]
144 [[tg:]]
145 [[th:]]
146 [[tk:]]
147 [[tl:]]
148 [[tr:]]
149 [[tt:]]
150 [[ug:]]
151 [[uk:]]
152 [[ur:]]
153 [[uz:]]
154 [[vi:]]
155 [[vo:]]
156 [[xh:]]
157 [[yo:]]
158 [[za:]]
159 [[zh:]]
160 [[zu:]]
161 ", '', false, false );
162
163 print "Adding to dblists\n";
164
165 # Add to dblist
166 $file = fopen( "$common/all.dblist", "a" );
167 fwrite( $file, "$dbName\n" );
168 fclose( $file );
169
170 # Update the sublists
171 system("cd $common && ./refresh-dblist");
172
173 print "Constructing interwiki SQL\n";
174 # Rebuild interwiki tables
175 $sql = getRebuildInterwikiSQL();
176 $tempname = tempnam( '/tmp', 'addwiki' );
177 $file = fopen( $tempname, 'w' );
178 if ( !$file ) {
179 die( "Error, unable to open temporary file $tempname\n" );
180 }
181 fwrite( $file, $sql );
182 fclose( $file );
183 print "Sourcing interwiki SQL\n";
184 dbsource( $tempname, $dbw );
185 unlink( $tempname );
186
187 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
188 }