Extension:PageNotice
From MediaWiki.org
|
PageNotice Release status: beta |
|
|---|---|
| Implementation | Notify |
| Description | lets you define a fixed header or footer message for each page or namespace |
| Author(s) | Duesentrieb |
| MediaWiki | 1.10 (1.9 probably, maybe older versions too) |
| Download | svn (browse), bundle log |
| Hooks used | |
Contents |
[edit] Description
The PageNotice extension provides a way for you to define fixed notice messages for the top or the bottom of
-
- a page (by individual page name), or
- entire namespaces (by namespace number).
You can define new fixed MediaWiki messages by creating new pages following a special page-naming pattern to hold that message, and then creating your desired message as the contents of that new page:
[edit] Usage
- top notice for page XXX goes in [[MediaWiki:top-notice-XXX]]
- bottom notice for page XXX goes in [[MediaWiki:bottom-notice-XXX]]
- top notice for pages in namespace NNN goes in [[MediaWiki:top-notice-ns-NNN]] (where NNN is the numeric namespace ID)
- bottom notice for pages in namespace NNN goes in [[MediaWiki:bottom-notice-ns-NNN]] (where NNN is the numeric namespace ID)
[edit] Installation
Download the PageNotice.php file (or create it via cut and paste from below) and save it to ... /extensions/PageNotice/... under your wiki directory structure.
In your LocalSettings.php, add the following line to the bottom end of the file:
require_once("$IP/extensions/PageNotice/PageNotice.php");
[edit] Examples
This will put the phrase: "Welcome to this wiki - you can edit every page!" at the top of every page in the main namespace:
- Create New Page, name:
- [[mediawiki:top-notice-ns-0]]
- Create new page contents:
- Welcome to this wiki - you can edit every page!
This will but a blue banner saying "Welcome to this wiki - you can edit every page!" at the bottom of every page:
- Create New Page, name:
- [[mediawiki:bottom-notice-ns-0]]
- Create new page contents:
- {| cellspacing="5" cellpadding="0" style="margin:0em 0em 1em 0em; border:1px solid #1DA0E7; background:#B3DDF4;width:100%"
- | ''''' Welcome to this wiki - you can edit every page!'''''
- |}
- Result looks like this:
| Welcome to this wiki - you can edit every page! |
[edit] PageNotice.php Source Code
<?php /** * PageNotice extension - lets you define a fixed header or * footer message for each page or namespace. * * Page notices (headers and footers) are maintained as * MediaWiki-messages. * For page Foo, MediaWiki:top-notice-Foo and * MediaWiki:bottom-notice-Foo can be used to define a * header or footer respectively. * For namespace 6, MediaWiki:top-notice-ns-6 and * MediaWiki:bottom-notice-ns-6 can be used to define a * header or footer respectively. Mind the capitalization. * * For more info see * http://mediawiki.org/wiki/Extension:PageNotice * * @package MediaWiki * @subpackage Extensions * @author Daniel Kinzler, brightbyte.de * @copyright © 2007 Daniel Kinzler * @license GNU General Public License 2.0 or later */ if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( 1 ); } $wgExtensionCredits['other'][] = array( 'name' => 'PageNotice', 'author' => 'Daniel Kinzler', 'url' => 'http://mediawiki.org/wiki/Extension:PageNotice', 'description' => 'lets you define a fixed header or footer message for each page or namespace.', ); $wgHooks['OutputPageBeforeHTML'][] = 'wfPageNoticeHook'; function wfPageNoticeHook( &$out, &$text ) { global $wgTitle, $wgParser; $name = $wgTitle->getPrefixedDBKey(); $ns = $wgTitle->getNamespace(); $opt = array( 'parseinline', ); $header = wfMsgExt("top-notice-$name", $opt); $nsheader = wfMsgExt("top-notice-ns-$ns", $opt); $footer = wfMsgExt("bottom-notice-$name", $opt); $nsfooter = wfMsgExt("bottom-notice-ns-$ns", $opt); if (!wfEmptyMsg("top-notice-$name", $header)) $text = "<div>$header</div>\n$text"; if (!wfEmptyMsg("top-notice-ns-$ns", $nsheader)) $text = "<div>$nsheader</div>\n$text"; if (!wfEmptyMsg("bottom-notice-$name", $footer)) $text = "$text\n<div>$footer</div>"; if (!wfEmptyMsg("bottom-notice-ns-$ns", $nsfooter)) $text = "$text\n<div>$nsfooter</div>"; return true; }

