Index: trunk/phase3/maintenance/mergeMessageFileList.php |
— | — | @@ -0,0 +1,59 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once( dirname( __FILE__ ).'/Maintenance.php' ); |
| 5 | +$maintClass = 'MergeMessageFileList'; |
| 6 | + |
| 7 | +class MergeMessageFileList extends Maintenance { |
| 8 | + |
| 9 | + function __construct() { |
| 10 | + $this->addOption( 'list-file', 'A file containing a list of wikis, one per line.', false, true ); |
| 11 | + $this->addOption( 'get', 'Get the message files for a single wiki (for internal use).' ); |
| 12 | + $this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true ); |
| 13 | + $this->mDescription = 'Merge $wgExtensionMessagesFiles from various wikis to produce a ' . |
| 14 | + 'single array containing all message files.'; |
| 15 | + } |
| 16 | + |
| 17 | + public function execute() { |
| 18 | + if ( $this->hasOption( 'get' ) ) { |
| 19 | + var_export( $GLOBALS['wgExtensionMessagesFiles'] ); |
| 20 | + return; |
| 21 | + } |
| 22 | + |
| 23 | + if ( !$this->hasOption( 'list-file' ) ) { |
| 24 | + $this->error( 'The --list-file option must be specified.' ); |
| 25 | + return; |
| 26 | + } |
| 27 | + |
| 28 | + $lines = file( $this->getOption( 'list-file' ) ); |
| 29 | + if ( $lines === false ) { |
| 30 | + $this->error( 'Unable to open list file.' ); |
| 31 | + } |
| 32 | + $wikis = array_map( 'trim', $lines ); |
| 33 | + |
| 34 | + # Find PHP |
| 35 | + $php = readlink( '/proc/' . posix_getpid() . '/exe' ); |
| 36 | + $allFiles = array(); |
| 37 | + |
| 38 | + foreach ( $wikis as $wiki ) { |
| 39 | + $s = wfShellExec( wfEscapeShellArg( $php, __FILE__, '--get', |
| 40 | + '--wiki', $wiki ) ); |
| 41 | + if ( !$s ) { |
| 42 | + $this->error( 'Unable to get messages for wiki '. $wiki ); |
| 43 | + continue; |
| 44 | + } |
| 45 | + $files = eval( "return $s;" ); |
| 46 | + $allFiles += $files; |
| 47 | + } |
| 48 | + $s = '$wgExtensionMessagesFiles = ' . |
| 49 | + var_export( $allFiles, true ) . |
| 50 | + ";\n"; |
| 51 | + if ( $this->hasOption( 'output' ) ) { |
| 52 | + file_put_contents( $this->getOption( 'output' ), $s ); |
| 53 | + } else { |
| 54 | + echo $s; |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +require_once( DO_MAINTENANCE ); |
| 60 | + |
Property changes on: trunk/phase3/maintenance/mergeMessageFileList.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 61 | + native |