r100100 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100099‎ | r100100 | r100101 >
Date:23:56, 17 October 2011
Author:awjrichards
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNoticeBannerLogPager.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/centralnotice.js (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerAllocation.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerController.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerListLoader.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerListLoader.php
___________________________________________________________________
Added: svn:mergeinfo
11 Merged /branches/wmf-deployment/extensions/CentralNotice/special/SpecialBannerListLoader.php:r60970
22 Merged /branches/wmf/1.16wmf4/extensions/CentralNotice/special/SpecialBannerListLoader.php:r67177,69199,76243,77266
33 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
44 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 @@
4444 * In order to circumvent the normal squid cache override we add '/cn.js' to the bannerlist URL.
4545 */
4646 function getOutput() {
47 - global $wgCentralPagePath, $wgNoticeFundraisingUrl, $wgContLang;
 47+ global $wgCentralPagePath, $wgContLang;
4848
4949 $js = $this->getScriptFunctions() . $this->getToggleScripts();
5050 $js .= <<<JAVASCRIPT
@@ -51,10 +51,13 @@
5252 $.ajaxSetup({ cache: true });
5353 $.centralNotice = {
5454 'data': {
55 - 'getVars': {}
 55+ 'getVars': {},
 56+ 'bannerType': 'default'
5657 },
5758 'fn': {
5859 '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;
5962 // Get the requested banner
6063 var bannerPageQuery = $.param( {
6164 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage,
@@ -159,9 +162,9 @@
160163 function getScriptFunctions() {
161164 global $wgNoticeFundraisingUrl;
162165 $script = <<<JAVASCRIPT
163 -function insertBanner(bannerJson) {
 166+function insertBanner( bannerJson ) {
164167 jQuery( 'div#centralNotice' ).prepend( bannerJson.bannerHtml );
165 - if ( bannerJson.fundraising ) {
 168+ if ( bannerJson.autolink ) {
166169 JAVASCRIPT;
167170 $script .= "\n\t\tvar url = '" .
168171 Xml::escapeJsString( $wgNoticeFundraisingUrl ) . "';\n";
@@ -176,12 +179,13 @@
177180 'utm_source': bannerJson.bannerName, 'language': wgUserLanguage,
178181 'country': Geo.country
179182 } );
180 - jQuery( '#cn_fundraising_link' ).attr( 'href', url );
 183+ jQuery( '#cn-landingpage-link' ).attr( 'href', url );
181184 }
182185 }
183186 }
184 -function hideBanner( bannerType ) {
 187+function hideBanner() {
185188 $( '#centralNotice' ).hide(); // Hide current banner
 189+ var bannerType = $.centralNotice.data.bannerType;
186190 if ( bannerType === undefined ) bannerType = 'default';
187191 setBannerHidingCookie( bannerType ); // Hide future banners of the same type
188192 }
@@ -191,28 +195,10 @@
192196 var work='centralnotice_'+bannerType+'=hide; expires=' + e.toGMTString() + '; path=/';
193197 document.cookie = work;
194198 }
 199+// This function is deprecated
195200 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();
205202 }
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 -}
217203
218204 JAVASCRIPT;
219205 return $script;
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerController.php
___________________________________________________________________
Modified: svn:mergeinfo
220206 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 @@
2424 $this->setHeaders();
2525 $this->outputHeader();
2626
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' );
2929
30 - // Add script file to the output headers
31 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" );
32 -
3330 // Check permissions
3431 $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
3532
@@ -58,7 +55,7 @@
5956 if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) {
6057
6158 // Handle adding a campaign
62 - if ( $method == 'addNotice' ) {
 59+ if ( $method == 'addCampaign' ) {
6360
6461 $noticeName = $wgRequest->getVal( 'noticeName' );
6562 $start = $wgRequest->getArray( 'start' );
@@ -69,7 +66,7 @@
7067 if ( $noticeName == '' ) {
7168 $this->showError( 'centralnotice-null-string' );
7269 } else {
73 - $this->addNotice( $noticeName, '0', $start, $projects,
 70+ $this->addCampaign( $noticeName, '0', $start, $projects,
7471 $project_languages, $geotargeted, $geo_countries );
7572 }
7673
@@ -77,11 +74,11 @@
7875 } else {
7976
8077 // Handle removing campaigns
81 - $toRemove = $wgRequest->getArray( 'removeNotices' );
 78+ $toRemove = $wgRequest->getArray( 'removeCampaigns' );
8279 if ( $toRemove ) {
8380 // Remove campaigns in list
8481 foreach ( $toRemove as $notice ) {
85 - $this->removeNotice( $notice );
 82+ $this->removeCampaign( $notice );
8683 }
8784 }
8885
@@ -271,7 +268,7 @@
272269 */
273270 public static function getDateRanges() {
274271 $dateRanges = array();
275 - $dateRanges['years'] = range( 2011, date("Y") );
 272+ $dateRanges['years'] = range( date('Y'), date('Y') + 1 ); // this year and next year
276273 $dateRanges['months'] = CentralNotice::paddedRange( 1, 12 );
277274 $dateRanges['days'] = CentralNotice::paddedRange( 1, 31 );
278275 return $dateRanges;
@@ -464,7 +461,7 @@
465462
466463 if ( $this->editable ) {
467464 // Remove
468 - $fields[] = Xml::check( 'removeNotices[]', false,
 465+ $fields[] = Xml::check( 'removeCampaigns[]', false,
469466 array( 'value' => $row->not_name, 'class' => 'noshiftselect' ) );
470467 }
471468
@@ -506,7 +503,7 @@
507504 if ( $this->editable ) {
508505
509506 // 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' ) ) {
511508 $startArray = $wgRequest->getArray( 'start' );
512509 $startTimestamp = $startArray['year'] .
513510 $startArray['month'] .
@@ -529,7 +526,7 @@
530527 $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) );
531528 $htmlOut .= Xml::element( 'h2', null, wfMsg( 'centralnotice-add-notice' ) );
532529 $htmlOut .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() );
533 - $htmlOut .= Html::hidden( 'method', 'addNotice' );
 530+ $htmlOut .= Html::hidden( 'method', 'addCampaign' );
534531
535532 $htmlOut .= Xml::openElement( 'table', array ( 'cellpadding' => 9 ) );
536533
@@ -605,7 +602,7 @@
606603 global $wgOut, $wgRequest, $wgUser;
607604
608605 // Make sure notice exists
609 - if ( !$this->noticeExists( $notice ) ) {
 606+ if ( !CentralNoticeDB::campaignExists( $notice ) ) {
610607 $this->showError( 'centralnotice-notice-doesnt-exist' );
611608 } else {
612609
@@ -617,7 +614,7 @@
618615
619616 // Handle removing campaign
620617 if ( $wgRequest->getVal( 'remove' ) ) {
621 - $this->removeNotice( $notice );
 618+ $this->removeCampaign( $notice );
622619 if ( !$this->centralNoticeError ) {
623620 // Leave campaign detail interface
624621 $wgOut->redirect( $this->getTitle()->getLocalUrl() );
@@ -1091,18 +1088,29 @@
10921089 return $htmlOut;
10931090 }
10941091
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,
10961104 $project_languages, $geotargeted, $geo_countries )
10971105 {
1098 - if ( $this->noticeExists( $noticeName ) ) {
 1106+ if ( CentralNoticeDB::campaignExists( $noticeName ) ) {
10991107 $this->showError( 'centralnotice-notice-exists' );
1100 - return;
 1108+ return null;
11011109 } elseif ( empty( $projects ) ) {
11021110 $this->showError( 'centralnotice-no-project' );
1103 - return;
 1111+ return null;
11041112 } elseif ( empty( $project_languages ) ) {
11051113 $this->showError( 'centralnotice-no-language' );
1106 - return;
 1114+ return null;
11071115 } else {
11081116 if ( !$geo_countries ) $geo_countries = array();
11091117 $dbw = wfGetDB( DB_MASTER );
@@ -1138,82 +1146,93 @@
11391147 );
11401148 $not_id = $dbw->insertId();
11411149
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 ) {
11571151
1158 - if ( $geotargeted ) {
1159 - // Do multi-row insert for campaign countries
 1152+ // Do multi-row insert for campaign projects
11601153 $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 );
11631156 }
1164 - $res = $dbw->insert( 'cn_notice_countries', $insertArray,
 1157+ $res = $dbw->insert( 'cn_notice_projects', $insertArray,
11651158 __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;
11661199 }
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;
11861200 }
11871201 }
11881202
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 ) {
11901209 $dbr = wfGetDB( DB_SLAVE );
11911210
11921211 $res = $dbr->select( 'cn_notices', 'not_name, not_locked',
1193 - array( 'not_name' => $noticeName )
 1212+ array( 'not_name' => $campaignName )
11941213 );
11951214 if ( $dbr->numRows( $res ) < 1 ) {
11961215 $this->showError( 'centralnotice-remove-notice-doesnt-exist' );
1197 - return;
 1216+ return null;
11981217 }
11991218 $row = $dbr->fetchObject( $res );
12001219 if ( $row->not_locked == '1' ) {
12011220 $this->showError( 'centralnotice-notice-is-locked' );
1202 - return;
 1221+ return null;
12031222 } else {
12041223 // 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 );
12071226
12081227 $dbw = wfGetDB( DB_MASTER );
12091228 $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 ) );
12151234 $dbw->commit();
12161235
1217 - return;
 1236+ return true;
12181237 }
12191238 }
12201239
@@ -1356,7 +1375,7 @@
13571376 }
13581377
13591378 // Invalid campaign name
1360 - if ( !$this->noticeExists( $noticeName ) ) {
 1379+ if ( !CentralNoticeDB::campaignExists( $noticeName ) ) {
13611380 $this->showError( 'centralnotice-notice-doesnt-exist' );
13621381 return;
13631382 }
@@ -1379,10 +1398,10 @@
13801399 * Update a boolean setting on a campaign
13811400 * @param $noticeName string: Name of the campaign
13821401 * @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
13841403 */
13851404 private function setBooleanCampaignSetting( $noticeName, $settingName, $settingValue ) {
1386 - if ( !$this->noticeExists( $noticeName ) ) {
 1405+ if ( !CentralNoticeDB::campaignExists( $noticeName ) ) {
13871406 // Exit quietly since campaign may have been deleted at the same time.
13881407 return;
13891408 } else {
@@ -1621,17 +1640,6 @@
16221641 }
16231642 }
16241643
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 -
16361644 public static function dropDownList( $text, $values ) {
16371645 $dropDown = "*{$text}\n";
16381646 foreach ( $values as $value ) {
@@ -1704,31 +1712,39 @@
17051713 * @param $endSettings array of campaign settings after changes (optional)
17061714 * @param $beginAssignments array of banner assignments before changes (optional)
17071715 * @param $endAssignments array of banner assignments after changes (optional)
 1716+ * @return integer: ID of log entry (or null)
17081717 */
17091718 function logCampaignChange( $action, $campaignId, $beginSettings = array(),
17101719 $endSettings = array(), $beginAssignments = array(), $endAssignments = array() )
17111720 {
17121721 global $wgUser;
17131722
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
17151725
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;
17261749 }
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;
17341750 }
17351751 }
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php
___________________________________________________________________
Modified: svn:mergeinfo
17361752 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 @@
3232 // Begin output
3333 $this->setHeaders();
3434
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' );
3737
38 - // Add script file to the output headers
39 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" );
40 -
4138 // Initialize error variable
4239 $this->centralNoticeError = false;
4340
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerAllocation.php
___________________________________________________________________
Modified: svn:mergeinfo
4441 Merged /trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php:r99189
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php
@@ -75,6 +75,7 @@
7676 'bannerHtml' => $bannerHtml,
7777 'campaign' => $this->campaign,
7878 'fundraising' => $this->getFundraising( $bannerName ),
 79+ 'autolink' => $this->getAutolink( $bannerName ),
7980 'landingPages' => $this->getLandingPages( $bannerName )
8081 );
8182 $bannerJs = 'insertBanner('.FormatJson::encode( $bannerArray ).');';
@@ -203,6 +204,14 @@
204205 return $row->tmp_fundraising;
205206 }
206207
 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+
207216 function getLandingPages( $bannerName ) {
208217 global $wgCentralDBname;
209218 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
210219 Merged /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php:r99160-99181
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -22,17 +22,8 @@
2323 // Begin output
2424 $this->setHeaders();
2525
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' );
3728
3829 // Check permissions
3930 $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
@@ -90,6 +81,7 @@
9182 $wgRequest->getBool( 'displayAnon' ),
9283 $wgRequest->getBool( 'displayAccount' ),
9384 $wgRequest->getBool( 'fundraising' ),
 85+ $wgRequest->getBool( 'autolink' ),
9486 $wgRequest->getVal( 'landingPages' )
9587 );
9688 $sub = 'view';
@@ -106,6 +98,7 @@
10799 $wgRequest->getBool( 'displayAnon' ),
108100 $wgRequest->getBool( 'displayAccount' ),
109101 $wgRequest->getBool( 'fundraising' ),
 102+ $wgRequest->getBool( 'autolink' ),
110103 $wgRequest->getVal( 'landingPages' )
111104 );
112105 $sub = 'view';
@@ -238,6 +231,7 @@
239232 $displayAnon = $wgRequest->getCheck( 'displayAnon' );
240233 $displayAccount = $wgRequest->getCheck( 'displayAccount' );
241234 $fundraising = $wgRequest->getCheck( 'fundraising' );
 235+ $autolink = $wgRequest->getCheck( 'autolink' );
242236 $landingPages = $wgRequest->getVal( 'landingPages' );
243237 $body = $wgRequest->getVal( 'templateBody' );
244238 } else { // Use default values
@@ -245,6 +239,7 @@
246240 $displayAnon = true;
247241 $displayAccount = true;
248242 $fundraising = false;
 243+ $autolink = false;
249244 $landingPages = '';
250245 $body = '';
251246 }
@@ -268,13 +263,24 @@
269264
270265 // Fundraising settings
271266 if ( $wgNoticeEnableFundraising ) {
 267+
 268+ // Checkbox for indicating if it is a fundraising banner
272269 $htmlOut .= Html::openElement( 'p', null );
273270 $htmlOut .= Xml::check( 'fundraising', $fundraising, array( 'id' => 'fundraising' ) );
274271 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ), 'fundraising' );
275272 $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
276281 $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' ) );
279285 $htmlOut .= Xml::tags( 'p', array(),
280286 Xml::inputLabel(
281287 wfMsg( 'centralnotice-banner-landing-pages' ),
@@ -548,12 +554,14 @@
549555 $displayAnon = $wgRequest->getCheck( 'displayAnon' );
550556 $displayAccount = $wgRequest->getCheck( 'displayAccount' );
551557 $fundraising = $wgRequest->getCheck( 'fundraising' );
 558+ $autolink = $wgRequest->getCheck( 'autolink' );
552559 $landingPages = $wgRequest->getVal( 'landingPages' );
553560 $body = $wgRequest->getVal( 'templateBody', $body );
554561 } else { // Use previously stored values
555562 $displayAnon = ( $bannerSettings['anon'] == 1 );
556563 $displayAccount = ( $bannerSettings['account'] == 1 );
557564 $fundraising = ( $bannerSettings['fundraising'] == 1 );
 565+ $autolink = ( $bannerSettings['autolink'] == 1 );
558566 $landingPages = $bannerSettings['landingpages'];
559567 // $body default is defined prior to message interface code
560568 }
@@ -572,20 +580,32 @@
573581
574582 // Fundraising settings
575583 if ( $wgNoticeEnableFundraising ) {
 584+
 585+ // Checkbox for indicating if it is a fundraising banner
576586 $htmlOut .= Html::openElement( 'p', null );
577587 $htmlOut .= Xml::check( 'fundraising', $fundraising,
578588 wfArrayMerge( $disabled, array( 'id' => 'fundraising' ) ) );
579589 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ),
580590 'fundraising' );
581591 $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' ) );
584604 } else {
585605 $htmlOut .= Html::openElement( 'div',
586 - array( 'id'=>'fundraisingInterface', 'style'=>'display:none;' ) );
 606+ array( 'id'=>'autolinkInterface', 'style'=>'display:none;' ) );
587607 }
588608 $htmlOut .= Xml::tags( 'p', array(),
589 - wfMsg( 'centralnotice-banner-fundraising-help' ) );
 609+ wfMsg( 'centralnotice-banner-autolink-help', 'id="cn-landingpage-link"', 'JimmyAppeal01' ) );
