mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
Move all Parser handling to Hooks::parserHook
Change-Id: I5d35c6d87b610ffb566588a3d0c75067c1d06962
This commit is contained in:
parent
a918bdea16
commit
921e6fe3f9
|
@ -33,7 +33,6 @@ use MediaWiki\Html\Html;
|
|||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Output\OutputPage;
|
||||
use MediaWiki\Parser\Parser;
|
||||
use MediaWiki\Registration\ExtensionRegistry;
|
||||
use MediaWiki\SpecialPage\SpecialPage;
|
||||
use MediaWiki\Title\Title;
|
||||
|
@ -73,31 +72,20 @@ class CategoryTree {
|
|||
/**
|
||||
* Custom tag implementation. This is called by Hooks::parserHook, which is used to
|
||||
* load CategoryTreeFunctions.php on demand.
|
||||
* @param ?Parser $parser
|
||||
* @param string $category
|
||||
* @param bool $hideroot
|
||||
* @param array $attr
|
||||
* @param int $depth
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getTag( ?Parser $parser, string $category, bool $hideroot = false, array $attr = [],
|
||||
public function getTag( string $category, bool $hideroot = false, array $attr = [],
|
||||
int $depth = 1
|
||||
) {
|
||||
$disableCache = $this->config->get( 'CategoryTreeDisableCache' );
|
||||
|
||||
$category = trim( $category );
|
||||
if ( $category === '' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $parser ) {
|
||||
if ( $disableCache === true ) {
|
||||
$parser->getOutput()->updateCacheExpiry( 0 );
|
||||
} elseif ( is_int( $disableCache ) ) {
|
||||
$parser->getOutput()->updateCacheExpiry( $disableCache );
|
||||
}
|
||||
}
|
||||
|
||||
$title = self::makeTitle( $category );
|
||||
|
||||
if ( $title === null ) {
|
||||
|
|
|
@ -197,6 +197,13 @@ class Hooks implements
|
|||
$parserOutput = $parser->getOutput();
|
||||
$parserOutput->addModuleStyles( [ 'ext.categoryTree.styles' ] );
|
||||
$parserOutput->addModules( [ 'ext.categoryTree' ] );
|
||||
|
||||
$disableCache = $this->config->get( 'CategoryTreeDisableCache' );
|
||||
if ( $disableCache === true ) {
|
||||
$parserOutput->updateCacheExpiry( 0 );
|
||||
} elseif ( is_int( $disableCache ) ) {
|
||||
$parserOutput->updateCacheExpiry( $disableCache );
|
||||
}
|
||||
}
|
||||
|
||||
$ct = new CategoryTree( $argv, $this->config, $this->dbProvider, $this->linkRenderer );
|
||||
|
@ -224,7 +231,7 @@ class Hooks implements
|
|||
}
|
||||
|
||||
return $message .
|
||||
$ct->getTag( $parser, $cat, $hideroot, $attr, $depth );
|
||||
$ct->getTag( $cat, $hideroot, $attr, $depth );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue