Extension:Simple namespaces

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Special:Namespaces

Release status: stable

Implementation Special page
Description Add new namespaces from Special:Namespaces page
Author(s) Unsupported derivative based on Special:Interwiki GPL by Stephanie Amanda Stevens
Last Version 0.1 (2007-4-11)
MediaWiki 1.7+
License No license specified
Download Extension:Simple namespaces/sourcecode

Special:Namespaces is a MediaWiki extension that allows administrators to create and modify custom namespaces without directly editing the configuration files. It is based on the Special:Interwiki special page to work with the interwiki table, which was released under GPL by Stephanie Amanda Stevens.

Contents

[edit] History

This code was intended to be a short-lived 'kludge', adapting or twisting an existing extension to fill a new task.

There was one branch ("wikidata") of MediaWiki 1.6 which included a partially-complete Special:Namespaces editor. Namespaces could simply be created, renamed or removed right from the web interface. While some of the proposed capabilities (such as automatic moves of existing pages into the new namespaces) hadn't been implemented, Special:Namespaces did appear to have the makings of a useful tool.

Special:Namespaces was to exist in some form in the core MediaWiki code from version 1.7 onward. This didn't happen.

Some wikis (including a few in the Uncyclopedia Babel series) were actively using Special:Namespaces (MW1.6-wikidata), creating a need to preserve at least minimal namespaces functionality despite site upgrades to MW1.7, 1.8, 1.9.

As the original Special:Interwiki is GPL'ed, a modified version to provide Special:Namespaces functions can be created subject to the same GPL. This code is provided as-is, do feel free to blame User:Carlb (Carl Austin Bennett) on Uncyclopædia if it horribly breaks but do keep in mind that this is unsupported code, patched together merely to avoid losing Special:Namespaces entirely.

This extension is therefore not guaranteed to exhibit the level of rigorous scientific validation which normally goes into Uncyclopædia content.

[edit] Installation

1. Copy the code from Extension:Simple namespaces/sourcecode to extensions/SpecialNamespaces.php
2. Create database table namespace_names with the following SQL query (replacing mw_ with your table prefix) (if it doesn't exist already):

CREATE TABLE `mw_namespace_names` (
  `ns_id` int(8) NOT NULL DEFAULT '0',
  `ns_name` varchar(200) NOT NULL DEFAULT '',
  `ns_default` tinyint(1) NOT NULL DEFAULT '0',
  `ns_canonical` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

3. Add one line to languages/Language.php, insert it immediately before the call to fixUpSettings():

        function load() {
                if ( !$this->mLoaded ) {
                        self::loadLocalisation( $this->getCode() );
                        $cache =& self::$mLocalisationCache[$this->getCode()];
                        foreach ( self::$mLocalisationKeys as $key ) {
                                $this->$key = $cache[$key];
                        }
                        $this->mLoaded = true;
 
/*** inserted code for Special:Namespaces extension ***/
                        wfRunHooks( 'LanguageNamespaces', array( &$this->namespaceNames, &$this->namespaceAliases, $this->getCode() ) );
/*** end of inserted code ***/
 
                        $this->fixUpSettings();
                }
        }

4. Add require_once('extensions/SpecialNamespaces.php'); to LocalSettings.php
5. Installation can be verified through Special:Version page of your wiki

If you're replacing MW1.6-wikidata with some subsequent MediaWiki version, the `namespace` and `namespace_names` tables will already exist. This extension ignores the `namespace` portion and uses `namespace_names` in a compatible manner so that any existing MW1.6-wikidata custom namespaces will continue to operate normally.

[edit] Notes

  • When creating new namespaces (as opposed to mere aliases for existing namespaces), it is normally advisable that 'default' and 'canonical' both be set to 1. Custom namespaces are each numbered, with 0-15 being reserved for MediaWiki's built-in namespaces. The convention of using even numbers (n) for primary namespaces and odd (n+1) for the corresponding talk pages still applies.
  • When renaming any of the existing MediaWiki namespaces (0-15), in most cases you will want the new name to be default (1) but not canonical (0). Setting both default and canonical to zero is only advisable if the name is merely an alias, used as an alternate link for something already listed.
  • This extension does not check for nor resolve existing page names that conflict with the names of new namespaces. There is a command-line utility provided as part of the base MediaWiki package that can move pages that are inaccessible due to naming conflicts:
php maintenance/namespaceDupes.php --fix
  • The project: namespace (namespace #4) is a special case in that Languages.php:fixUpSettings() will automatically insert the name of your project (as listed in LocalSettings). If you wish to be able to use the Special:Namespaces page to rename the project namespace, fixUpSettings() will need to be updated to check for this.
To verify that Project: namespace hasn't already been renamed in Special:Namespaces, change fixUpSettings to replace:
$this->namespaceNames[NS_PROJECT] = $wgMetaNamespace;
with:
if (!$this->namespaceNames[NS_PROJECT])
$this->namespaceNames[NS_PROJECT] = $wgMetaNamespace;
  • If using this code to create aliases to MediaWiki's built-in namespaces under MediaWiki 1.14, it appears that getCanonicalIndex() is not returning the proper namespace name -> namespace number conversion for these aliases. This routine is called from Languages.php and is needed to cause tags such as [[category: to be flagged for special handling.
  • The extension is relying heavily on memcached to store all of the information which it initially read from the database; this may cause problems in an environment in which multiple webservers are operating with one shared memcache and database serving MediaWiki installations across multiple machines. The scalability of this extension is therefore unknown.

[edit] See also

  • Special page to work with the interwiki table, from which this code was blatantly stolen. All install requirements there, including setting privilege levels to edit the data, also apply here.
  • Namespace manager as originally proposed for MW1.6-wikidata and its successors. This functionality exists in OmegaWiki but is not in the mainstream MediaWiki software.
  • OmegaWiki, based on MediaWiki 1.10alpha (r26222), is the successor to WikiData 1.6
  • Extension:Configure allows web-based control over most or all of the standard LocalSettings.php settings. It should be capable of allowing bureaucrats to add extra namespaces, but beware: it is a powerful tool which by default allows bureaucrats to make fundamental wiki configuration changes affecting filesystem paths and executables, more than a few of which could disable a wiki entirely if misused. It is primarily a system administration tool.
Personal tools