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

From Organic Design wiki
m
(Private wiki & Public www)
Line 3: Line 3:
 
Has anyone an more detailed demo or description for setting up the wikiskin? --[[User:nope]] 14.5.2007
 
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. --[[User:Nad|Nad]] 21:50, 14 May 2007 (UTC)
 
: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. --[[User:Nad|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>
 +
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></head>
 +
                <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;
 +
        }
 +
 +
$wgHooks['ArticleAfterFetchContent'][] = 'wfPublicCategory';
 +
function wfPublicCategory(&$article,&$text) {
 +
        global $wgWikiSkinArticle,$wgUser,$wgParser;
 +
        $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();
 +
                $wgWikiSkinArticle = 'WebSkin';
 +
                }
 +
        return true;
 +
        }
 +
 +
# No anoymous users allowed
 +
$wgExtensionFunctions[] = 'wfLocalSettingsArticle';
 +
function wfLocalSettingsArticle() {
 +
        global $wgUser,$wgServer,$wgWikiSkinArticle,$wgParser;
 +
        if (ereg('^wiki.',$_SERVER['HTTP_HOST'])) {
 +
                if ($wgUser->isAnon() && $_REQUEST['title'] != 'Special:Userlogin') {
 +
                        if (array_key_exists('live',$_REQUEST)) die;
 +
                        header("Location: $wgServer/Special:Userlogin");
 +
                        }
 +
                }
 +
        else {
 +
                $t = Title::newFromText($_REQUEST['title']);
 +
                if (is_object($t) && !$t->exists()) wf404();
 +
                }
 +
        }
 +
</php>

Revision as of 11:01, 17 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

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

$wgHooks['ArticleAfterFetchContent'][] = 'wfPublicCategory'; function wfPublicCategory(&$article,&$text) {

       global $wgWikiSkinArticle,$wgUser,$wgParser;
       $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();
               $wgWikiSkinArticle = 'WebSkin';
               }
       return true;
       }
  1. No anoymous users allowed

$wgExtensionFunctions[] = 'wfLocalSettingsArticle'; function wfLocalSettingsArticle() {

       global $wgUser,$wgServer,$wgWikiSkinArticle,$wgParser;
       if (ereg('^wiki.',$_SERVER['HTTP_HOST'])) {
               if ($wgUser->isAnon() && $_REQUEST['title'] != 'Special:Userlogin') {
                       if (array_key_exists('live',$_REQUEST)) die;
                       header("Location: $wgServer/Special:Userlogin");
                       }
               }
       else {
               $t = Title::newFromText($_REQUEST['title']);
               if (is_object($t) && !$t->exists()) wf404();
               }
       }

</php>