590610 $htmlOut .= Xml::tags( 'p', array(),
591611 Xml::inputLabel(
592612 wfMsg( 'centralnotice-banner-landing-pages' ),
@@ -594,6 +614,7 @@
595615 )
596616 );
597617 $htmlOut .= Html::closeElement( 'div' );
 618+
598619 }
599620
600621 // Begin banner body section
@@ -780,11 +801,12 @@
781802 * @param $displayAnon integer flag for display to anonymous users
782803 * @param $displayAccount integer flag for display to logged in users
783804 * @param $fundraising integer flag for fundraising banner (optional)
 805+ * @param $autolink integer flag for automatically creating landing page links (optional)
784806 * @param $landingPages string list of landing pages (optional)
785807 * @return true or false depending on whether banner was successfully added
786808 */
787809 public function addTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising = 0,
788 - $landingPages = '' ) {
 810+ $autolink = 0, $landingPages = '' ) {
789811
790812 if ( $body == '' || $name == '' ) {
791813 $this->showError( 'centralnotice-null-string' );
@@ -813,6 +835,7 @@
814836 'tmp_display_anon' => $displayAnon,
815837 'tmp_display_account' => $displayAccount,
816838 'tmp_fundraising' => $fundraising,
 839+ 'tmp_autolink' => $autolink,
817840 'tmp_landing_pages' => $landingPages
818841 ),
819842 __METHOD__
@@ -831,6 +854,7 @@
832855 'anon' => $displayAnon,
833856 'account' => $displayAccount,
834857 'fundraising' => $fundraising,
 858+ 'autolink' => $autolink,
835859 'landingpages' => $landingPages
836860 );
837861 $this->logBannerChange( 'created', $bannerId, $beginSettings, $endSettings );
@@ -843,7 +867,7 @@
844868 * Update a banner
845869 */
846870 private function editTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising,
847 - $landingPages ) {
 871+ $autolink, $landingPages ) {
848872
849873 if ( $body == '' || $name == '' ) {
850874 $this->showError( 'centralnotice-null-string' );
@@ -865,6 +889,7 @@
866890 'tmp_display_anon' => $displayAnon,
867891 'tmp_display_account' => $displayAccount,
868892 'tmp_fundraising' => $fundraising,
 893+ 'tmp_autolink' => $autolink,
869894 'tmp_landing_pages' => $landingPages
870895 ),
871896 array( 'tmp_name' => $name )
@@ -911,6 +936,7 @@
912937 'tmp_display_anon',
913938 'tmp_display_account',
914939 'tmp_fundraising',
 940+ 'tmp_autolink',
915941 'tmp_landing_pages'
916942 ),
917943 array( 'tmp_name' => $source ),
@@ -919,6 +945,7 @@
920946 $displayAnon = $row->tmp_display_anon;
921947 $displayAccount = $row->tmp_display_account;
922948 $fundraising = $row->tmp_fundraising;
 949+ $autolink = $row->tmp_autolink;
