Open main menu

Extension:PublicCat

MediaWiki extensions manual
OOjs UI icon advanced.svg
PublicCat
Release status: stable
Implementation User rights
Description Divides wiki into private and public by domain name, but allows unrestricted access to articles in a public category.
Author(s) User:Nad
Latest version 1.0.4 (2008-02-12)
MediaWiki all versions
License No license specified
Download PublicCat.php
Translate the PublicCat extension if it is available at translatewiki.net
Check usage and version matrix.

A lot of the MediaWiki's we maintain at OrganicDesign:OrganicDesign are mainly for internal document management use for intranets. But often it's convenient to have a single category available publically which looks like a normal website (having none of the usual wiki links for editing and history etc).

This extension divides the site into public and private based on the domain that the requests originate from (we use www.domain for public and wiki.domain for private.

The private domain has all the normal wiki functionality, but is completely inaccessible unless logged in. If not logged in then all requests to the private wiki domain will take you to the login page.

Requests to the public domain results in the usual content but only articles which are members of a specified public category are available and all other requests will result in a 404 not found error. Also only view, raw or render actions are allowed from the public domain, all other actions will be changed to view.

The removal of the wiki content-actions and personal links etc is not handled by this extension, we use Extension:WikiSkin to render the skin aspects conditionally.

InstallationEdit

The extension is a single script which you can obtain from OrganicDesign:Extension:PublicCat.php and save into your extensions directory and include in your LocalSettings.php file as in the following example,

include("$IP/extensions/PublicCat.php");

UsageEdit

A useful wikitext expression is shown below which allows content to be displayed only if the user is accessing the wiki from the private domain.

{{#if:{{#pos:{{SERVER}}|wiki}}|Private content here}}

ConfigurationEdit

Configuration of this extension is done via two global variables which can be set in your LocalSettings file after the include of the PublicCat.php script. NOTE: to change the default values of these variables, you must set them before the include line.

Variable Default value Meaning
$wgPublicCat Public This is the name of the category which articles must be a member of to be accessible from the public site. Any requests from the public domain for article which are not in this category will result in a 404 not found error.
$wgPublicCatPrivatePattern /^wiki\\./ This is a regular expression which will be matched against the domain name of the requested URL to determine if the request is private or public. The default value specifies that if the domain starts with "wiki." then it is private, anything else is considered to be a public site request.

ChangesEdit

  • 1.0.4 (2008-02-12): 1.0.4 - bug fix - couldn't change defaults
  • 1.0.3 (2007-09-22): use $wgOut->disable() instead of die
  • 1.0.2 (2007-09-14): fixed warning messages in MW1.11