Index: trunk/extensions/CentralNotice/rebuildTemplates.php |
— | — | @@ -1,51 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -require_once dirname( dirname( dirname( __FILE__ ) ) ) . "/maintenance/commandLine.inc"; |
5 | | - |
6 | | -if ( !$wgNoticeCentralDirectory ) { |
7 | | - echo "\$wgNoticeCentralDirectory isn't set -- we're not configured to build static templates."; |
8 | | -} |
9 | | - |
10 | | -if ( isset( $options['help'] ) ) { |
11 | | - echo "Rebuilds templates for all notices in DB.\n"; |
12 | | - echo "Usage:\n"; |
13 | | - echo " php extensions/CentralNotice/rebuildTemplates [-o|Output to disk] [-n test/en|Output just a single notice]\n"; |
14 | | -} else { |
15 | | - echo "Rebuilding templates ...\n"; |
16 | | - |
17 | | - // Hack for parser to avoid barfing from no $wgTitle |
18 | | - $wgTitle = Title::newFromText( wfMsg( 'mainpage' ) ); |
19 | | - |
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 | | - } |
28 | | - foreach ( $projects as $project ) { |
29 | | - foreach ( $langs as $lang ) { |
30 | | - $key = "$project/$lang"; |
31 | | - echo "$key\n"; |
32 | | - |
33 | | - $builder = new SpecialNoticeText(); |
34 | | - $js = $builder->getOutput( $key ); |
35 | | - |
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 | | - } |
50 | | - } |
51 | | - } |
52 | | -} |
Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -1,18 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -// Override this URL to point to the central notice text loader... |
5 | | -// This guy gets loaded from every page on every wiki, so caching helps! |
6 | | -// / |
7 | | -// Can be set to a directory where static files will be made -- |
8 | | -// match that up with $wgNoticeStaticDirectory and use rebuildTemplates.php |
9 | | -// to fill out the directory tree. |
10 | | -// |
11 | | -// Default: Local path to Special:NoticeText |
12 | | -// |
13 | | -// Loads: $wgNoticeCentralPath/<project>/<lang>/centralnotice.js |
14 | | -// |
15 | | -$wgNoticeCentralPath = false; |
16 | | - |
17 | 4 | // Override these per-wiki to pass on via the loader to the text system |
18 | 5 | // for localization by language and project. |
19 | 6 | // Actual user language is used for localization; $wgNoticeLang is used |
— | — | @@ -20,8 +7,7 @@ |
21 | 8 | $wgNoticeLang = $wgLanguageCode; |
22 | 9 | $wgNoticeProject = 'wikipedia'; |
23 | 10 | |
24 | | -// List of available projects, which will be used to generate static |
25 | | -// output .js in the batch generation... |
| 11 | +// List of available projects |
26 | 12 | $wgNoticeProjects = array( |
27 | 13 | 'wikipedia', |
28 | 14 | 'wiktionary', |
— | — | @@ -36,13 +22,6 @@ |
37 | 23 | 'wikispecies', |
38 | 24 | ); |
39 | 25 | |
40 | | -// Local filesystem path under which static .js output is written |
41 | | -// for the central notice system. |
42 | | -// |
43 | | -// $wgNoticeCentralDirectory = "/mnt/uploads/centralnotice"; |
44 | | -// |
45 | | -$wgNoticeCentralDirectory = false; |
46 | | - |
47 | 26 | // Enable the notice-hosting infrastructure on this wiki... |
48 | 27 | // Leave at false for wikis that only use a sister site for the control. |
49 | 28 | // All remaining options apply only to the infrastructure wiki. |
— | — | @@ -143,19 +122,11 @@ |
144 | 123 | } |
145 | 124 | |
146 | 125 | function efCentralNoticeLoader( $out, $skin ) { |
147 | | - global $wgUser, $wgOut, $wgLanguageCode; |
148 | | - global $wgNoticeProject, $wgNoticeCentralPath; |
| 126 | + global $wgUser, $wgOut; |
149 | 127 | |
150 | | - // Pull the static Javascript file for this site |
151 | | - $centralNotice = "$wgNoticeProject/$wgLanguageCode/centralnotice.js"; |
| 128 | + $centralLoader = SpecialPage::getTitleFor( 'NoticeText' )->getLocalUrl(); |
152 | 129 | |
153 | | - if ( $wgNoticeCentralPath === false ) { |
154 | | - $centralLoader = SpecialPage::getTitleFor( 'NoticeText', $centralNotice )->getLocalUrl(); |
155 | | - } else { |
156 | | - $centralLoader = "$wgNoticeCentralPath/$centralNotice"; |
157 | | - } |
158 | | - |
159 | | - // Load the notice text from <head> |
| 130 | + // Insert the banner controller Javascript into the <head> |
160 | 131 | $wgOut->addScriptFile( $centralLoader ); |
161 | 132 | |
162 | 133 | return true; |
— | — | @@ -169,7 +140,7 @@ |
170 | 141 | } |
171 | 142 | |
172 | 143 | function efCentralNoticeDisplay( &$notice ) { |
173 | | - // Slip in load of the data... |
| 144 | + // Slip in loading of the banner (inside the siteNotice div) |
174 | 145 | $notice = |
175 | 146 | Html::inlineScript( "if (wgNotice != '') document.writeln(wgNotice);" ) . |
176 | 147 | $notice; |