Jump to content

Extension:SysSidebar

From mediawiki.org
MediaWiki extensions manual
SysSidebar
Release status: unmaintained
Implementation Skin
Description Makes "Recent changes" on the sidebar link to unpatrolled edits, for sysops
Author(s) יוסף שמחtalk
Latest version 1.2 (2009-08-30)
MediaWiki 1.15.0+
PHP 5.3.0+
License GPL
Download Code here
$wgSsbAdd, $wgSsbAddTxt, $wgSsbSection

Slight modification of Sidebar . For sysops only - makes "Recent changes" link to recent changes list of unpatrolled edits. Easier control and access to managing edits and patrolling them.

Usage

[edit]

Log in as sysop, and click on the link :)

Download instructions

[edit]

Please cut and paste the code found below and place it in $IP/extensions/SysSidebar/SysSidebar.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php .

Installation

[edit]

To install this extension, add the following to LocalSettings.php :

require_once("$IP/extensions/SysSidebar/SysSidebar.php");

Configuration

[edit]

Note: all parameters are optional. Extension works also if you don't set any of them.

$wgSsbAdd: If you would like the Unpatrolled Edits link added to the navigation box, not coming instead of regular Recent changes, set this to true in LocalSettings.php

Default setting: false

$wgSsbAddTxt: If you set $wgSsbAddTxt to true, this optional parameter sets the text for the new link added. Set in LocalSettings.php

Default setting: "Unpatrolled Edits"

$wgSsbSection: Which section the "Recent changes" link is in, or should be added to. Set in LocalSettings.php

Note: If link is not found in section the link will be added - even if $wgSsbAdd is set to false. In such a case link will be added according to $wgSsbAddTxt rules as written above, and in section specified (if none specified and it doesn't exist in neither navigation nor site the link will be created in navigation).

Default setting: navigation (detects "site" too)

Code

[edit]
<?php
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
if (!defined('MEDIAWIKI')) {
        exit( 1 );
}

/* Future functionality - internationalization
$dir = dirname(__FILE__) . '/';
$wgExtensionMessagesFiles['sysSidebar'] = $dir . 'sysSidebar.i18n.php';
*/
 
$wgExtensionFunctions[] = 'wfSysopSB';
$wgExtensionCredits['other'][] = array(
	'name' => "SysSidebar",
	'description' => "Sidebar for sysops - recent changes automatically refers to recent change list of unpatrolled edits",
	'version' => '1.2',
	'author' => "Happy Joe",
	'url' => "http://www.mediawiki.org/wiki/Extension:SysSidebar",
);

$wgHooks['SkinBuildSidebar'][] = 'wfSysopSB';
function wfSysopSB( $skin, &$bar )
{
	global $wgUser, $wgSsbAdd, $wgSsbAddTxt, $wgSsbSection;

	//Checking which bar section is wanted or availible
	if ($wgSsbSection)
		$ssbBar = &$bar[$wgSsbSection];
	else
	{
		if (isset($bar['site']))
			$ssbBar = &$bar['site'];
		else
			$ssbBar = &$bar['navigation'];
	}

	if ($wgUser->isAllowed('patrol'))
	{
		$ssbUrl = Title::makeTitle(NS_SPECIAL, 'RecentChanges')->getLocalUrl() . '&hidepatrolled=1';

		if ($wgSsbAdd) //If set to true - adding new link
		{
			if ($wgSsbAddTxt)
				$ssbBar[] = array(text => $wgSsbAddTxt, href => $ssbUrl, id => 'n-sysSidebarUP', active => '');
			else
				$ssbBar[] = array(text => 'Unpatrolled Edits', href => $ssbUrl, id => 'n-sysSidebarUP', active => '');
		}
		else // Modifying existing link
		{
			$ssbKey = -1;

			foreach($ssbBar as $key => $nav) //Searching for existing link
			{
				if ($nav['id'] == 'n-recentchanges')
					$ssbKey = $key;
			}
			if ($ssbKey != -1) //Modifying existing link
				$ssbBar[$ssbKey]['href'] = $ssbUrl;
			else //Default link not found. Adding link.
			{
				if ($wgSsbAddTxt)
					$ssbBar[] = array(text => $wgSsbAddTxt, href => $ssbUrl, id => 'n-sysSidebar', active => '');
				else
					$ssbBar[] = array(text => 'Unpatrolled Edits', href => $ssbUrl, id => 'n-sysSidebar', active => '');
			}
		}
	}
	return true;
}