Extension talk:Wikiskin.php

From Organic Design wiki
Revision as of 03:52, 25 May 2007 by Nad (talk | contribs) (Private wiki & Public www: comments)

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

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. <php>

  1. WIKISKIN

include("extensions/WikiSkin.php"); $wgWikiSkinArticle = 'Zenovia/WikiSkin';

  1. 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'; }

  1. 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">404 Not Found

Not Found

The requested URL was not found on this server.

'; if (in_array('Content-Encoding: gzip',headers_list())) $err = gzencode($err); echo $err; die; }

  1. 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; }

  1. 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:

{{#if:{{#pos:{{SERVER}}|wiki}}|PRIVATE-CONTENT|PUBLIC-CONTENT}}