Hi folks,
I've been looking at the namespace manager in wikidata, as well as
looking at how things are in the trunk. I'm eager to have improved
namespace facilities, since it makes my life easier in creating
extensions. It may be easier to discuss these ideas face-to-face later
this week, but I figured it'd be better to compose my thoughts as a
starting point.
Suggestions:
* Change $wgNamespace to a static variable, accessed by new global
function: wfGetNamespace($nsnumber). This makes it much easier to
enforce the edict "Do NOT alter the $wgNamespaces object" (especially if
you threaten to return a clone from wfGetNamespace in future versions,
performance be damned)
* Create mNamespace member variable for the Title and Article objects
which is merely a reference to the corresponding namespace object (viva
PHP5).
* Add utility function for getting the default name given a constant.
Change this:
global $wgNamespace;
$wgNamespaces[NS_TALK]->getDefaultName()
...to one of the following, as appropriate:
wfGetDefaultNSName(NS_TALK)
...or (preferable when applicable):
$this->mNamespace->getDefaultName()
* (down the road) Create new objects which extend the Article object,
and remove some/all of the namespace conditionals from the Article
object altogether (e.g. UserTalkPage object for User_talk:, SpecialPage
for "Special:", and SystemPage or MediaWikiPage for "MediaWiki:")
* Consolidate "new Article" instantiation in a class factory. It may
be easiest to make this a method of the Title object, so that rather
than creating an article like this:
$article = new Article($title)
...you create it using:
$article = $title->newArticle();
(actually, this doesn't need to wait for a new namespace manager...I may
just submit a patch for this)
Those are some thoughts for now. Looking forward to seeing everyone at
Wikimania.
Rob