923950 $landingPages = $row->tmp_landing_pages;
924951
925952 // Pull banner text and respect any inc: markup
@@ -927,7 +954,7 @@
928955
929956 // Create new banner
930957 if ( $this->addTemplate( $dest, $template_body, $displayAnon, $displayAccount, $fundraising,
931 - $landingPages ) ) {
 958+ $autolink, $landingPages ) ) {
932959
933960 // Populate the fields
934961 foreach ( $langs as $lang => $fields ) {
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php
___________________________________________________________________
Modified: svn:mergeinfo
935962 Merged /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php:r98908-100099
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
@@ -24,11 +24,8 @@
2525 // Begin output
2626 $this->setHeaders();
2727
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' );
3330
3431 // Initialize error variable
3532 $this->centralNoticeError = false;
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
___________________________________________________________________
Modified: svn:mergeinfo
3633 Merged /trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php:r99189
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.php
@@ -80,6 +80,15 @@
8181 # Unit tests
8282 $wgHooks['UnitTestsList'][] = 'efCentralNoticeUnitTests';
8383
 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+
8493 function efCentralNoticeUnitTests( &$files ) {
8594 $files[] = dirname( __FILE__ ) . '/tests/CentralNoticeTest.php';
8695 return true;
@@ -161,6 +170,8 @@
162171 $base . '/patches/patch-notice_log.sql' );
163172 $wgExtNewTables[] = array( 'cn_template_log',
164173 $base . '/patches/patch-template_log.sql' );
 174+ $wgExtNewFields[] = array( 'cn_templates', 'tmp_autolink',
 175+ $base . '/patches/patch-template_autolink.sql' );
165176 }
166177 } else {
167178 if ( $updater->getDB()->getType() == 'mysql' ) {
@@ -182,6 +193,8 @@
183194 $base . '/patches/patch-notice_log.sql', true ) );
184195 $updater->addExtensionUpdate( array( 'addTable', 'cn_template_log',
185196 $base . '/patches/patch-template_log.sql', true ) );
 197+ $updater->addExtensionUpdate( array( 'addField', 'cn_templates', 'tmp_autolink',
 198+ $base . '/patches/patch-template_autolink.sql', true ) );
