r72625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72624‎ | r72625 | r72626 >
Date:02:01, 9 September 2010
Author:kaldari
Status:ok
Tags:
Comment:
remove code for static javascript files (being replaced with dynamic banner loader)
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/rebuildTemplates.php (deleted) (history)

Diff [purge]

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 @@
22 <?php
33
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 -
174 // Override these per-wiki to pass on via the loader to the text system
185 // for localization by language and project.
196 // Actual user language is used for localization; $wgNoticeLang is used
@@ -20,8 +7,7 @@
218 $wgNoticeLang = $wgLanguageCode;
229 $wgNoticeProject = 'wikipedia';
2310
24 -// List of available projects, which will be used to generate static
25 -// output .js in the batch generation...
 11+// List of available projects
2612 $wgNoticeProjects = array(
2713 'wikipedia',
2814 'wiktionary',
@@ -36,13 +22,6 @@
3723 'wikispecies',
3824 );
3925
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 -
4726 // Enable the notice-hosting infrastructure on this wiki...
4827 // Leave at false for wikis that only use a sister site for the control.
4928 // All remaining options apply only to the infrastructure wiki.
@@ -143,19 +122,11 @@
144123 }
145124
146125 function efCentralNoticeLoader( $out, $skin ) {
147 - global $wgUser, $wgOut, $wgLanguageCode;
148 - global $wgNoticeProject, $wgNoticeCentralPath;
 126+ global $wgUser, $wgOut;
149127
150 - // Pull the static Javascript file for this site
151 - $centralNotice = "$wgNoticeProject/$wgLanguageCode/centralnotice.js";
 128+ $centralLoader = SpecialPage::getTitleFor( 'NoticeText' )->getLocalUrl();
152129
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>
160131 $wgOut->addScriptFile( $centralLoader );
161132
162133 return true;
@@ -169,7 +140,7 @@
170141 }
171142
172143 function efCentralNoticeDisplay( &$notice ) {
173 - // Slip in load of the data...
 144+ // Slip in loading of the banner (inside the siteNotice div)
174145 $notice =
175146 Html::inlineScript( "if (wgNotice != '') document.writeln(wgNotice);" ) .
176147 $notice;

Status & tagging log