mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-30 19:16:15 +00:00
Inject service LinkRenderer into CategoryTree
Change-Id: Id70e9b26229332889de009b55837dbab6ecbb163
This commit is contained in:
parent
e81f6fe15e
commit
e492044e44
|
@ -26,6 +26,7 @@
|
||||||
"ConfigFactory",
|
"ConfigFactory",
|
||||||
"DBLoadBalancerFactory",
|
"DBLoadBalancerFactory",
|
||||||
"LanguageConverterFactory",
|
"LanguageConverterFactory",
|
||||||
|
"LinkRenderer",
|
||||||
"MainWANObjectCache"
|
"MainWANObjectCache"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,8 @@
|
||||||
"class": "MediaWiki\\Extension\\CategoryTree\\Hooks",
|
"class": "MediaWiki\\Extension\\CategoryTree\\Hooks",
|
||||||
"services": [
|
"services": [
|
||||||
"CategoryTree.CategoryCache",
|
"CategoryTree.CategoryCache",
|
||||||
"MainConfig"
|
"MainConfig",
|
||||||
|
"LinkRenderer"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|
|
@ -8,6 +8,7 @@ use FormatJson;
|
||||||
use MediaWiki\Config\Config;
|
use MediaWiki\Config\Config;
|
||||||
use MediaWiki\Config\ConfigFactory;
|
use MediaWiki\Config\ConfigFactory;
|
||||||
use MediaWiki\Languages\LanguageConverterFactory;
|
use MediaWiki\Languages\LanguageConverterFactory;
|
||||||
|
use MediaWiki\Linker\LinkRenderer;
|
||||||
use MediaWiki\Title\Title;
|
use MediaWiki\Title\Title;
|
||||||
use WANObjectCache;
|
use WANObjectCache;
|
||||||
use Wikimedia\ParamValidator\ParamValidator;
|
use Wikimedia\ParamValidator\ParamValidator;
|
||||||
|
@ -37,6 +38,9 @@ class ApiCategoryTree extends ApiBase {
|
||||||
/** @var LanguageConverterFactory */
|
/** @var LanguageConverterFactory */
|
||||||
private $languageConverterFactory;
|
private $languageConverterFactory;
|
||||||
|
|
||||||
|
/** @var LinkRenderer */
|
||||||
|
private $linkRenderer;
|
||||||
|
|
||||||
/** @var IConnectionProvider */
|
/** @var IConnectionProvider */
|
||||||
private $dbProvider;
|
private $dbProvider;
|
||||||
|
|
||||||
|
@ -49,6 +53,7 @@ class ApiCategoryTree extends ApiBase {
|
||||||
* @param ConfigFactory $configFactory
|
* @param ConfigFactory $configFactory
|
||||||
* @param IConnectionProvider $dbProvider
|
* @param IConnectionProvider $dbProvider
|
||||||
* @param LanguageConverterFactory $languageConverterFactory
|
* @param LanguageConverterFactory $languageConverterFactory
|
||||||
|
* @param LinkRenderer $linkRenderer
|
||||||
* @param WANObjectCache $wanCache
|
* @param WANObjectCache $wanCache
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -57,11 +62,13 @@ class ApiCategoryTree extends ApiBase {
|
||||||
ConfigFactory $configFactory,
|
ConfigFactory $configFactory,
|
||||||
IConnectionProvider $dbProvider,
|
IConnectionProvider $dbProvider,
|
||||||
LanguageConverterFactory $languageConverterFactory,
|
LanguageConverterFactory $languageConverterFactory,
|
||||||
|
LinkRenderer $linkRenderer,
|
||||||
WANObjectCache $wanCache
|
WANObjectCache $wanCache
|
||||||
) {
|
) {
|
||||||
parent::__construct( $main, $action );
|
parent::__construct( $main, $action );
|
||||||
$this->configFactory = $configFactory;
|
$this->configFactory = $configFactory;
|
||||||
$this->languageConverterFactory = $languageConverterFactory;
|
$this->languageConverterFactory = $languageConverterFactory;
|
||||||
|
$this->linkRenderer = $linkRenderer;
|
||||||
$this->dbProvider = $dbProvider;
|
$this->dbProvider = $dbProvider;
|
||||||
$this->wanCache = $wanCache;
|
$this->wanCache = $wanCache;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +88,7 @@ class ApiCategoryTree extends ApiBase {
|
||||||
|
|
||||||
$depth = isset( $options['depth'] ) ? (int)$options['depth'] : 1;
|
$depth = isset( $options['depth'] ) ? (int)$options['depth'] : 1;
|
||||||
|
|
||||||
$ct = new CategoryTree( $options );
|
$ct = new CategoryTree( $options, $this->linkRenderer );
|
||||||
$depth = OptionManager::capDepth( $ct->optionManager->getOption( 'mode' ), $depth );
|
$depth = OptionManager::capDepth( $ct->optionManager->getOption( 'mode' ), $depth );
|
||||||
$ctConfig = $this->configFactory->makeConfig( 'categorytree' );
|
$ctConfig = $this->configFactory->makeConfig( 'categorytree' );
|
||||||
$html = $this->getHTML( $ct, $title, $depth, $ctConfig );
|
$html = $this->getHTML( $ct, $title, $depth, $ctConfig );
|
||||||
|
|
|
@ -49,10 +49,14 @@ class CategoryTree {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
* @param LinkRenderer $linkRenderer
|
||||||
*/
|
*/
|
||||||
public function __construct( array $options ) {
|
public function __construct(
|
||||||
|
array $options,
|
||||||
|
LinkRenderer $linkRenderer
|
||||||
|
) {
|
||||||
$this->optionManager = new OptionManager( $options );
|
$this->optionManager = new OptionManager( $options );
|
||||||
$this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
$this->linkRenderer = $linkRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,7 +100,7 @@ class CategoryTreePage extends SpecialPage {
|
||||||
$options[$option] = $request->getVal( $option, $default );
|
$options[$option] = $request->getVal( $option, $default );
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tree = new CategoryTree( $options );
|
$this->tree = new CategoryTree( $options, $this->getLinkRenderer() );
|
||||||
|
|
||||||
$this->getOutput()->addWikiMsg( 'categorytree-header' );
|
$this->getOutput()->addWikiMsg( 'categorytree-header' );
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ use MediaWiki\Hook\SkinBuildSidebarHook;
|
||||||
use MediaWiki\Hook\SpecialTrackingCategories__generateCatLinkHook;
|
use MediaWiki\Hook\SpecialTrackingCategories__generateCatLinkHook;
|
||||||
use MediaWiki\Hook\SpecialTrackingCategories__preprocessHook;
|
use MediaWiki\Hook\SpecialTrackingCategories__preprocessHook;
|
||||||
use MediaWiki\Html\Html;
|
use MediaWiki\Html\Html;
|
||||||
|
use MediaWiki\Linker\LinkRenderer;
|
||||||
use MediaWiki\Linker\LinkTarget;
|
use MediaWiki\Linker\LinkTarget;
|
||||||
use MediaWiki\Output\OutputPage;
|
use MediaWiki\Output\OutputPage;
|
||||||
use MediaWiki\Parser\Sanitizer;
|
use MediaWiki\Parser\Sanitizer;
|
||||||
|
@ -67,13 +68,22 @@ class Hooks implements
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
/** @var LinkRenderer */
|
||||||
|
private $linkRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CategoryCache $categoryCache
|
* @param CategoryCache $categoryCache
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
|
* @param LinkRenderer $linkRenderer
|
||||||
*/
|
*/
|
||||||
public function __construct( CategoryCache $categoryCache, Config $config ) {
|
public function __construct(
|
||||||
|
CategoryCache $categoryCache,
|
||||||
|
Config $config,
|
||||||
|
LinkRenderer $linkRenderer
|
||||||
|
) {
|
||||||
$this->categoryCache = $categoryCache;
|
$this->categoryCache = $categoryCache;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->linkRenderer = $linkRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +203,7 @@ class Hooks implements
|
||||||
$parserOutput->addModules( [ 'ext.categoryTree' ] );
|
$parserOutput->addModules( [ 'ext.categoryTree' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
$ct = new CategoryTree( $argv );
|
$ct = new CategoryTree( $argv, $this->linkRenderer );
|
||||||
|
|
||||||
$attr = Sanitizer::validateTagAttributes( $argv, 'div' );
|
$attr = Sanitizer::validateTagAttributes( $argv, 'div' );
|
||||||
|
|
||||||
|
@ -316,7 +326,7 @@ class Hooks implements
|
||||||
if ( $mode !== null ) {
|
if ( $mode !== null ) {
|
||||||
$options['mode'] = $mode;
|
$options['mode'] = $mode;
|
||||||
}
|
}
|
||||||
$tree = new CategoryTree( $options );
|
$tree = new CategoryTree( $options, $this->linkRenderer );
|
||||||
|
|
||||||
$cat = $this->categoryCache->getCategory( $title );
|
$cat = $this->categoryCache->getCategory( $title );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue