Extension:CentralNotice
![]() Release status: stable |
|||
---|---|---|---|
Implementation | Special page | ||
Description | Adds a central sitenotice | ||
Author(s) | Brion Vibber, Tomasz Finc, Trevor Parscal, Kaldari | ||
License | GPL | ||
Download | Download snapshot Subversion [Help] |
||
|
|||
|
|||
|
|||
check usage (experimental) |
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.
Contents |
[edit] Installation
- Download the latest snapshot and extract it to your extensions directory.
- From the wiki root, run php maintenance/sql.php extensions/CentralNotice/CentralNotice.sql
- Add
require_once( "$IP/extensions/CentralNotice/CentralNotice.php" );
- The extension should now be active.
[edit] 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 CentralNotice extension installed on all wikis, but the designated wiki instance (currently Meta) is used to provide management interface as well. This designated wiki is called infrastructure wiki and has $wgNoticeInfrastructure
set to "true". All sister wikis use should have $wgCentralDBname
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 $wgCentralPagePath
(this is also Meta in case of Wikimedia wikis).
[edit] Settings
$wgNoticeInfrastructure
(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.$wgCentralDBname
(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.)$wgCentralPagePath
— Script path to the wiki serving actual banners. Should be adjusted if secure connection is used.$wgCentralNoticeLoader
(default: true) — enable actual hooks.$wgNoticeLang
,$wgNoticeProject
(default: $wgLanguageCode and "wikipedia") — Determines which banners will be selected for this project.$wgNoticeProjects
— The infrastructure wiki uses this as a liste of possible$wgNoticeProjects
that banners can be assigned to.$wgNoticeCookieDomain
— Domain to have cookies set by the Special:HideBanner feature.$wgNoticeCounterSource
— Full URL to the script that returns amount of money donated to the WMF.
[edit] Permissions
centralnotice-admin
— Permission required to modify campaigns and banners. Relevant only to the infrastructure wikis (see also bugzilla:26377).
[edit] New Banner
- Load Special:NoticeTemplate
- Click on the add banner link at the bottom of the page (must be logged in as an admin).
- Enter in a name and the raw HTML for the given banner.
- If this banner is going to be translated then enclose any text to be translated with triple parens - {{{FOO}}}.
- Submit
[edit] New Campaign
- Each banner has its banner definition stored in MediaWiki:Centralnotice-template-<name>
- All of its messages are stored below the banner def ala MediaWiki:Centralnotice-template-<name>-<message>/<language_code>
- Load Special:CentralNotice
- Add a campaign with a given start time at the bottom portion of the page and click submit.
- If this campaign is only run on a specific wiki and or language then select it from the pull downs.
- Click on the new campaign and add the banners you want within this running campaign and their respective weights.
- If all looks well then set this campaign to enabled and it will show at the corresponding time.
[edit]
It was quickly realized that we were duplicating work when messages were copied over for such strings as Hide to each banner. Instead of this, the accepted practice to is to use a shared message for commonly used messages. Then use the following to reference it:
{{int:centralnotice-shared-message-name}}
Note only 2 curly brackets.
If there is a need to only do this for two banners then you might want to use the clone feature at the bottom of any banner page.
[edit] Testing
You can test-load any banner on any wiki by adding ?banner=<bannername>
to the end of the URL.
You can simulate loading a wiki page from any country (to test campaign geotargeting) by adding ?country=<countrycode>
to the end of the URL. (Use the 2-letter ISO 3166-1 code.)
[edit] 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
$wgNoticeInfrastructure
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
$wgCentralPagePath
- SpecialCentralNotice.php — interface for admins to create and administer banner campaigns, enabled if
$wgNoticeInfrastructure
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
$wgNoticeInfrastructure
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
[edit] Development
[edit] See also
- Help:CentralNotice on meta
![]() |
This extension is being used on one or more of Wikimedia's wikis. This means that the extension is stable and works well enough to be used by such high traffic websites. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |