http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59025
Revision: 59025 Author: siebrand Date: 2009-11-13 21:05:08 +0000 (Fri, 13 Nov 2009) Log Message: ----------- Allow suppression of progress report Modified Paths: -------------- trunk/extensions/Translate/scripts/createMessageIndex.php trunk/extensions/Translate/utils/MessageIndexRebuilder.php Modified: trunk/extensions/Translate/scripts/createMessageIndex.php =================================================================== --- trunk/extensions/Translate/scripts/createMessageIndex.php 2009-11-13 20:45:13 UTC (rev 59024) +++ trunk/extensions/Translate/scripts/createMessageIndex.php 2009-11-13 21:05:08 UTC (rev 59025) @@ -14,4 +14,27 @@ require( dirname( __FILE__ ) . '/cli.inc' ); -MessageIndexRebuilder::execute(); \ No newline at end of file +function showUsage() { + STDERR( <<<EOT +Message index creation command line script + +Usage: php createMessageIndex.php [options...] + +Options: + --help Show this help text + --progress Report on progress (default: false) + +EOT +); + exit( 1 ); +} + +if ( isset( $options['help'] ) ) { + showUsage(); +} + +if ( isset( $options['progress'] ) ) { + MessageIndexRebuilder::execute(); +} else { + MessageIndexRebuilder::execute( false ); +} Modified: trunk/extensions/Translate/utils/MessageIndexRebuilder.php =================================================================== --- trunk/extensions/Translate/utils/MessageIndexRebuilder.php 2009-11-13 20:45:13 UTC (rev 59024) +++ trunk/extensions/Translate/utils/MessageIndexRebuilder.php 2009-11-13 21:05:08 UTC (rev 59025) @@ -13,14 +13,18 @@ */ class MessageIndexRebuilder { - public static function execute() { + protected $reportProgress; + public static function execute( $reportProgress = true ) { $groups = MessageGroups::singleton()->getGroups(); $hugearray = array(); $postponed = array(); - STDOUT( "Working with ", 'main' ); + if( $reportProgress ) { + STDOUT( "Working with ", 'main' ); + $this->reportProgress = true; + } foreach ( $groups as $g ) { if ( !$g->exists() ) continue; @@ -36,7 +40,7 @@ foreach ( $postponed as $g ) { self::checkAndAdd( $hugearray, $g, true ); } - + global $wgCacheDirectory; $filename = "$wgCacheDirectory/translate_messageindex.cdb"; $writer = CdbWriter::open( $filename ); @@ -60,7 +64,9 @@ $id = $g->getId(); - STDOUT( "$id ", 'main' ); + if( $this->reportProgress ) { + STDOUT( "$id ", 'main' ); + } $namespace = $g->getNamespace(); @@ -92,4 +98,4 @@ } unset( $id ); // Disconnect the previous references to this $id } -} \ No newline at end of file +} _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs