Index: branches/wmf-deployment/maintenance/mergeMessageFileList.php |
— | — | @@ -0,0 +1,67 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once( dirname( __FILE__ ).'/Maintenance.php' ); |
| 5 | +$maintClass = 'MergeMessageFileList'; |
| 6 | +$mmfl = false; |
| 7 | +class MergeMessageFileList extends Maintenance { |
| 8 | + |
| 9 | + function __construct() { |
| 10 | + $this->addOption( 'list-file', 'A file containing a list of extension setup files, one per line.', false, true ); |
| 11 | + $this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true ); |
| 12 | + $this->mDescription = 'Merge $wgExtensionMessagesFiles from various extensions to produce a ' . |
| 13 | + 'single array containing all message files.'; |
| 14 | + } |
| 15 | + |
| 16 | + public function execute() { |
| 17 | + global $IP, $mmfl; |
| 18 | + if ( !$this->hasOption( 'list-file' ) ) { |
| 19 | + $this->error( 'The --list-file option must be specified.' ); |
| 20 | + return; |
| 21 | + } |
| 22 | + |
| 23 | + $lines = file( $this->getOption( 'list-file' ) ); |
| 24 | + if ( $lines === false ) { |
| 25 | + $this->error( 'Unable to open list file.' ); |
| 26 | + } |
| 27 | + $mmfl = array( 'setupFiles' => array_map( 'trim', $lines ) ); |
| 28 | + if ( $this->hasOption( 'output' ) ) { |
| 29 | + $mmfl['output'] = $this->getOption( 'output' ); |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +require_once( DO_MAINTENANCE ); |
| 35 | + |
| 36 | +foreach ( $mmfl['setupFiles'] as $fileName ) { |
| 37 | + if ( strval( $fileName ) === '' ) { |
| 38 | + continue; |
| 39 | + } |
| 40 | + $fileName = str_replace( '$IP', $IP, $fileName ); |
| 41 | + include_once( $fileName ); |
| 42 | +} |
| 43 | +fwrite( STDERR, "\n" ); |
| 44 | +$s = |
| 45 | + "<" . "?php\n" . |
| 46 | + "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" . |
| 47 | + '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" . |
| 48 | + '$wgExtensionAliasesFiles = ' . var_export( $wgExtensionAliasesFiles, true ) . ";\n"; |
| 49 | + |
| 50 | +$dirs = array( |
| 51 | + $IP, |
| 52 | + dirname( dirname( __FILE__ ) ), |
| 53 | + realpath( $IP ) |
| 54 | +); |
| 55 | + |
| 56 | +foreach ( $dirs as $dir ) { |
| 57 | + $s = preg_replace( |
| 58 | + "/'" . preg_quote( $dir, '/' ) . "([^']*)'/", |
| 59 | + '"$IP\1"', |
| 60 | + $s ); |
| 61 | +} |
| 62 | + |
| 63 | +if ( isset( $mmfl['output'] ) ) { |
| 64 | + file_put_contents( $mmfl['output'], $s ); |
| 65 | +} else { |
| 66 | + echo $s; |
| 67 | +} |
| 68 | + |
Property changes on: branches/wmf-deployment/maintenance/mergeMessageFileList.php |
___________________________________________________________________ |
Name: svn:mergeinfo |
1 | 69 | + /branches/REL1_15/phase3/maintenance/mergeMessageFileList.php:51646 |
Name: svn:eol-style |
2 | 70 | + native |