From d78fc9add9f7b314231bed1d3e25b31a0ef22580 Mon Sep 17 00:00:00 2001 From: Sharptrick Date: Wed, 31 Jul 2019 05:46:31 +0000 Subject: [PATCH] Altered renderNodeInfo() to use LinkRenderer.php. Using LinkRenderer.php instead of compiling links manually gives the HtmlPageLinkRendererBegin hook a chance to be called. This enables compatibility with the DisplayTitle extension. Change-Id: I67633d1add6d1409eac6962a7bd854c3cc93d5ff --- includes/CategoryTree.php | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/includes/CategoryTree.php b/includes/CategoryTree.php index 1a0479f7..c6ddd266 100644 --- a/includes/CategoryTree.php +++ b/includes/CategoryTree.php @@ -22,12 +22,15 @@ * @author Daniel Kinzler, brightbyte.de */ +use MediaWiki\MediaWikiServices; + /** * Core functions for the CategoryTree extension, an AJAX based gadget * to display the category structure of a wiki */ class CategoryTree { public $mOptions = []; + private $linkRenderer; /** * @suppress PhanTypeInvalidDimOffset @@ -35,6 +38,7 @@ class CategoryTree { */ public function __construct( array $options ) { global $wgCategoryTreeDefaultOptions; + $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); // ensure default values and order of options. // Order may become important, it may influence the cache key! @@ -590,24 +594,7 @@ class CategoryTree { $label = $title->getPrefixedText(); } - $labelClass = 'CategoryTreeLabel ' . ' CategoryTreeLabelNs' . $ns; - - if ( !$title->getArticleID() ) { - $labelClass .= ' new'; - $wikiLink = $title->getLocalURL( 'action=edit&redlink=1' ); - } else { - $wikiLink = $title->getLocalURL(); - } - - if ( $ns == NS_CATEGORY ) { - $labelClass .= ' CategoryTreeLabelCategory'; - } else { - $labelClass .= ' CategoryTreeLabelPage'; - } - - if ( ( $ns % 2 ) > 0 ) { - $labelClass .= ' CategoryTreeLabelTalk'; - } + $link = $this->linkRenderer->makeLink( $title, $label ); $count = false; $s = ''; @@ -659,15 +646,7 @@ class CategoryTree { } $s .= Xml::tags( 'span', $attr, $bullet ) . ' '; - $s .= Xml::element( - 'a', - [ - 'class' => $labelClass, - 'href' => $wikiLink, - 'title' => $title->getPrefixedText() - ], - $label - ); + $s .= $link; if ( $count !== false && $this->getOption( 'showcount' ) ) { $s .= self::createCountString( RequestContext::getMain(), $cat, $count );