miscellaneous improvements
[lhc/web/wiklou.git] / maintenance / rebuildMessages.php
1 <?php
2 require_once( "commandLine.inc" );
3 include_once( "InitialiseMessages.inc" );
4
5 $wgTitle = Title::newFromText( "Rebuild messages script" );
6
7 if ( isset( $args[0] ) ) {
8 $response = array_shift( $args );
9 if ( $response == "update" ) {
10 $response = 1;
11 } elseif ( $response == "rebuild" ) {
12 $response = 2;
13 }
14 } else {
15 $response = 0;
16 }
17 if ( isset( $args[0] ) ) {
18 $messages = loadLanguageFile( array_shift( $args ) );
19 } else {
20 $messages = false;
21 }
22
23 if ( $response == 0 ) {
24 $row = wfGetArray( "cur", array("count(*) as c"), array("cur_namespace" => NS_MEDIAWIKI) );
25 print "Current namespace size: {$row->c}\n";
26
27 print "1. Update messages to include latest additions to Language.php\n" .
28 "2. Delete all messages and reinitialise namespace\n" .
29 "3. Quit\n\n".
30
31 "Please enter a number: ";
32
33 do {
34 $response = IntVal(readconsole());
35 if ( $response >= 1 && $response <= 3 ) {
36 $good = true;
37 } else {
38 $good = false;
39 print "Please type a number between 1 and 3: ";
40 }
41 } while ( !$good );
42 }
43
44 switch ( $response ) {
45 case 1:
46 initialiseMessages( false, $messages );
47 break;
48 case 2:
49 initialiseMessages( true, $messages );
50 break;
51 }
52
53 exit();
54
55 ?>