no size
[lhc/web/wiklou.git] / maintenance / rebuildMessages.php
1 <?php
2 $wgCommandLineMode = true;
3 # Turn off output buffering if it's on
4 @ob_end_flush();
5
6 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
7 if ( isset($argv[1]) && $argv[1] ) {
8 $lang = $argv[1];
9 putenv( "wikilang=$lang");
10 $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
11 $newpath = "/apache/common/php$sep";
12 } else {
13 $settingsFile = "../LocalSettings.php";
14 $newpath = "";
15 }
16
17 if ( isset($argv[2]) && $argv[2] == "update" ) {
18 $response = 1;
19 } elseif ( isset($argv[2]) && $argv[2] == "reinitialise" ) {
20 $response = 2;
21 } else {
22 $response = 0;
23 }
24
25 if ( ! is_readable( $settingsFile ) ) {
26 print "A copy of your installation's LocalSettings.php\n" .
27 "must exist in the source directory.\n";
28 exit();
29 }
30
31 ini_set( "include_path", "../includes$sep../languages$sep$newpath$IP$sep$include_path" );
32
33 $wgCommandLineMode = true;
34 $DP = "../includes";
35 require_once( $settingsFile );
36
37 require_once( "Setup.php" );
38 require_once( "./InitialiseMessages.inc" );
39 require_once( "../install-utils.inc" );
40 $wgTitle = Title::newFromText( "Rebuild messages script" );
41 $wgCommandLineMode = true;
42 set_time_limit(0);
43
44 if ( isset($argv) && count( $argv ) >= 3 ) {
45 $messages = loadArrayFromFile( $argv[3] );
46 } else {
47 $messages = false;
48 }
49
50 if ( $response == 0 ) {
51 $row = wfGetArray( "cur", array("count(*) as c"), array("cur_namespace" => NS_MEDIAWIKI) );
52 print "Current namespace size: {$row->c}\n";
53
54 print "1. Update messages to include latest additions to Language.php\n" .
55 "2. Delete all messages and reinitialise namespace\n" .
56 "3. Quit\n\n".
57
58 "Please enter a number: ";
59
60 do {
61 $response = IntVal(readconsole());
62 if ( $response >= 1 && $response <= 3 ) {
63 $good = true;
64 } else {
65 $good = false;
66 print "Please type a number between 1 and 3: ";
67 }
68 } while ( !$good );
69 }
70
71 switch ( $response ) {
72 case 1:
73 initialiseMessages( false, $messages );
74 break;
75 case 2:
76 initialiseMessages( true, $messages );
77 break;
78 }
79
80 exit();
81
82 ?>