Page MenuHomePhabricator

Custom namespace handlers
Closed, ResolvedPublic

Description

Author: bugs

Description:
Currently, MediaWiki handles Category and Image pages specially when they are
displayed. This is hard coded in Wiki.php/MediaWiki::articleFromTitle(). It
would be nice if extensions could define their own namespace handling classes
without having to patch core MediaWiki code. The idea is to enable extensions to
define their own classes similar to CategoryPage and ImagePage, and assign them
to custom namespaces. This is possible with minimal changes to the core code,
and would allow extensions to redefine the behavior of article pages.

For example, for a given namespace, an extension could list additional
information after the page contents, change navigation/action/toolbox-links, or
simply display an extra image or a few namespace-specific links along the side
of the page.

A patch with a possible implementation follows.


Version: 1.8.x
Severity: enhancement

Details

Reference
bz5135

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:07 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz5135.
bzimport added a subscriber: Unknown Object (MLST).

bugs wrote:

Possible implementation

This is how I implemented this on my own MediaWiki installation.

There is one additional config var in DefaultSettings.php, and a few changed
lines in Wiki.php to load the namespace handling class. Also a new extension
type for SpecialVersion.php.

Attached:

It looks like the concept of a "namespace manager" will be integrated into 1.9,
see bug 7803. I marked this as a dupe, since if I understand correctly, 7803
will cover the functionality requested here.

  • This bug has been marked as a duplicate of 7803 ***

webboy wrote:

Sorry, the namespace manager does not contain this function.

bugs wrote:

I think that this issue was effectively resolved in a different manner by the
new "ArticleFromTitle" hook introduced in r16210 (released with 1.8.0). The
documentation is still missing
(http://www.mediawiki.org/wiki/Manual:MediaWiki_hooks), but it is pretty
straightforward by looking into the code:

http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/Wiki.php?view=diff&r1=16209&r2=16210

Thanks Tim Starling!