Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerController.php |
— | — | @@ -191,7 +191,7 @@ |
192 | 192 | } |
193 | 193 | function setBannerHidingCookie( bannerType ) { |
194 | 194 | var e = new Date(); |
195 | | - e.setTime( e.getTime() + (7*24*60*60*1000) ); // one week |
| 195 | + e.setTime( e.getTime() + (14*24*60*60*1000) ); // two weeks |
196 | 196 | var work='centralnotice_'+bannerType+'=hide; expires=' + e.toGMTString() + '; path=/'; |
197 | 197 | document.cookie = work; |
198 | 198 | } |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerController.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
199 | 199 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerController.php:r100100-102469 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -7,12 +7,12 @@ |
8 | 8 | |
9 | 9 | class CentralNotice extends SpecialPage { |
10 | 10 | var $editable, $centralNoticeError; |
11 | | - |
| 11 | + |
12 | 12 | function __construct() { |
13 | 13 | // Register special page |
14 | 14 | parent::__construct( 'CentralNotice' ); |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | /** |
18 | 18 | * Handle different types of page requests |
19 | 19 | */ |
— | — | @@ -22,24 +22,24 @@ |
23 | 23 | // Begin output |
24 | 24 | $this->setHeaders(); |
25 | 25 | $this->outputHeader(); |
26 | | - |
| 26 | + |
27 | 27 | // Output ResourceLoader module for styling and javascript functions |
28 | 28 | $wgOut->addModules( 'ext.centralNotice.interface' ); |
29 | | - |
| 29 | + |
30 | 30 | // Check permissions |
31 | 31 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
32 | | - |
| 32 | + |
33 | 33 | // Initialize error variable |
34 | 34 | $this->centralNoticeError = false; |
35 | 35 | |
36 | 36 | // Show header |
37 | 37 | $this->printHeader( $sub ); |
38 | | - |
| 38 | + |
39 | 39 | // Begin Campaigns tab content |
40 | 40 | $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'preferences' ) ) ); |
41 | | - |
| 41 | + |
42 | 42 | $method = $wgRequest->getVal( 'method' ); |
43 | | - |
| 43 | + |
44 | 44 | // Switch to campaign detail interface if requested |
45 | 45 | if ( $method == 'listNoticeDetail' ) { |
46 | 46 | $notice = $wgRequest->getVal ( 'notice' ); |
— | — | @@ -47,16 +47,16 @@ |
48 | 48 | $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
49 | 49 | return; |
50 | 50 | } |
51 | | - |
| 51 | + |
52 | 52 | // Handle form submissions from "Manage campaigns" or "Add a campaign" interface |
53 | 53 | if ( $this->editable && $wgRequest->wasPosted() ) { |
54 | | - |
| 54 | + |
55 | 55 | // Check authentication token |
56 | 56 | if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) { |
57 | | - |
| 57 | + |
58 | 58 | // Handle adding a campaign |
59 | 59 | if ( $method == 'addCampaign' ) { |
60 | | - |
| 60 | + |
61 | 61 | $noticeName = $wgRequest->getVal( 'noticeName' ); |
62 | 62 | $start = $wgRequest->getArray( 'start' ); |
63 | 63 | $projects = $wgRequest->getArray( 'projects' ); |
— | — | @@ -69,10 +69,10 @@ |
70 | 70 | $this->addCampaign( $noticeName, '0', $start, $projects, |
71 | 71 | $project_languages, $geotargeted, $geo_countries ); |
72 | 72 | } |
73 | | - |
| 73 | + |
74 | 74 | // Handle changing settings to existing campaigns |
75 | 75 | } else { |
76 | | - |
| 76 | + |
77 | 77 | // Handle removing campaigns |
78 | 78 | $toRemove = $wgRequest->getArray( 'removeCampaigns' ); |
79 | 79 | if ( $toRemove ) { |
— | — | @@ -81,20 +81,20 @@ |
82 | 82 | $this->removeCampaign( $notice ); |
83 | 83 | } |
84 | 84 | } |
85 | | - |
| 85 | + |
86 | 86 | // Get all the initial campaign settings for logging |
87 | 87 | $allCampaignNames = $this->getAllCampaignNames(); |
88 | 88 | $allInitialCampaignSettings = array(); |
89 | 89 | foreach ( $allCampaignNames as $campaignName ) { |
90 | 90 | $allInitialCampaignSettings[$campaignName] = CentralNoticeDB::getCampaignSettings( $campaignName, false ); |
91 | 91 | } |
92 | | - |
| 92 | + |
93 | 93 | // Handle locking/unlocking campaigns |
94 | 94 | $lockedNotices = $wgRequest->getArray( 'locked' ); |
95 | 95 | if ( $lockedNotices ) { |
96 | 96 | // Build list of campaigns to lock |
97 | 97 | $unlockedNotices = array_diff( $this->getAllCampaignNames(), $lockedNotices ); |
98 | | - |
| 98 | + |
99 | 99 | // Set locked/unlocked flag accordingly |
100 | 100 | foreach ( $lockedNotices as $notice ) { |
101 | 101 | $this->setBooleanCampaignSetting( $notice, 'locked', 1 ); |
— | — | @@ -109,13 +109,13 @@ |
110 | 110 | $this->setBooleanCampaignSetting( $notice, 'locked', 0 ); |
111 | 111 | } |
112 | 112 | } |
113 | | - |
| 113 | + |
114 | 114 | // Handle enabling/disabling campaigns |
115 | 115 | $enabledNotices = $wgRequest->getArray( 'enabled' ); |
116 | 116 | if ( $enabledNotices ) { |
117 | 117 | // Build list of campaigns to disable |
118 | 118 | $disabledNotices = array_diff( $this->getAllCampaignNames(), $enabledNotices ); |
119 | | - |
| 119 | + |
120 | 120 | // Set enabled/disabled flag accordingly |
121 | 121 | foreach ( $enabledNotices as $notice ) { |
122 | 122 | $this->setBooleanCampaignSetting( $notice, 'enabled', 1 ); |
— | — | @@ -130,13 +130,13 @@ |
131 | 131 | $this->setBooleanCampaignSetting( $notice, 'enabled', 0 ); |
132 | 132 | } |
133 | 133 | } |
134 | | - |
| 134 | + |
135 | 135 | // Handle setting preferred campaigns |
136 | 136 | $preferredNotices = $wgRequest->getArray( 'preferred' ); |
137 | 137 | if ( $preferredNotices ) { |
138 | | - // Build list of campaigns to unset |
| 138 | + // Build list of campaigns to unset |
139 | 139 | $unsetNotices = array_diff( $this->getAllCampaignNames(), $preferredNotices ); |
140 | | - |
| 140 | + |
141 | 141 | // Set flag accordingly |
142 | 142 | foreach ( $preferredNotices as $notice ) { |
143 | 143 | $this->setBooleanCampaignSetting( $notice, 'preferred', 1 ); |
— | — | @@ -151,7 +151,7 @@ |
152 | 152 | $this->setBooleanCampaignSetting( $notice, 'preferred', 0 ); |
153 | 153 | } |
154 | 154 | } |
155 | | - |
| 155 | + |
156 | 156 | // Get all the final campaign settings for potential logging |
157 | 157 | foreach ( $allCampaignNames as $campaignName ) { |
158 | 158 | $finalCampaignSettings = CentralNoticeDB::getCampaignSettings( $campaignName, false ); |
— | — | @@ -163,13 +163,13 @@ |
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
167 | | - |
| 167 | + |
168 | 168 | // If there were no errors, reload the page to prevent duplicate form submission |
169 | 169 | if ( !$this->centralNoticeError ) { |
170 | 170 | $wgOut->redirect( $this->getTitle()->getLocalUrl() ); |
171 | 171 | return; |
172 | 172 | } |
173 | | - |
| 173 | + |
174 | 174 | } else { |
175 | 175 | $this->showError( 'sessionfailure' ); |
176 | 176 | } |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | |
180 | 180 | // Show list of campaigns |
181 | 181 | $this->listNotices(); |
182 | | - |
| 182 | + |
183 | 183 | // End Campaigns tab content |
184 | 184 | $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
185 | 185 | } |
— | — | @@ -241,28 +241,28 @@ |
242 | 242 | if ( $editable ) { |
243 | 243 | $dateRanges = CentralNotice::getDateRanges(); |
244 | 244 | |
245 | | - // Normalize timestamp format. If no timestamp is passed, default to now. If -1 is |
| 245 | + // Normalize timestamp format. If no timestamp is passed, default to now. If -1 is |
246 | 246 | // passed, set no defaults. |
247 | 247 | if ( $timestamp === -1 ) { |
248 | 248 | $ts = '00000000'; |
249 | 249 | } else { |
250 | 250 | $ts = wfTimestamp( TS_MW, $timestamp ); |
251 | 251 | } |
252 | | - |
| 252 | + |
253 | 253 | $fields = array( |
254 | 254 | array( "month", "centralnotice-month", $dateRanges['months'], substr( $ts, 4, 2 ) ), |
255 | 255 | array( "day", "centralnotice-day", $dateRanges['days'], substr( $ts, 6, 2 ) ), |
256 | 256 | array( "year", "centralnotice-year", $dateRanges['years'], substr( $ts, 0, 4 ) ), |
257 | 257 | ); |
258 | | - |
| 258 | + |
259 | 259 | return CentralNotice::createSelector( $prefix, $fields ); |
260 | 260 | } else { |
261 | 261 | global $wgLang; |
262 | 262 | return $wgLang->date( $timestamp ); |
263 | 263 | } |
264 | 264 | } |
265 | | - |
266 | | - /* |
| 265 | + |
| 266 | + /** |
267 | 267 | * Get date ranges for use in date selectors |
268 | 268 | * @return array of ranges for months, days, and years (padded with zeros) |
269 | 269 | */ |
— | — | @@ -278,15 +278,15 @@ |
279 | 279 | if ( $editable ) { |
280 | 280 | $minutes = CentralNotice::paddedRange( 0, 59 ); |
281 | 281 | $hours = CentralNotice::paddedRange( 0 , 23 ); |
282 | | - |
| 282 | + |
283 | 283 | // Normalize timestamp format... |
284 | 284 | $ts = wfTimestamp( TS_MW, $timestamp ); |
285 | | - |
| 285 | + |
286 | 286 | $fields = array( |
287 | 287 | array( "hour", "centralnotice-hours", $hours, substr( $ts, 8, 2 ) ), |
288 | 288 | array( "min", "centralnotice-min", $minutes, substr( $ts, 10, 2 ) ), |
289 | 289 | ); |
290 | | - |
| 290 | + |
291 | 291 | return CentralNotice::createSelector( $prefix, $fields ); |
292 | 292 | } else { |
293 | 293 | global $wgLang; |
— | — | @@ -298,7 +298,7 @@ |
299 | 299 | * Build a set of select lists. Used by dateSelector and timeSelector. |
300 | 300 | * @param $prefix string to identify selector set, for example, 'start' or 'end' |
301 | 301 | * @param $fields array of select lists to build |
302 | | - */ |
| 302 | + */ |
303 | 303 | public static function createSelector( $prefix, $fields ) { |
304 | 304 | $out = ''; |
305 | 305 | foreach ( $fields as $data ) { |
— | — | @@ -340,20 +340,20 @@ |
341 | 341 | __METHOD__, |
342 | 342 | array( 'ORDER BY' => 'not_id DESC' ) |
343 | 343 | ); |
344 | | - |
| 344 | + |
345 | 345 | // Begin building HTML |
346 | 346 | $htmlOut = ''; |
347 | | - |
| 347 | + |
348 | 348 | // Begin Manage campaigns fieldset |
349 | 349 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
350 | | - |
| 350 | + |
351 | 351 | // If there are campaigns to show... |
352 | 352 | if ( $dbr->numRows( $res ) >= 1 ) { |
353 | 353 | if ( $this->editable ) { |
354 | 354 | $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) ); |
355 | 355 | } |
356 | 356 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-manage' ) ); |
357 | | - |
| 357 | + |
358 | 358 | // Begin table of campaigns |
359 | 359 | $htmlOut .= Xml::openElement( 'table', |
360 | 360 | array( |
— | — | @@ -362,7 +362,7 @@ |
363 | 363 | 'class' => 'wikitable sortable' |
364 | 364 | ) |
365 | 365 | ); |
366 | | - |
| 366 | + |
367 | 367 | // Table headers |
368 | 368 | $headers = array( |
369 | 369 | wfMsgHtml( 'centralnotice-notice-name' ), |
— | — | @@ -378,7 +378,7 @@ |
379 | 379 | $headers[] = wfMsgHtml( 'centralnotice-remove' ); |
380 | 380 | } |
381 | 381 | $htmlOut .= $this->tableRow( $headers, 'th' ); |
382 | | - |
| 382 | + |
383 | 383 | // Table rows |
384 | 384 | foreach ( $res as $row ) { |
385 | 385 | $fields = array(); |
— | — | @@ -464,21 +464,21 @@ |
465 | 465 | $fields[] = Xml::check( 'removeCampaigns[]', false, |
466 | 466 | array( 'value' => $row->not_name, 'class' => 'noshiftselect' ) ); |
467 | 467 | } |
468 | | - |
| 468 | + |
469 | 469 | // If campaign is currently active, set special class on table row. |
470 | 470 | $attribs = array(); |
471 | | - if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) |
472 | | - && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) |
473 | | - && $row->not_enabled == '1' ) |
| 471 | + if ( wfTimestamp() > wfTimestamp( TS_UNIX , $row->not_start ) |
| 472 | + && wfTimestamp() < wfTimestamp( TS_UNIX , $row->not_end ) |
| 473 | + && $row->not_enabled == '1' ) |
474 | 474 | { |
475 | 475 | $attribs = array( 'class' => 'cn-active-campaign' ); |
476 | 476 | } |
477 | | - |
| 477 | + |
478 | 478 | $htmlOut .= $this->tableRow( $fields, 'td', $attribs ); |
479 | 479 | } |
480 | 480 | // End table of campaigns |
481 | 481 | $htmlOut .= Xml::closeElement( 'table' ); |
482 | | - |
| 482 | + |
483 | 483 | if ( $this->editable ) { |
484 | 484 | $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
485 | 485 | $htmlOut .= Xml::openElement( 'div', array( 'class' => 'cn-buttons' ) ); |
— | — | @@ -496,12 +496,12 @@ |
497 | 497 | } else { |
498 | 498 | $htmlOut .= wfMsg( 'centralnotice-no-notices-exist' ); |
499 | 499 | } |
500 | | - |
| 500 | + |
501 | 501 | // End Manage Campaigns fieldset |
502 | 502 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
503 | 503 | |
504 | 504 | if ( $this->editable ) { |
505 | | - |
| 505 | + |
506 | 506 | // If there was an error, we'll need to restore the state of the form |
507 | 507 | if ( $wgRequest->wasPosted() && ( $wgRequest->getVal( 'method' ) == 'addCampaign' ) ) { |
508 | 508 | $startArray = $wgRequest->getArray( 'start' ); |
— | — | @@ -518,22 +518,22 @@ |
519 | 519 | $noticeProjects = array(); |
520 | 520 | $noticeLanguages = array(); |
521 | 521 | } |
522 | | - |
| 522 | + |
523 | 523 | // Begin Add a campaign fieldset |
524 | 524 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
525 | | - |
| 525 | + |
526 | 526 | // Form for adding a campaign |
527 | 527 | $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) ); |
528 | 528 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-add-notice' ) ); |
529 | 529 | $htmlOut .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ); |
530 | 530 | $htmlOut .= Html::hidden( 'method', 'addCampaign' ); |
531 | | - |
| 531 | + |
532 | 532 | $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9 ) ); |
533 | | - |
| 533 | + |
534 | 534 | // Name |
535 | 535 | $htmlOut .= Xml::openElement( 'tr' ); |
536 | 536 | $htmlOut .= Xml::tags( 'td', array(), wfMsgHtml( 'centralnotice-notice-name' ) ); |
537 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 537 | + $htmlOut .= Xml::tags( 'td', array(), |
538 | 538 | Xml::input( 'noticeName', 25, $wgRequest->getVal( 'noticeName' ) ) ); |
539 | 539 | $htmlOut .= Xml::closeElement( 'tr' ); |
540 | 540 | // Start Date |
— | — | @@ -554,42 +554,42 @@ |
555 | 555 | $htmlOut .= Xml::closeElement( 'tr' ); |
556 | 556 | // Languages |
557 | 557 | $htmlOut .= Xml::openElement( 'tr' ); |
558 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 558 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
559 | 559 | wfMsgHtml( 'centralnotice-languages' ) ); |
560 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 560 | + $htmlOut .= Xml::tags( 'td', array(), |
561 | 561 | $this->languageMultiSelector( $noticeLanguages ) ); |
562 | 562 | $htmlOut .= Xml::closeElement( 'tr' ); |
563 | 563 | // Countries |
564 | 564 | $htmlOut .= Xml::openElement( 'tr' ); |
565 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 565 | + $htmlOut .= Xml::tags( 'td', array(), |
566 | 566 | Xml::label( wfMsg( 'centralnotice-geo' ), 'geotargeted' ) ); |
567 | | - $htmlOut .= Xml::tags( 'td', array(), |
568 | | - Xml::check( 'geotargeted', false, |
| 567 | + $htmlOut .= Xml::tags( 'td', array(), |
| 568 | + Xml::check( 'geotargeted', false, |
569 | 569 | wfArrayMerge( $readonly, array( 'value' => 1, 'id' => 'geotargeted' ) ) ) ); |
570 | 570 | $htmlOut .= Xml::closeElement( 'tr' ); |
571 | | - $htmlOut .= Xml::openElement( 'tr', |
| 571 | + $htmlOut .= Xml::openElement( 'tr', |
572 | 572 | array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
573 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 573 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
574 | 574 | wfMsgHtml( 'centralnotice-countries' ) ); |
575 | 575 | $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector() ); |
576 | 576 | $htmlOut .= Xml::closeElement( 'tr' ); |
577 | | - |
| 577 | + |
578 | 578 | $htmlOut .= Xml::closeElement( 'table' ); |
579 | 579 | $htmlOut .= Html::hidden( 'change', 'weight' ); |
580 | 580 | $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
581 | | - |
| 581 | + |
582 | 582 | // Submit button |
583 | | - $htmlOut .= Xml::tags( 'div', |
584 | | - array( 'class' => 'cn-buttons' ), |
585 | | - Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) |
| 583 | + $htmlOut .= Xml::tags( 'div', |
| 584 | + array( 'class' => 'cn-buttons' ), |
| 585 | + Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) |
586 | 586 | ); |
587 | | - |
| 587 | + |
588 | 588 | $htmlOut .= Xml::closeElement( 'form' ); |
589 | | - |
| 589 | + |
590 | 590 | // End Add a campaign fieldset |
591 | 591 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
592 | 592 | } |
593 | | - |
| 593 | + |
594 | 594 | // Output HTML |
595 | 595 | $wgOut->addHTML( $htmlOut ); |
596 | 596 | } |
— | — | @@ -600,7 +600,7 @@ |
601 | 601 | */ |
602 | 602 | function listNoticeDetail( $notice ) { |
603 | 603 | global $wgOut, $wgRequest, $wgUser; |
604 | | - |
| 604 | + |
605 | 605 | // Make sure notice exists |
606 | 606 | if ( !CentralNoticeDB::campaignExists( $notice ) ) { |
607 | 607 | $this->showError( 'centralnotice-notice-doesnt-exist' ); |
— | — | @@ -608,10 +608,10 @@ |
609 | 609 | |
610 | 610 | // Handle form submissions from campaign detail interface |
611 | 611 | if ( $this->editable && $wgRequest->wasPosted() ) { |
612 | | - |
| 612 | + |
613 | 613 | // Check authentication token |
614 | 614 | if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) { |
615 | | - |
| 615 | + |
616 | 616 | // Handle removing campaign |
617 | 617 | if ( $wgRequest->getVal( 'remove' ) ) { |
618 | 618 | $this->removeCampaign( $notice ); |
— | — | @@ -621,30 +621,30 @@ |
622 | 622 | return; |
623 | 623 | } |
624 | 624 | } |
625 | | - |
| 625 | + |
626 | 626 | $initialCampaignSettings = CentralNoticeDB::getCampaignSettings( $notice ); |
627 | | - |
| 627 | + |
628 | 628 | // Handle locking/unlocking campaign |
629 | 629 | if ( $wgRequest->getCheck( 'locked' ) ) { |
630 | 630 | $this->setBooleanCampaignSetting( $notice, 'locked', 1 ); |
631 | 631 | } else { |
632 | 632 | $this->setBooleanCampaignSetting( $notice, 'locked', 0 ); |
633 | 633 | } |
634 | | - |
| 634 | + |
635 | 635 | // Handle enabling/disabling campaign |
636 | 636 | if ( $wgRequest->getCheck( 'enabled' ) ) { |
637 | 637 | $this->setBooleanCampaignSetting( $notice, 'enabled', 1 ); |
638 | 638 | } else { |
639 | 639 | $this->setBooleanCampaignSetting( $notice, 'enabled', 0 ); |
640 | 640 | } |
641 | | - |
| 641 | + |
642 | 642 | // Handle setting campaign to preferred/not preferred |
643 | 643 | if ( $wgRequest->getCheck( 'preferred' ) ) { |
644 | 644 | $this->setBooleanCampaignSetting( $notice, 'preferred', 1 ); |
645 | 645 | } else { |
646 | 646 | $this->setBooleanCampaignSetting( $notice, 'preferred', 0 ); |
647 | 647 | } |
648 | | - |
| 648 | + |
649 | 649 | // Handle updating geotargeting |
650 | 650 | if ( $wgRequest->getCheck( 'geotargeted' ) ) { |
651 | 651 | $this->setBooleanCampaignSetting( $notice, 'geo', 1 ); |
— | — | @@ -655,7 +655,7 @@ |
656 | 656 | } else { |
657 | 657 | $this->setBooleanCampaignSetting( $notice, 'geo', 0 ); |
658 | 658 | } |
659 | | - |
| 659 | + |
660 | 660 | // Handle updating the start and end settings |
661 | 661 | $start = $wgRequest->getArray( 'start' ); |
662 | 662 | $end = $wgRequest->getArray( 'end' ); |
— | — | @@ -674,10 +674,10 @@ |
675 | 675 | $end['hour'], |
676 | 676 | $end['min'] |
677 | 677 | ); |
678 | | - |
| 678 | + |
679 | 679 | $this->updateNoticeDate( $notice, $updatedStart, $updatedEnd ); |
680 | 680 | } |
681 | | - |
| 681 | + |
682 | 682 | // Handle adding of banners to the campaign |
683 | 683 | $templatesToAdd = $wgRequest->getArray( 'addTemplates' ); |
684 | 684 | if ( $templatesToAdd ) { |
— | — | @@ -687,7 +687,7 @@ |
688 | 688 | $this->addTemplateTo( $notice, $templateName, $weight[$templateId] ); |
689 | 689 | } |
690 | 690 | } |
691 | | - |
| 691 | + |
692 | 692 | // Handle removing of banners from the campaign |
693 | 693 | $templateToRemove = $wgRequest->getArray( 'removeTemplates' ); |
694 | 694 | if ( $templateToRemove ) { |
— | — | @@ -695,7 +695,7 @@ |
696 | 696 | $this->removeTemplateFor( $notice, $template ); |
697 | 697 | } |
698 | 698 | } |
699 | | - |
| 699 | + |
700 | 700 | // Handle weight changes |
701 | 701 | $updatedWeights = $wgRequest->getArray( 'weight' ); |
702 | 702 | if ( $updatedWeights ) { |
— | — | @@ -703,56 +703,56 @@ |
704 | 704 | $this->updateWeight( $notice, $templateId, $weight ); |
705 | 705 | } |
706 | 706 | } |
707 | | - |
| 707 | + |
708 | 708 | // Handle new projects |
709 | 709 | $projects = $wgRequest->getArray( 'projects' ); |
710 | 710 | if ( $projects ) { |
711 | 711 | $this->updateProjects( $notice, $projects ); |
712 | 712 | } |
713 | | - |
| 713 | + |
714 | 714 | // Handle new project languages |
715 | 715 | $projectLangs = $wgRequest->getArray( 'project_languages' ); |
716 | 716 | if ( $projectLangs ) { |
717 | 717 | $this->updateProjectLanguages( $notice, $projectLangs ); |
718 | 718 | } |
719 | | - |
| 719 | + |
720 | 720 | $finalCampaignSettings = CentralNoticeDB::getCampaignSettings( $notice ); |
721 | 721 | $campaignId = CentralNotice::getNoticeId( $notice ); |
722 | 722 | $this->logCampaignChange( 'modified', $campaignId, $initialCampaignSettings, $finalCampaignSettings ); |
723 | | - |
| 723 | + |
724 | 724 | // If there were no errors, reload the page to prevent duplicate form submission |
725 | 725 | if ( !$this->centralNoticeError ) { |
726 | | - $wgOut->redirect( $this->getTitle()->getLocalUrl( |
| 726 | + $wgOut->redirect( $this->getTitle()->getLocalUrl( |
727 | 727 | "method=listNoticeDetail¬ice=$notice" ) ); |
728 | 728 | return; |
729 | 729 | } |
730 | 730 | } else { |
731 | 731 | $this->showError( 'sessionfailure' ); |
732 | 732 | } |
733 | | - |
| 733 | + |
734 | 734 | } |
735 | | - |
| 735 | + |
736 | 736 | $htmlOut = ''; |
737 | | - |
| 737 | + |
738 | 738 | // Begin Campaign detail fieldset |
739 | 739 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
740 | | - |
| 740 | + |
741 | 741 | if ( $this->editable ) { |
742 | 742 | $htmlOut .= Xml::openElement( 'form', |
743 | 743 | array( |
744 | 744 | 'method' => 'post', |
745 | | - 'action' => $this->getTitle()->getLocalUrl( |
| 745 | + 'action' => $this->getTitle()->getLocalUrl( |
746 | 746 | "method=listNoticeDetail¬ice=$notice" ) |
747 | 747 | ) |
748 | 748 | ); |
749 | 749 | } |
750 | | - |
| 750 | + |
751 | 751 | $output_detail = $this->noticeDetailForm( $notice ); |
752 | 752 | $output_assigned = $this->assignedTemplatesForm( $notice ); |
753 | 753 | $output_templates = $this->addTemplatesForm( $notice ); |
754 | | - |
| 754 | + |
755 | 755 | $htmlOut .= $output_detail; |
756 | | - |
| 756 | + |
757 | 757 | // Catch for no banners so that we don't double message |
758 | 758 | if ( $output_assigned == '' && $output_templates == '' ) { |
759 | 759 | $htmlOut .= wfMsg( 'centralnotice-no-templates' ); |
— | — | @@ -776,14 +776,14 @@ |
777 | 777 | } |
778 | 778 | if ( $this->editable ) { |
779 | 779 | $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); |
780 | | - |
| 780 | + |
781 | 781 | // Submit button |
782 | | - $htmlOut .= Xml::tags( 'div', |
783 | | - array( 'class' => 'cn-buttons' ), |
784 | | - Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) |
| 782 | + $htmlOut .= Xml::tags( 'div', |
| 783 | + array( 'class' => 'cn-buttons' ), |
| 784 | + Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) |
785 | 785 | ); |
786 | 786 | } |
787 | | - |
| 787 | + |
788 | 788 | if ( $this->editable ) { |
789 | 789 | $htmlOut .= Xml::closeElement( 'form' ); |
790 | 790 | } |
— | — | @@ -791,23 +791,23 @@ |
792 | 792 | $wgOut->addHTML( $htmlOut ); |
793 | 793 | } |
794 | 794 | } |
795 | | - |
| 795 | + |
796 | 796 | /** |
797 | 797 | * Create form for managing campaign settings (start date, end date, languages, etc.) |
798 | 798 | */ |
799 | 799 | function noticeDetailForm( $notice ) { |
800 | 800 | global $wgRequest; |
801 | | - |
| 801 | + |
802 | 802 | if ( $this->editable ) { |
803 | 803 | $readonly = array(); |
804 | 804 | } else { |
805 | 805 | $readonly = array( 'disabled' => 'disabled' ); |
806 | 806 | } |
807 | | - |
| 807 | + |
808 | 808 | $campaign = CentralNoticeDB::getCampaignSettings( $notice ); |
809 | | - |
| 809 | + |
810 | 810 | if ( $campaign ) { |
811 | | - |
| 811 | + |
812 | 812 | // If there was an error, we'll need to restore the state of the form |
813 | 813 | if ( $wgRequest->wasPosted() ) { |
814 | 814 | $startArray = $wgRequest->getArray( 'start' ); |
— | — | @@ -842,7 +842,7 @@ |
843 | 843 | $isGeotargeted = ( $campaign['geo'] == '1' ); |
844 | 844 | $countries = CentralNotice::getNoticeCountries( $notice ); |
845 | 845 | } |
846 | | - |
| 846 | + |
847 | 847 | // Build Html |
848 | 848 | $htmlOut = ''; |
849 | 849 | $htmlOut .= Xml::tags( 'h2', null, wfMsg( 'centralnotice-notice-heading', $notice ) ); |
— | — | @@ -871,72 +871,72 @@ |
872 | 872 | $htmlOut .= Xml::closeElement( 'tr' ); |
873 | 873 | // Project |
874 | 874 | $htmlOut .= Xml::openElement( 'tr' ); |
875 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 875 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
876 | 876 | wfMsgHtml( 'centralnotice-projects' ) ); |
877 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 877 | + $htmlOut .= Xml::tags( 'td', array(), |
878 | 878 | $this->projectMultiSelector( $noticeProjects ) ); |
879 | 879 | $htmlOut .= Xml::closeElement( 'tr' ); |
880 | 880 | // Languages |
881 | 881 | $htmlOut .= Xml::openElement( 'tr' ); |
882 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 882 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
883 | 883 | wfMsgHtml( 'centralnotice-languages' ) ); |
884 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 884 | + $htmlOut .= Xml::tags( 'td', array(), |
885 | 885 | $this->languageMultiSelector( $noticeLanguages ) ); |
886 | 886 | $htmlOut .= Xml::closeElement( 'tr' ); |
887 | 887 | // Countries |
888 | 888 | $htmlOut .= Xml::openElement( 'tr' ); |
889 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 889 | + $htmlOut .= Xml::tags( 'td', array(), |
890 | 890 | Xml::label( wfMsg( 'centralnotice-geo' ), 'geotargeted' ) ); |
891 | | - $htmlOut .= Xml::tags( 'td', array(), |
892 | | - Xml::check( 'geotargeted', $isGeotargeted, |
893 | | - wfArrayMerge( |
894 | | - $readonly, |
| 891 | + $htmlOut .= Xml::tags( 'td', array(), |
| 892 | + Xml::check( 'geotargeted', $isGeotargeted, |
| 893 | + wfArrayMerge( |
| 894 | + $readonly, |
895 | 895 | array( 'value' => $notice, 'id' => 'geotargeted' ) ) ) ); |
896 | 896 | $htmlOut .= Xml::closeElement( 'tr' ); |
897 | 897 | if ( $isGeotargeted ) { |
898 | 898 | $htmlOut .= Xml::openElement( 'tr', array( 'id'=>'geoMultiSelector' ) ); |
899 | 899 | } else { |
900 | | - $htmlOut .= Xml::openElement( 'tr', |
| 900 | + $htmlOut .= Xml::openElement( 'tr', |
901 | 901 | array( 'id'=>'geoMultiSelector', 'style'=>'display:none;' ) ); |
902 | 902 | } |
903 | | - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
| 903 | + $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), |
904 | 904 | wfMsgHtml( 'centralnotice-countries' ) ); |
905 | 905 | $htmlOut .= Xml::tags( 'td', array(), $this->geoMultiSelector( $countries ) ); |
906 | 906 | $htmlOut .= Xml::closeElement( 'tr' ); |
907 | 907 | // Enabled |
908 | 908 | $htmlOut .= Xml::openElement( 'tr' ); |
909 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 909 | + $htmlOut .= Xml::tags( 'td', array(), |
910 | 910 | Xml::label( wfMsg( 'centralnotice-enabled' ), 'enabled' ) ); |
911 | | - $htmlOut .= Xml::tags( 'td', array(), |
912 | | - Xml::check( 'enabled', $isEnabled, |
913 | | - wfArrayMerge( $readonly, |
| 911 | + $htmlOut .= Xml::tags( 'td', array(), |
| 912 | + Xml::check( 'enabled', $isEnabled, |
| 913 | + wfArrayMerge( $readonly, |
914 | 914 | array( 'value' => $notice, 'id' => 'enabled' ) ) ) ); |
915 | 915 | $htmlOut .= Xml::closeElement( 'tr' ); |
916 | 916 | // Preferred |
917 | 917 | $htmlOut .= Xml::openElement( 'tr' ); |
918 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 918 | + $htmlOut .= Xml::tags( 'td', array(), |
919 | 919 | Xml::label( wfMsg( 'centralnotice-preferred' ), 'preferred' ) ); |
920 | | - $htmlOut .= Xml::tags( 'td', array(), |
921 | | - Xml::check( 'preferred', $isPreferred, |
922 | | - wfArrayMerge( $readonly, |
| 920 | + $htmlOut .= Xml::tags( 'td', array(), |
| 921 | + Xml::check( 'preferred', $isPreferred, |
| 922 | + wfArrayMerge( $readonly, |
923 | 923 | array( 'value' => $notice, 'id' => 'preferred' ) ) ) ); |
924 | 924 | $htmlOut .= Xml::closeElement( 'tr' ); |
925 | 925 | // Locked |
926 | 926 | $htmlOut .= Xml::openElement( 'tr' ); |
927 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 927 | + $htmlOut .= Xml::tags( 'td', array(), |
928 | 928 | Xml::label( wfMsg( 'centralnotice-locked' ), 'locked' ) ); |
929 | | - $htmlOut .= Xml::tags( 'td', array(), |
930 | | - Xml::check( 'locked', $isLocked, |
931 | | - wfArrayMerge( $readonly, |
| 929 | + $htmlOut .= Xml::tags( 'td', array(), |
| 930 | + Xml::check( 'locked', $isLocked, |
| 931 | + wfArrayMerge( $readonly, |
932 | 932 | array( 'value' => $notice, 'id' => 'locked' ) ) ) ); |
933 | 933 | $htmlOut .= Xml::closeElement( 'tr' ); |
934 | 934 | if ( $this->editable ) { |
935 | 935 | // Locked |
936 | 936 | $htmlOut .= Xml::openElement( 'tr' ); |
937 | | - $htmlOut .= Xml::tags( 'td', array(), |
| 937 | + $htmlOut .= Xml::tags( 'td', array(), |
938 | 938 | Xml::label( wfMsg( 'centralnotice-remove' ), 'remove' ) ); |
939 | | - $htmlOut .= Xml::tags( 'td', array(), |
940 | | - Xml::check( 'remove', false, |
| 939 | + $htmlOut .= Xml::tags( 'td', array(), |
| 940 | + Xml::check( 'remove', false, |
941 | 941 | array( 'value' => $notice, 'id' => 'remove' ) ) ); |
942 | 942 | $htmlOut .= Xml::closeElement( 'tr' ); |
943 | 943 | } |
— | — | @@ -1022,7 +1022,7 @@ |
1023 | 1023 | $render->siteName = 'Wikipedia'; |
1024 | 1024 | global $wgRequest; |
1025 | 1025 | $render->language = $wgRequest->getVal( 'wpUserLanguage' ); |
1026 | | - try { |
| 1026 | + try { |
1027 | 1027 | $preview = $render->getHtmlNotice( $row->tmp_name ); |
1028 | 1028 | } catch ( SpecialBannerLoaderException $e ) { |
1029 | 1029 | $preview = wfMsg( 'centralnotice-nopreview' ); |
— | — | @@ -1044,7 +1044,7 @@ |
1045 | 1045 | return $htmlOut; |
1046 | 1046 | |
1047 | 1047 | } |
1048 | | - |
| 1048 | + |
1049 | 1049 | function weightDropDown( $name, $selected ) { |
1050 | 1050 | if ( $this->editable ) { |
1051 | 1051 | return Xml::listDropDown( $name, |
— | — | @@ -1066,20 +1066,20 @@ |
1067 | 1067 | $pager = new CentralNoticePager( $this ); |
1068 | 1068 | $dbr = wfGetDB( DB_SLAVE ); |
1069 | 1069 | $res = $dbr->select( 'cn_templates', 'tmp_name', '', '', array( 'ORDER BY' => 'tmp_id' ) ); |
1070 | | - |
| 1070 | + |
1071 | 1071 | if ( $dbr->numRows( $res ) > 0 ) { |
1072 | 1072 | // Build HTML |
1073 | 1073 | $htmlOut = Xml::fieldset( wfMsg( "centralnotice-available-templates" ) ); |
1074 | | - |
| 1074 | + |
1075 | 1075 | // Show paginated list of banners |
1076 | | - $htmlOut .= Xml::tags( 'div', |
1077 | | - array( 'class' => 'cn-pager' ), |
| 1076 | + $htmlOut .= Xml::tags( 'div', |
| 1077 | + array( 'class' => 'cn-pager' ), |
1078 | 1078 | $pager->getNavigationBar() ); |
1079 | 1079 | $htmlOut .= $pager->getBody(); |
1080 | | - $htmlOut .= Xml::tags( 'div', |
1081 | | - array( 'class' => 'cn-pager' ), |
| 1080 | + $htmlOut .= Xml::tags( 'div', |
| 1081 | + array( 'class' => 'cn-pager' ), |
1082 | 1082 | $pager->getNavigationBar() ); |
1083 | | - |
| 1083 | + |
1084 | 1084 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
1085 | 1085 | } else { |
1086 | 1086 | // Nothing found |
— | — | @@ -1099,8 +1099,8 @@ |
1100 | 1100 | * @param $geo_countries array: Targeted countries |
1101 | 1101 | * @return true or null |
1102 | 1102 | */ |
1103 | | - function addCampaign( $noticeName, $enabled, $start, $projects, |
1104 | | - $project_languages, $geotargeted, $geo_countries ) |
| 1103 | + function addCampaign( $noticeName, $enabled, $start, $projects, |
| 1104 | + $project_languages, $geotargeted, $geo_countries ) |
1105 | 1105 | { |
1106 | 1106 | if ( CentralNoticeDB::campaignExists( $noticeName ) ) { |
1107 | 1107 | $this->showError( 'centralnotice-notice-exists' ); |
— | — | @@ -1124,14 +1124,14 @@ |
1125 | 1125 | $end['month'] = '10'; |
1126 | 1126 | $end['year'] = $start['year']; |
1127 | 1127 | } else { |
1128 | | - $end['month'] = |
1129 | | - ( substr( $start['month'], 0, 1 ) ) == 0 |
1130 | | - ? 0 . ( intval( $start['month'] ) + 1 ) |
| 1128 | + $end['month'] = |
| 1129 | + ( substr( $start['month'], 0, 1 ) ) == 0 |
| 1130 | + ? 0 . ( intval( $start['month'] ) + 1 ) |
1131 | 1131 | : ( $start['month'] + 1 ); |
1132 | 1132 | $end['year'] = $start['year']; |
1133 | 1133 | } |
1134 | 1134 | |
1135 | | - $startTs = wfTimeStamp( TS_MW, "{$start['year']}:{$start['month']}:{$start['day']} " . |
| 1135 | + $startTs = wfTimeStamp( TS_MW, "{$start['year']}:{$start['month']}:{$start['day']} " . |
1136 | 1136 | "{$start['hour']}:{$start['min']}:00" ); |
1137 | 1137 | $endTs = wfTimeStamp( TS_MW, "{$end['year']}:{$end['month']}:{$start['day']} " . |
1138 | 1138 | "{$start['hour']}:{$start['min']}:00" ); |
— | — | @@ -1145,37 +1145,37 @@ |
1146 | 1146 | ) |
1147 | 1147 | ); |
1148 | 1148 | $not_id = $dbw->insertId(); |
1149 | | - |
| 1149 | + |
1150 | 1150 | if ( $not_id ) { |
1151 | | - |
| 1151 | + |
1152 | 1152 | // Do multi-row insert for campaign projects |
1153 | 1153 | $insertArray = array(); |
1154 | 1154 | foreach( $projects as $project ) { |
1155 | 1155 | $insertArray[] = array( 'np_notice_id' => $not_id, 'np_project' => $project ); |
1156 | 1156 | } |
1157 | | - $res = $dbw->insert( 'cn_notice_projects', $insertArray, |
| 1157 | + $res = $dbw->insert( 'cn_notice_projects', $insertArray, |
1158 | 1158 | __METHOD__, array( 'IGNORE' ) ); |
1159 | | - |
| 1159 | + |
1160 | 1160 | // Do multi-row insert for campaign languages |
1161 | 1161 | $insertArray = array(); |
1162 | 1162 | foreach( $project_languages as $code ) { |
1163 | 1163 | $insertArray[] = array( 'nl_notice_id' => $not_id, 'nl_language' => $code ); |
1164 | 1164 | } |
1165 | | - $res = $dbw->insert( 'cn_notice_languages', $insertArray, |
| 1165 | + $res = $dbw->insert( 'cn_notice_languages', $insertArray, |
1166 | 1166 | __METHOD__, array( 'IGNORE' ) ); |
1167 | | - |
| 1167 | + |
1168 | 1168 | if ( $geotargeted ) { |
1169 | 1169 | // Do multi-row insert for campaign countries |
1170 | 1170 | $insertArray = array(); |
1171 | 1171 | foreach( $geo_countries as $code ) { |
1172 | 1172 | $insertArray[] = array( 'nc_notice_id' => $not_id, 'nc_country' => $code ); |
1173 | 1173 | } |
1174 | | - $res = $dbw->insert( 'cn_notice_countries', $insertArray, |
| 1174 | + $res = $dbw->insert( 'cn_notice_countries', $insertArray, |
1175 | 1175 | __METHOD__, array( 'IGNORE' ) ); |
1176 | 1176 | } |
1177 | | - |
| 1177 | + |
1178 | 1178 | $dbw->commit(); |
1179 | | - |
| 1179 | + |
1180 | 1180 | // Log the creation of the campaign |
1181 | 1181 | $beginSettings = array(); |
1182 | 1182 | $endSettings = array( |
— | — | @@ -1190,9 +1190,9 @@ |
1191 | 1191 | 'geo' => $geotargeted |
1192 | 1192 | ); |
1193 | 1193 | $this->logCampaignChange( 'created', $not_id, $beginSettings, $endSettings ); |
1194 | | - |
| 1194 | + |
1195 | 1195 | return true; |
1196 | | - |
| 1196 | + |
1197 | 1197 | } else { |
1198 | 1198 | return null; |
1199 | 1199 | } |
— | — | @@ -1222,7 +1222,7 @@ |
1223 | 1223 | // Log the removal of the campaign |
1224 | 1224 | $campaignId = CentralNotice::getNoticeId( $campaignName ); |
1225 | 1225 | $this->logCampaignChange( 'removed', $campaignId ); |
1226 | | - |
| 1226 | + |
1227 | 1227 | $dbw = wfGetDB( DB_MASTER ); |
1228 | 1228 | $dbw->begin(); |
1229 | 1229 | $res = $dbw->delete( 'cn_assignments', array ( 'not_id' => $campaignId ) ); |
— | — | @@ -1231,7 +1231,7 @@ |
1232 | 1232 | $res = $dbw->delete( 'cn_notice_projects', array ( 'np_notice_id' => $campaignId ) ); |
1233 | 1233 | $res = $dbw->delete( 'cn_notice_countries', array ( 'nc_notice_id' => $campaignId ) ); |
1234 | 1234 | $dbw->commit(); |
1235 | | - |
| 1235 | + |
1236 | 1236 | return true; |
1237 | 1237 | } |
1238 | 1238 | } |
— | — | @@ -1281,8 +1281,8 @@ |
1282 | 1282 | return null; |
1283 | 1283 | } |
1284 | 1284 | } |
1285 | | - |
1286 | | - /* |
| 1285 | + |
| 1286 | + /** |
1287 | 1287 | * Lookup the name of a campaign based on the campaign ID |
1288 | 1288 | */ |
1289 | 1289 | public static function getNoticeName( $noticeId ) { |
— | — | @@ -1296,7 +1296,7 @@ |
1297 | 1297 | } |
1298 | 1298 | return null; |
1299 | 1299 | } |
1300 | | - |
| 1300 | + |
1301 | 1301 | static function getNoticeProjects( $noticeName ) { |
1302 | 1302 | // Read from the master database to avoid concurrency problems |
1303 | 1303 | $dbr = wfGetDB( DB_MASTER ); |
— | — | @@ -1304,7 +1304,7 @@ |
1305 | 1305 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1306 | 1306 | $projects = array(); |
1307 | 1307 | if ( $row ) { |
1308 | | - $res = $dbr->select( 'cn_notice_projects', 'np_project', |
| 1308 | + $res = $dbr->select( 'cn_notice_projects', 'np_project', |
1309 | 1309 | array( 'np_notice_id' => $row->not_id ) ); |
1310 | 1310 | foreach ( $res as $projectRow ) { |
1311 | 1311 | $projects[] = $projectRow->np_project; |
— | — | @@ -1320,7 +1320,7 @@ |
1321 | 1321 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1322 | 1322 | $languages = array(); |
1323 | 1323 | if ( $row ) { |
1324 | | - $res = $dbr->select( 'cn_notice_languages', 'nl_language', |
| 1324 | + $res = $dbr->select( 'cn_notice_languages', 'nl_language', |
1325 | 1325 | array( 'nl_notice_id' => $row->not_id ) ); |
1326 | 1326 | foreach ( $res as $langRow ) { |
1327 | 1327 | $languages[] = $langRow->nl_language; |
— | — | @@ -1328,7 +1328,7 @@ |
1329 | 1329 | } |
1330 | 1330 | return $languages; |
1331 | 1331 | } |
1332 | | - |
| 1332 | + |
1333 | 1333 | static function getNoticeCountries( $noticeName ) { |
1334 | 1334 | // Read from the master database to avoid concurrency problems |
1335 | 1335 | $dbr = wfGetDB( DB_MASTER ); |
— | — | @@ -1336,7 +1336,7 @@ |
1337 | 1337 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1338 | 1338 | $countries = array(); |
1339 | 1339 | if ( $row ) { |
1340 | | - $res = $dbr->select( 'cn_notice_countries', 'nc_country', |
| 1340 | + $res = $dbr->select( 'cn_notice_countries', 'nc_country', |
1341 | 1341 | array( 'nc_notice_id' => $row->not_id ) ); |
1342 | 1342 | foreach ( $res as $countryRow ) { |
1343 | 1343 | $countries[] = $countryRow->nc_country; |
— | — | @@ -1393,7 +1393,7 @@ |
1394 | 1394 | array( 'not_name' => $noticeName ) |
1395 | 1395 | ); |
1396 | 1396 | } |
1397 | | - |
| 1397 | + |
1398 | 1398 | /** |
1399 | 1399 | * Update a boolean setting on a campaign |
1400 | 1400 | * @param $noticeName string: Name of the campaign |
— | — | @@ -1437,7 +1437,7 @@ |
1438 | 1438 | $scriptPath = "$wgExtensionAssetsPath/CentralNotice"; |
1439 | 1439 | if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) { |
1440 | 1440 | // Retrieve the list of languages in user's language (via CLDR) |
1441 | | - $languages = LanguageNames::getNames( |
| 1441 | + $languages = LanguageNames::getNames( |
1442 | 1442 | $wgLang->getCode(), // User's language |
1443 | 1443 | LanguageNames::FALLBACK_NORMAL, // Use fallback chain |
1444 | 1444 | LanguageNames::LIST_MW // Pull all languages that are in Names.php |
— | — | @@ -1446,7 +1446,7 @@ |
1447 | 1447 | // Use this as fallback if CLDR extension is not enabled |
1448 | 1448 | $languages = Language::getLanguageNames(); |
1449 | 1449 | } |
1450 | | - // Make sure the site language is in the list; a custom language code |
| 1450 | + // Make sure the site language is in the list; a custom language code |
1451 | 1451 | // might not have a defined name... |
1452 | 1452 | if( !array_key_exists( $wgLanguageCode, $languages ) ) { |
1453 | 1453 | $languages[$wgLanguageCode] = $wgLanguageCode; |
— | — | @@ -1468,32 +1468,32 @@ |
1469 | 1469 | $options |
1470 | 1470 | ); |
1471 | 1471 | $buttons = array(); |
1472 | | - $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . |
| 1472 | + $buttons[] = '<a href="#" onclick="selectLanguages(true);return false;">' . |
1473 | 1473 | wfMsg( 'powersearch-toggleall' ) . '</a>'; |
1474 | | - $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . |
| 1474 | + $buttons[] = '<a href="#" onclick="selectLanguages(false);return false;">' . |
1475 | 1475 | wfMsg( 'powersearch-togglenone' ) . '</a>'; |
1476 | | - $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . |
| 1476 | + $buttons[] = '<a href="#" onclick="top10Languages();return false;">' . |
1477 | 1477 | wfMsg( 'centralnotice-top-ten-languages' ) . '</a>'; |
1478 | 1478 | $htmlOut .= Xml::tags( 'div', |
1479 | 1479 | array( 'style' => 'margin-top: 0.2em;' ), |
1480 | | - '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . |
| 1480 | + '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . |
1481 | 1481 | wfMsg( 'centralnotice-select', $wgLang->commaList( $buttons ) ) |
1482 | 1482 | ); |
1483 | 1483 | } else { |
1484 | 1484 | $htmlOut .= Xml::tags( 'select', |
1485 | | - array( |
1486 | | - 'multiple' => 'multiple', |
1487 | | - 'size' => 4, |
1488 | | - 'id' => 'project_languages[]', |
1489 | | - 'name' => 'project_languages[]', |
1490 | | - 'disabled' => 'disabled' |
| 1485 | + array( |
| 1486 | + 'multiple' => 'multiple', |
| 1487 | + 'size' => 4, |
| 1488 | + 'id' => 'project_languages[]', |
| 1489 | + 'name' => 'project_languages[]', |
| 1490 | + 'disabled' => 'disabled' |
1491 | 1491 | ), |
1492 | 1492 | $options |
1493 | 1493 | ); |
1494 | 1494 | } |
1495 | 1495 | return $htmlOut; |
1496 | 1496 | } |
1497 | | - |
| 1497 | + |
1498 | 1498 | /** |
1499 | 1499 | * Generates a multiple select list of all project types. |
1500 | 1500 | * @param $selected The name of the selected project type |
— | — | @@ -1502,7 +1502,7 @@ |
1503 | 1503 | function projectMultiSelector( $selected = array() ) { |
1504 | 1504 | global $wgNoticeProjects, $wgExtensionAssetsPath, $wgLang; |
1505 | 1505 | $scriptPath = "$wgExtensionAssetsPath/CentralNotice"; |
1506 | | - |
| 1506 | + |
1507 | 1507 | $options = "\n"; |
1508 | 1508 | foreach( $wgNoticeProjects as $project ) { |
1509 | 1509 | $options .= Xml::option( |
— | — | @@ -1518,30 +1518,30 @@ |
1519 | 1519 | $options |
1520 | 1520 | ); |
1521 | 1521 | $buttons = array(); |
1522 | | - $buttons[] = '<a href="#" onclick="selectProjects(true);return false;">' . |
| 1522 | + $buttons[] = '<a href="#" onclick="selectProjects(true);return false;">' . |
1523 | 1523 | wfMsg( 'powersearch-toggleall' ) . '</a>'; |
1524 | | - $buttons[] = '<a href="#" onclick="selectProjects(false);return false;">' . |
| 1524 | + $buttons[] = '<a href="#" onclick="selectProjects(false);return false;">' . |
1525 | 1525 | wfMsg( 'powersearch-togglenone' ) . '</a>'; |
1526 | 1526 | $htmlOut .= Xml::tags( 'div', |
1527 | 1527 | array( 'style' => 'margin-top: 0.2em;' ), |
1528 | | - '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . |
| 1528 | + '<img src="'.$scriptPath.'/up-arrow.png" style="vertical-align:baseline;"/>' . |
1529 | 1529 | wfMsg( 'centralnotice-select', $wgLang->commaList( $buttons ) ) |
1530 | 1530 | ); |
1531 | 1531 | } else { |
1532 | 1532 | $htmlOut .= Xml::tags( 'select', |
1533 | | - array( |
1534 | | - 'multiple' => 'multiple', |
1535 | | - 'size' => 4, |
1536 | | - 'id' => 'projects[]', |
1537 | | - 'name' => 'projects[]', |
1538 | | - 'disabled' => 'disabled' |
| 1533 | + array( |
| 1534 | + 'multiple' => 'multiple', |
| 1535 | + 'size' => 4, |
| 1536 | + 'id' => 'projects[]', |
| 1537 | + 'name' => 'projects[]', |
| 1538 | + 'disabled' => 'disabled' |
1539 | 1539 | ), |
1540 | 1540 | $options |
1541 | 1541 | ); |
1542 | 1542 | } |
1543 | 1543 | return $htmlOut; |
1544 | 1544 | } |
1545 | | - |
| 1545 | + |
1546 | 1546 | function getProjectName( $value ) { |
1547 | 1547 | return $value; // @fixme -- use wfMsg() |
1548 | 1548 | } |
— | — | @@ -1555,17 +1555,17 @@ |
1556 | 1556 | ) |
1557 | 1557 | ); |
1558 | 1558 | } |
1559 | | - |
| 1559 | + |
1560 | 1560 | function updateProjects( $notice, $newProjects ) { |
1561 | 1561 | $dbw = wfGetDB( DB_MASTER ); |
1562 | 1562 | $dbw->begin(); |
1563 | | - |
| 1563 | + |
1564 | 1564 | // Get the previously assigned projects |
1565 | 1565 | $oldProjects = CentralNotice::getNoticeProjects( $notice ); |
1566 | | - |
| 1566 | + |
1567 | 1567 | // Get the notice id |
1568 | 1568 | $row = $dbw->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $notice ) ); |
1569 | | - |
| 1569 | + |
1570 | 1570 | // Add newly assigned projects |
1571 | 1571 | $addProjects = array_diff( $newProjects, $oldProjects ); |
1572 | 1572 | $insertArray = array(); |
— | — | @@ -1573,7 +1573,7 @@ |
1574 | 1574 | $insertArray[] = array( 'np_notice_id' => $row->not_id, 'np_project' => $project ); |
1575 | 1575 | } |
1576 | 1576 | $res = $dbw->insert( 'cn_notice_projects', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
1577 | | - |
| 1577 | + |
1578 | 1578 | // Remove disassociated projects |
1579 | 1579 | $removeProjects = array_diff( $oldProjects, $newProjects ); |
1580 | 1580 | if ( $removeProjects ) { |
— | — | @@ -1581,20 +1581,20 @@ |
1582 | 1582 | array( 'np_notice_id' => $row->not_id, 'np_project' => $removeProjects ) |
1583 | 1583 | ); |
1584 | 1584 | } |
1585 | | - |
| 1585 | + |
1586 | 1586 | $dbw->commit(); |
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | function updateProjectLanguages( $notice, $newLanguages ) { |
1590 | 1590 | $dbw = wfGetDB( DB_MASTER ); |
1591 | 1591 | $dbw->begin(); |
1592 | | - |
| 1592 | + |
1593 | 1593 | // Get the previously assigned languages |
1594 | 1594 | $oldLanguages = CentralNotice::getNoticeLanguages( $notice ); |
1595 | | - |
| 1595 | + |
1596 | 1596 | // Get the notice id |
1597 | 1597 | $row = $dbw->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $notice ) ); |
1598 | | - |
| 1598 | + |
1599 | 1599 | // Add newly assigned languages |
1600 | 1600 | $addLanguages = array_diff( $newLanguages, $oldLanguages ); |
1601 | 1601 | $insertArray = array(); |
— | — | @@ -1602,7 +1602,7 @@ |
1603 | 1603 | $insertArray[] = array( 'nl_notice_id' => $row->not_id, 'nl_language' => $code ); |
1604 | 1604 | } |
1605 | 1605 | $res = $dbw->insert( 'cn_notice_languages', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
1606 | | - |
| 1606 | + |
1607 | 1607 | // Remove disassociated languages |
1608 | 1608 | $removeLanguages = array_diff( $oldLanguages, $newLanguages ); |
1609 | 1609 | if ( $removeLanguages ) { |
— | — | @@ -1610,19 +1610,19 @@ |
1611 | 1611 | array( 'nl_notice_id' => $row->not_id, 'nl_language' => $removeLanguages ) |
1612 | 1612 | ); |
1613 | 1613 | } |
1614 | | - |
| 1614 | + |
1615 | 1615 | $dbw->commit(); |
1616 | 1616 | } |
1617 | | - |
| 1617 | + |
1618 | 1618 | function updateCountries( $notice, $newCountries ) { |
1619 | 1619 | $dbw = wfGetDB( DB_MASTER ); |
1620 | | - |
| 1620 | + |
1621 | 1621 | // Get the previously assigned languages |
1622 | 1622 | $oldCountries = CentralNotice::getNoticeCountries( $notice ); |
1623 | | - |
| 1623 | + |
1624 | 1624 | // Get the notice id |
1625 | 1625 | $row = $dbw->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $notice ) ); |
1626 | | - |
| 1626 | + |
1627 | 1627 | // Add newly assigned countries |
1628 | 1628 | $addCountries = array_diff( $newCountries, $oldCountries ); |
1629 | 1629 | $insertArray = array(); |
— | — | @@ -1630,7 +1630,7 @@ |
1631 | 1631 | $insertArray[] = array( 'nc_notice_id' => $row->not_id, 'nc_country' => $code ); |
1632 | 1632 | } |
1633 | 1633 | $res = $dbw->insert( 'cn_notice_countries', $insertArray, __METHOD__, array( 'IGNORE' ) ); |
1634 | | - |
| 1634 | + |
1635 | 1635 | // Remove disassociated countries |
1636 | 1636 | $removeCountries = array_diff( $oldCountries, $newCountries ); |
1637 | 1637 | if ( $removeCountries ) { |
— | — | @@ -1639,7 +1639,7 @@ |
1640 | 1640 | ); |
1641 | 1641 | } |
1642 | 1642 | } |
1643 | | - |
| 1643 | + |
1644 | 1644 | public static function dropDownList( $text, $values ) { |
1645 | 1645 | $dropDown = "*{$text}\n"; |
1646 | 1646 | foreach ( $values as $value ) { |
— | — | @@ -1647,7 +1647,7 @@ |
1648 | 1648 | } |
1649 | 1649 | return $dropDown; |
1650 | 1650 | } |
1651 | | - |
| 1651 | + |
1652 | 1652 | public static function paddedRange( $begin, $end ) { |
1653 | 1653 | $unpaddedRange = range( $begin, $end ); |
1654 | 1654 | $paddedRange = array(); |
— | — | @@ -1662,7 +1662,7 @@ |
1663 | 1663 | $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", $message ); |
1664 | 1664 | $this->centralNoticeError = true; |
1665 | 1665 | } |
1666 | | - |
| 1666 | + |
1667 | 1667 | /** |
1668 | 1668 | * Generates a multiple select list of all countries. |
1669 | 1669 | * @param $selected The country codes of the selected countries |
— | — | @@ -1681,29 +1681,29 @@ |
1682 | 1682 | $htmlOut = ''; |
1683 | 1683 | if ( $this->editable ) { |
1684 | 1684 | $htmlOut .= Xml::tags( 'select', |
1685 | | - array( |
1686 | | - 'multiple' => 'multiple', |
1687 | | - 'size' => 5, |
1688 | | - 'id' => 'geo_countries[]', |
1689 | | - 'name' => 'geo_countries[]' |
| 1685 | + array( |
| 1686 | + 'multiple' => 'multiple', |
| 1687 | + 'size' => 5, |
| 1688 | + 'id' => 'geo_countries[]', |
| 1689 | + 'name' => 'geo_countries[]' |
1690 | 1690 | ), |
1691 | 1691 | $options |
1692 | 1692 | ); |
1693 | 1693 | } else { |
1694 | 1694 | $htmlOut .= Xml::tags( 'select', |
1695 | | - array( |
1696 | | - 'multiple' => 'multiple', |
1697 | | - 'size' => 5, |
1698 | | - 'id' => 'geo_countries[]', |
1699 | | - 'name' => 'geo_countries[]', |
1700 | | - 'disabled' => 'disabled' |
| 1695 | + array( |
| 1696 | + 'multiple' => 'multiple', |
| 1697 | + 'size' => 5, |
| 1698 | + 'id' => 'geo_countries[]', |
| 1699 | + 'name' => 'geo_countries[]', |
| 1700 | + 'disabled' => 'disabled' |
1701 | 1701 | ), |
1702 | 1702 | $options |
1703 | 1703 | ); |
1704 | 1704 | } |
1705 | 1705 | return $htmlOut; |
1706 | 1706 | } |
1707 | | - |
| 1707 | + |
1708 | 1708 | /** |
1709 | 1709 | * Log any changes related to a campaign |
1710 | 1710 | * @param $action string: 'created', 'modified', or 'removed' |
— | — | @@ -1714,16 +1714,16 @@ |
1715 | 1715 | * @param $endAssignments array of banner assignments after changes (optional) |
1716 | 1716 | * @return integer: ID of log entry (or null) |
1717 | 1717 | */ |
1718 | | - function logCampaignChange( $action, $campaignId, $beginSettings = array(), |
| 1718 | + function logCampaignChange( $action, $campaignId, $beginSettings = array(), |
1719 | 1719 | $endSettings = array(), $beginAssignments = array(), $endAssignments = array() ) |
1720 | 1720 | { |
1721 | 1721 | global $wgUser; |
1722 | | - |
| 1722 | + |
1723 | 1723 | // Only log the change if it is done by an actual user (rather than a testing script) |
1724 | 1724 | if ( $wgUser->getId() > 0 ) { // User::getID returns 0 for anonymous or non-existant users |
1725 | | - |
| 1725 | + |
1726 | 1726 | $dbw = wfGetDB( DB_MASTER ); |
1727 | | - |
| 1727 | + |
1728 | 1728 | $log = array( |
1729 | 1729 | 'notlog_timestamp' => $dbw->timestamp(), |
1730 | 1730 | 'notlog_user_id' => $wgUser->getId(), |
— | — | @@ -1731,18 +1731,18 @@ |
1732 | 1732 | 'notlog_not_id' => $campaignId, |
1733 | 1733 | 'notlog_not_name' => CentralNotice::getNoticeName( $campaignId ) |
1734 | 1734 | ); |
1735 | | - |
| 1735 | + |
1736 | 1736 | foreach ( $beginSettings as $key => $value ) { |
1737 | 1737 | $log['notlog_begin_'.$key] = $value; |
1738 | 1738 | } |
1739 | 1739 | foreach ( $endSettings as $key => $value ) { |
1740 | 1740 | $log['notlog_end_'.$key] = $value; |
1741 | 1741 | } |
1742 | | - |
| 1742 | + |
1743 | 1743 | $res = $dbw->insert( 'cn_notice_log', $log ); |
1744 | 1744 | $log_id = $dbw->insertId(); |
1745 | 1745 | return $log_id; |
1746 | | - |
| 1746 | + |
1747 | 1747 | } else { |
1748 | 1748 | return null; |
1749 | 1749 | } |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1750 | 1750 | Merged /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php:r100780 |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1751 | 1751 | Merged /trunk/extensions/CentralNotice/CentralNotice.php:r100100-102469 |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/patches/patch-template_autolink.sql |
___________________________________________________________________ |
Added: svn:mergeinfo |
1752 | 1752 | Merged /trunk/phase3/extensions/CentralNotice/patches/patch-template_autolink.sql:r63545-63546,63549,63643,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,77555,77558-77560,77563-77565,77573 |
1753 | 1753 | Merged /branches/wmf-deployment/extensions/CentralNotice/patches/patch-template_autolink.sql:r60970 |
1754 | 1754 | Merged /branches/wmf/1.16wmf4/extensions/CentralNotice/patches/patch-template_autolink.sql:r67177,69199,76243,77266 |
1755 | 1755 | Merged /trunk/extensions/CentralNotice/patches/patch-template_autolink.sql:r62820-67552,67557,67559-71720,71725-71731,71734-71739,71748-71753,71774-71997,72058-72131,72136-73830,73847,73850,73852,73855,73959,73963,73973,73980,73983,73991,73994-73995,74000-74321,74325-74406,75376-75470,75567,75643,75646,75674,75680,75726,75849,75889,75908,75973,76141,76145,76333,76347,76351,76356-76358,76361,76363,76462,76543,76763,77622-79761,79780,79783-80145,80147-80148,80150,80152-80602,81461-83563,83565-91117,91146,91368-95517,100092-102468 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -11,25 +11,25 @@ |
12 | 12 | class CentralNoticeDB { |
13 | 13 | |
14 | 14 | /* Functions */ |
15 | | - /* |
| 15 | + /** |
16 | 16 | * Return campaigns in the system within given constraints |
17 | 17 | * By default returns enabled campaigns, if $enabled set to false, returns both enabled and disabled campaigns |
18 | 18 | * @return an array of ids |
19 | 19 | */ |
20 | 20 | static function getCampaigns( $project = false, $language = false, $date = false, $enabled = true, $preferred = false, $location = false ) { |
21 | 21 | global $wgCentralDBname; |
22 | | - |
| 22 | + |
23 | 23 | $notices = array(); |
24 | | - |
| 24 | + |
25 | 25 | // Database setup |
26 | 26 | $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
27 | | - |
| 27 | + |
28 | 28 | if ( !$date ) { |
29 | 29 | $encTimestamp = $dbr->addQuotes( $dbr->timestamp() ); |
30 | 30 | } else { |
31 | 31 | $encTimestamp = $dbr->addQuotes( $dbr->timestamp( $date ) ); |
32 | 32 | } |
33 | | - |
| 33 | + |
34 | 34 | $tables = array( 'cn_notices' ); |
35 | 35 | if ( $project ) { |
36 | 36 | $tables[] = 'cn_notice_projects'; |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | foreach ( $res as $row ) { |
73 | 73 | $notices[] = $row->not_id; |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | // If a location is passed, also pull geotargeted campaigns that match the location |
77 | 77 | if ( $location ) { |
78 | 78 | $tables = array( 'cn_notices', 'cn_notice_countries' ); |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | if ( $language ) { |
83 | 83 | $tables[] = 'cn_notice_languages'; |
84 | 84 | } |
85 | | - |
| 85 | + |
86 | 86 | // Use whatever conditional arguments got passed in |
87 | 87 | $conds = array( |
88 | 88 | 'not_geo' => 1, |
— | — | @@ -98,13 +98,13 @@ |
99 | 99 | $conds[] = "nl_notice_id = cn_notices.not_id"; |
100 | 100 | $conds['nl_language'] = $language; |
101 | 101 | } |
102 | | - |
| 102 | + |
103 | 103 | if ( $enabled ) { |
104 | 104 | $conds['not_enabled'] = 1; |
105 | 105 | } |
106 | 106 | if ( $preferred ) { |
107 | 107 | $conds['not_preferred'] = 1; |
108 | | - } |
| 108 | + } |
109 | 109 | // Pull db data |
110 | 110 | $res = $dbr->select( |
111 | 111 | $tables, |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | $conds, |
114 | 114 | __METHOD__ |
115 | 115 | ); |
116 | | - |
| 116 | + |
117 | 117 | // Loop through result set and return ids |
118 | 118 | foreach ( $res as $row ) { |
119 | 119 | $notices[] = $row->not_id; |
— | — | @@ -121,8 +121,8 @@ |
122 | 122 | |
123 | 123 | return $notices; |
124 | 124 | } |
125 | | - |
126 | | - /* |
| 125 | + |
| 126 | + /** |
127 | 127 | * Return settings for a campaign |
128 | 128 | * @param $campaignName string: The name of the campaign |
129 | 129 | * @param $detailed boolean: Whether or not to include targeting and banner assignment info |
— | — | @@ -130,10 +130,10 @@ |
131 | 131 | */ |
132 | 132 | static function getCampaignSettings( $campaignName, $detailed = true ) { |
133 | 133 | global $wgCentralDBname; |
134 | | - |
| 134 | + |
135 | 135 | // Read from the master database to avoid concurrency problems |
136 | 136 | $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname ); |
137 | | - |
| 137 | + |
138 | 138 | $campaign = array(); |
139 | 139 | |
140 | 140 | // Get campaign info from database |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | 'geo' => $row->not_geo |
162 | 162 | ); |
163 | 163 | } |
164 | | - |
| 164 | + |
165 | 165 | if ( $detailed ) { |
166 | 166 | $projects = CentralNotice::getNoticeProjects( $campaignName ); |
167 | 167 | $languages = CentralNotice::getNoticeLanguages( $campaignName ); |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | $campaign['projects'] = implode( ", ", $projects ); |
170 | 170 | $campaign['languages'] = implode( ", ", $languages ); |
171 | 171 | $campaign['countries'] = implode( ", ", $geo_countries ); |
172 | | - |
| 172 | + |
173 | 173 | $bannersIn = CentralNoticeDB::getCampaignBanners( $row->not_id, true ); |
174 | 174 | $bannersOut = array(); |
175 | 175 | // All we want are the banner names and weights |
— | — | @@ -179,11 +179,11 @@ |
180 | 180 | // Encode into a JSON string for storage |
181 | 181 | $campaign['banners'] = FormatJson::encode( $bannersOut ); |
182 | 182 | } |
183 | | - |
| 183 | + |
184 | 184 | return $campaign; |
185 | 185 | } |
186 | 186 | |
187 | | - /* |
| 187 | + /** |
188 | 188 | * Given one or more campaign ids, return all banners bound to them |
189 | 189 | * @param $campaigns array of id numbers |
190 | 190 | * @param $logging boolean whether or not request is for logging (optional) |
— | — | @@ -191,7 +191,7 @@ |
192 | 192 | */ |
193 | 193 | static function getCampaignBanners( $campaigns, $logging = false ) { |
194 | 194 | global $wgCentralDBname; |
195 | | - |
| 195 | + |
196 | 196 | // If logging, read from the master database to avoid concurrency problems |
197 | 197 | if ( $logging ) { |
198 | 198 | $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname ); |
— | — | @@ -241,7 +241,7 @@ |
242 | 242 | } |
243 | 243 | return $banners; |
244 | 244 | } |
245 | | - |
| 245 | + |
246 | 246 | /** |
247 | 247 | * Return settings for a banner |
248 | 248 | * @param $bannerName string name of banner |
— | — | @@ -250,16 +250,16 @@ |
251 | 251 | */ |
252 | 252 | static function getBannerSettings( $bannerName, $logging = false ) { |
253 | 253 | global $wgCentralDBname; |
254 | | - |
| 254 | + |
255 | 255 | $banner = array(); |
256 | | - |
| 256 | + |
257 | 257 | // If logging, read from the master database to avoid concurrency problems |
258 | 258 | if ( $logging ) { |
259 | 259 | $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname ); |
260 | 260 | } else { |
261 | 261 | $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
262 | 262 | } |
263 | | - |
| 263 | + |
264 | 264 | $row = $dbr->selectRow( 'cn_templates', |
265 | 265 | array( |
266 | 266 | 'tmp_display_anon', |
— | — | @@ -271,7 +271,7 @@ |
272 | 272 | array( 'tmp_name' => $bannerName ), |
273 | 273 | __METHOD__ |
274 | 274 | ); |
275 | | - |
| 275 | + |
276 | 276 | if ( $row ) { |
277 | 277 | $banner = array( |
278 | 278 | 'anon' => $row->tmp_display_anon, |
— | — | @@ -281,23 +281,23 @@ |
282 | 282 | 'landingpages' => $row->tmp_landing_pages |
283 | 283 | ); |
284 | 284 | } |
285 | | - |
| 285 | + |
286 | 286 | return $banner; |
287 | 287 | } |
288 | | - |
| 288 | + |
289 | 289 | /** |
290 | | - * Lookup function for active banners under a given language/project/location. This function is |
| 290 | + * Lookup function for active banners under a given language/project/location. This function is |
291 | 291 | * called by SpecialBannerListLoader::getJsonList() in order to build the banner list JSON for |
292 | 292 | * each project. |
293 | 293 | * @return a 2D array of running banners with associated weights and settings |
294 | 294 | */ |
295 | 295 | static function getBannersByTarget( $project, $language, $location = null ) { |
296 | 296 | global $wgCentralDBname; |
297 | | - |
| 297 | + |
298 | 298 | $campaigns = array(); |
299 | 299 | $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
300 | 300 | $encTimestamp = $dbr->addQuotes( $dbr->timestamp() ); |
301 | | - |
| 301 | + |
302 | 302 | // Pull non-geotargeted campaigns |
303 | 303 | $campaignResults1 = $dbr->select( |
304 | 304 | array( |
— | — | @@ -324,12 +324,12 @@ |
325 | 325 | $campaigns[] = $row->not_id; |
326 | 326 | } |
327 | 327 | if ( $location ) { |
328 | | - |
| 328 | + |
329 | 329 | // Normalize location parameter (should be an uppercase 2-letter country code) |
330 | 330 | preg_match( '/[a-zA-Z][a-zA-Z]/', $location, $matches ); |
331 | 331 | if ( $matches ) { |
332 | 332 | $location = strtoupper( $matches[0] ); |
333 | | - |
| 333 | + |
334 | 334 | // Pull geotargeted campaigns |
335 | 335 | $campaignResults2 = $dbr->select( |
336 | 336 | array( |
— | — | @@ -360,7 +360,7 @@ |
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
364 | | - |
| 364 | + |
365 | 365 | $banners = array(); |
366 | 366 | if ( $campaigns ) { |
367 | 367 | // Pull all banners assigned to the campaigns |
— | — | @@ -368,8 +368,8 @@ |
369 | 369 | } |
370 | 370 | return $banners; |
371 | 371 | } |
372 | | - |
373 | | - /* |
| 372 | + |
| 373 | + /** |
374 | 374 | * See if a given campaign exists in the database |
375 | 375 | */ |
376 | 376 | public static function campaignExists( $campaignName ) { |
— | — | @@ -379,8 +379,8 @@ |
380 | 380 | $eCampaignName = htmlspecialchars( $campaignName ); |
381 | 381 | return (bool)$dbr->selectRow( 'cn_notices', 'not_name', array( 'not_name' => $eCampaignName ) ); |
382 | 382 | } |
383 | | - |
384 | | - /* |
| 383 | + |
| 384 | + /** |
385 | 385 | * See if a given banner exists in the database |
386 | 386 | */ |
387 | 387 | public static function bannerExists( $bannerName ) { |
— | — | @@ -395,8 +395,8 @@ |
396 | 396 | return false; |
397 | 397 | } |
398 | 398 | } |
399 | | - |
400 | | - /* |
| 399 | + |
| 400 | + /** |
401 | 401 | * Return all of the available countries for geotargeting |
402 | 402 | * (This should probably be moved to a core database table at some point.) |
403 | 403 | */ |
— | — | @@ -601,6 +601,7 @@ |
602 | 602 | 'SO'=>'Somalia', |
603 | 603 | 'ZA'=>'South Africa', |
604 | 604 | 'KR'=>'South Korea', |
| 605 | + 'SS'=>'South Sudan', |
605 | 606 | 'ES'=>'Spain', |
606 | 607 | 'LK'=>'Sri Lanka', |
607 | 608 | 'SD'=>'Sudan', |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
608 | 609 | Merged /trunk/extensions/CentralNotice/CentralNotice.db.php:r100780-102469 |