186199 }
187200 }
188201 return true;
@@ -190,10 +203,10 @@
191204 function efCentralNoticeLoader( $out, $skin ) {
192205 global $wgOut;
193206
194 - // Include '.js' to exempt script from squid cache override
 207+ // Include '.js' to exempt script from squid cache expiration override
195208 $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl( 'cache=/cn.js' );
196209
197 - // Insert the banner controller Javascript into the <head>
 210+ // Insert the banner controller Javascript into the page
198211 $wgOut->addScriptFile( $centralLoader );
199212
200213 return true;
@@ -201,7 +214,7 @@
202215
203216 function efCentralNoticeGeoLoader( $skin, &$text ) {
204217 // Insert the geo IP lookup
205 - $text .= '<script type="text/javascript" src="//geoiplookup.wikimedia.org/"></script>';
 218+ $text .= Html::linkedScript( "//geoiplookup.wikimedia.org/" );
206219 return true;
207220 }
208221
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.php
___________________________________________________________________
Modified: svn:mergeinfo
209222 Merged /trunk/extensions/CentralNotice/CentralNotice.php:r98917-100099
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNoticeBannerLogPager.php
@@ -149,6 +149,11 @@
150150 wfMsg ( 'centralnotice-fundraising' ),
151151 ($row->tmplog_end_fundraising ? 'on' : 'off')
152152 )."<br/>";
 153+ $details .= wfMsg (
 154+ 'centralnotice-log-label',
 155+ wfMsg ( 'centralnotice-autolink' ),
 156+ ($row->tmplog_end_autolink ? 'on' : 'off')
 157+ )."<br/>";
