Extension:PersistUseskin

From MediaWiki.org

Jump to: navigation, search

           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
PersistUseskin

Release status: beta

Implementation  Parser extension
Description Persists use of &useskin=, if found in query string
Author(s)  [1] (SmdTalk)
Last Version  0.0.1 (2008-Dec-28)
MediaWiki  1.13.3
License GPL
Download see below

check usage (experimental)

Contents

[edit] Description

Persists use of &useskin=, if found in query string. Possibly the shortest MediaWiki extension ever (could be seen as one-liner :) ) ... For more, see comments in Code below


[edit] Download instructions

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

[edit] Installation

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

require_once( $IP.'/extensions/PersistUseskin.php' );

[edit] Code

<?php
# PersistUseskin MediaWiki Extention
#
#
# Gives any user the choice to view wiki in any of the installed skins, by clicking on a link containing the '&useskin=' query string
# simply remove the  '&useskin=' query string from the adress, to go back to default skin 
# you can then use a link like: 
# [{{SERVER}}{{SCRIPTPATH}}/index.php?title={{PAGENAMEE}}&useskin=monobook monobook] 
# to allow users to persistently browse the wiki in the chosen skin. 
 
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'PersistUseskin',
	'author' => 'http://www.mediawiki.org/wiki/User:Smd',
	'url' => 'http://www.mediawiki.org/wiki/Extension:PersistUseskin',
	'description' => 'Persists use of &useskin=, if found in query string',
	'version'=>'0.0.1'
);
 
# URL hook list: 
# GetInternalURL Used to modify fully-qualified URLs (useful for squid cache purging) # no trigger for local pages?
# GetLocalURL 	Used to modify local URLs as output into page links
# GetFullURL 	Used to modify fully-qualified URLs used in redirects/export/offsite data

$wgHooks['GetLocalURL'][] = 'PersistUseskin';
 
 
function PersistUseskin($title, $url, $query) 
{
	# for debug 
	# echo ("PersistUseskin title" . $title . "<br>\r\n" . " url  " . $url . " query " .  $query. "<br>\r\n". "<br>\r\n");
	
	# if we found the 'useskin' query string - simply append it again to local link ...
	if ($_GET["useskin"]) 
		if ($_GET["useskin"] != "" ) 
			$url .= "&useskin=" . $_GET["useskin"];
 
	# that's it ! :) go back ... 
	
	return true;
}
?>