Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerLoader.php |
— | — | @@ -53,7 +53,8 @@ |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Generate the JS for the requested banner |
57 | | - * @return a string of Javascript containing a call to insertBanner() with JSON containing the banner content as the parameter |
| 57 | + * @return a string of Javascript containing a call to insertBanner() |
| 58 | + * with JSON containing the banner content as the parameter |
58 | 59 | */ |
59 | 60 | function getJsNotice( $bannerName ) { |
60 | 61 | // Make sure the banner exists |
— | — | @@ -161,16 +162,18 @@ |
162 | 163 | wfRestoreWarnings(); |
163 | 164 | if ( !$count ) { |
164 | 165 | // Pull long-cached amount |
165 | | - $count = intval( $wgMemc->get( wfMemcKey( 'centralnotice', 'counter', 'fallback' ) ) ); |
| 166 | + $count = intval( $wgMemc->get( |
| 167 | + wfMemcKey( 'centralnotice', 'counter', 'fallback' ) ) ); |
166 | 168 | if ( !$count ) { |
167 | 169 | // Return hard-coded amount if all else fails |
168 | 170 | return 1100000; // Update as needed during fundraiser |
169 | 171 | } |
170 | 172 | } |
171 | | - $wgMemc->set( wfMemcKey( 'centralnotice', 'counter' ), $count, 60 ); // Expire in 60 seconds |
172 | | - $wgMemc->set( wfMemcKey( 'centralnotice', 'counter', 'fallback' ), $count ); // No expiration |
| 173 | + // Expire in 60 seconds |
| 174 | + $wgMemc->set( wfMemcKey( 'centralnotice', 'counter' ), $count, 60 ); |
| 175 | + // No expiration |
| 176 | + $wgMemc->set( wfMemcKey( 'centralnotice', 'counter', 'fallback' ), $count ); |
173 | 177 | } |
174 | 178 | return $count; |
175 | 179 | } |
176 | | - |
177 | 180 | } |
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerController.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | global $wgCentralPagePath; |
47 | 47 | |
48 | 48 | $js = $this->getScriptFunctions() . $this->getToggleScripts(); |
49 | | - $js .= <<<EOT |
| 49 | + $js .= <<<JAVASCRIPT |
50 | 50 | ( function( $ ) { |
51 | 51 | $.ajaxSetup({ cache: true }); |
52 | 52 | $.centralNotice = { |
— | — | @@ -55,12 +55,18 @@ |
56 | 56 | 'fn': { |
57 | 57 | 'loadBanner': function( bannerName ) { |
58 | 58 | // Get the requested banner |
59 | | - var bannerPageQuery = $.param( { 'banner': bannerName, 'userlang': wgUserLanguage, 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country } ); |
| 59 | + var bannerPageQuery = $.param( { |
| 60 | + 'banner': bannerName, 'userlang': wgUserLanguage, |
| 61 | + 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country } ); |
60 | 62 | var bannerPage = '?title=Special:BannerLoader&' + bannerPageQuery; |
61 | | -EOT; |
62 | | - $js .= "\n\t\t\t\tvar bannerScript = '<script type=\"text/javascript\" src=\"".Xml::escapeJsString( $wgCentralPagePath )."' + bannerPage + '\"></script>';\n"; |
63 | | - $js .= <<<EOT |
64 | | - $( '#siteNotice' ).prepend( '<div id="centralNotice" class="' + ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) + '">'+bannerScript+'</div>' ); |
| 63 | +JAVASCRIPT; |
| 64 | + $js .= "\n\t\t\t\tvar bannerScript = '<script type=\"text/javascript\" src=\"" . |
| 65 | + Xml::escapeJsString( $wgCentralPagePath ) . |
| 66 | + "' + bannerPage + '\"></script>';\n"; |
| 67 | + $js .= <<<JAVASCRIPT |
| 68 | + $( '#siteNotice' ).prepend( '<div id="centralNotice" class="' + |
| 69 | + ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) + |
| 70 | + '">'+bannerScript+'</div>' ); |
65 | 71 | }, |
66 | 72 | 'loadBannerList': function( geoOverride ) { |
67 | 73 | if ( geoOverride ) { |
— | — | @@ -87,7 +93,9 @@ |
88 | 94 | |
89 | 95 | for( var i = 0; i < bannerList.length; i++ ) { |
90 | 96 | // Only include this banner if it's inteded for the current user |
91 | | - if( ( wgUserName && bannerList[i].display_account ) || ( !wgUserName && bannerList[i].display_anon == 1 ) ) { |
| 97 | + if( ( wgUserName && bannerList[i].display_account ) || |
| 98 | + ( !wgUserName && bannerList[i].display_anon == 1 ) ) |
| 99 | + { |
92 | 100 | // add the banner to our list once per weight |
93 | 101 | for( var j=0; j < bannerList[i].weight; j++ ) { |
94 | 102 | groomedBannerList.push( bannerList[i] ); |
— | — | @@ -100,7 +108,9 @@ |
101 | 109 | |
102 | 110 | // Load a random banner from our groomed list |
103 | 111 | $.centralNotice.fn.loadBanner( |
104 | | - groomedBannerList[ Math.floor( Math.random() * groomedBannerList.length ) ].name |
| 112 | + groomedBannerList[ |
| 113 | + Math.floor( Math.random() * groomedBannerList.length ) |
| 114 | + ].name |
105 | 115 | ); |
106 | 116 | }, |
107 | 117 | 'getQueryStringVariables': function() { |
— | — | @@ -125,19 +135,19 @@ |
126 | 136 | } |
127 | 137 | } ); //document ready |
128 | 138 | } )( jQuery ); |
129 | | -EOT; |
| 139 | +JAVASCRIPT; |
130 | 140 | return $js; |
131 | 141 | |
132 | 142 | } |
133 | 143 | |
134 | 144 | function getToggleScripts() { |
135 | | - $showStyle = <<<END |
| 145 | + $showStyle = <<<HTML |
136 | 146 | <style type="text/css"> |
137 | 147 | #centralNotice .siteNoticeSmall {display:none;} |
138 | 148 | #centralNotice.collapsed .siteNoticeBig {display:none;} |
139 | 149 | #centralNotice.collapsed .siteNoticeSmall {display:block;} |
140 | 150 | </style> |
141 | | -END; |
| 151 | +HTML; |
142 | 152 | $encShowStyle = Xml::encodeJsVar( $showStyle ); |
143 | 153 | |
144 | 154 | $script = " |
— | — | @@ -147,7 +157,7 @@ |
148 | 158 | } |
149 | 159 | |
150 | 160 | function getScriptFunctions() { |
151 | | - $script = " |
| 161 | + $script = <<<JAVASCRIPT |
152 | 162 | function insertBanner(bannerJson) { |
153 | 163 | jQuery('div#centralNotice').prepend( bannerJson.banner ); |
154 | 164 | } |
— | — | @@ -172,7 +182,9 @@ |
173 | 183 | e.setTime( e.getTime() + (7*24*60*60*1000) ); // one week |
174 | 184 | var work='hidesnmessage='+state+'; expires=' + e.toGMTString() + '; path=/'; |
175 | 185 | document.cookie = work; |
176 | | -}\n\n"; |
| 186 | +} |
| 187 | + |
| 188 | +JAVASCRIPT; |
177 | 189 | return $script; |
178 | 190 | } |
179 | 191 | |
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerAllocation.php |
— | — | @@ -59,7 +59,9 @@ |
60 | 60 | |
61 | 61 | $htmlOut .= Xml::openElement( 'table', array ( 'id' => 'envpicker', 'cellpadding' => 7 ) ); |
62 | 62 | $htmlOut .= Xml::openElement( 'tr' ); |
63 | | - $htmlOut .= Xml::tags( 'td', array( 'style' => 'width: 20%;' ), wfMsg( 'centralnotice-project-name' ) ); |
| 63 | + $htmlOut .= Xml::tags( 'td', |
| 64 | + array( 'style' => 'width: 20%;' ), |
| 65 | + wfMsg( 'centralnotice-project-name' ) ); |
64 | 66 | $htmlOut .= Xml::openElement( 'td' ); |
65 | 67 | $htmlOut .= Xml::openElement( 'select', array( 'name' => 'project' ) ); |
66 | 68 | foreach ( $wgNoticeProjects as $value ) { |
— | — | @@ -69,9 +71,12 @@ |
70 | 72 | $htmlOut .= Xml::closeElement( 'td' ); |
71 | 73 | $htmlOut .= Xml::closeElement( 'tr' ); |
72 | 74 | $htmlOut .= Xml::openElement( 'tr' ); |
73 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsg( 'centralnotice-project-language' ) ); |
| 75 | + $htmlOut .= Xml::tags( 'td', |
| 76 | + array( 'valign' => 'top' ), |
| 77 | + wfMsg( 'centralnotice-project-language' ) ); |
74 | 78 | $htmlOut .= Xml::openElement( 'td' ); |
75 | | - // Make sure the site language is in the list; a custom language code might not have a defined name... |
| 79 | + // Make sure the site language is in the list; a custom language code |
| 80 | + // might not have a defined name... |
76 | 81 | $languages = Language::getLanguageNames( true ); |
77 | 82 | if( !array_key_exists( $wgLanguageCode, $languages ) ) { |
78 | 83 | $languages[$wgLanguageCode] = $wgLanguageCode; |
— | — | @@ -79,7 +84,9 @@ |
80 | 85 | ksort( $languages ); |
81 | 86 | $htmlOut .= Xml::openElement( 'select', array( 'name' => 'language' ) ); |
82 | 87 | foreach( $languages as $code => $name ) { |
83 | | - $htmlOut .= Xml::option( wfMsg( 'centralnotice-language-listing', $code, $name ), $code, $code === $this->language ); |
| 88 | + $htmlOut .= Xml::option( |
| 89 | + wfMsg( 'centralnotice-language-listing', $code, $name ), |
| 90 | + $code, $code === $this->language ); |
84 | 91 | } |
85 | 92 | $htmlOut .= Xml::closeElement( 'select' ); |
86 | 93 | $htmlOut .= Xml::closeElement( 'td' ); |
— | — | @@ -153,10 +160,13 @@ |
154 | 161 | $totalWeight += $banner['weight']; |
155 | 162 | } |
156 | 163 | if ( $banners ) { |
157 | | - $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9, 'class' => 'wikitable sortable' ) ); |
| 164 | + $htmlOut .= Xml::openElement( 'table', |
| 165 | + array ( 'cellpadding' => 9, 'class' => 'wikitable sortable' ) ); |
158 | 166 | $htmlOut .= Xml::openElement( 'tr' ); |
159 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), wfMsg ( 'centralnotice-percentage' ) ); |
160 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '60%' ), wfMsg ( 'centralnotice-banner' ) ); |
| 167 | + $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), |
| 168 | + wfMsg ( 'centralnotice-percentage' ) ); |
| 169 | + $htmlOut .= Xml::element( 'th', array( 'width' => '60%' ), |
| 170 | + wfMsg ( 'centralnotice-banner' ) ); |
161 | 171 | $htmlOut .= Xml::closeElement( 'tr' ); |
162 | 172 | foreach ( $banners as $banner ) { |
163 | 173 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -165,7 +175,8 @@ |
166 | 176 | $htmlOut .= wfMsg ( 'percent', $wgLang->formatNum( $percentage ) ); |
167 | 177 | $htmlOut .= Xml::closeElement( 'td' ); |
168 | 178 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
169 | | - $sk->makeLinkObj( $viewPage, htmlspecialchars( $banner['name'] ), 'template=' . urlencode( $banner['name'] ) ) |
| 179 | + $sk->makeLinkObj( $viewPage, htmlspecialchars( $banner['name'] ), |
| 180 | + 'template=' . urlencode( $banner['name'] ) ) |
170 | 181 | ); |
171 | 182 | $htmlOut .= Xml::closeElement( 'tr' ); |
172 | 183 | } |
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -146,7 +146,8 @@ |
147 | 147 | $newTemplate = $wgRequest->getVal( 'newTemplate' ); |
148 | 148 | // We use the returned name in case any special characters had to be removed |
149 | 149 | $template = $this->cloneTemplate( $oldTemplate, $newTemplate ); |
150 | | - $wgOut->redirect( $this->getTitle( 'view' )->getLocalUrl( "template=$template" ) ); |
| 150 | + $wgOut->redirect( |
| 151 | + $this->getTitle( 'view' )->getLocalUrl( "template=$template" ) ); |
151 | 152 | return; |
152 | 153 | |
153 | 154 | } else { |
— | — | @@ -188,9 +189,11 @@ |
189 | 190 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-manage-templates' ) ); |
190 | 191 | |
191 | 192 | // Show paginated list of banners |
192 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 193 | + $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), |
| 194 | + $pager->getNavigationBar() ); |
193 | 195 | $htmlOut .= $pager->getBody(); |
194 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 196 | + $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), |
| 197 | + $pager->getNavigationBar() ); |
195 | 198 | |
196 | 199 | if ( $this->editable ) { |
197 | 200 | $htmlOut .= Xml::closeElement( 'form' ); |
— | — | @@ -219,40 +222,53 @@ |
220 | 223 | // Build HTML |
221 | 224 | $htmlOut = ''; |
222 | 225 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
223 | | - $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) ); |
| 226 | + $htmlOut .= Xml::openElement( 'form', |
| 227 | + array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) ); |
224 | 228 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-add-template' ) ); |
225 | 229 | $htmlOut .= Xml::hidden( 'wpMethod', 'addTemplate' ); |
226 | 230 | $htmlOut .= Xml::tags( 'p', null, |
227 | | - Xml::inputLabel( wfMsg( 'centralnotice-banner-name' ), 'templateName', 'templateName', 25, $wgRequest->getVal( 'templateName' ) ) |
| 231 | + Xml::inputLabel( |
| 232 | + wfMsg( 'centralnotice-banner-name' ), |
| 233 | + 'templateName', 'templateName', 25, $wgRequest->getVal( 'templateName' ) |
| 234 | + ) |
228 | 235 | ); |
229 | 236 | |
230 | 237 | $htmlOut .= Xml::openElement( 'p', null ); |
231 | 238 | $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
232 | 239 | if ( $wgRequest->wasPosted() ) { |
233 | | - $displayAnon = $wgRequest->getCheck( 'displayAnon' ); // Restore checkbox state in event of error |
| 240 | + // Restore checkbox state in event of error |
| 241 | + $displayAnon = $wgRequest->getCheck( 'displayAnon' ); |
234 | 242 | } else { |
235 | | - $displayAnon = true; // Default is checked |
| 243 | + // Default is checked |
| 244 | + $displayAnon = true; |
236 | 245 | } |
237 | 246 | $htmlOut .= Xml::check( 'displayAnon', $displayAnon, array( 'id' => 'displayAnon' ) ); |
238 | 247 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
239 | 248 | if ( $wgRequest->wasPosted() ) { |
240 | | - $displayAccount = $wgRequest->getCheck( 'displayAccount' ); // Restore checkbox state in event of error |
| 249 | + // Restore checkbox state in event of error |
| 250 | + $displayAccount = $wgRequest->getCheck( 'displayAccount' ); |
241 | 251 | } else { |
242 | | - $displayAccount = true; // Default is checked |
| 252 | + // Default is checked |
| 253 | + $displayAccount = true; |
243 | 254 | } |
244 | | - $htmlOut .= Xml::check( 'displayAccount', $displayAccount, array( 'id' => 'displayAccount' ) ); |
| 255 | + $htmlOut .= Xml::check( 'displayAccount', $displayAccount, |
| 256 | + array( 'id' => 'displayAccount' ) ); |
245 | 257 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
246 | 258 | $htmlOut .= Xml::closeElement( 'p' ); |
247 | 259 | |
248 | 260 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) ); |
249 | 261 | $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
250 | 262 | $buttons = array(); |
251 | | - $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . wfMsg( 'centralnotice-close-button' ) . '</a>'; |
252 | | - $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
253 | | - $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
| 263 | + $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . |
| 264 | + wfMsg( 'centralnotice-close-button' ) . '</a>'; |
| 265 | + $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . |
| 266 | + wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
| 267 | + $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . |
| 268 | + wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
254 | 269 | $htmlOut .= Xml::tags( 'div', |
255 | 270 | array( 'style' => 'margin-bottom: 0.2em;' ), |
256 | | - '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
| 271 | + '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . |
| 272 | + wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
257 | 273 | ); |
258 | 274 | |
259 | 275 | // Restore banner body state in the event of an error on form submit |
— | — | @@ -319,14 +335,16 @@ |
320 | 336 | // Begin View Banner fieldset |
321 | 337 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
322 | 338 | |
323 | | - $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-banner-heading', $currentTemplate ) ); |
| 339 | + $htmlOut .= Xml::element( 'h2', null, |
| 340 | + wfMsg( 'centralnotice-banner-heading', $currentTemplate ) ); |
324 | 341 | |
325 | 342 | // Show preview of banner |
326 | 343 | $render = new SpecialBannerLoader(); |
327 | 344 | $render->siteName = 'Wikipedia'; |
328 | 345 | $render->language = $wpUserLang; |
329 | 346 | if ( $render->language != '' ) { |
330 | | - $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-preview' ) . " ($render->language)", |
| 347 | + $htmlOut .= Xml::fieldset( |
| 348 | + wfMsg( 'centralnotice-preview' ) . " ($render->language)", |
331 | 349 | $render->getHtmlNotice( $wgRequest->getText( 'template' ) ) |
332 | 350 | ); |
333 | 351 | } else { |
— | — | @@ -336,7 +354,8 @@ |
337 | 355 | } |
338 | 356 | |
339 | 357 | // Pull banner text and respect any inc: markup |
340 | | - $bodyPage = Title::newFromText( "Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI ); |
| 358 | + $bodyPage = Title::newFromText( |
| 359 | + "Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI ); |
341 | 360 | $curRev = Revision::newFromTitle( $bodyPage ); |
342 | 361 | $body = $curRev ? $curRev->getText() : ''; |
343 | 362 | |
— | — | @@ -363,22 +382,29 @@ |
364 | 383 | ); |
365 | 384 | |
366 | 385 | // Table headers |
367 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '15%' ), wfMsg( 'centralnotice-message' ) ); |
368 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '5%' ), wfMsg ( 'centralnotice-number-uses' ) ); |
369 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), wfMsg ( 'centralnotice-english' ) ); |
| 386 | + $htmlOut .= Xml::element( 'th', array( 'width' => '15%' ), |
| 387 | + wfMsg( 'centralnotice-message' ) ); |
| 388 | + $htmlOut .= Xml::element( 'th', array( 'width' => '5%' ), |
| 389 | + wfMsg ( 'centralnotice-number-uses' ) ); |
| 390 | + $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), |
| 391 | + wfMsg ( 'centralnotice-english' ) ); |
370 | 392 | $languages = Language::getLanguageNames(); |
371 | | - $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), $languages[$wpUserLang] ); |
| 393 | + $htmlOut .= Xml::element( 'th', array( 'width' => '40%' ), |
| 394 | + $languages[$wpUserLang] ); |
372 | 395 | |
373 | 396 | // Remove duplicate message fields |
374 | 397 | $filteredFields = array(); |
375 | 398 | foreach ( $fields[1] as $field ) { |
376 | | - $filteredFields[$field] = array_key_exists( $field, $filteredFields ) ? $filteredFields[$field] + 1 : 1; |
| 399 | + $filteredFields[$field] = array_key_exists( $field, $filteredFields ) |
| 400 | + ? $filteredFields[$field] + 1 : 1; |
377 | 401 | } |
378 | 402 | |
379 | 403 | // Table rows |
380 | 404 | foreach ( $filteredFields as $field => $count ) { |
381 | 405 | // Message |
382 | | - $message = ( $wpUserLang == 'en' ) ? "Centralnotice-{$currentTemplate}-{$field}" : "Centralnotice-{$currentTemplate}-{$field}/{$wpUserLang}"; |
| 406 | + $message = ( $wpUserLang == 'en' ) |
| 407 | + ? "Centralnotice-{$currentTemplate}-{$field}" |
| 408 | + : "Centralnotice-{$currentTemplate}-{$field}/{$wpUserLang}"; |
383 | 409 | |
384 | 410 | // English value |
385 | 411 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -393,7 +419,11 @@ |
394 | 420 | // English text |
395 | 421 | $englishText = wfMsg( 'centralnotice-message-not-set' ); |
396 | 422 | $englishTextExists = false; |
397 | | - if ( Title::newFromText( "Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI )->exists() ) { |
| 423 | + if ( |
| 424 | + Title::newFromText( |
| 425 | + "Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI |
| 426 | + )->exists() ) |
| 427 | + { |
398 | 428 | $englishText = wfMsgExt( "Centralnotice-{$currentTemplate}-{$field}", |
399 | 429 | array( 'language' => 'en' ) |
400 | 430 | ); |
— | — | @@ -401,7 +431,10 @@ |
402 | 432 | } |
403 | 433 | $htmlOut .= Xml::tags( 'td', null, |
404 | 434 | Xml::element( 'span', |
405 | | - array( 'style' => 'font-style:italic;' . ( !$englishTextExists ? 'color:silver' : '' ) ), |
| 435 | + array( |
| 436 | + 'style' => 'font-style:italic;' . |
| 437 | + ( !$englishTextExists ? 'color:silver' : '' ) |
| 438 | + ), |
406 | 439 | $englishText |
407 | 440 | ) |
408 | 441 | ); |
— | — | @@ -416,9 +449,13 @@ |
417 | 450 | $foreignTextExists = true; |
418 | 451 | } |
419 | 452 | $htmlOut .= Xml::tags( 'td', null, |
420 | | - Xml::input( "updateText[{$wpUserLang}][{$currentTemplate}-{$field}]", '', $foreignText, |
| 453 | + Xml::input( |
| 454 | + "updateText[{$wpUserLang}][{$currentTemplate}-{$field}]", |
| 455 | + '', |
| 456 | + $foreignText, |
421 | 457 | wfArrayMerge( $readonly, |
422 | | - array( 'style' => 'width:100%;' . ( !$foreignTextExists ? 'color:red' : '' ) ) ) |
| 458 | + array( 'style' => 'width:100%;' . |
| 459 | + ( !$foreignTextExists ? 'color:red' : '' ) ) ) |
423 | 460 | ) |
424 | 461 | ); |
425 | 462 | $htmlOut .= Xml::closeElement( 'tr' ); |
— | — | @@ -430,7 +467,10 @@ |
431 | 468 | $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); |
432 | 469 | $htmlOut .= Xml::tags( 'div', |
433 | 470 | array( 'class' => 'cn-buttons' ), |
434 | | - Xml::submitButton( wfMsg( 'centralnotice-modify' ), array( 'name' => 'update' ) ) |
| 471 | + Xml::submitButton( |
| 472 | + wfMsg( 'centralnotice-modify' ), |
| 473 | + array( 'name' => 'update' ) |
| 474 | + ) |
435 | 475 | ); |
436 | 476 | } |
437 | 477 | |
— | — | @@ -457,7 +497,12 @@ |
458 | 498 | ); |
459 | 499 | $htmlOut .= Xml::tags( 'tr', null, |
460 | 500 | Xml::tags( 'td', null, '' ) . |
461 | | - Xml::tags( 'td', null, $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-preview-all-template-translations' ), "template=$currentTemplate&wpUserLanguage=all" ) ) |
| 501 | + Xml::tags( 'td', null, |
| 502 | + $sk->makeLinkObj( |
| 503 | + $newPage, |
| 504 | + wfMsgHtml( 'centralnotice-preview-all-template-translations' ), |
| 505 | + "template=$currentTemplate&wpUserLanguage=all" ) |
| 506 | + ) |
462 | 507 | ); |
463 | 508 | $htmlOut .= Xml::closeElement( 'table' ); |
464 | 509 | $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); |
— | — | @@ -467,7 +512,12 @@ |
468 | 513 | |
469 | 514 | // Show edit form |
470 | 515 | if ( $this->editable ) { |
471 | | - $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) ); |
| 516 | + $htmlOut .= Xml::openElement( 'form', |
| 517 | + array( |
| 518 | + 'method' => 'post', |
| 519 | + 'onsubmit' => 'return validateBannerForm(this)' |
| 520 | + ) |
| 521 | + ); |
472 | 522 | $htmlOut .= Xml::hidden( 'wpMethod', 'editTemplate' ); |
473 | 523 | } |
474 | 524 | |
— | — | @@ -485,9 +535,11 @@ |
486 | 536 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-settings' ) ); |
487 | 537 | $htmlOut .= Xml::openElement( 'p', null ); |
488 | 538 | $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
489 | | - $htmlOut .= Xml::check( 'displayAnon', $displayAnon, wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) ); |
| 539 | + $htmlOut .= Xml::check( 'displayAnon', $displayAnon, |
| 540 | + wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) ); |
490 | 541 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
491 | | - $htmlOut .= Xml::check( 'displayAccount', $displayAccount, wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) ); |
| 542 | + $htmlOut .= Xml::check( 'displayAccount', $displayAccount, |
| 543 | + wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) ); |
492 | 544 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
493 | 545 | $htmlOut .= Xml::closeElement( 'p' ); |
494 | 546 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
— | — | @@ -495,12 +547,17 @@ |
496 | 548 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-edit-template' ) ); |
497 | 549 | $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
498 | 550 | $buttons = array(); |
499 | | - $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . wfMsg( 'centralnotice-close-button' ) . '</a>'; |
500 | | - $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
501 | | - $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
| 551 | + $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . |
| 552 | + wfMsg( 'centralnotice-close-button' ) . '</a>'; |
| 553 | + $buttons[] = '<a href="#" onclick="insertButton(\'hide\');return false;">' . |
| 554 | + wfMsg( 'centralnotice-hide-button' ) . '</a>'; |
| 555 | + $buttons[] = '<a href="#" onclick="insertButton(\'translate\');return false;">' . |
| 556 | + wfMsg( 'centralnotice-translate-button' ) . '</a>'; |
502 | 557 | $htmlOut .= Xml::tags( 'div', |
503 | 558 | array( 'style' => 'margin-bottom: 0.2em;' ), |
504 | | - '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
| 559 | + '<img src="' . $scriptPath . '/down-arrow.png" ' . |
| 560 | + 'style="vertical-align:baseline;"/>' . |
| 561 | + wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) ) |
505 | 562 | ); |
506 | 563 | } else { |
507 | 564 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) ); |
— | — | @@ -508,8 +565,9 @@ |
509 | 566 | $htmlOut .= Xml::textarea( 'templateBody', $body, 60, 20, $readonly ); |
510 | 567 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
511 | 568 | if ( $this->editable ) { |
512 | | - $htmlOut .= Xml::hidden( 'mainform', 'true' ); // Indicate which form was submitted |
513 | | - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); |
| 569 | + // Indicate which form was submitted |
| 570 | + $htmlOut .= Html::hidden( 'mainform', 'true' ); |
| 571 | + $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
514 | 572 | $htmlOut .= Xml::tags( 'div', |
515 | 573 | array( 'class' => 'cn-buttons' ), |
516 | 574 | Xml::submitButton( wfMsg( 'centralnotice-save-banner' ) ) |
— | — | @@ -529,8 +587,12 @@ |
530 | 588 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-clone-notice' ) ); |
531 | 589 | $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) ); |
532 | 590 | $htmlOut .= Xml::openElement( 'tr' ); |
533 | | - $htmlOut .= Xml::inputLabel( wfMsg( 'centralnotice-clone-name' ), 'newTemplate', 'newTemplate', '25' ); |
534 | | - $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-clone' ), array ( 'id' => 'clone' ) ); |
| 591 | + $htmlOut .= Xml::inputLabel( |
| 592 | + wfMsg( 'centralnotice-clone-name' ), |
| 593 | + 'newTemplate', 'newTemplate', '25' ); |
| 594 | + $htmlOut .= Xml::submitButton( |
| 595 | + wfMsg( 'centralnotice-clone' ), |
| 596 | + array ( 'id' => 'clone' ) ); |
535 | 597 | $htmlOut .= Xml::hidden( 'oldTemplate', $currentTemplate ); |
536 | 598 | |
537 | 599 | $htmlOut .= Xml::closeElement( 'tr' ); |
— | — | @@ -783,8 +845,9 @@ |
784 | 846 | // Remove duplicates |
785 | 847 | $filteredFields = array(); |
786 | 848 | foreach ( $fields[1] as $field ) { |
787 | | - $filteredFields[$field] = array_key_exists( $field, $filteredFields ) ? $filteredFields[$field] + 1 : |
788 | | - 1; |
| 849 | + $filteredFields[$field] = array_key_exists( $field, $filteredFields ) |
| 850 | + ? $filteredFields[$field] + 1 |
| 851 | + : 1; |
789 | 852 | } |
790 | 853 | return $filteredFields; |
791 | 854 | } |
— | — | @@ -807,7 +870,9 @@ |
808 | 871 | // Iterate through all possible message fields |
809 | 872 | foreach ( $fields as $field => $count ) { |
810 | 873 | // Put all message fields together for a lookup |
811 | | - $message = ( $lang == 'en' ) ? "Centralnotice-{$template}-{$field}" : "Centralnotice-{$template}-{$field}/{$lang}"; |
| 874 | + $message = ( $lang == 'en' ) |
| 875 | + ? "Centralnotice-{$template}-{$field}" |
| 876 | + : "Centralnotice-{$template}-{$field}/{$lang}"; |
812 | 877 | if ( Title::newFromText( $message, NS_MEDIAWIKI )->exists() ) { |
813 | 878 | $translations[$lang][$field] = wfMsgExt( |
814 | 879 | "Centralnotice-{$template}-{$field}", |
— | — | @@ -828,7 +893,8 @@ |
829 | 894 | public static function templateExists( $templateName ) { |
830 | 895 | $dbr = wfGetDB( DB_SLAVE ); |
831 | 896 | $eTemplateName = htmlspecialchars( $templateName ); |
832 | | - $row = $dbr->selectRow( 'cn_templates', 'tmp_name', array( 'tmp_name' => $eTemplateName ) ); |
| 897 | + $row = $dbr->selectRow( 'cn_templates', 'tmp_name', |
| 898 | + array( 'tmp_name' => $eTemplateName ) ); |
833 | 899 | if ( $row ) { |
834 | 900 | return true; |
835 | 901 | } else { |
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerListLoader.php |
— | — | @@ -72,7 +72,8 @@ |
73 | 73 | |
74 | 74 | if ( !$templates && $this->project == 'wikipedia' ) { |
75 | 75 | // See if we have any preferred notices for this language wikipedia |
76 | | - $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, false, 1, 1, $this->location ); |
| 76 | + $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, |
| 77 | + false, 1, 1, $this->location ); |
77 | 78 | |
78 | 79 | if ( $notices ) { |
79 | 80 | // Pull banners |
— | — | @@ -82,7 +83,8 @@ |
83 | 84 | |
84 | 85 | // Didn't find any preferred matches so do an old style lookup |
85 | 86 | if ( !$templates ) { |
86 | | - $templates = CentralNotice::selectNoticeTemplates( $this->project, $this->language, $this->location ); |
| 87 | + $templates = CentralNotice::selectNoticeTemplates( |
| 88 | + $this->project, $this->language, $this->location ); |
87 | 89 | } |
88 | 90 | |
89 | 91 | return FormatJson::encode( $templates ); |
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -122,19 +122,29 @@ |
123 | 123 | global $wgDBtype, $wgExtNewTables, $wgExtNewFields; |
124 | 124 | |
125 | 125 | if ( $wgDBtype == 'mysql' ) { |
126 | | - $wgExtNewTables[] = array( 'cn_notices', $base . '/CentralNotice.sql' ); |
127 | | - $wgExtNewFields[] = array( 'cn_notices', 'not_preferred', $base . '/patches/patch-notice_preferred.sql' ); |
128 | | - $wgExtNewTables[] = array( 'cn_notice_languages', $base . '/patches/patch-notice_languages.sql' ); |
129 | | - $wgExtNewFields[] = array( 'cn_templates', 'tmp_display_anon', $base . '/patches/patch-template_settings.sql' ); |
130 | | - $wgExtNewTables[] = array( 'cn_notice_countries', $base . '/patches/patch-notice_countries.sql' ); |
| 126 | + $wgExtNewTables[] = array( 'cn_notices', |
| 127 | + $base . '/CentralNotice.sql' ); |
| 128 | + $wgExtNewFields[] = array( 'cn_notices', 'not_preferred', |
| 129 | + $base . '/patches/patch-notice_preferred.sql' ); |
| 130 | + $wgExtNewTables[] = array( 'cn_notice_languages', |
| 131 | + $base . '/patches/patch-notice_languages.sql' ); |
| 132 | + $wgExtNewFields[] = array( 'cn_templates', 'tmp_display_anon', |
| 133 | + $base . '/patches/patch-template_settings.sql' ); |
| 134 | + $wgExtNewTables[] = array( 'cn_notice_countries', |
| 135 | + $base . '/patches/patch-notice_countries.sql' ); |
131 | 136 | } |
132 | 137 | } else { |
133 | 138 | if ( $updater->getDB()->getType() == 'mysql' ) { |
134 | | - $updater->addExtensionUpdate( array( 'addTable', 'cn_notices', $base . '/CentralNotice.sql' ) ); |
135 | | - $updater->addExtensionUpdate( array( 'addField', 'cn_notices', 'not_preferred', $base . '/patches/patch-notice_preferred.sql' ) ); |
136 | | - $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_languages', $base . '/patches/patch-notice_languages.sql' ) ); |
137 | | - $updater->addExtensionUpdate( array( 'addField', 'cn_templates', 'tmp_display_anon', $base . '/patches/patch-template_settings.sql' ) ); |
138 | | - $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_countries', $base . '/patches/patch-notice_countries.sql' ) ); |
| 139 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notices', |
| 140 | + $base . '/CentralNotice.sql' ) ); |
| 141 | + $updater->addExtensionUpdate( array( 'addField', 'cn_notices', 'not_preferred', |
| 142 | + $base . '/patches/patch-notice_preferred.sql' ) ); |
| 143 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_languages', |
| 144 | + $base . '/patches/patch-notice_languages.sql' ) ); |
| 145 | + $updater->addExtensionUpdate( array( 'addField', 'cn_templates', 'tmp_display_anon', |
| 146 | + $base . '/patches/patch-template_settings.sql' ) ); |
| 147 | + $updater->addExtensionUpdate( array( 'addTable', 'cn_notice_countries', |
| 148 | + $base . '/patches/patch-notice_countries.sql' ) ); |
139 | 149 | } |
140 | 150 | } |
141 | 151 | return true; |
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -147,7 +147,8 @@ |
148 | 148 | if ( $noticeName == '' ) { |
149 | 149 | $this->showError( 'centralnotice-null-string' ); |
150 | 150 | } else { |
151 | | - $this->addNotice( $noticeName, '0', $start, $project_name, $project_languages, $geotargeted, $geo_countries ); |
| 151 | + $this->addNotice( $noticeName, '0', $start, $project_name, |
| 152 | + $project_languages, $geotargeted, $geo_countries ); |
152 | 153 | } |
153 | 154 | } |
154 | 155 | |
— | — | @@ -419,7 +420,10 @@ |
420 | 421 | |
421 | 422 | // If campaign is currently active, set special class on table row. |
422 | 423 | $attribs = array(); |
423 | | - if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) && $row->not_enabled == '1' ) { |
| 424 | + if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) |
| 425 | + && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) |
| 426 | + && $row->not_enabled == '1' ) |
| 427 | + { |
424 | 428 | $attribs = array( 'class' => 'cn-active-campaign' ); |
425 | 429 | } |
426 | 430 | |
— | — | @@ -482,7 +486,8 @@ |
483 | 487 | // Name |
484 | 488 | $htmlOut .= Xml::openElement( 'tr' ); |
485 | 489 | $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-notice-name' ) ); |
486 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::input( 'noticeName', 25, $wgRequest->getVal( 'noticeName' ) ) ); |
| 490 | + $htmlOut .= Xml::tags( 'td', array(), |
| 491 | + Xml::input( 'noticeName', 25, $wgRequest->getVal( 'noticeName' ) ) ); |
487 | 492 | $htmlOut .= Xml::closeElement( 'tr' ); |
488 | 493 | // Start Date |
489 | 494 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -502,15 +507,21 @@ |
503 | 508 | // Languages |
504 | 509 | $htmlOut .= Xml::openElement( 'tr' ); |
505 | 510 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
506 | | - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
| 511 | + $htmlOut .= Xml::tags( 'td', array(), |
| 512 | + $this->languageMultiSelector( $noticeLanguages ) ); |
507 | 513 | $htmlOut .= Xml::closeElement( 'tr' ); |
508 | 514 | // Countries |
509 | 515 | $htmlOut .= Xml::openElement( 'tr' ); |
510 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
511 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'geotargeted', false, wfArrayMerge( $readonly, array( 'value' => 1, 'id' => 'geotargeted' ) ) ) ); |
| 516 | + $htmlOut .= Xml::tags( 'td', array(), |
| 517 | + Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
| 518 | + $htmlOut .= Xml::tags( 'td', array(), |
| 519 | + Xml::check( 'geotargeted', false, |
| 520 | + wfArrayMerge( $readonly, array( 'value' => 1, 'id' => 'geotargeted' ) ) ) ); |
512 | 521 | $htmlOut .= Xml::closeElement( 'tr' ); |
513 | | - $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
514 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'centralnotice-countries' ) ); |
| 522 | + $htmlOut .= Xml::openElement( 'tr', |
| 523 | + array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
| 524 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 525 | + wfMsgHtml( 'centralnotice-countries' ) ); |
515 | 526 | $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector() ); |
516 | 527 | $htmlOut .= Xml::closeElement( 'tr' ); |
517 | 528 | |
— | — | @@ -652,7 +663,8 @@ |
653 | 664 | |
654 | 665 | // If there were no errors, reload the page to prevent duplicate form submission |
655 | 666 | if ( !$this->centralNoticeError ) { |
656 | | - $wgOut->redirect( $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$notice" ) ); |
| 667 | + $wgOut->redirect( $this->getTitle()->getLocalUrl( |
| 668 | + "method=listNoticeDetail¬ice=$notice" ) ); |
657 | 669 | return; |
658 | 670 | } |
659 | 671 | } else { |
— | — | @@ -670,7 +682,8 @@ |
671 | 683 | $htmlOut .= Xml::openElement( 'form', |
672 | 684 | array( |
673 | 685 | 'method' => 'post', |
674 | | - 'action' => $this->getTitle()->getLocalUrl( "method=listNoticeDetail¬ice=$notice" ) |
| 686 | + 'action' => $this->getTitle()->getLocalUrl( |
| 687 | + "method=listNoticeDetail¬ice=$notice" ) |
675 | 688 | ) |
676 | 689 | ); |
677 | 690 | } |
— | — | @@ -821,41 +834,64 @@ |
822 | 835 | // Languages |
823 | 836 | $htmlOut .= Xml::openElement( 'tr' ); |
824 | 837 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
825 | | - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
| 838 | + $htmlOut .= Xml::tags( 'td', array(), |
| 839 | + $this->languageMultiSelector( $noticeLanguages ) ); |
826 | 840 | $htmlOut .= Xml::closeElement( 'tr' ); |
827 | 841 | // Countries |
828 | 842 | $htmlOut .= Xml::openElement( 'tr' ); |
829 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
830 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'geotargeted', $isGeotargeted, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'geotargeted' ) ) ) ); |
| 843 | + $htmlOut .= Xml::tags( 'td', array(), |
| 844 | + Xml::label( wfMsg( 'centralnotice-geotargeted' ), 'geotargeted' ) ); |
| 845 | + $htmlOut .= Xml::tags( 'td', array(), |
| 846 | + Xml::check( 'geotargeted', $isGeotargeted, |
| 847 | + wfArrayMerge( |
| 848 | + $readonly, |
| 849 | + array( 'value' => $row->not_name, 'id' => 'geotargeted' ) ) ) ); |
831 | 850 | $htmlOut .= Xml::closeElement( 'tr' ); |
832 | 851 | if ( $isGeotargeted ) { |
833 | 852 | $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector' ) ); |
834 | 853 | } else { |
835 | | - $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
| 854 | + $htmlOut .= Xml::openElement( 'tr', |
| 855 | + array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
836 | 856 | } |
837 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'centralnotice-countries' ) ); |
| 857 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 858 | + wfMsgHtml( 'centralnotice-countries' ) ); |
838 | 859 | $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector( $countries ) ); |
839 | 860 | $htmlOut .= Xml::closeElement( 'tr' ); |
840 | 861 | // Enabled |
841 | 862 | $htmlOut .= Xml::openElement( 'tr' ); |
842 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-enabled' ), 'enabled' ) ); |
843 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'enabled', $isEnabled, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'enabled' ) ) ) ); |
| 863 | + $htmlOut .= Xml::tags( 'td', array(), |
| 864 | + Xml::label( wfMsg( 'centralnotice-enabled' ), 'enabled' ) ); |
| 865 | + $htmlOut .= Xml::tags( 'td', array(), |
| 866 | + Xml::check( 'enabled', $isEnabled, |
| 867 | + wfArrayMerge( $readonly, |
| 868 | + array( 'value' => $row->not_name, 'id' => 'enabled' ) ) ) ); |
844 | 869 | $htmlOut .= Xml::closeElement( 'tr' ); |
845 | 870 | // Preferred |
846 | 871 | $htmlOut .= Xml::openElement( 'tr' ); |
847 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-preferred' ), 'preferred' ) ); |
848 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'preferred', $isPreferred, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'preferred' ) ) ) ); |
| 872 | + $htmlOut .= Xml::tags( 'td', array(), |
| 873 | + Xml::label( wfMsg( 'centralnotice-preferred' ), 'preferred' ) ); |
| 874 | + $htmlOut .= Xml::tags( 'td', array(), |
| 875 | + Xml::check( 'preferred', $isPreferred, |
| 876 | + wfArrayMerge( $readonly, |
| 877 | + array( 'value' => $row->not_name, 'id' => 'preferred' ) ) ) ); |
849 | 878 | $htmlOut .= Xml::closeElement( 'tr' ); |
850 | 879 | // Locked |
851 | 880 | $htmlOut .= Xml::openElement( 'tr' ); |
852 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-locked' ), 'locked' ) ); |
853 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'locked', $isLocked, wfArrayMerge( $readonly, array( 'value' => $row->not_name, 'id' => 'locked' ) ) ) ); |
| 881 | + $htmlOut .= Xml::tags( 'td', array(), |
| 882 | + Xml::label( wfMsg( 'centralnotice-locked' ), 'locked' ) ); |
| 883 | + $htmlOut .= Xml::tags( 'td', array(), |
| 884 | + Xml::check( 'locked', $isLocked, |
| 885 | + wfArrayMerge( $readonly, |
| 886 | + array( 'value' => $row->not_name, 'id' => 'locked' ) ) ) ); |
854 | 887 | $htmlOut .= Xml::closeElement( 'tr' ); |
855 | 888 | if ( $this->editable ) { |
856 | 889 | // Locked |
857 | 890 | $htmlOut .= Xml::openElement( 'tr' ); |
858 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::label( wfMsg( 'centralnotice-remove' ), 'remove' ) ); |
859 | | - $htmlOut .= Xml::tags( 'td', array(), Xml::check( 'remove', false, array( 'value' => $row->not_name, 'id' => 'remove' ) ) ); |
| 891 | + $htmlOut .= Xml::tags( 'td', array(), |
| 892 | + Xml::label( wfMsg( 'centralnotice-remove' ), 'remove' ) ); |
| 893 | + $htmlOut .= Xml::tags( 'td', array(), |
| 894 | + Xml::check( 'remove', false, |
| 895 | + array( 'value' => $row->not_name, 'id' => 'remove' ) ) ); |
860 | 896 | $htmlOut .= Xml::closeElement( 'tr' ); |
861 | 897 | } |
862 | 898 | $htmlOut .= Xml::closeElement( 'table' ); |
— | — | @@ -983,9 +1019,13 @@ |
984 | 1020 | $htmlOut = Xml::fieldset( wfMsg( "centralnotice-available-templates" ) ); |
985 | 1021 | |
986 | 1022 | // Show paginated list of banners |
987 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 1023 | + $htmlOut .= Xml::tags( 'div', |
| 1024 | + array( 'class' => 'cn-pager' ), |
| 1025 | + $pager->getNavigationBar() ); |
988 | 1026 | $htmlOut .= $pager->getBody(); |
989 | | - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ), $pager->getNavigationBar() ); |
| 1027 | + $htmlOut .= Xml::tags( 'div', |
| 1028 | + array( 'class' => 'cn-pager' ), |
| 1029 | + $pager->getNavigationBar() ); |
990 | 1030 | |
991 | 1031 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
992 | 1032 | } else { |
— | — | @@ -1075,7 +1115,9 @@ |
1076 | 1116 | return $templates; |
1077 | 1117 | } |
1078 | 1118 | |
1079 | | - function addNotice( $noticeName, $enabled, $start, $project_name, $project_languages, $geotargeted, $geo_countries ) { |
| 1119 | + function addNotice( $noticeName, $enabled, $start, $project_name, |
| 1120 | + $project_languages, $geotargeted, $geo_countries ) |
| 1121 | + { |
1080 | 1122 | global $wgOut; |
1081 | 1123 | |
1082 | 1124 | if ( $this->noticeExists( $noticeName ) ) { |
— | — | @@ -1096,12 +1138,17 @@ |
1097 | 1139 | $end['month'] = '10'; |
1098 | 1140 | $end['year'] = $start['year']; |
1099 | 1141 | } else { |
1100 | | - $end['month'] = ( substr( $start['month'], 0, 1 ) ) == 0 ? 0 . ( intval( $start['month'] ) + 1 ) : ( $start['month'] + 1 ); |
| 1142 | + $end['month'] = |
| 1143 | + ( substr( $start['month'], 0, 1 ) ) == 0 |
| 1144 | + ? 0 . ( intval( $start['month'] ) + 1 ) |
| 1145 | + : ( $start['month'] + 1 ); |
1101 | 1146 | $end['year'] = $start['year']; |
1102 | 1147 | } |
1103 | 1148 | |
1104 | | - $startTs = wfTimeStamp( TS_MW, "{$start['year']}:{$start['month']}:{$start['day']} {$start['hour']}:{$start['min']}:00" ); |
1105 | | - $endTs = wfTimeStamp( TS_MW, "{$end['year']}:{$end['month']}:{$start['day']} {$start['hour']}:{$start['min']}:00" ); |
| 1149 | + $startTs = wfTimeStamp( TS_MW, "{$start['year']}:{$start['month']}:{$start['day']} " . |
| 1150 | + "{$start['hour']}:{$start['min']}:00" ); |
| 1151 | + $endTs = wfTimeStamp( TS_MW, "{$end['year']}:{$end['month']}:{$start['day']} " . |
| 1152 | + "{$start['hour']}:{$start['min']}:00" ); |
1106 | 1153 | |
1107 | 1154 | $res = $dbw->insert( 'cn_notices', |
1108 | 1155 | array( 'not_name' => $noticeName, |
— | — | @@ -1119,7 +1166,8 @@ |
1120 | 1167 | foreach( $project_languages as $code ) { |
1121 | 1168 | $insertArray[] = array( 'nl_notice_id' => $not_id, 'nl_language' => $code ); |
1122 | 1169 | } |
1123 | | - $res = $dbw->insert( 'cn_notice_languages', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
| 1170 | + $res = $dbw->insert( 'cn_notice_languages', $insertArray, |
| 1171 | + __METHOD__, array( 'IGNORE' ) ); |
1124 | 1172 | |
1125 | 1173 | if ( $geotargeted ) { |
1126 | 1174 | // Do multi-row insert for campaign countries |
— | — | @@ -1127,7 +1175,8 @@ |
1128 | 1176 | foreach( $geo_countries as $code ) { |
1129 | 1177 | $insertArray[] = array( 'nc_notice_id' => $not_id, 'nc_country' => $code ); |
1130 | 1178 | } |
1131 | | - $res = $dbw->insert( 'cn_notice_countries', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
| 1179 | + $res = $dbw->insert( 'cn_notice_countries', $insertArray, |
| 1180 | + __METHOD__, array( 'IGNORE' ) ); |
1132 | 1181 | } |
1133 | 1182 | |
1134 | 1183 | $dbw->commit(); |
— | — | @@ -1213,7 +1262,8 @@ |
1214 | 1263 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1215 | 1264 | $languages = array(); |
1216 | 1265 | if ( $row ) { |
1217 | | - $res = $dbr->select( 'cn_notice_languages', 'nl_language', array( 'nl_notice_id' => $row->not_id ) ); |
| 1266 | + $res = $dbr->select( 'cn_notice_languages', 'nl_language', |
| 1267 | + array( 'nl_notice_id' => $row->not_id ) ); |
1218 | 1268 | foreach ( $res as $langRow ) { |
1219 | 1269 | $languages[] = $langRow->nl_language; |
1220 | 1270 | } |
— | — | @@ -1227,7 +1277,8 @@ |
1228 | 1278 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1229 | 1279 | $countries = array(); |
1230 | 1280 | if ( $row ) { |
1231 | | - $res = $dbr->select( 'cn_notice_countries', 'nc_country', array( 'nc_notice_id' => $row->not_id ) ); |
| 1281 | + $res = $dbr->select( 'cn_notice_countries', 'nc_country', |
| 1282 | + array( 'nc_notice_id' => $row->not_id ) ); |
1232 | 1283 | foreach ( $res as $countryRow ) { |
1233 | 1284 | $countries[] = $countryRow->nc_country; |
1234 | 1285 | } |
— | — | @@ -1400,7 +1451,8 @@ |
1401 | 1452 | function languageMultiSelector( $selected = array(), $customisedOnly = true ) { |
1402 | 1453 | global $wgContLanguageCode, $wgExtensionAssetsPath, $wgLang; |
1403 | 1454 | $scriptPath = "$wgExtensionAssetsPath/CentralNotice"; |
1404 | | - // Make sure the site language is in the list; a custom language code might not have a defined name... |
| 1455 | + // Make sure the site language is in the list; a custom language code |
| 1456 | + // might not have a defined name... |
1405 | 1457 | $languages = Language::getLanguageNames( $customisedOnly ); |
1406 | 1458 | if( !array_key_exists( $wgContLanguageCode, $languages ) ) { |
1407 | 1459 | $languages[$wgContLanguageCode] = $wgContLanguageCode; |
— | — | @@ -1422,16 +1474,26 @@ |
1423 | 1475 | $options |
1424 | 1476 | ); |
1425 | 1477 | $buttons = array(); |
1426 | | - $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . wfMsg( 'powersearch-toggleall' ) . '</a>'; |
1427 | | - $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . wfMsg( 'powersearch-togglenone' ) . '</a>'; |
1428 | | - $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . wfMsg( 'centralnotice-top-ten-languages' ) . '</a>'; |
| 1478 | + $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . |
| 1479 | + wfMsg( 'powersearch-toggleall' ) . '</a>'; |
| 1480 | + $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . |
| 1481 | + wfMsg( 'powersearch-togglenone' ) . '</a>'; |
| 1482 | + $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . |
| 1483 | + wfMsg( 'centralnotice-top-ten-languages' ) . '</a>'; |
1429 | 1484 | $htmlOut .= Xml::tags( 'div', |
1430 | 1485 | array( 'style' => 'margin-top: 0.2em;' ), |
1431 | | - '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . wfMsg( 'centralnotice-select', $wgLang->commaList( $buttons ) ) |
| 1486 | + '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . |
| 1487 | + wfMsg( 'centralnotice-select', $wgLang->commaList( $buttons ) ) |
1432 | 1488 | ); |
1433 | 1489 | } else { |
1434 | 1490 | $htmlOut .= Xml::tags( 'select', |
1435 | | - array( 'multiple' => 'multiple', 'size' => 4, 'id' => 'project_languages[]', 'name' => 'project_languages[]', 'disabled' => 'disabled' ), |
| 1491 | + array( |
| 1492 | + 'multiple' => 'multiple', |
| 1493 | + 'size' => 4, |
| 1494 | + 'id' => 'project_languages[]', |
| 1495 | + 'name' => 'project_languages[]', |
| 1496 | + 'disabled' => 'disabled' |
| 1497 | + ), |
1436 | 1498 | $options |
1437 | 1499 | ); |
1438 | 1500 | } |
— | — | @@ -1559,12 +1621,23 @@ |
1560 | 1622 | $htmlOut = ''; |
1561 | 1623 | if ( $this->editable ) { |
1562 | 1624 | $htmlOut .= Xml::tags( 'select', |
1563 | | - array( 'multiple' => 'multiple', 'size' => 5, 'id' => 'geo_countries[]', 'name' => 'geo_countries[]' ), |
| 1625 | + array( |
| 1626 | + 'multiple' => 'multiple', |
| 1627 | + 'size' => 5, |
| 1628 | + 'id' => 'geo_countries[]', |
| 1629 | + 'name' => 'geo_countries[]' |
| 1630 | + ), |
1564 | 1631 | $options |
1565 | 1632 | ); |
1566 | 1633 | } else { |
1567 | 1634 | $htmlOut .= Xml::tags( 'select', |
1568 | | - array( 'multiple' => 'multiple', 'size' => 5, 'id' => 'geo_countries[]', 'name' => 'geo_countries[]', 'disabled' => 'disabled' ), |
| 1635 | + array( |
| 1636 | + 'multiple' => 'multiple', |
| 1637 | + 'size' => 5, |
| 1638 | + 'id' => 'geo_countries[]', |
| 1639 | + 'name' => 'geo_countries[]', |
| 1640 | + 'disabled' => 'disabled' |
| 1641 | + ), |
1569 | 1642 | $options |
1570 | 1643 | ); |
1571 | 1644 | } |
— | — | @@ -1595,7 +1668,8 @@ |
1596 | 1669 | 'join_conds' => array( |
1597 | 1670 | 'cn_assignments' => array( |
1598 | 1671 | 'LEFT JOIN', |
1599 | | - "cn_assignments.tmp_id = cn_templates.tmp_id AND cn_assignments.not_id = $noticeId" |
| 1672 | + "cn_assignments.tmp_id = cn_templates.tmp_id " . |
| 1673 | + "AND cn_assignments.not_id = $noticeId" |
1600 | 1674 | ) |
1601 | 1675 | ) |
1602 | 1676 | ); |
— | — | @@ -1624,7 +1698,9 @@ |
1625 | 1699 | // Weight select |
1626 | 1700 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
1627 | 1701 | Xml::listDropDown( "weight[$row->tmp_id]", |
1628 | | - CentralNotice::dropDownList( wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 ) ) , |
| 1702 | + CentralNotice::dropDownList( |
| 1703 | + wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 ) |
| 1704 | + ) , |
1629 | 1705 | '', |
1630 | 1706 | '25', |
1631 | 1707 | '', |
Property changes on: branches/wmf/1.16wmf4/extensions/CentralNotice |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1632 | 1708 | Merged /trunk/extensions/CentralNotice:r75908 |