Extension:ProtectedNotice

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
ProtectedNotice

Release status: beta

Description Allow you to show a notice on protected page
Author(s) Yedidia Klein
Last version 0.2
MediaWiki Tested on 1.14
License GPL
Download [1]

Check usage (experimental)

Contents

[edit] Description

Dumb users do not understand why some pages aren't editable for them, this extension let you adding a clear notice that will appear on head of each protected page.

[edit] Download and Installation Instructions

  • The extension can be downloaded from here : [2] or copied from end of this doc.
  • Extract the tarball in your extension directory or create a dir called ProtectedNotice and save the file there.
  • Add this line to your LocalSettings.php:
require_once("$IP/extensions/ProtectedNotice/ProtectedNotice.php");

[edit] Usage

  • Create the page MediaWiki:protected-notice and put there your text for the notice.
  • Now you will see the text that you entered on previous step on each protected page.
  • if you will put the following "code" in this page - you will get a nice white on red notice.
{| cellspacing="5" cellpadding="0" style="margin:0em 0em 1em 0em; border:1px solid #1DA0E7; background:#FF0033;width:100%"
|<font color=white> ''''' This is a Protected Page - You can't edit it! '''''</font>
|}

[edit] License

This Piece of code is Under Gnu Public License.

[edit] The extension itself

<?php
/**
 * ProtectedNotice extension - lets you define a fixed header
 *
 * Protected notice is maintained as MediaWiki-messages.
 * MediaWiki:protected-notice
 *
 * For more info see
 * http://mediawiki.org/wiki/Extension:ProtectedNotice
 *
 * @package MediaWiki
 * @subpackage Extensions
 * @author Yedidia Klein yedidia@atarplpl.co.il
 * @copyright Yedidia Klein
 * @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' => 'ProtectedNotice',
        'author' => 'Yedidia Klein',
        'url' => 'http://mediawiki.org/wiki/Extension:ProtectedNotice',
        'description' => 'lets you define a fixed header for protected pages.',
);

$wgHooks['OutputPageBeforeHTML'][] = 'wfProtectedNoticeHook';

function wfProtectedNoticeHook( &$out, &$text ) {
        global $wgTitle, $wgParser;

        $opt = array(
                'parseinline',
        );

        if ($wgTitle->isProtected()) {
          $header = wfMsgExt("protected-notice", $opt);
        } else {
          $header="";
        }

        if (!wfEmptyMsg("protected-notice", $header)) $text = "<div>$header</div>\n$text";

        return true;
}
?>
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox