Difference between revisions of "Extension talk:Wikiskin.php"

From Organic Design wiki
m (Private wiki & Public www: comments)
Line 5: Line 5:
  
 
== Private wiki & Public www ==
 
== Private wiki & Public www ==
Thie following LocalSettings code is the current way I'm using to server public website or private wiki based on subdomain (it must be added after the WikiSkin extension is installed. If in ''wiki'' subdomain, then users are required to login to view any page at all. Once logged in, standard wiki skin is used with all personal links, and actions. If in the ''www'' subdomain, actions, personal and catlinks etc are not sent to client, and all actions except ''view'' and ''raw'' are disabled, there is no login required, but any pages not in the ''Public'' category return a ''404''.
+
See [[Maintaining websites with a wiki]]
<php>
 
# WIKISKIN
 
include("extensions/WikiSkin.php");
 
$wgWikiSkinArticle = 'Zenovia/WikiSkin';
 
 
 
# Only allow view,edit and raw actions from www subdomain
 
if (!ereg('^wiki.',$_SERVER['HTTP_HOST'])) {
 
if ($_REQUEST['action'] != 'view' && $_REQUEST['action'] != 'raw' && $_REQUEST['action'] != 'render')
 
$_REQUEST['action'] = 'view';
 
}
 
 
 
# A function to return a 404 and die
 
function wf404() {
 
header('HTTP/1.0 404 Not Found');
 
$err = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></he$
 
<body><h1>Not Found</h1><p>The requested URL was not found on this server.</p></body></html>';
 
if (in_array('Content-Encoding: gzip',headers_list())) $err = gzencode($err);
 
echo $err;
 
die;
 
}
 
 
 
# Return a 404 and die if www subdomain and article not in Category:Public
 
$wgHooks['ArticleAfterFetchContent'][] = 'wfPublicCategory';
 
function wfPublicCategory(&$article,&$text) {
 
$t = $_REQUEST['title'];
 
if ($article->mTitle->getText() != $t) return true;
 
if (eregi('\\.(css|js)$',$t)) return true;
 
if (!ereg('^wiki.',$_SERVER['HTTP_HOST'])) {
 
preg_match_all('/\\[{2}(category:.+?)(\\|.+?)?\\]/i',strtolower($text),$cats);
 
if (!in_array('category:public',$cats[1])) wf404();
 
}
 
return true;
 
}
 
 
 
# No anoymous users allowed in wiki
 
$wgExtensionFunctions[] = 'wfLocalSettingsArticle';
 
function wfLocalSettingsArticle() {
 
global $wgUser,$wgServer;
 
if (ereg('^wiki.',$_SERVER['HTTP_HOST'])) {
 
 
 
# Bounce to login if anonymous
 
if ($wgUser->isAnon() && $_REQUEST['title'] != 'Special:Userlogin') {
 
if (array_key_exists('live',$_REQUEST)) die;
 
header("Location: $wgServer/Special:Userlogin");
 
}
 
}
 
else {
 
 
 
# Don't allow non-existent articles in www
 
$t = Title::newFromText($_REQUEST['title']);
 
if (is_object($t) && !$t->exists()) wf404();
 
}
 
}
 
</php>
 
The WikiSkin can compliment this private/public distinction too by allowing the returning of different content for each using the following parser-function syntax:
 
:<tt><nowiki>{{#if:{{#pos:{{SERVER}}|wiki}}|PRIVATE-CONTENT|PUBLIC-CONTENT}}</nowiki></tt>
 

Revision as of 21:04, 28 May 2007

Where can I see a page that uses this extention? --Rob 14:58, 6 Apr 2007 (NZST)

I'm testing it on WikiFS: --Nad 15:01, 6 Apr 2007 (NZST)

Has anyone an more detailed demo or description for setting up the wikiskin? --User:nope 14.5.2007

It's still in beta state, but is working ok, just save the code into a file and include the file from your localsettings.php, but make sure your skin article is created first (the name of the article is set in $wgWikiSkin, the default name for the article is WikiSkin). OrganicDesign and our other wikis use it, OrganicDesign:Default-skin is the $wgWikiSkin article on it. We're just using it to replicate the standard monobook layout currently, but it's been developed for use with MW:Extension:Wiklets which is a desktop-like skin where different articles and forms work like windows on a desktop. --Nad 21:50, 14 May 2007 (UTC)

Private wiki & Public www

See Maintaining websites with a wiki