Index: trunk/extensions/CentralNotice/rebuildTemplates.php |
— | — | @@ -9,17 +9,21 @@ |
10 | 10 | if ( isset( $options['help'] ) ) { |
11 | 11 | echo "Rebuilds templates for all notices in DB.\n"; |
12 | 12 | echo "Usage:\n"; |
13 | | - echo " php extensions/CentralNotice/rebuildTemplates\n"; |
| 13 | + echo " php extensions/CentralNotice/rebuildTemplates [-o|Output to disk] [-n test/en|Output just a single notice]\n"; |
14 | 14 | } else { |
15 | 15 | echo "Rebuilding templates ...\n"; |
16 | 16 | |
17 | 17 | // Hack for parser to avoid barfing from no $wgTitle |
18 | 18 | $wgTitle = Title::newFromText( wfMsg( 'mainpage' ) ); |
19 | 19 | |
20 | | - $projects = $wgNoticeProjects; |
21 | | - $langs = array_keys( Language::getLanguageNames() ); |
22 | | - // $langs = array( 'en' ); |
23 | | - |
| 20 | + if ( isset( $options['n'] ) ) { |
| 21 | + $notice = explode( "/", $args[0] ); |
| 22 | + $projects = array( $notice[0] ); |
| 23 | + $langs = array( $notice[1] ); |
| 24 | + } else { |
| 25 | + $projects = $wgNoticeProjects; |
| 26 | + $langs = array_keys( Language::getLanguageNames() ); |
| 27 | + } |
24 | 28 | foreach ( $projects as $project ) { |
25 | 29 | foreach ( $langs as $lang ) { |
26 | 30 | $key = "$project/$lang"; |
— | — | @@ -28,16 +32,20 @@ |
29 | 33 | $builder = new SpecialNoticeText(); |
30 | 34 | $js = $builder->getJsOutput( $key ); |
31 | 35 | |
32 | | - $outputDir = "$wgNoticeCentralDirectory/$project/$lang"; |
33 | | - if ( wfMkDirParents( $outputDir ) ) { |
34 | | - $outputFile = "$outputDir/centralnotice.js"; |
35 | | - $ok = file_put_contents( $outputFile, $js ); |
36 | | - if ( !$ok ) { |
37 | | - echo "FAILED to write $outputFile!\n"; |
38 | | - } |
39 | | - } else { |
40 | | - echo "FAILED to create $outputDir!\n"; |
41 | | - } |
| 36 | + if ( isset( $options['o'] ) ) { |
| 37 | + $outputDir = "$wgNoticeCentralDirectory/$project/$lang"; |
| 38 | + if ( wfMkDirParents( $outputDir ) ) { |
| 39 | + $outputFile = "$outputDir/centralnotice.js"; |
| 40 | + $ok = file_put_contents( $outputFile, $js ); |
| 41 | + if ( !$ok ) { |
| 42 | + echo "FAILED to write $outputFile!\n"; |
| 43 | + } |
| 44 | + } else { |
| 45 | + echo "FAILED to create $outputDir!\n"; |
| 46 | + } |
| 47 | + } else { |
| 48 | + echo $js; |
| 49 | + } |
42 | 50 | } |
43 | 51 | } |
44 | 52 | } |