Index: trunk/phase3/maintenance/mergeMessageFileList.php |
— | — | @@ -26,8 +26,7 @@ |
27 | 27 | define( 'MW_NO_EXTENSION_MESSAGES', 1 ); |
28 | 28 | |
29 | 29 | require_once( dirname( __FILE__ ) . '/Maintenance.php' ); |
30 | | -$maintClass = 'MergeMessageFileList'; |
31 | | -$mmfl = false; |
| 30 | + |
32 | 31 | class MergeMessageFileList extends Maintenance { |
33 | 32 | |
34 | 33 | function __construct() { |
— | — | @@ -39,8 +38,6 @@ |
40 | 39 | } |
41 | 40 | |
42 | 41 | public function execute() { |
43 | | - global $mmfl; |
44 | | - |
45 | 42 | $lines = file( $this->getOption( 'list-file' ) ); |
46 | 43 | if ( $lines === false ) { |
47 | 44 | $this->error( 'Unable to open list file.' ); |
— | — | @@ -49,43 +46,44 @@ |
50 | 47 | if ( $this->hasOption( 'output' ) ) { |
51 | 48 | $mmfl['output'] = $this->getOption( 'output' ); |
52 | 49 | } |
53 | | - } |
54 | | -} |
55 | 50 | |
56 | | -require_once( RUN_MAINTENANCE_IF_MAIN ); |
| 51 | + global $IP, $wgExtensionMessagesFiles, $wgExtensionAliasesFiles; |
| 52 | + foreach ( $mmfl['setupFiles'] as $fileName ) { |
| 53 | + if ( strval( $fileName ) === '' ) { |
| 54 | + continue; |
| 55 | + } |
| 56 | + $fileName = str_replace( '$IP', $IP, $fileName ); |
| 57 | + fwrite( STDERR, "Loading data from $fileName\n" ); |
| 58 | + include_once( $fileName ); |
| 59 | + } |
| 60 | + fwrite( STDERR, "\n" ); |
| 61 | + $s = |
| 62 | + "<" . "?php\n" . |
| 63 | + "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" . |
| 64 | + "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" . |
| 65 | + '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" . |
| 66 | + '$wgExtensionAliasesFiles = ' . var_export( $wgExtensionAliasesFiles, true ) . ";\n"; |
57 | 67 | |
58 | | -foreach ( $mmfl['setupFiles'] as $fileName ) { |
59 | | - if ( strval( $fileName ) === '' ) { |
60 | | - continue; |
61 | | - } |
62 | | - $fileName = str_replace( '$IP', $IP, $fileName ); |
63 | | - fwrite( STDERR, "Loading data from $fileName\n" ); |
64 | | - include_once( $fileName ); |
65 | | -} |
66 | | -fwrite( STDERR, "\n" ); |
67 | | -$s = |
68 | | - "<" . "?php\n" . |
69 | | - "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" . |
70 | | - "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" . |
71 | | - '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" . |
72 | | - '$wgExtensionAliasesFiles = ' . var_export( $wgExtensionAliasesFiles, true ) . ";\n"; |
| 68 | + $dirs = array( |
| 69 | + $IP, |
| 70 | + dirname( dirname( __FILE__ ) ), |
| 71 | + realpath( $IP ) |
| 72 | + ); |
73 | 73 | |
74 | | -$dirs = array( |
75 | | - $IP, |
76 | | - dirname( dirname( __FILE__ ) ), |
77 | | - realpath( $IP ) |
78 | | -); |
| 74 | + foreach ( $dirs as $dir ) { |
| 75 | + $s = preg_replace( |
| 76 | + "/'" . preg_quote( $dir, '/' ) . "([^']*)'/", |
| 77 | + '"$IP\1"', |
| 78 | + $s ); |
| 79 | + } |
79 | 80 | |
80 | | -foreach ( $dirs as $dir ) { |
81 | | - $s = preg_replace( |
82 | | - "/'" . preg_quote( $dir, '/' ) . "([^']*)'/", |
83 | | - '"$IP\1"', |
84 | | - $s ); |
| 81 | + if ( isset( $mmfl['output'] ) ) { |
| 82 | + file_put_contents( $mmfl['output'], $s ); |
| 83 | + } else { |
| 84 | + echo $s; |
| 85 | + } |
| 86 | + } |
85 | 87 | } |
86 | 88 | |
87 | | -if ( isset( $mmfl['output'] ) ) { |
88 | | - file_put_contents( $mmfl['output'], $s ); |
89 | | -} else { |
90 | | - echo $s; |
91 | | -} |
92 | | - |
| 89 | +$maintClass = 'MergeMessageFileList'; |
| 90 | +require_once( RUN_MAINTENANCE_IF_MAIN ); |