Add hook to replace logic for generating category links. May be used by CategoryTree...
authorDaniel Kinzler <daniel@users.mediawiki.org>
Wed, 2 Jul 2008 20:02:51 +0000 (20:02 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Wed, 2 Jul 2008 20:02:51 +0000 (20:02 +0000)
docs/hooks.txt
includes/OutputPage.php

index 57e6a85..8a787c3 100644 (file)
@@ -859,6 +859,12 @@ $text: the text that will be displayed, in HTML (string)
 $out: OutputPage instance (object)
 $parserOutput: parserOutput instance being added in $out
 
+'OutputPageMakeCategoryLinks': links are about to be generated for the page's categories.
+  Implementations should return false if they generate the category links, so the default link generation is skipped.
+$out: OutputPage instance (object)
+$categories: associative array, keys are category names, values are category types ("normal" or "hidden")
+$links: array, intended to hold the result. Must be an associative array with category types as keys and arrays of HTML links as values.
+
 'PageHistoryBeforeList': When a history page list is about to be constructed.
 $article: the article that the history is loading for
 
index d6a6877..99c752b 100644 (file)
@@ -320,11 +320,13 @@ class OutputPage {
                }
 
                # Add the remaining categories to the skin
-               $sk = $wgUser->getSkin();
-               foreach ( $categories as $category => $type ) {
-                       $title = Title::makeTitleSafe( NS_CATEGORY, $category );
-                       $text = $wgContLang->convertHtml( $title->getText() );
-                       $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
+               if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
+                       $sk = $wgUser->getSkin();
+                       foreach ( $categories as $category => $type ) {
+                               $title = Title::makeTitleSafe( NS_CATEGORY, $category );
+                               $text = $wgContLang->convertHtml( $title->getText() );
+                               $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
+                       }
                }
        }