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
On 01/11/05, Rob Lanphier robla@robla.net wrote:
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.
This sounds like a very nice idea, and would personally approve of making Image: and Category: work this way, since it adds consistency, and guarantees that the extension mechanism is flexible enough to have future applications. [For similar reasons, I think <math> should probably be implemented as an extension, and the magic ISBN, RFC, etc, handlers, should be generalised to a new extension mechanism.]
One thing you might want to look into is Erik's work preparing the way for "Wikidata", in which he's implemented an experimental system for storing namespace metadata in the database. If that ever hits the main code, it would be nice to combine that work with yours... See http://mail.wikimedia.org/pipermail/wikitech-l/2005-August/031257.html
-- Rowan Collins BSc [IMSoP]
Hi Rowan,
Thanks for the feedback and the pointer. It looks like I have yet another reason to check out the Wikidata branch. A lot of my approach on Electowidget has been very wikidata-ish in nature, so I should probably bite the bullet and learn where things are headed there.
Rob
On Tue, 2005-11-01 at 12:51 +0000, Rowan Collins wrote:
On 01/11/05, Rob Lanphier robla@robla.net wrote:
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.
This sounds like a very nice idea, and would personally approve of making Image: and Category: work this way, since it adds consistency, and guarantees that the extension mechanism is flexible enough to have future applications. [For similar reasons, I think <math> should probably be implemented as an extension, and the magic ISBN, RFC, etc, handlers, should be generalised to a new extension mechanism.]
One thing you might want to look into is Erik's work preparing the way for "Wikidata", in which he's implemented an experimental system for storing namespace metadata in the database. If that ever hits the main code, it would be nice to combine that work with yours... See http://mail.wikimedia.org/pipermail/wikitech-l/2005-August/031257.html
-- Rowan Collins BSc [IMSoP] _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org