[Mediawiki-l] Proposed change in wiki links

Chris Phoenix cphoenix at CRNano.org
Mon Sep 27 04:21:14 UTC 2004


I propose that if a link like [[foo]] is processed for output, and 
article foo doesn't exist but category foo does, then the link should be 
treated like [[:Category:foo|foo]].  The former is a lot easier to write.

This will make it hard to create an article foo if category foo already 
exists.  I'm not sure that's a bad thing.  If someone does manage to do 
that, then all [[foo]] links will switch from category to article.  But 
these are the only drawbacks I can see.

The code is very simple.  In the place in Skin.php:makeLinkObj() where 
it checks if the article ID is 0 and makes a broken link, use this code 
instead:

$aid = $nt->getArticleID() ;
if ( 0 == $aid ) {
        #New stuff starts here...
   $ttext = $nt->getText() ;
   $cname = Namespace::getCanonicalName(Namespace::getCategory());
   $cnt = Title::newFromText ( $cname.":".$ttext ) ;
   if (0 == $cnt->getArticleID()) {
     $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, 
$prefix );
   } else {
     $retVal = $this->makeKnownLinkObj( $cnt, $text, $query, $trail, 
$prefix );
} else { #...

Is this the right place to propose this kind of change?

Chris

-- 
Chris Phoenix                                  cphoenix at CRNano.org
Director of Research
Center for Responsible Nanotechnology          http://CRNano.org



More information about the MediaWiki-l mailing list