153158 if ( $row->tmplog_end_landingpages ) {
154159 $details .= wfMsg (
155160 'centralnotice-log-label',
@@ -165,6 +170,7 @@
166171 $details .= $this->testBooleanChange( 'anon', $row );
167172 $details .= $this->testBooleanChange( 'account', $row );
168173 $details .= $this->testBooleanChange( 'fundraising', $row );
 174+ $details .= $this->testBooleanChange( 'autolink', $row );
169175 $details .= $this->testTextChange( 'landingpages', $row );
170176 if ( $row->tmplog_content_change ) {
171177 // Show changes to banner content
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNoticeBannerLogPager.php
___________________________________________________________________
Modified: svn:mergeinfo
172178 Merged /trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php:r98918-100099
Index: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php
@@ -214,6 +214,7 @@
215215 'tmp_display_anon',
216216 'tmp_display_account',
217217 'tmp_fundraising',
 218+ 'tmp_autolink',
218219 'tmp_landing_pages',
219220 'not_name'
220221 ),
@@ -232,6 +233,7 @@
233234 'display_anon' => intval( $row->tmp_display_anon ), // display to anonymous users?
234235 'display_account' => intval( $row->tmp_display_account ), // display to logged in users?
235236 'fundraising' => intval( $row->tmp_fundraising ), // fundraising banner?
 237+ 'autolink' => intval( $row->tmp_autolink ), // automatically create links?
236238 'landing_pages' => $row->tmp_landing_pages, // landing pages to link to
237239 'campaign' => $row->not_name // campaign the banner is assigned to
238240 );
@@ -263,6 +265,7 @@
264266 'tmp_display_anon',
265267 'tmp_display_account',
266268 'tmp_fundraising',
 269+ 'tmp_autolink',
267270 'tmp_landing_pages'
268271 ),
269272 array( 'tmp_name' => $bannerName ),
@@ -274,6 +277,7 @@
275278 'anon' => $row->tmp_display_anon,
276279 'account' => $row->tmp_display_account,
277280 'fundraising' => $row->tmp_fundraising,
 281+ 'autolink' => $row->tmp_autolink,
