[Mediawiki-l] Namespace handlers

Rob Lanphier robla at robla.net
Tue Nov 1 08:02:42 UTC 2005


Hi folks,

As part of writing my extension for MediaWiki, I created a mechanism for
plugging in namespace handlers, which work similarly to the way that
"Image:" and "Category:" are handled, but defined outside the core code.

I wrote the attached patch for MediaWiki 1.5.1.  I haven't yet tried to
port it to head, but I intend to, assuming I receive no negative
feedback on the idea here.  I see the code is slightly different in the
head, but it doesn't look like a drastically different approach.

The way this patch works is by introducing a new global array:
$wgNamespaceHandler.  Here's the structure:

$wgNamespaceHandler[$nid] = array containing the namespace handler for
namespace with numeric id of $nid

$wgNamespaceHandler[$nid]['ArticleClass'] = class name of the class
meant to extend the Article class.
$wgNamespaceHandler[$nid]['ArticleInclude'] = include file for the above
class.
$wgNamespaceHandler[$nid]['EditClass'] = class name of the class meant
to extend the EditPage class.
$wgNamespaceHandler[$nid]['EditInclude'] = include file for the above
class
$wgNamespaceHandler[$nid]['NameSpaceKey'] = the l10n key for the article
tab in the UI

The patch adds checks for the presence of this array, and potentially
instantiates the defined classes instead of Article and EditPage if set.
One could theoretically simplify the code by implementing categories and
images this way, too, but in the interest of keeping my patch as
non-invasive as possible, I'm not doing that.

Anyway, I don't expect that the patch below would be accepted for the
1.5.x branch.  What I'm hoping to do is get some feedback on the
approach for getting this in the head before tearing in.

Thoughts?

Rob


More information about the MediaWiki-l mailing list