Extension:CentralNotice

CentralNotice adds the possibility to manage sitenotices from one central wiki. If you only need to post one global message (sitenotice) to a single wiki, you may want to use MediaWiki:Sitenotice instead.

Installation
Note: CentralNotice assumes you are not using table prefixes in your database. If you are, it is likely to not work.


 * 1) Download the latest snapshot and extract it to your extensions directory.
 * 2) Add  to LocalSettings.php.
 * 3) From the command line, go to the wiki root and run php maintenance/update.php
 * 4) The extension should now be active.

Settings

 *   (default: true) — Set to true on the infrastructure wiki (the wiki you will be managing the campaigns from). Set to false on your target wikis.
 *   (default: $wgDBname) — The name of the database for the infrastructure wiki. (This is needed so that the target wikis can retrieve banners from the controller wiki.)
 *   — Script path to the wiki serving actual banners. Should be adjusted if secure connection is used.
 *   (default: true)  — enable actual hooks.
 *  ,   (default: $wgLanguageCode and "wikipedia") — Determines which banners will be selected for this project.
 *   — The infrastructure wiki uses this as a list of possible  that banners can be assigned to.
 *   — Domain to have cookies set by the Special:HideBanner feature.
 *   - When the cookie set by Special:HideBanner should expire
 *   — Full URL to the script that returns amount of money donated to the WMF.

Permissions

 *   — Permission required to modify campaigns and banners. Relevant only to the infrastructure wikis (see also 26377).

Design
The CentralNotice system consists of both campaigns (a.k.a. notices) and banners (a.k.a. templates).


 * Banner — a single block of text/css/image that will display at the top of all set wiki pages.
 * Campaign — a collection of banners that are set to show according to a specified weight. You can configure as many campaigns at the same time as you want and each one will show with its configured banners at their own weighted percentages.
 * Preferred — A campaign with preferred set will always replace any other campaigns that happens to have the same language & wiki combo.
 * Locked — A locked notice can not be deleted unless it is unlocked.
 * Enabled — only campaigns that are enabled will show banners.

CentralNotice may work on a single wiki, but Wikimedia has a centralized setup, having the CentralNotice extension installed on all wikis, but the designated wiki instance (currently Meta) is used to provide the management interface. This designated wiki is called the infrastructure wiki and has  set to "true". All sister wikis should have  set to the database name of the infrastructure wiki in order to be able to roll out the centrally defined campaigns. Actual banners are served from the central wiki, as defined by  (this is also Meta in case of Wikimedia wikis).

Usage
Full usage instructions can be found at meta:Help:CentralNotice.

New Banner

 * 1) Load Special:NoticeTemplate
 * 2) Click on the add banner link at the bottom of the page (must be logged in as an admin).
 * 3) Enter in a name and the raw HTML for the given banner.
 * 4) If this banner is going to be translated then enclose any text to be translated with triple parens -.
 * 5) Submit

New Campaign

 * Each banner has its banner definition stored in MediaWiki:Centralnotice-template-
 * All of its messages are stored below the banner def ala MediaWiki:Centralnotice-template- - /


 * 1) Load Special:CentralNotice
 * 2) Add a campaign with a given start time at the bottom portion of the page and click submit.
 * 3) If this campaign is only run on a specific wiki and or language then select it from the pull downs.
 * 4) Click on the new campaign and add the banners you want within this running campaign and their respective weights.
 * 5) If all looks well then set this campaign to enabled and it will show at the corresponding time.

Testing
You can test-load any banner on any wiki by adding  to the end of the URL.

You can simulate loading a wiki page from any country (to test campaign geotargeting) by adding ? to the end of the URL. (Use the 2-letter ISO 3166-1 code.)

File descriptions
CentralNotice includes the following files:
 * CentralNotice.alias.php — the aliases for all of the special pages
 * CentralNotice.db.php — static functions for retrieving campaigns and banners from the database
 * CentralNotice.i18n.php — localized messages
 * CentralNotice.php — configuration, special page registration, hook functions
 * CentralNotice.sql — database set-up (updates handled by patch files)
 * SpecialBannerAllocation.php — special page for viewing banner allocation, enabled if  is true
 * SpecialBannerController.php — generates Javascript file which controls banner selection on the client side, served from the local wiki
 * SpecialBannerListLoader.php — generates JSON list of banners currently assigned to a particular wiki, served from the local wiki
 * SpecialBannerLoader.php — generates Javascript which inserts a banner into the page (via insertBanner callback function), accessed via
 * SpecialCentralNotice.php — interface for admins to create and administer banner campaigns, enabled if  is true
 * SpecialHideBanners.php — used to set cross-site cookies for hiding banners after someone has donated
 * SpecialNoticeTemplate.php — interface for admins to create and administer banners, enabled if  is true
 * TemplatePager.php — provides paging functionality for viewing banner lists in administrative interface
 * centralnotice.css — CSS for administrative interface
 * centralnotice.js — Javascript for administrative interface
 * README — A document describing caching architecture of the extension

API
CentralNotice adds an API call centralnoticeallocations. This call returns the expected allocation of banners for both anonymous and logged in users in a given country, language, and project group.

It accepts three arguments
 * project - The project to filter on, ie: 'wikipedia' or 'wikibooks'
 * country - The ISO country code to filter on, ie: 'US' or 'RU'
 * language - The ISO language code to filter on, ie: 'en' or 'es'

As of this time, the XML output of this API does not work.

Development

 * /Phase 2 - Completed
 * /Phase 3 - Completed
 * /Caching Overhaul -- Edge Side Includes
 * /Objectivization and ContentHandler