278282 'landingpages' => $row->tmp_landing_pages
279283 );
280284 }
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/CentralNotice.db.php
___________________________________________________________________
Modified: svn:mergeinfo
281285 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 ) {
34 var thisCollapsed = document.getElementById( 'cn-collapsed-'+logId );
45 var thisUncollapsed = document.getElementById( 'cn-uncollapsed-'+logId );
56 var thisDetails = document.getElementById( 'cn-log-details-'+logId );
@@ -11,8 +12,10 @@
1213 thisUncollapsed.style.display = "block";
1314 thisDetails.style.display = "table-row";
1415 }
15 -}
16 -function toggleFilterDisplay() {
 16+};
 17+
 18+// Collapse and uncollapse log filter interface
 19+window.toggleFilterDisplay = function() {
1720 var thisCollapsed = document.getElementById( 'cn-collapsed-filter-arrow' );
1821 var thisUncollapsed = document.getElementById( 'cn-uncollapsed-filter-arrow' );
1922 var thisFilters = document.getElementById( 'cn-log-filters' );
@@ -25,26 +28,29 @@
2629 thisUncollapsed.style.display = "inline-block";
2730 thisFilters.style.display = "block";
2831 }
29 -}
30 -function switchLogs( baseUrl, logType ) {
 32+};
 33+
 34+// Switch among various log displays
 35+window.switchLogs = function( baseUrl, logType ) {
3136 encodeURIComponent( logType );
3237 window.location = baseUrl + '?log=' + logType;
33 -}
34 -function selectProjects( selectAll ) {
 38+};
 39+
 40+window.selectProjects = function( selectAll ) {
3541 var selectBox = document.getElementById('projects[]');
3642 var firstSelect = selectBox.options.length - 1;
3743 for (var i = firstSelect; i >= 0; i--) {
3844 selectBox.options[i].selected = selectAll;
3945 }
40 -}
41 -function selectLanguages( selectAll ) {
 46+};
 47+window.selectLanguages = function( selectAll ) {
4248 var selectBox = document.getElementById('project_languages[]');
4349 var firstSelect = selectBox.options.length - 1;
4450 for (var i = firstSelect; i >= 0; i--) {
4551 selectBox.options[i].selected = selectAll;
4652 }
47 -}
48 -function top10Languages() {
 53+};
 54+window.top10Languages = function() {
4955 var selectBox = document.getElementById('project_languages[]');
5056 var top10 = new Array('en','de','fr','it','pt','ja','es','pl','ru','nl');
5157 selectLanguages(false);
@@ -54,16 +60,16 @@
5561 selectBox.options[i].selected = true;
5662 }
5763 }
58 -}
59 -function insertButton( buttonType ) {
 64+};
 65+
 66+// Insert banner close button
 67+window.insertButton = function( buttonType ) {
6068 var bannerField = document.getElementById('templateBody');
6169 switch( buttonType ) {
6270 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>';
6874 break;
6975 }
7076 if (document.selection) {
@@ -76,28 +82,31 @@
7783 var startPos = bannerField.selectionStart;
7884 var endPos = bannerField.selectionEnd;
7985 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);
8288 } else {
8389 bannerField.value += buttonValue;
8490 }
8591 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 ) {
8896 var output = '';
8997 var pos = form.templateBody.value.indexOf("document.write");
9098 if( pos > -1 ) {
91 - output += documentWriteError + '\n';
 99+ output += mw.msg( 'centralnotice-documentwrite-error' ) + '\n';
92100 }
93101 if( output ) {
94102 alert( output );
95103 return false;
96104 }
97105 return true;
98 -}
99 -// Handle revealing the geoMultiSelector when the geotargetted checkbox is checked
 106+};
 107+
