Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerListLoader.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
1 | 1 | Merged /branches/wmf-deployment/extensions/CentralNotice/special/SpecialBannerListLoader.php:r60970 |
2 | 2 | Merged /branches/wmf/1.16wmf4/extensions/CentralNotice/special/SpecialBannerListLoader.php:r67177,69199,76243,77266 |
3 | 3 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerListLoader.php: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,75910,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-92408,92767,99341-99496 |
4 | 4 | Merged /trunk/phase3/extensions/CentralNotice/special/SpecialBannerListLoader.php:r63545-63546,63549,63643,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,77555,77558-77560,77563-77565,77573 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerController.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | * In order to circumvent the normal squid cache override we add '/cn.js' to the bannerlist URL. |
45 | 45 | */ |
46 | 46 | function getOutput() { |
47 | | - global $wgCentralPagePath, $wgNoticeFundraisingUrl, $wgContLang; |
| 47 | + global $wgCentralPagePath, $wgContLang; |
48 | 48 | |
49 | 49 | $js = $this->getScriptFunctions() . $this->getToggleScripts(); |
50 | 50 | $js .= <<<JAVASCRIPT |
— | — | @@ -51,10 +51,13 @@ |
52 | 52 | $.ajaxSetup({ cache: true }); |
53 | 53 | $.centralNotice = { |
54 | 54 | 'data': { |
55 | | - 'getVars': {} |
| 55 | + 'getVars': {}, |
| 56 | + 'bannerType': 'default' |
56 | 57 | }, |
57 | 58 | 'fn': { |
58 | 59 | 'loadBanner': function( bannerName, campaign, bannerType ) { |
| 60 | + // Store the bannerType in case we need to set a banner hiding cookie later |
| 61 | + $.centralNotice.data.bannerType = bannerType; |
59 | 62 | // Get the requested banner |
60 | 63 | var bannerPageQuery = $.param( { |
61 | 64 | 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage, |
— | — | @@ -159,9 +162,9 @@ |
160 | 163 | function getScriptFunctions() { |
161 | 164 | global $wgNoticeFundraisingUrl; |
162 | 165 | $script = <<<JAVASCRIPT |
163 | | -function insertBanner(bannerJson) { |
| 166 | +function insertBanner( bannerJson ) { |
164 | 167 | jQuery( 'div#centralNotice' ).prepend( bannerJson.bannerHtml ); |
165 | | - if ( bannerJson.fundraising ) { |
| 168 | + if ( bannerJson.autolink ) { |
166 | 169 | JAVASCRIPT; |
167 | 170 | $script .= "\n\t\tvar url = '" . |
168 | 171 | Xml::escapeJsString( $wgNoticeFundraisingUrl ) . "';\n"; |
— | — | @@ -176,12 +179,13 @@ |
177 | 180 | 'utm_source': bannerJson.bannerName, 'language': wgUserLanguage, |
178 | 181 | 'country': Geo.country |
179 | 182 | } ); |
180 | | - jQuery( '#cn_fundraising_link' ).attr( 'href', url ); |
| 183 | + jQuery( '#cn-landingpage-link' ).attr( 'href', url ); |
181 | 184 | } |
182 | 185 | } |
183 | 186 | } |
184 | | -function hideBanner( bannerType ) { |
| 187 | +function hideBanner() { |
185 | 188 | $( '#centralNotice' ).hide(); // Hide current banner |
| 189 | + var bannerType = $.centralNotice.data.bannerType; |
186 | 190 | if ( bannerType === undefined ) bannerType = 'default'; |
187 | 191 | setBannerHidingCookie( bannerType ); // Hide future banners of the same type |
188 | 192 | } |
— | — | @@ -191,28 +195,10 @@ |
192 | 196 | var work='centralnotice_'+bannerType+'=hide; expires=' + e.toGMTString() + '; path=/'; |
193 | 197 | document.cookie = work; |
194 | 198 | } |
| 199 | +// This function is deprecated |
195 | 200 | function toggleNotice() { |
196 | | - var notice = document.getElementById('centralNotice'); |
197 | | - if (!wgNoticeToggleState) { |
198 | | - notice.className = notice.className.replace('collapsed', 'expanded'); |
199 | | - toggleNoticeCookie('0'); // Expand banners |
200 | | - } else { |
201 | | - notice.className = notice.className.replace('expanded', 'collapsed'); |
202 | | - toggleNoticeCookie('1'); // Collapse banners |
203 | | - } |
204 | | - wgNoticeToggleState = !wgNoticeToggleState; |
| 201 | + hideBanner(); |
205 | 202 | } |
206 | | -function toggleNoticeStyle(elems, display) { |
207 | | - if(elems) |
208 | | - for(var i=0;i<elems.length;i++) |
209 | | - elems[i].style.display = display; |
210 | | -} |
211 | | -function toggleNoticeCookie(state) { |
212 | | - var e = new Date(); |
213 | | - e.setTime( e.getTime() + (7*24*60*60*1000) ); // one week |
214 | | - var work='hidesnmessage='+state+'; expires=' + e.toGMTString() + '; path=/'; |
215 | | - document.cookie = work; |
216 | | -} |
217 | 203 | |
218 | 204 | JAVASCRIPT; |
219 | 205 | return $script; |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerController.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
220 | 206 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerController.php:r95515-97303,97305-100099 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -23,12 +23,9 @@ |
24 | 24 | $this->setHeaders(); |
25 | 25 | $this->outputHeader(); |
26 | 26 | |
27 | | - // Add style file to the output headers |
28 | | - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" ); |
| 27 | + // Output ResourceLoader module for styling and javascript functions |
| 28 | + $wgOut->addModules( 'ext.centralNotice.interface' ); |
29 | 29 | |
30 | | - // Add script file to the output headers |
31 | | - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" ); |
32 | | - |
33 | 30 | // Check permissions |
34 | 31 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
35 | 32 | |
— | — | @@ -58,7 +55,7 @@ |
59 | 56 | if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) { |
60 | 57 | |
61 | 58 | // Handle adding a campaign |
62 | | - if ( $method == 'addNotice' ) { |
| 59 | + if ( $method == 'addCampaign' ) { |
63 | 60 | |
64 | 61 | $noticeName = $wgRequest->getVal( 'noticeName' ); |
65 | 62 | $start = $wgRequest->getArray( 'start' ); |
— | — | @@ -69,7 +66,7 @@ |
70 | 67 | if ( $noticeName == '' ) { |
71 | 68 | $this->showError( 'centralnotice-null-string' ); |
72 | 69 | } else { |
73 | | - $this->addNotice( $noticeName, '0', $start, $projects, |
| 70 | + $this->addCampaign( $noticeName, '0', $start, $projects, |
74 | 71 | $project_languages, $geotargeted, $geo_countries ); |
75 | 72 | } |
76 | 73 | |
— | — | @@ -77,11 +74,11 @@ |
78 | 75 | } else { |
79 | 76 | |
80 | 77 | // Handle removing campaigns |
81 | | - $toRemove = $wgRequest->getArray( 'removeNotices' ); |
| 78 | + $toRemove = $wgRequest->getArray( 'removeCampaigns' ); |
82 | 79 | if ( $toRemove ) { |
83 | 80 | // Remove campaigns in list |
84 | 81 | foreach ( $toRemove as $notice ) { |
85 | | - $this->removeNotice( $notice ); |
| 82 | + $this->removeCampaign( $notice ); |
86 | 83 | } |
87 | 84 | } |
88 | 85 | |
— | — | @@ -271,7 +268,7 @@ |
272 | 269 | */ |
273 | 270 | public static function getDateRanges() { |
274 | 271 | $dateRanges = array(); |
275 | | - $dateRanges['years'] = range( 2011, date("Y") ); |
| 272 | + $dateRanges['years'] = range( date('Y'), date('Y') + 1 ); // this year and next year |
276 | 273 | $dateRanges['months'] = CentralNotice::paddedRange( 1, 12 ); |
277 | 274 | $dateRanges['days'] = CentralNotice::paddedRange( 1, 31 ); |
278 | 275 | return $dateRanges; |
— | — | @@ -464,7 +461,7 @@ |
465 | 462 | |
466 | 463 | if ( $this->editable ) { |
467 | 464 | // Remove |
468 | | - $fields[] = Xml::check( 'removeNotices[]', false, |
| 465 | + $fields[] = Xml::check( 'removeCampaigns[]', false, |
469 | 466 | array( 'value' => $row->not_name, 'class' => 'noshiftselect' ) ); |
470 | 467 | } |
471 | 468 | |
— | — | @@ -506,7 +503,7 @@ |
507 | 504 | if ( $this->editable ) { |
508 | 505 | |
509 | 506 | // If there was an error, we'll need to restore the state of the form |
510 | | - if ( $wgRequest->wasPosted() && ( $wgRequest->getVal( 'method' ) == 'addNotice' ) ) { |
| 507 | + if ( $wgRequest->wasPosted() && ( $wgRequest->getVal( 'method' ) == 'addCampaign' ) ) { |
511 | 508 | $startArray = $wgRequest->getArray( 'start' ); |
512 | 509 | $startTimestamp = $startArray['year'] . |
513 | 510 | $startArray['month'] . |
— | — | @@ -529,7 +526,7 @@ |
530 | 527 | $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) ); |
531 | 528 | $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-add-notice' ) ); |
532 | 529 | $htmlOut .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ); |
533 | | - $htmlOut .= Html::hidden( 'method', 'addNotice' ); |
| 530 | + $htmlOut .= Html::hidden( 'method', 'addCampaign' ); |
534 | 531 | |
535 | 532 | $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9 ) ); |
536 | 533 | |
— | — | @@ -605,7 +602,7 @@ |
606 | 603 | global $wgOut, $wgRequest, $wgUser; |
607 | 604 | |
608 | 605 | // Make sure notice exists |
609 | | - if ( !$this->noticeExists( $notice ) ) { |
| 606 | + if ( !CentralNoticeDB::campaignExists( $notice ) ) { |
610 | 607 | $this->showError( 'centralnotice-notice-doesnt-exist' ); |
611 | 608 | } else { |
612 | 609 | |
— | — | @@ -617,7 +614,7 @@ |
618 | 615 | |
619 | 616 | // Handle removing campaign |
620 | 617 | if ( $wgRequest->getVal( 'remove' ) ) { |
621 | | - $this->removeNotice( $notice ); |
| 618 | + $this->removeCampaign( $notice ); |
622 | 619 | if ( !$this->centralNoticeError ) { |
623 | 620 | // Leave campaign detail interface |
624 | 621 | $wgOut->redirect( $this->getTitle()->getLocalUrl() ); |
— | — | @@ -1091,18 +1088,29 @@ |
1092 | 1089 | return $htmlOut; |
1093 | 1090 | } |
1094 | 1091 | |
1095 | | - function addNotice( $noticeName, $enabled, $start, $projects, |
| 1092 | + /** |
| 1093 | + * Add a new campaign to the database |
| 1094 | + * @param $noticeName string: Name of the campaign |
| 1095 | + * @param $enabled int: Boolean setting, 0 or 1 |
| 1096 | + * @param $start array: Start date and time |
| 1097 | + * @param $projects array: Targeted project types (wikipedia, wikibooks, etc.) |
| 1098 | + * @param $project_languages array: Targeted project languages (en, de, etc.) |
| 1099 | + * @param $geotargeted int: Boolean setting, 0 or 1 |
| 1100 | + * @param $geo_countries array: Targeted countries |
| 1101 | + * @return true or null |
| 1102 | + */ |
| 1103 | + function addCampaign( $noticeName, $enabled, $start, $projects, |
1096 | 1104 | $project_languages, $geotargeted, $geo_countries ) |
1097 | 1105 | { |
1098 | | - if ( $this->noticeExists( $noticeName ) ) { |
| 1106 | + if ( CentralNoticeDB::campaignExists( $noticeName ) ) { |
1099 | 1107 | $this->showError( 'centralnotice-notice-exists' ); |
1100 | | - return; |
| 1108 | + return null; |
1101 | 1109 | } elseif ( empty( $projects ) ) { |
1102 | 1110 | $this->showError( 'centralnotice-no-project' ); |
1103 | | - return; |
| 1111 | + return null; |
1104 | 1112 | } elseif ( empty( $project_languages ) ) { |
1105 | 1113 | $this->showError( 'centralnotice-no-language' ); |
1106 | | - return; |
| 1114 | + return null; |
1107 | 1115 | } else { |
1108 | 1116 | if ( !$geo_countries ) $geo_countries = array(); |
1109 | 1117 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -1138,82 +1146,93 @@ |
1139 | 1147 | ); |
1140 | 1148 | $not_id = $dbw->insertId(); |
1141 | 1149 | |
1142 | | - // Do multi-row insert for campaign projects |
1143 | | - $insertArray = array(); |
1144 | | - foreach( $projects as $project ) { |
1145 | | - $insertArray[] = array( 'np_notice_id' => $not_id, 'np_project' => $project ); |
1146 | | - } |
1147 | | - $res = $dbw->insert( 'cn_notice_projects', $insertArray, |
1148 | | - __METHOD__, array( 'IGNORE' ) ); |
1149 | | - |
1150 | | - // Do multi-row insert for campaign languages |
1151 | | - $insertArray = array(); |
1152 | | - foreach( $project_languages as $code ) { |
1153 | | - $insertArray[] = array( 'nl_notice_id' => $not_id, 'nl_language' => $code ); |
1154 | | - } |
1155 | | - $res = $dbw->insert( 'cn_notice_languages', $insertArray, |
1156 | | - __METHOD__, array( 'IGNORE' ) ); |
| 1150 | + if ( $not_id ) { |
1157 | 1151 | |
1158 | | - if ( $geotargeted ) { |
1159 | | - // Do multi-row insert for campaign countries |
| 1152 | + // Do multi-row insert for campaign projects |
1160 | 1153 | $insertArray = array(); |
1161 | | - foreach( $geo_countries as $code ) { |
1162 | | - $insertArray[] = array( 'nc_notice_id' => $not_id, 'nc_country' => $code ); |
| 1154 | + foreach( $projects as $project ) { |
| 1155 | + $insertArray[] = array( 'np_notice_id' => $not_id, 'np_project' => $project ); |
1163 | 1156 | } |
1164 | | - $res = $dbw->insert( 'cn_notice_countries', $insertArray, |
| 1157 | + $res = $dbw->insert( 'cn_notice_projects', $insertArray, |
1165 | 1158 | __METHOD__, array( 'IGNORE' ) ); |
| 1159 | + |
| 1160 | + // Do multi-row insert for campaign languages |
| 1161 | + $insertArray = array(); |
| 1162 | + foreach( $project_languages as $code ) { |
| 1163 | + $insertArray[] = array( 'nl_notice_id' => $not_id, 'nl_language' => $code ); |
| 1164 | + } |
| 1165 | + $res = $dbw->insert( 'cn_notice_languages', $insertArray, |
| 1166 | + __METHOD__, array( 'IGNORE' ) ); |
| 1167 | + |
| 1168 | + if ( $geotargeted ) { |
| 1169 | + // Do multi-row insert for campaign countries |
| 1170 | + $insertArray = array(); |
| 1171 | + foreach( $geo_countries as $code ) { |
| 1172 | + $insertArray[] = array( 'nc_notice_id' => $not_id, 'nc_country' => $code ); |
| 1173 | + } |
| 1174 | + $res = $dbw->insert( 'cn_notice_countries', $insertArray, |
| 1175 | + __METHOD__, array( 'IGNORE' ) ); |
| 1176 | + } |
| 1177 | + |
| 1178 | + $dbw->commit(); |
| 1179 | + |
| 1180 | + // Log the creation of the campaign |
| 1181 | + $beginSettings = array(); |
| 1182 | + $endSettings = array( |
| 1183 | + 'projects' => implode( ", ", $projects ), |
| 1184 | + 'languages' => implode( ", ", $project_languages ), |
| 1185 | + 'countries' => implode( ", ", $geo_countries ), |
| 1186 | + 'start' => $dbw->timestamp( $startTs ), |
| 1187 | + 'end' => $dbw->timestamp( $endTs ), |
| 1188 | + 'enabled' => $enabled, |
| 1189 | + 'preferred' => 0, |
| 1190 | + 'locked' => 0, |
| 1191 | + 'geo' => $geotargeted |
| 1192 | + ); |
| 1193 | + $this->logCampaignChange( 'created', $not_id, $beginSettings, $endSettings ); |
| 1194 | + |
| 1195 | + return true; |
| 1196 | + |
| 1197 | + } else { |
| 1198 | + return null; |
1166 | 1199 | } |
1167 | | - |
1168 | | - $dbw->commit(); |
1169 | | - |
1170 | | - // Log the creation of the campaign |
1171 | | - $beginSettings = array(); |
1172 | | - $endSettings = array( |
1173 | | - 'projects' => implode( ", ", $projects ), |
1174 | | - 'languages' => implode( ", ", $project_languages ), |
1175 | | - 'countries' => implode( ", ", $geo_countries ), |
1176 | | - 'start' => $dbw->timestamp( $startTs ), |
1177 | | - 'end' => $dbw->timestamp( $endTs ), |
1178 | | - 'enabled' => $enabled, |
1179 | | - 'preferred' => 0, |
1180 | | - 'locked' => 0, |
1181 | | - 'geo' => $geotargeted |
1182 | | - ); |
1183 | | - $this->logCampaignChange( 'created', $not_id, $beginSettings, $endSettings ); |
1184 | | - |
1185 | | - return; |
1186 | 1200 | } |
1187 | 1201 | } |
1188 | 1202 | |
1189 | | - function removeNotice( $noticeName ) { |
| 1203 | + /** |
| 1204 | + * Remove a campaign from the database |
| 1205 | + * @param $noticeName string: Name of the campaign |
| 1206 | + * @return true or null |
| 1207 | + */ |
| 1208 | + function removeCampaign( $campaignName ) { |
1190 | 1209 | $dbr = wfGetDB( DB_SLAVE ); |
1191 | 1210 | |
1192 | 1211 | $res = $dbr->select( 'cn_notices', 'not_name, not_locked', |
1193 | | - array( 'not_name' => $noticeName ) |
| 1212 | + array( 'not_name' => $campaignName ) |
1194 | 1213 | ); |
1195 | 1214 | if ( $dbr->numRows( $res ) < 1 ) { |
1196 | 1215 | $this->showError( 'centralnotice-remove-notice-doesnt-exist' ); |
1197 | | - return; |
| 1216 | + return null; |
1198 | 1217 | } |
1199 | 1218 | $row = $dbr->fetchObject( $res ); |
1200 | 1219 | if ( $row->not_locked == '1' ) { |
1201 | 1220 | $this->showError( 'centralnotice-notice-is-locked' ); |
1202 | | - return; |
| 1221 | + return null; |
1203 | 1222 | } else { |
1204 | 1223 | // Log the removal of the campaign |
1205 | | - $noticeId = CentralNotice::getNoticeId( $noticeName ); |
1206 | | - $this->logCampaignChange( 'removed', $noticeId ); |
| 1224 | + $campaignId = CentralNotice::getNoticeId( $campaignName ); |
| 1225 | + $this->logCampaignChange( 'removed', $campaignId ); |
1207 | 1226 | |
1208 | 1227 | $dbw = wfGetDB( DB_MASTER ); |
1209 | 1228 | $dbw->begin(); |
1210 | | - $res = $dbw->delete( 'cn_assignments', array ( 'not_id' => $noticeId ) ); |
1211 | | - $res = $dbw->delete( 'cn_notices', array ( 'not_name' => $noticeName ) ); |
1212 | | - $res = $dbw->delete( 'cn_notice_languages', array ( 'nl_notice_id' => $noticeId ) ); |
1213 | | - $res = $dbw->delete( 'cn_notice_projects', array ( 'np_notice_id' => $noticeId ) ); |
1214 | | - $res = $dbw->delete( 'cn_notice_countries', array ( 'nc_notice_id' => $noticeId ) ); |
| 1229 | + $res = $dbw->delete( 'cn_assignments', array ( 'not_id' => $campaignId ) ); |
| 1230 | + $res = $dbw->delete( 'cn_notices', array ( 'not_name' => $campaignName ) ); |
| 1231 | + $res = $dbw->delete( 'cn_notice_languages', array ( 'nl_notice_id' => $campaignId ) ); |
| 1232 | + $res = $dbw->delete( 'cn_notice_projects', array ( 'np_notice_id' => $campaignId ) ); |
| 1233 | + $res = $dbw->delete( 'cn_notice_countries', array ( 'nc_notice_id' => $campaignId ) ); |
1215 | 1234 | $dbw->commit(); |
1216 | 1235 | |
1217 | | - return; |
| 1236 | + return true; |
1218 | 1237 | } |
1219 | 1238 | } |
1220 | 1239 | |
— | — | @@ -1356,7 +1375,7 @@ |
1357 | 1376 | } |
1358 | 1377 | |
1359 | 1378 | // Invalid campaign name |
1360 | | - if ( !$this->noticeExists( $noticeName ) ) { |
| 1379 | + if ( !CentralNoticeDB::campaignExists( $noticeName ) ) { |
1361 | 1380 | $this->showError( 'centralnotice-notice-doesnt-exist' ); |
1362 | 1381 | return; |
1363 | 1382 | } |
— | — | @@ -1379,10 +1398,10 @@ |
1380 | 1399 | * Update a boolean setting on a campaign |
1381 | 1400 | * @param $noticeName string: Name of the campaign |
1382 | 1401 | * @param $settingName string: Name of a boolean setting (enabled, preferred, locked, or geo) |
1383 | | - * @param $settingValue boolean: Value to use for the setting |
| 1402 | + * @param $settingValue int: Value to use for the setting, 0 or 1 |
1384 | 1403 | */ |
1385 | 1404 | private function setBooleanCampaignSetting( $noticeName, $settingName, $settingValue ) { |
1386 | | - if ( !$this->noticeExists( $noticeName ) ) { |
| 1405 | + if ( !CentralNoticeDB::campaignExists( $noticeName ) ) { |
1387 | 1406 | // Exit quietly since campaign may have been deleted at the same time. |
1388 | 1407 | return; |
1389 | 1408 | } else { |
— | — | @@ -1621,17 +1640,6 @@ |
1622 | 1641 | } |
1623 | 1642 | } |
1624 | 1643 | |
1625 | | - public static function noticeExists( $noticeName ) { |
1626 | | - $dbr = wfGetDB( DB_SLAVE ); |
1627 | | - $eNoticeName = htmlspecialchars( $noticeName ); |
1628 | | - $row = $dbr->selectRow( 'cn_notices', 'not_name', array( 'not_name' => $eNoticeName ) ); |
1629 | | - if ( $row ) { |
1630 | | - return true; |
1631 | | - } else { |
1632 | | - return false; |
1633 | | - } |
1634 | | - } |
1635 | | - |
1636 | 1644 | public static function dropDownList( $text, $values ) { |
1637 | 1645 | $dropDown = "*{$text}\n"; |
1638 | 1646 | foreach ( $values as $value ) { |
— | — | @@ -1704,31 +1712,39 @@ |
1705 | 1713 | * @param $endSettings array of campaign settings after changes (optional) |
1706 | 1714 | * @param $beginAssignments array of banner assignments before changes (optional) |
1707 | 1715 | * @param $endAssignments array of banner assignments after changes (optional) |
| 1716 | + * @return integer: ID of log entry (or null) |
1708 | 1717 | */ |
1709 | 1718 | function logCampaignChange( $action, $campaignId, $beginSettings = array(), |
1710 | 1719 | $endSettings = array(), $beginAssignments = array(), $endAssignments = array() ) |
1711 | 1720 | { |
1712 | 1721 | global $wgUser; |
1713 | 1722 | |
1714 | | - $dbw = wfGetDB( DB_MASTER ); |
| 1723 | + // Only log the change if it is done by an actual user (rather than a testing script) |
| 1724 | + if ( $wgUser->getId() > 0 ) { // User::getID returns 0 for anonymous or non-existant users |
1715 | 1725 | |
1716 | | - $log = array( |
1717 | | - 'notlog_timestamp' => $dbw->timestamp(), |
1718 | | - 'notlog_user_id' => $wgUser->getId(), |
1719 | | - 'notlog_action' => $action, |
1720 | | - 'notlog_not_id' => $campaignId, |
1721 | | - 'notlog_not_name' => CentralNotice::getNoticeName( $campaignId ) |
1722 | | - ); |
1723 | | - |
1724 | | - foreach ( $beginSettings as $key => $value ) { |
1725 | | - $log['notlog_begin_'.$key] = $value; |
| 1726 | + $dbw = wfGetDB( DB_MASTER ); |
| 1727 | + |
| 1728 | + $log = array( |
| 1729 | + 'notlog_timestamp' => $dbw->timestamp(), |
| 1730 | + 'notlog_user_id' => $wgUser->getId(), |
| 1731 | + 'notlog_action' => $action, |
| 1732 | + 'notlog_not_id' => $campaignId, |
| 1733 | + 'notlog_not_name' => CentralNotice::getNoticeName( $campaignId ) |
| 1734 | + ); |
| 1735 | + |
| 1736 | + foreach ( $beginSettings as $key => $value ) { |
| 1737 | + $log['notlog_begin_'.$key] = $value; |
| 1738 | + } |
| 1739 | + foreach ( $endSettings as $key => $value ) { |
| 1740 | + $log['notlog_end_'.$key] = $value; |
| 1741 | + } |
| 1742 | + |
| 1743 | + $res = $dbw->insert( 'cn_notice_log', $log ); |
| 1744 | + $log_id = $dbw->insertId(); |
| 1745 | + return $log_id; |
| 1746 | + |
| 1747 | + } else { |
| 1748 | + return null; |
1726 | 1749 | } |
1727 | | - foreach ( $endSettings as $key => $value ) { |
1728 | | - $log['notlog_end_'.$key] = $value; |
1729 | | - } |
1730 | | - |
1731 | | - $res = $dbw->insert( 'cn_notice_log', $log ); |
1732 | | - $log_id = $dbw->insertId(); |
1733 | | - return $log_id; |
1734 | 1750 | } |
1735 | 1751 | } |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1736 | 1752 | Merged /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php:r92510,92516,92676,95516-100099 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerAllocation.php |
— | — | @@ -31,12 +31,9 @@ |
32 | 32 | // Begin output |
33 | 33 | $this->setHeaders(); |
34 | 34 | |
35 | | - // Add style file to the output headers |
36 | | - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" ); |
| 35 | + // Output ResourceLoader module for styling and javascript functions |
| 36 | + $wgOut->addModules( 'ext.centralNotice.interface' ); |
37 | 37 | |
38 | | - // Add script file to the output headers |
39 | | - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" ); |
40 | | - |
41 | 38 | // Initialize error variable |
42 | 39 | $this->centralNoticeError = false; |
43 | 40 | |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerAllocation.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
44 | 41 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php:r99189 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php |
— | — | @@ -75,6 +75,7 @@ |
76 | 76 | 'bannerHtml' => $bannerHtml, |
77 | 77 | 'campaign' => $this->campaign, |
78 | 78 | 'fundraising' => $this->getFundraising( $bannerName ), |
| 79 | + 'autolink' => $this->getAutolink( $bannerName ), |
79 | 80 | 'landingPages' => $this->getLandingPages( $bannerName ) |
80 | 81 | ); |
81 | 82 | $bannerJs = 'insertBanner('.FormatJson::encode( $bannerArray ).');'; |
— | — | @@ -203,6 +204,14 @@ |
204 | 205 | return $row->tmp_fundraising; |
205 | 206 | } |
206 | 207 | |
| 208 | + function getAutolink( $bannerName ) { |
| 209 | + global $wgCentralDBname; |
| 210 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
| 211 | + $eBannerName = htmlspecialchars( $bannerName ); |
| 212 | + $row = $dbr->selectRow( 'cn_templates', 'tmp_autolink', array( 'tmp_name' => $eBannerName ) ); |
| 213 | + return $row->tmp_autolink; |
| 214 | + } |
| 215 | + |
207 | 216 | function getLandingPages( $bannerName ) { |
208 | 217 | global $wgCentralDBname; |
209 | 218 | $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
210 | 219 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php:r99160-99181 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php |
— | — | @@ -22,17 +22,8 @@ |
23 | 23 | // Begin output |
24 | 24 | $this->setHeaders(); |
25 | 25 | |
26 | | - // Add style file to the output headers |
27 | | - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" ); |
28 | | - |
29 | | - // Add localized script error messages |
30 | | - $scriptVars = array( |
31 | | - 'documentWriteError' => wfMsg( 'centralnotice-documentwrite-error' ) |
32 | | - ); |
33 | | - $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
34 | | - |
35 | | - // Add script file to the output headers |
36 | | - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" ); |
| 26 | + // Output ResourceLoader module for styling and javascript functions |
| 27 | + $wgOut->addModules( 'ext.centralNotice.interface' ); |
37 | 28 | |
38 | 29 | // Check permissions |
39 | 30 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
— | — | @@ -90,6 +81,7 @@ |
91 | 82 | $wgRequest->getBool( 'displayAnon' ), |
92 | 83 | $wgRequest->getBool( 'displayAccount' ), |
93 | 84 | $wgRequest->getBool( 'fundraising' ), |
| 85 | + $wgRequest->getBool( 'autolink' ), |
94 | 86 | $wgRequest->getVal( 'landingPages' ) |
95 | 87 | ); |
96 | 88 | $sub = 'view'; |
— | — | @@ -106,6 +98,7 @@ |
107 | 99 | $wgRequest->getBool( 'displayAnon' ), |
108 | 100 | $wgRequest->getBool( 'displayAccount' ), |
109 | 101 | $wgRequest->getBool( 'fundraising' ), |
| 102 | + $wgRequest->getBool( 'autolink' ), |
110 | 103 | $wgRequest->getVal( 'landingPages' ) |
111 | 104 | ); |
112 | 105 | $sub = 'view'; |
— | — | @@ -238,6 +231,7 @@ |
239 | 232 | $displayAnon = $wgRequest->getCheck( 'displayAnon' ); |
240 | 233 | $displayAccount = $wgRequest->getCheck( 'displayAccount' ); |
241 | 234 | $fundraising = $wgRequest->getCheck( 'fundraising' ); |
| 235 | + $autolink = $wgRequest->getCheck( 'autolink' ); |
242 | 236 | $landingPages = $wgRequest->getVal( 'landingPages' ); |
243 | 237 | $body = $wgRequest->getVal( 'templateBody' ); |
244 | 238 | } else { // Use default values |
— | — | @@ -245,6 +239,7 @@ |
246 | 240 | $displayAnon = true; |
247 | 241 | $displayAccount = true; |
248 | 242 | $fundraising = false; |
| 243 | + $autolink = false; |
249 | 244 | $landingPages = ''; |
250 | 245 | $body = ''; |
251 | 246 | } |
— | — | @@ -268,13 +263,24 @@ |
269 | 264 | |
270 | 265 | // Fundraising settings |
271 | 266 | if ( $wgNoticeEnableFundraising ) { |
| 267 | + |
| 268 | + // Checkbox for indicating if it is a fundraising banner |
272 | 269 | $htmlOut .= Html::openElement( 'p', null ); |
273 | 270 | $htmlOut .= Xml::check( 'fundraising', $fundraising, array( 'id' => 'fundraising' ) ); |
274 | 271 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ), 'fundraising' ); |
275 | 272 | $htmlOut .= Html::closeElement( 'p' ); |
| 273 | + |
| 274 | + // Checkbox for whether or not to automatically create landing page link |
| 275 | + $htmlOut .= Html::openElement( 'p', null ); |
| 276 | + $htmlOut .= Xml::check( 'autolink', $autolink, array( 'id' => 'autolink' ) ); |
| 277 | + $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-autolink' ), 'autolink' ); |
| 278 | + $htmlOut .= Html::closeElement( 'p' ); |
| 279 | + |
| 280 | + // Interface for setting the landing pages |
276 | 281 | $htmlOut .= Html::openElement( 'div', |
277 | | - array( 'id' => 'fundraisingInterface', 'style' => 'display: none;' ) ); |
278 | | - $htmlOut .= Xml::tags( 'p', array(), wfMsg( 'centralnotice-banner-fundraising-help' ) ); |
| 282 | + array( 'id' => 'autolinkInterface', 'style' => 'display: none;' ) ); |
| 283 | + $htmlOut .= Xml::tags( 'p', array(), |
| 284 | + wfMsg( 'centralnotice-banner-autolink-help', 'id="cn-landingpage-link"', 'JimmyAppeal01' ) ); |
279 | 285 | $htmlOut .= Xml::tags( 'p', array(), |
280 | 286 | Xml::inputLabel( |
281 | 287 | wfMsg( 'centralnotice-banner-landing-pages' ), |
— | — | @@ -548,12 +554,14 @@ |
549 | 555 | $displayAnon = $wgRequest->getCheck( 'displayAnon' ); |
550 | 556 | $displayAccount = $wgRequest->getCheck( 'displayAccount' ); |
551 | 557 | $fundraising = $wgRequest->getCheck( 'fundraising' ); |
| 558 | + $autolink = $wgRequest->getCheck( 'autolink' ); |
552 | 559 | $landingPages = $wgRequest->getVal( 'landingPages' ); |
553 | 560 | $body = $wgRequest->getVal( 'templateBody', $body ); |
554 | 561 | } else { // Use previously stored values |
555 | 562 | $displayAnon = ( $bannerSettings['anon'] == 1 ); |
556 | 563 | $displayAccount = ( $bannerSettings['account'] == 1 ); |
557 | 564 | $fundraising = ( $bannerSettings['fundraising'] == 1 ); |
| 565 | + $autolink = ( $bannerSettings['autolink'] == 1 ); |
558 | 566 | $landingPages = $bannerSettings['landingpages']; |
559 | 567 | // $body default is defined prior to message interface code |
560 | 568 | } |
— | — | @@ -572,20 +580,32 @@ |
573 | 581 | |
574 | 582 | // Fundraising settings |
575 | 583 | if ( $wgNoticeEnableFundraising ) { |
| 584 | + |
| 585 | + // Checkbox for indicating if it is a fundraising banner |
576 | 586 | $htmlOut .= Html::openElement( 'p', null ); |
577 | 587 | $htmlOut .= Xml::check( 'fundraising', $fundraising, |
578 | 588 | wfArrayMerge( $disabled, array( 'id' => 'fundraising' ) ) ); |
579 | 589 | $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ), |
580 | 590 | 'fundraising' ); |
581 | 591 | $htmlOut .= Html::closeElement( 'p' ); |
582 | | - if ( $fundraising ) { |
583 | | - $htmlOut .= Html::openElement( 'div', array( 'id'=>'fundraisingInterface' ) ); |
| 592 | + |
| 593 | + // Checkbox for whether or not to automatically create landing page link |
| 594 | + $htmlOut .= Html::openElement( 'p', null ); |
| 595 | + $htmlOut .= Xml::check( 'autolink', $autolink, |
| 596 | + wfArrayMerge( $disabled, array( 'id' => 'autolink' ) ) ); |
| 597 | + $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-autolink' ), |
| 598 | + 'autolink' ); |
| 599 | + $htmlOut .= Html::closeElement( 'p' ); |
| 600 | + |
| 601 | + // Interface for setting the landing pages |
| 602 | + if ( $autolink ) { |
| 603 | + $htmlOut .= Html::openElement( 'div', array( 'id'=>'autolinkInterface' ) ); |
584 | 604 | } else { |
585 | 605 | $htmlOut .= Html::openElement( 'div', |
586 | | - array( 'id'=>'fundraisingInterface', 'style'=>'display:none;' ) ); |
| 606 | + array( 'id'=>'autolinkInterface', 'style'=>'display:none;' ) ); |
587 | 607 | } |
588 | 608 | $htmlOut .= Xml::tags( 'p', array(), |
589 | | - wfMsg( 'centralnotice-banner-fundraising-help' ) ); |
| 609 | + wfMsg( 'centralnotice-banner-autolink-help', 'id="cn-landingpage-link"', 'JimmyAppeal01' ) ); |
590 | 610 | $htmlOut .= Xml::tags( 'p', array(), |
591 | 611 | Xml::inputLabel( |
592 | 612 | wfMsg( 'centralnotice-banner-landing-pages' ), |
— | — | @@ -594,6 +614,7 @@ |
595 | 615 | ) |
596 | 616 | ); |
597 | 617 | $htmlOut .= Html::closeElement( 'div' ); |
| 618 | + |
598 | 619 | } |
599 | 620 | |
600 | 621 | // Begin banner body section |
— | — | @@ -780,11 +801,12 @@ |
781 | 802 | * @param $displayAnon integer flag for display to anonymous users |
782 | 803 | * @param $displayAccount integer flag for display to logged in users |
783 | 804 | * @param $fundraising integer flag for fundraising banner (optional) |
| 805 | + * @param $autolink integer flag for automatically creating landing page links (optional) |
784 | 806 | * @param $landingPages string list of landing pages (optional) |
785 | 807 | * @return true or false depending on whether banner was successfully added |
786 | 808 | */ |
787 | 809 | public function addTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising = 0, |
788 | | - $landingPages = '' ) { |
| 810 | + $autolink = 0, $landingPages = '' ) { |
789 | 811 | |
790 | 812 | if ( $body == '' || $name == '' ) { |
791 | 813 | $this->showError( 'centralnotice-null-string' ); |
— | — | @@ -813,6 +835,7 @@ |
814 | 836 | 'tmp_display_anon' => $displayAnon, |
815 | 837 | 'tmp_display_account' => $displayAccount, |
816 | 838 | 'tmp_fundraising' => $fundraising, |
| 839 | + 'tmp_autolink' => $autolink, |
817 | 840 | 'tmp_landing_pages' => $landingPages |
818 | 841 | ), |
819 | 842 | __METHOD__ |
— | — | @@ -831,6 +854,7 @@ |
832 | 855 | 'anon' => $displayAnon, |
833 | 856 | 'account' => $displayAccount, |
834 | 857 | 'fundraising' => $fundraising, |
| 858 | + 'autolink' => $autolink, |
835 | 859 | 'landingpages' => $landingPages |
836 | 860 | ); |
837 | 861 | $this->logBannerChange( 'created', $bannerId, $beginSettings, $endSettings ); |
— | — | @@ -843,7 +867,7 @@ |
844 | 868 | * Update a banner |
845 | 869 | */ |
846 | 870 | private function editTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising, |
847 | | - $landingPages ) { |
| 871 | + $autolink, $landingPages ) { |
848 | 872 | |
849 | 873 | if ( $body == '' || $name == '' ) { |
850 | 874 | $this->showError( 'centralnotice-null-string' ); |
— | — | @@ -865,6 +889,7 @@ |
866 | 890 | 'tmp_display_anon' => $displayAnon, |
867 | 891 | 'tmp_display_account' => $displayAccount, |
868 | 892 | 'tmp_fundraising' => $fundraising, |
| 893 | + 'tmp_autolink' => $autolink, |
869 | 894 | 'tmp_landing_pages' => $landingPages |
870 | 895 | ), |
871 | 896 | array( 'tmp_name' => $name ) |
— | — | @@ -911,6 +936,7 @@ |
912 | 937 | 'tmp_display_anon', |
913 | 938 | 'tmp_display_account', |
914 | 939 | 'tmp_fundraising', |
| 940 | + 'tmp_autolink', |
915 | 941 | 'tmp_landing_pages' |
916 | 942 | ), |
917 | 943 | array( 'tmp_name' => $source ), |
— | — | @@ -919,6 +945,7 @@ |
920 | 946 | $displayAnon = $row->tmp_display_anon; |
921 | 947 | $displayAccount = $row->tmp_display_account; |
922 | 948 | $fundraising = $row->tmp_fundraising; |
| 949 | + $autolink = $row->tmp_autolink; |
923 | 950 | $landingPages = $row->tmp_landing_pages; |
924 | 951 | |
925 | 952 | // Pull banner text and respect any inc: markup |
— | — | @@ -927,7 +954,7 @@ |
928 | 955 | |
929 | 956 | // Create new banner |
930 | 957 | if ( $this->addTemplate( $dest, $template_body, $displayAnon, $displayAccount, $fundraising, |
931 | | - $landingPages ) ) { |
| 958 | + $autolink, $landingPages ) ) { |
932 | 959 | |
933 | 960 | // Populate the fields |
934 | 961 | foreach ( $langs as $lang => $fields ) { |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
935 | 962 | Merged /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php:r98908-100099 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
— | — | @@ -24,11 +24,8 @@ |
25 | 25 | // Begin output |
26 | 26 | $this->setHeaders(); |
27 | 27 | |
28 | | - // Add style file to the output headers |
29 | | - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" ); |
30 | | - |
31 | | - // Add script file to the output headers |
32 | | - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" ); |
| 28 | + // Output ResourceLoader module for styling and javascript functions |
| 29 | + $wgOut->addModules( 'ext.centralNotice.interface' ); |
33 | 30 | |
34 | 31 | // Initialize error variable |
35 | 32 | $this->centralNoticeError = false; |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
36 | 33 | Merged /trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php:r99189 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -80,6 +80,15 @@ |
81 | 81 | # Unit tests |
82 | 82 | $wgHooks['UnitTestsList'][] = 'efCentralNoticeUnitTests'; |
83 | 83 | |
| 84 | +// Register ResourceLoader modules |
| 85 | +$wgResourceModules['ext.centralNotice.interface'] = array( |
| 86 | + 'localBasePath' => dirname( __FILE__ ), |
| 87 | + 'remoteExtPath' => 'CentralNotice', |
| 88 | + 'scripts' => 'centralnotice.js', |
| 89 | + 'styles' => 'centralnotice.css', |
| 90 | + 'messages' => 'centralnotice-documentwrite-error' |
| 91 | +); |
| 92 | + |
84 | 93 | function efCentralNoticeUnitTests( &$files ) { |
85 | 94 | $files[] = dirname( __FILE__ ) . '/tests/CentralNoticeTest.php'; |
86 | 95 | return true; |
— | — | @@ -161,6 +170,8 @@ |
162 | 171 | $base . '/patches/patch-notice_log.sql' ); |
163 | 172 | $wgExtNewTables[] = array( 'cn_template_log', |
164 | 173 | $base . '/patches/patch-template_log.sql' ); |
| 174 | + $wgExtNewFields[] = array( 'cn_templates', 'tmp_autolink', |
| 175 | + $base . '/patches/patch-template_autolink.sql' ); |
165 | 176 | } |
166 | 177 | } else { |
167 | 178 | if ( $updater->getDB()->getType() == 'mysql' ) { |
— | — | @@ -182,6 +193,8 @@ |
183 | 194 | $base . '/patches/patch-notice_log.sql', true ) ); |
184 | 195 | $updater->addExtensionUpdate( array( 'addTable', 'cn_template_log', |
185 | 196 | $base . '/patches/patch-template_log.sql', true ) ); |
| 197 | + $updater->addExtensionUpdate( array( 'addField', 'cn_templates', 'tmp_autolink', |
| 198 | + $base . '/patches/patch-template_autolink.sql', true ) ); |
186 | 199 | } |
187 | 200 | } |
188 | 201 | return true; |
— | — | @@ -190,10 +203,10 @@ |
191 | 204 | function efCentralNoticeLoader( $out, $skin ) { |
192 | 205 | global $wgOut; |
193 | 206 | |
194 | | - // Include '.js' to exempt script from squid cache override |
| 207 | + // Include '.js' to exempt script from squid cache expiration override |
195 | 208 | $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl( 'cache=/cn.js' ); |
196 | 209 | |
197 | | - // Insert the banner controller Javascript into the <head> |
| 210 | + // Insert the banner controller Javascript into the page |
198 | 211 | $wgOut->addScriptFile( $centralLoader ); |
199 | 212 | |
200 | 213 | return true; |
— | — | @@ -201,7 +214,7 @@ |
202 | 215 | |
203 | 216 | function efCentralNoticeGeoLoader( $skin, &$text ) { |
204 | 217 | // Insert the geo IP lookup |
205 | | - $text .= '<script type="text/javascript" src="//geoiplookup.wikimedia.org/"></script>'; |
| 218 | + $text .= Html::linkedScript( "//geoiplookup.wikimedia.org/" ); |
206 | 219 | return true; |
207 | 220 | } |
208 | 221 | |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
209 | 222 | Merged /trunk/extensions/CentralNotice/CentralNotice.php:r98917-100099 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNoticeBannerLogPager.php |
— | — | @@ -149,6 +149,11 @@ |
150 | 150 | wfMsg ( 'centralnotice-fundraising' ), |
151 | 151 | ($row->tmplog_end_fundraising ? 'on' : 'off') |
152 | 152 | )."<br/>"; |
| 153 | + $details .= wfMsg ( |
| 154 | + 'centralnotice-log-label', |
| 155 | + wfMsg ( 'centralnotice-autolink' ), |
| 156 | + ($row->tmplog_end_autolink ? 'on' : 'off') |
| 157 | + )."<br/>"; |
153 | 158 | if ( $row->tmplog_end_landingpages ) { |
154 | 159 | $details .= wfMsg ( |
155 | 160 | 'centralnotice-log-label', |
— | — | @@ -165,6 +170,7 @@ |
166 | 171 | $details .= $this->testBooleanChange( 'anon', $row ); |
167 | 172 | $details .= $this->testBooleanChange( 'account', $row ); |
168 | 173 | $details .= $this->testBooleanChange( 'fundraising', $row ); |
| 174 | + $details .= $this->testBooleanChange( 'autolink', $row ); |
169 | 175 | $details .= $this->testTextChange( 'landingpages', $row ); |
170 | 176 | if ( $row->tmplog_content_change ) { |
171 | 177 | // Show changes to banner content |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNoticeBannerLogPager.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
172 | 178 | Merged /trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php:r98918-100099 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -214,6 +214,7 @@ |
215 | 215 | 'tmp_display_anon', |
216 | 216 | 'tmp_display_account', |
217 | 217 | 'tmp_fundraising', |
| 218 | + 'tmp_autolink', |
218 | 219 | 'tmp_landing_pages', |
219 | 220 | 'not_name' |
220 | 221 | ), |
— | — | @@ -232,6 +233,7 @@ |
233 | 234 | 'display_anon' => intval( $row->tmp_display_anon ), // display to anonymous users? |
234 | 235 | 'display_account' => intval( $row->tmp_display_account ), // display to logged in users? |
235 | 236 | 'fundraising' => intval( $row->tmp_fundraising ), // fundraising banner? |
| 237 | + 'autolink' => intval( $row->tmp_autolink ), // automatically create links? |
236 | 238 | 'landing_pages' => $row->tmp_landing_pages, // landing pages to link to |
237 | 239 | 'campaign' => $row->not_name // campaign the banner is assigned to |
238 | 240 | ); |
— | — | @@ -263,6 +265,7 @@ |
264 | 266 | 'tmp_display_anon', |
265 | 267 | 'tmp_display_account', |
266 | 268 | 'tmp_fundraising', |
| 269 | + 'tmp_autolink', |
267 | 270 | 'tmp_landing_pages' |
268 | 271 | ), |
269 | 272 | array( 'tmp_name' => $bannerName ), |
— | — | @@ -274,6 +277,7 @@ |
275 | 278 | 'anon' => $row->tmp_display_anon, |
276 | 279 | 'account' => $row->tmp_display_account, |
277 | 280 | 'fundraising' => $row->tmp_fundraising, |
| 281 | + 'autolink' => $row->tmp_autolink, |
278 | 282 | 'landingpages' => $row->tmp_landing_pages |
279 | 283 | ); |
280 | 284 | } |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
281 | 285 | Merged /trunk/extensions/CentralNotice/CentralNotice.db.php:r95930-100099 |
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/centralnotice.js |
— | — | @@ -1,4 +1,5 @@ |
2 | | -function toggleLogDisplay( logId ) { |
| 2 | +// Collapse and uncollapse detailed view for an individual log entry |
| 3 | +window.toggleLogDisplay = function( logId ) { |
3 | 4 | var thisCollapsed = document.getElementById( 'cn-collapsed-'+logId ); |
4 | 5 | var thisUncollapsed = document.getElementById( 'cn-uncollapsed-'+logId ); |
5 | 6 | var thisDetails = document.getElementById( 'cn-log-details-'+logId ); |
— | — | @@ -11,8 +12,10 @@ |
12 | 13 | thisUncollapsed.style.display = "block"; |
13 | 14 | thisDetails.style.display = "table-row"; |
14 | 15 | } |
15 | | -} |
16 | | -function toggleFilterDisplay() { |
| 16 | +}; |
| 17 | + |
| 18 | +// Collapse and uncollapse log filter interface |
| 19 | +window.toggleFilterDisplay = function() { |
17 | 20 | var thisCollapsed = document.getElementById( 'cn-collapsed-filter-arrow' ); |
18 | 21 | var thisUncollapsed = document.getElementById( 'cn-uncollapsed-filter-arrow' ); |
19 | 22 | var thisFilters = document.getElementById( 'cn-log-filters' ); |
— | — | @@ -25,26 +28,29 @@ |
26 | 29 | thisUncollapsed.style.display = "inline-block"; |
27 | 30 | thisFilters.style.display = "block"; |
28 | 31 | } |
29 | | -} |
30 | | -function switchLogs( baseUrl, logType ) { |
| 32 | +}; |
| 33 | + |
| 34 | +// Switch among various log displays |
| 35 | +window.switchLogs = function( baseUrl, logType ) { |
31 | 36 | encodeURIComponent( logType ); |
32 | 37 | window.location = baseUrl + '?log=' + logType; |
33 | | -} |
34 | | -function selectProjects( selectAll ) { |
| 38 | +}; |
| 39 | + |
| 40 | +window.selectProjects = function( selectAll ) { |
35 | 41 | var selectBox = document.getElementById('projects[]'); |
36 | 42 | var firstSelect = selectBox.options.length - 1; |
37 | 43 | for (var i = firstSelect; i >= 0; i--) { |
38 | 44 | selectBox.options[i].selected = selectAll; |
39 | 45 | } |
40 | | -} |
41 | | -function selectLanguages( selectAll ) { |
| 46 | +}; |
| 47 | +window.selectLanguages = function( selectAll ) { |
42 | 48 | var selectBox = document.getElementById('project_languages[]'); |
43 | 49 | var firstSelect = selectBox.options.length - 1; |
44 | 50 | for (var i = firstSelect; i >= 0; i--) { |
45 | 51 | selectBox.options[i].selected = selectAll; |
46 | 52 | } |
47 | | -} |
48 | | -function top10Languages() { |
| 53 | +}; |
| 54 | +window.top10Languages = function() { |
49 | 55 | var selectBox = document.getElementById('project_languages[]'); |
50 | 56 | var top10 = new Array('en','de','fr','it','pt','ja','es','pl','ru','nl'); |
51 | 57 | selectLanguages(false); |
— | — | @@ -54,16 +60,16 @@ |
55 | 61 | selectBox.options[i].selected = true; |
56 | 62 | } |
57 | 63 | } |
58 | | -} |
59 | | -function insertButton( buttonType ) { |
| 64 | +}; |
| 65 | + |
| 66 | +// Insert banner close button |
| 67 | +window.insertButton = function( buttonType ) { |
60 | 68 | var bannerField = document.getElementById('templateBody'); |
61 | 69 | switch( buttonType ) { |
62 | 70 | case 'close': // Insert close button |
63 | | - if ( $( '#fundraising' ).is( ':checked' ) ) { |
64 | | - var buttonValue = '<a href="#" onclick="hideBanner(\'fundraising\');return false;"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>'; |
65 | | - } else { |
66 | | - var buttonValue = '<a href="#" onclick="hideBanner();return false;"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>'; |
67 | | - } |
| 71 | + var buttonValue = '<a href="#" onclick="hideBanner();return false;">' |
| 72 | + + '<img border="0" src="' + mw.config.get( 'stylepath' ) |
| 73 | + + '/common/images/closewindow.png" alt="Close" /></a>'; |
68 | 74 | break; |
69 | 75 | } |
70 | 76 | if (document.selection) { |
— | — | @@ -76,28 +82,31 @@ |
77 | 83 | var startPos = bannerField.selectionStart; |
78 | 84 | var endPos = bannerField.selectionEnd; |
79 | 85 | bannerField.value = bannerField.value.substring(0, startPos) |
80 | | - + buttonValue |
81 | | - + bannerField.value.substring(endPos, bannerField.value.length); |
| 86 | + + buttonValue |
| 87 | + + bannerField.value.substring(endPos, bannerField.value.length); |
82 | 88 | } else { |
83 | 89 | bannerField.value += buttonValue; |
84 | 90 | } |
85 | 91 | bannerField.focus(); |
86 | | -} |
87 | | -function validateBannerForm( form ) { |
| 92 | +}; |
| 93 | + |
| 94 | +// Make sure the contents of the banner body are valid |
| 95 | +window.validateBannerForm = function( form ) { |
88 | 96 | var output = ''; |
89 | 97 | var pos = form.templateBody.value.indexOf("document.write"); |
90 | 98 | if( pos > -1 ) { |
91 | | - output += documentWriteError + '\n'; |
| 99 | + output += mw.msg( 'centralnotice-documentwrite-error' ) + '\n'; |
92 | 100 | } |
93 | 101 | if( output ) { |
94 | 102 | alert( output ); |
95 | 103 | return false; |
96 | 104 | } |
97 | 105 | return true; |
98 | | -} |
99 | | -// Handle revealing the geoMultiSelector when the geotargetted checkbox is checked |
| 106 | +}; |
| 107 | + |
100 | 108 | ( function( $ ) { |
101 | 109 | $(document).ready(function() { |
| 110 | + // Reveal the geoMultiSelector when the geotargetted checkbox is checked |
102 | 111 | $("#geotargeted").click(function () { |
103 | 112 | if ($('#geotargeted:checked').val() !== undefined) { |
104 | 113 | $("#geoMultiSelector").fadeIn('fast'); |
— | — | @@ -105,11 +114,12 @@ |
106 | 115 | $("#geoMultiSelector").fadeOut('fast'); |
107 | 116 | } |
108 | 117 | }); |
109 | | - $("#fundraising").click(function () { |
110 | | - if ($('#fundraising:checked').val() !== undefined) { |
111 | | - $("#fundraisingInterface").fadeIn('fast'); |
| 118 | + // Reveal the landing page interface when the autolink checkbox is checked |
| 119 | + $("#autolink").click(function () { |
| 120 | + if ($('#autolink:checked').val() !== undefined) { |
| 121 | + $("#autolinkInterface").fadeIn('fast'); |
112 | 122 | } else { |
113 | | - $("#fundraisingInterface").fadeOut('fast'); |
| 123 | + $("#autolinkInterface").fadeOut('fast'); |
114 | 124 | } |
115 | 125 | }); |
116 | 126 | }); |
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/centralnotice.js |
___________________________________________________________________ |
Modified: svn:mergeinfo |
117 | 127 | Merged /trunk/extensions/CentralNotice/centralnotice.js:r95669-100099 |