Fix syntax error
[lhc/web/wiklou.git] / maintenance / addwiki.php
index 5a556bb..dfb9c9e 100644 (file)
@@ -1,4 +1,11 @@
 <?php
+/**
+ * Add a new wiki
+ * Wikimedia specific!
+ *
+ * @file
+ * @ingroup Maintenance
+ */
 
 $wgNoDBParam = true;
 
@@ -6,7 +13,7 @@ require_once( "commandLine.inc" );
 require_once( "rebuildInterwiki.inc" );
 require_once( "languages/Names.php" );
 if ( count( $args ) != 3 ) {
-       wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
+       wfDie( "Usage: php addwiki.php <language> <site> <dbname>\nThe site for Wikipedia is 'wikipedia'.\n" );
 }
 
 addWiki( $args[0], $args[1], $args[2] );
@@ -17,13 +24,17 @@ function addWiki( $lang, $site, $dbName )
 {
        global $IP, $wgLanguageNames, $wgDefaultExternalStore;
 
+       if ( !isset( $wgLanguageNames[$lang] ) ) {
+               print "Language $lang not found in \$wgLanguageNames\n";
+               return;
+       }
        $name = $wgLanguageNames[$lang];
 
-       $dbw =& wfGetDB( DB_WRITE );
+       $dbw = wfGetDB( DB_MASTER );
        $common = "/home/wikipedia/common";
        $maintenance = "$IP/maintenance";
 
-       print "Creating database $dbName for $lang.$site\n";
+       print "Creating database $dbName for $lang.$site ($name)\n";
        
        # Set up the database
        $dbw->query( "SET table_type=Innodb" );
@@ -34,6 +45,11 @@ function addWiki( $lang, $site, $dbName )
        dbsource( "$maintenance/tables.sql", $dbw );
        dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
        dbsource( "$IP/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw );
+       dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw );
+       dbsource( "$IP/extensions/CheckUser/cu_log.sql", $dbw );
+       dbsource( "$IP/extensions/TitleKey/titlekey.sql", $dbw );
+       dbsource( "$IP/extensions/Oversight/hidden.sql", $dbw );
+
        $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
 
        # Initialise external storage
@@ -70,23 +86,33 @@ function addWiki( $lang, $site, $dbName )
                }
        }
 
-       $wgTitle = Title::newMainPage();
+       global $wgTitle, $wgArticle;
+       $wgTitle = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
+       print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n";
        $wgArticle = new Article( $wgTitle );
        $ucsite = ucfirst( $site );
 
-       $wgArticle->insertNewArticle( "
-==This subdomain is reserved for the creation of a $ucsite in '''[[:en:{$name}|{$name}]]''' language==
+       $wgArticle->insertNewArticle( <<<EOT
+==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
 
-If you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.
+* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|BetaWikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.
 
-Go ahead. Translate this page and start working on your encyclopedia.
+* If you would like to help translating the interface to this language, please do not translate here, but go to [[betawiki:|Betawiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].
 
-For help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.
+* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].
 
-==Sister projects==
-[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]
+== Sister projects ==
+<span class="plainlinks">
+[http://www.wikipedia.org Wikipedia] |
+[http://www.wiktionary.org Wiktonary] |
+[http://www.wikibooks.org Wikibooks] |
+[http://www.wikinews.org Wikinews] |
+[http://www.wikiquote.org Wikiquote] |
+[http://www.wikisource.org Wikisource]
+[http://www.wikiversity.org Wikiversity]
+</span>
 
-See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
+See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
 
 [[aa:]]
 [[af:]]
@@ -98,6 +124,7 @@ See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedia
 [[ast:]]
 [[ay:]]
 [[az:]]
+[[bcl:]]
 [[be:]]
 [[bg:]]
 [[bn:]]
@@ -124,6 +151,7 @@ See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedia
 [[he:]]
 [[hi:]]
 [[hr:]]
+[[hsb:]]
 [[hy:]]
 [[ia:]]
 [[id:]]
@@ -194,7 +222,9 @@ See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedia
 [[za:]]
 [[zh:]]
 [[zu:]]
-", '', false, false );
+
+EOT
+, '', false, false );
 
        print "Adding to dblists\n";
 
@@ -204,32 +234,16 @@ See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedia
        fclose( $file );
 
        # Update the sublists
-       system("cd $common && ./refresh-dblist");
+       shell_exec("cd $common && ./refresh-dblist");
 
-       print "Constructing interwiki SQL\n";
+       #print "Constructing interwiki SQL\n";
        # Rebuild interwiki tables
-       $sql = getRebuildInterwikiSQL();
-       $tempname = tempnam( '/tmp', 'addwiki' );
-       $file = fopen( $tempname, 'w' );
-       if ( !$file ) {
-               wfDie( "Error, unable to open temporary file $tempname\n" );
-       }
-       fwrite( $file, $sql );
-       fclose( $file );
-       print "Sourcing interwiki SQL\n";
-       dbsource( $tempname, $dbw );
-       #unlink( $tempname );
-       
-       # Create the upload dir
-       global $wgUploadDirectory;
-       if( file_exists( $wgUploadDirectory ) ) {
-               echo "$wgUploadDirectory already exists.\n";
-       } else {
-               echo "Creating $wgUploadDirectory...\n";
-               mkdir( $wgUploadDirectory, 0777 );
-               chmod( $wgUploadDirectory, 0777 );
-       }
+       #passthru( '/home/wikipedia/conf/interwiki/update' );
 
-       print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
+       print "Script ended. You still have to:
+* Add any required settings in InitialiseSettings.php
+* Run sync-common-all
+* Run /home/wikipedia/conf/interwiki/update
+";
 }
-?>
+