100108 ( function( $ ) {
101109 $(document).ready(function() {
 110+ // Reveal the geoMultiSelector when the geotargetted checkbox is checked
102111 $("#geotargeted").click(function () {
103112 if ($('#geotargeted:checked').val() !== undefined) {
104113 $("#geoMultiSelector").fadeIn('fast');
@@ -105,11 +114,12 @@
106115 $("#geoMultiSelector").fadeOut('fast');
107116 }
108117 });
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');
112122 } else {
113 - $("#fundraisingInterface").fadeOut('fast');
 123+ $("#autolinkInterface").fadeOut('fast');
114124 }
115125 });
116126 });
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/centralnotice.js
___________________________________________________________________
Modified: svn:mergeinfo
117127 Merged /trunk/extensions/CentralNotice/centralnotice.js:r95669-100099

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92510code clean-up: updating method names, adding comments, etc.kaldari00:02, 19 July 2011
r92676only log changes if they are done by actual userskaldari20:23, 20 July 2011
r96496follow up to r92922 - removing banner content change detection from the banne...kaldari21:02, 7 September 2011
r97304adding missing linebreakkaldari18:12, 16 September 2011
r99160separating fundraising specific features into 2 checkboxes - one for the cook...kaldari22:51, 6 October 2011
r99165fixing year selector for campaignskaldari23:01, 6 October 2011
r99169removing unused global varkaldari23:28, 6 October 2011
r99176more generic messaging, automatically constructed fundraising links dont necc...kaldari00:58, 7 October 2011
r99178follow-up to r99176 - forgot to update the js that generates the linkkaldari01:03, 7 October 2011
r99181more generic messaging, automatically constructed fundraising links dont necc...kaldari01:28, 7 October 2011
r99189quick and dirty resourceloaderification - should move all js functions out of...kaldari04:01, 7 October 2011
r99191keeping code within 80 char margins for better readabilitykaldari04:24, 7 October 2011
r99194fix for Bug 31488 - hideBanner() no longer requires bannerType parameter, als...kaldari05:14, 7 October 2011
r99341entirely new scheme to optimize banner loading - down from 1.1 seconds to 0.1...kaldari08:33, 9 October 2011
r99383follow-up to r99341 - abstracting script calls, switching to camelcase for co...kaldari23:07, 9 October 2011
r99496reverting new banner loading scheme for now - reverts r99341 and r99383kaldari17:02, 11 October 2011

Status & tagging log