Extension:PersistUseskin
From MediaWiki.org
|
PersistUseskin Release status: beta |
|||
|---|---|---|---|
| Implementation | Parser extension | ||
| Description | Persists use of &useskin=, if found in query string | ||
| Author(s) | User:Smd (Smdtalk) | ||
| Last version | 0.0.1 (2008-Dec-28) | ||
| MediaWiki | 1.13.3 | ||
| License | GPL | ||
| Download | see below | ||
|
|||
| Check usage and version matrix | |||
Contents |
Description [edit]
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
Download instructions [edit]
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.
Installation [edit]
To install this extension, add the following to LocalSettings.php:
require_once( $IP.'/extensions/PersistUseskin.php' );
Code [edit]
<?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; } ?>
If Short urls are used, the following change might be required:
--- PersistUseskin.orig 2011-01-26 00:18:47.000000000 +0100 +++ PersistUseskin.php 2011-01-26 00:32:02.000000000 +0100 @@ -31,8 +31,10 @@ function PersistUseskin($title, $url, $q # if we found the 'useskin' query string - simply append it again to local link ... if ($_GET["useskin"]) - if ($_GET["useskin"] != "" ) - $url .= "&useskin=" . $_GET["useskin"]; + if ($_GET["useskin"] != "" ) { + $qsa = strrchr ($url, '?') ? '&' : '?'; + $url .= $qsa . "useskin=" . $_GET["useskin"]; + } # that's it ! :) go back ...
