jenkins-bot has submitted this change and it was merged.
Change subject: Crosswiki Banner Hiding
......................................................................
Crosswiki Banner Hiding
Using a new configuration variable $wgNoticeHideUrls, banners
using the standard close button will now hide cross wiki using
the 'standard' fundraising hide special page.
Bug: 16821
Change-Id: Id12a7f21943e590952baf4a78a6ddd01c145f6a4
---
M CentralNotice.hooks.php
M CentralNotice.php
M modules/ext.centralNotice.bannerController/bannerController.js
3 files changed, 31 insertions(+), 5 deletions(-)
Approvals:
Adamw: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CentralNotice.hooks.php b/CentralNotice.hooks.php
index 6cf39a9..bfbd034 100644
--- a/CentralNotice.hooks.php
+++ b/CentralNotice.hooks.php
@@ -286,7 +286,8 @@
global $wgNoticeFundraisingUrl, $wgCentralPagePath, $wgContLang,
$wgNoticeXXCountries,
$wgNoticeInfrastructure, $wgNoticeCloseButton,
$wgCentralBannerDispatcher,
$wgCentralBannerRecorder, $wgNoticeNumberOfBuckets,
$wgNoticeBucketExpiry,
- $wgNoticeNumberOfControllerBuckets,
$wgNoticeCookieShortExpiry, $wgScript;
+ $wgNoticeNumberOfControllerBuckets,
$wgNoticeCookieShortExpiry, $wgScript,
+ $wgNoticeHideUrls;
// Making these calls too soon will causes issues with the namespace
localisation cache. This seems
// to be just right. We require them at all because MW will 302 page
requests made to non localised
@@ -307,6 +308,7 @@
$vars[ 'wgNoticeBucketExpiry' ] = $wgNoticeBucketExpiry;
$vars[ 'wgNoticeNumberOfControllerBuckets' ] =
$wgNoticeNumberOfControllerBuckets;
$vars[ 'wgNoticeCookieShortExpiry' ] = $wgNoticeCookieShortExpiry;
+ $vars[ 'wgNoticeHideUrls' ] = $wgNoticeHideUrls;
if ( $wgNoticeInfrastructure ) {
$vars[ 'wgNoticeCloseButton' ] = $wgNoticeCloseButton;
diff --git a/CentralNotice.php b/CentralNotice.php
index cd4662d..0fa4357 100644
--- a/CentralNotice.php
+++ b/CentralNotice.php
@@ -115,6 +115,17 @@
// Defaults to one year.
$wgNoticeCookieLongExpiry = 31536000;
+/**
+ * @var string[] $wgNoticeHideUrls Locations of Special:HideBanner targets to
hit
+ * when a banner close button is pressed. The hides will then be specific to
each
+ * domain specified by $wgNoticeCookieDomain on that wiki.
+ *
+ * If CentralNotice is only enabled on a single wiki, or if cross-wiki hiding
is
+ * not desired, the leave this as array(). Page code will always hide a banner
+ * by setting a cookie for that wiki's domain.
+ */
+$wgNoticeHideUrls = array();
+
// Server-side banner cache timeout in seconds
$wgNoticeBannerMaxAge = 600;
diff --git a/modules/ext.centralNotice.bannerController/bannerController.js
b/modules/ext.centralNotice.bannerController/bannerController.js
index 18b051c..9d0a0ae 100644
--- a/modules/ext.centralNotice.bannerController/bannerController.js
+++ b/modules/ext.centralNotice.bannerController/bannerController.js
@@ -336,17 +336,30 @@
// Function for hiding banners when the user clicks the close button
// TODO: Make it call up to the special page for cross project hiding
window.hideBanner = function () {
- // Hide current banner
+ var d = new Date(),
+ expiry = mw.config.get( 'wgNoticeCookieShortExpiry' );
+
+ // Immediately hide the banner on the page
$( '#centralNotice' ).hide();
- // Set the banner hiding cookie to hide future banners of the
same type
- var d = new Date();
- d.setSeconds( d.getSeconds() + mw.config.get(
'wgNoticeCookieShortExpiry' ) );
+ // Set a local hide cookie for this banner category
+ d.setSeconds( d.getSeconds() + expiry );
$.cookie(
'centralnotice_hide_' + mw.centralNotice.data.category,
'hide',
{ expires: d, path: '/' }
);
+
+ // Iterate over all configured URLs to hide this category of
banner for all
+ // wikis in a cluster
+ $.each( mw.config.get( 'wgNoticeHideUrls' ), function( idx,
value ) {
+ (new Image()).src = value + '?' + $.param( {
+ 'duration': expiry,
+ 'category': mw.centralNotice.data.category
+ } );
+ } );
+
+
};
// This function is deprecated
--
To view, visit https://gerrit.wikimedia.org/r/92777
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id12a7f21943e590952baf4a78a6ddd01c145f6a4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
Gerrit-Reviewer: Adamw <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits