dirty hack to work around the one-space-at-beginning-required problem
[mediawiki.git] / maintenance / rebuildMessages.php
blob58bcdc60242682d80e7ea92edd436ea063313ab1
1 <?php
2 $wgCommandLineMode = true;
4 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
5 if ( $argv[1] ) {
6 $lang = $argv[1];
7 putenv( "wikilang=$lang");
8 $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
9 $newpath = "/apache/common/php$sep";
10 } else {
11 $settingsFile = "../LocalSettings.php";
12 $newpath = "";
15 if ( $argv[2] == "update" ) {
16 $response = 1;
17 } elseif ( $argv[2] == "reinitialise" ) {
18 $response = 2;
19 } else {
20 $response = 0;
23 if ( ! is_readable( $settingsFile ) ) {
24 print "A copy of your installation's LocalSettings.php\n" .
25 "must exist in the source directory.\n";
26 exit();
29 ini_set( "include_path", "../includes$sep../languages$sep$newpath$IP$sep$include_path" );
31 $wgCommandLineMode = true;
32 $DP = "../includes";
33 include_once( $settingsFile );
35 include_once( "Setup.php" );
36 include_once( "./InitialiseMessages.inc" );
37 include_once( "../install-utils.inc" );
38 $wgTitle = Title::newFromText( "Rebuild messages script" );
39 $wgCommandLineMode = true;
40 set_time_limit(0);
42 if ( count( $argv ) >= 3 ) {
43 $messages = loadArrayFromFile( $argv[3] );
44 } else {
45 $messages = false;
48 if ( $response == 0 ) {
49 $row = wfGetArray( "cur", array("count(*) as c"), array("cur_namespace" => NS_MEDIAWIKI) );
50 print "Current namespace size: {$row->c}\n";
52 print "1. Update messages to include latest additions to Language.php\n" .
53 "2. Delete all messages and reinitialise namespace\n" .
54 "3. Quit\n\n".
56 "Please enter a number: ";
58 do {
59 $response = IntVal(readconsole());
60 if ( $response >= 1 && $response <= 3 ) {
61 $good = true;
62 } else {
63 $good = false;
64 print "Please type a number between 1 and 3: ";
66 } while ( !$good );
69 switch ( $response ) {
70 case 1:
71 initialiseMessages( false, $messages );
72 break;
73 case 2:
74 initialiseMessages( true, $messages );
75 break;
78 exit();