- global $wgUseCategoryMagic;
- if( !$wgUseCategoryMagic ) return "" ;
- if( count( $wgOut->mCategoryLinks ) == 0 ) return "";
- if( !$wgOut->isArticle() ) return "";
-
- $t = implode ( " | " , $wgOut->mCategoryLinks ) ;
- $s = $this->makeKnownLink( "Special:Categories",
- wfMsg( "categories" ), "article=" . urlencode( $wgTitle->getPrefixedDBkey() ) )
- . ": " . $t;
-
- $s .= "<br/><hr/>";
- $catstack = array();
- $wgTitle->getAllParentCategories(&$catstack);
- foreach ($catstack as $key => $cat)
- {
- $s .= $key." > ".$cat."<br/>\n";
+ global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
+
+ if( !$wgUseCategoryMagic ) return '' ;
+ if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
+
+ # Taken out so that they will be displayed in previews -- TS
+ #if( !$wgOut->isArticle() ) return '';
+
+ $t = implode ( ' | ' , $wgOut->mCategoryLinks ) ;
+ $s = $this->makeKnownLink( 'Special:Categories',
+ wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
+ . ': ' . $t;
+
+ # optional 'dmoz-like' category browser. Will be shown under the list
+ # of categories an article belong to
+ if($wgUseCategoryBrowser) {
+ $s .= '<br/><hr/>';
+
+ # get a big array of the parents tree
+ $parenttree = $wgTitle->getCategorieBrowser();
+
+ # Render the array as a serie of links
+ function walkThrough ($tree) {
+ global $wgUser;
+ $sk = $wgUser->getSkin();
+ $return = '';
+ foreach($tree as $element => $parent) {
+ if(empty($parent)) {
+ # element start a new list
+ $return .= '<br />';
+ } else {
+ # grab the others elements
+ $return .= walkThrough($parent);
+ }
+ # add our current element to the list
+ $eltitle = Title::NewFromText($element);
+ # FIXME : should be makeLink() [AV]
+ $return .= $sk->makeKnownLink($element, $eltitle->getText()).' > ';
+ }
+ return $return;
+ }
+
+ $s .= walkThrough($parenttree);