overwriting of old default messages; ability to dump messages to a file
[lhc/web/wiklou.git] / maintenance / rebuildMessages.php
1 <?php
2 $wgCommandLineMode = true;
3
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 = "";
13 }
14
15 if ( $argv[2] == "update" ) {
16 $response = 1;
17 } elseif ( $argv[2] == "reinitialise" ) {
18 $response = 2;
19 } else {
20 $response = 0;
21 }
22
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();
27 }
28
29 ini_set( "include_path", "../includes$sep../languages$sep$newpath$IP$sep$include_path" );
30
31 $wgCommandLineMode = true;
32 $DP = "../includes";
33 include_once( $settingsFile );
34
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);
41
42 if ( count( $argv ) >= 3 ) {
43 $messages = loadArrayFromFile( $argv[3] );
44 } else {
45 $messages = false;
46 }
47
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";
51
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".
55
56 "Please enter a number: ";
57
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: ";
65 }
66 } while ( !$good );
67 }
68
69 switch ( $response ) {
70 case 1:
71 initialiseMessages( false, $messages );
72 break;
73 case 2:
74 initialiseMessages( true, $messages );
75 break;
76 }
77
78 exit();
79
80 ?>