Suppress links to empty categories
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 23 Aug 2006 05:00:16 +0000 (05:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 23 Aug 2006 05:00:16 +0000 (05:00 +0000)
skins/disabled/HTMLDump.php

index 20ec01e..2adf338 100644 (file)
@@ -75,7 +75,13 @@ class SkinHTMLDump extends SkinTemplate {
                }
 
                if ( $nt->getNamespace() == NS_CATEGORY ) {
-                       return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
+                       # Determine if the category has any articles in it
+                       $dbr =& wfGetDB( DB_SLAVE );
+                       $hasMembers = $dbr->selectField( 'categorylinks', '1', 
+                               array( 'cl_to' => $nt->getDBkey() ), __METHOD__ );
+                       if ( $hasMembers ) {
+                               return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
+                       }
                }
 
                if ( $text == '' ) {