Index: trunk/extensions/CentralNotice/newCentralNotice.js |
— | — | @@ -1,102 +0,0 @@ |
2 | | -/* |
3 | | - * New Central Notice Javascript |
4 | | - * |
5 | | - * Mostly stubbed functionallity for central notice improvements |
6 | | - * May or may not be used, definitely will be changed. |
7 | | - * More of a sketch of what we think needs to be done. |
8 | | - */ |
9 | | -( function( $ ) { |
10 | | - $.centralNotice = { |
11 | | - 'data': { |
12 | | - 'getVars': {} |
13 | | - }, |
14 | | - 'fn': { |
15 | | - 'loadBanner': function( bannerName ) { |
16 | | - // get the requested banner |
17 | | - var bannerPage = 'Special:BannerLoader?banner='+bannerName+'&userlang='+wgContentLanguage+'&sitename='+wgNoticeProject; |
18 | | - var bannerURL = wgArticlePath.replace( '$1', bannerPage ); |
19 | | - var request = $.ajax( { |
20 | | - url: bannerURL, |
21 | | - dataType: 'html', |
22 | | - success: function( data ) { |
23 | | - $.centralNotice.fn.displayBanner( data ); |
24 | | - } |
25 | | - }); |
26 | | - }, |
27 | | - 'loadBannerList': function( timestamp ) { |
28 | | - var bannerListURL; |
29 | | - if ( timestamp ) { |
30 | | - bannerListURL = "TBD" |
31 | | - } else { |
32 | | - // http://geoiplookup.wikimedia.org/ |
33 | | - var geoLocation = 'US'; // Hard-coding for now |
34 | | - var bannerListPage = 'Special:BannerListLoader?language='+wgContentLanguage+'&project='+wgNoticeProject+'&location='+geoLocation; |
35 | | - bannerListURL = wgArticlePath.replace( '$1', bannerListPage ); |
36 | | - } |
37 | | - var request = $.ajax( { |
38 | | - url: bannerListURL, |
39 | | - dataType: 'json', |
40 | | - success: $.centralNotice.fn.chooseBanner |
41 | | - } ); |
42 | | - }, |
43 | | - 'chooseBanner': function( bannerList ) { |
44 | | - // convert the json object to a true array |
45 | | - bannerList = Array.prototype.slice.call( bannerList ); |
46 | | - |
47 | | - // Make sure there are some banners to choose from |
48 | | - if ( bannerList.length == 0 ) return false; |
49 | | - |
50 | | - var totalWeight = 0; |
51 | | - // run through the bannerlist and sum the weights of all banners |
52 | | - for( var i = 0; i < bannerList.length; i++ ) { |
53 | | - totalWeight += bannerList[i].weight; |
54 | | - } |
55 | | - |
56 | | - // select a random integer between 0 and our total weight |
57 | | - var pointer = Math.floor( Math.random() * totalWeight ), |
58 | | - selectedBanner = bannerList[0], |
59 | | - w = 0; |
60 | | - // run through the banner list and start accumulating weights |
61 | | - for( var i = 0; i < bannerList.length; i++ ) { |
62 | | - w += bannerList[i].weight; |
63 | | - // when the weight tally exceeds the random integer, return the banner and stop the loop |
64 | | - if( w > pointer ) { |
65 | | - selectedBanner = bannerList[i]; |
66 | | - break; |
67 | | - } |
68 | | - } |
69 | | - // return our selected banner |
70 | | - $.centralNotice.fn.loadBanner( |
71 | | - selectedBanner.name |
72 | | - ); |
73 | | - }, |
74 | | - 'displayBanner': function( bannerHTML ) { |
75 | | - // inject the banner html into the page |
76 | | - $( '#siteNotice' ) |
77 | | - .prepend( '<div id="centralnotice" class="' + ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) + '">' + bannerHTML + '</div>' ); |
78 | | - }, |
79 | | - 'getQueryStringVariables': function() { |
80 | | - document.location.search.replace( /\??(?:([^=]+)=([^&]*)&?)/g, function () { |
81 | | - function decode( s ) { |
82 | | - return decodeURIComponent( s.split( "+" ).join( " " ) ); |
83 | | - } |
84 | | - $.centralNotice.data.getVars[decode( arguments[1] )] = decode( arguments[2] ); |
85 | | - } ); |
86 | | - } |
87 | | - } |
88 | | - } |
89 | | - $( document ).ready( function () { |
90 | | - // initialize the query string vars |
91 | | - $.centralNotice.fn.getQueryStringVariables(); |
92 | | - if( $.centralNotice.data.getVars['forceBanner'] ) { |
93 | | - // if we're forcing one banner |
94 | | - $.centralNotice.fn.loadBanner( $.centralNotice.data.getVars['forceBanner'] ); |
95 | | - } else if ( $.centralNotice.data.getVars['forceTimestamp'] ) { |
96 | | - // if we're forcing a future campaign time |
97 | | - $.centralNotice.fn.loadBannerList( $.centralNotice.data.getVars['forceTimestamp'] ); |
98 | | - } else { |
99 | | - // look for banners ready to go NOW |
100 | | - $.centralNotice.fn.loadBannerList( ); |
101 | | - } |
102 | | - } ); //document ready |
103 | | -} )( jQuery ); |
Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -133,6 +133,8 @@ |
134 | 134 | $base . '/patches/patch-template_settings.sql' ); |
135 | 135 | $wgExtNewTables[] = array( 'cn_notice_countries', |
136 | 136 | $base . '/patches/patch-notice_countries.sql' ); |
| 137 | + $wgExtNewTables[] = array( 'cn_notice_projects', |
| 138 | + $base . '/patches/patch-notice_projects.sql' ); |
137 | 139 | } |
138 | 140 | } else { |
139 | 141 | if ( $updater->getDB()->getType() == 'mysql' ) { |
— | — | @@ -146,6 +148,8 @@ |
147 | 149 | $base . '/patches/patch-template_settings.sql' ) ); |
148 | 150 | $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_countries', |
149 | 151 | $base . '/patches/patch-notice_countries.sql' ) ); |
| 152 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_projects', |
| 153 | + $base . '/patches/patch-notice_projects.sql' ) ); |
150 | 154 | } |
151 | 155 | } |
152 | 156 | return true; |
Index: trunk/extensions/CentralNotice/patches/patch-notice_languages.sql |
— | — | @@ -1,4 +1,4 @@ |
| 2 | +-- Update to allow for any number of languages per campaign. |
2 | 3 | |
3 | 4 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_notice_languages ( |
4 | 5 | `nl_notice_id` int unsigned NOT NULL, |
Index: trunk/extensions/CentralNotice/patches/patch-notice_projects.sql |
— | — | @@ -0,0 +1,7 @@ |
| 2 | +-- Update to allow for any number of projects per campaign. |
| 3 | + |
| 4 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_notice_projects ( |
| 5 | + `np_notice_id` int unsigned NOT NULL, |
| 6 | + `np_project` varchar(32) NOT NULL |
| 7 | +) /*$wgDBTableOptions*/; |
| 8 | +CREATE UNIQUE INDEX /*i*/np_notice_id_project ON /*$wgDBprefix*/cn_notice_projects (np_notice_id, np_project); |