36 global $wgCategoryTreeForceHeaders;
37 return $wgCategoryTreeForceHeaders;
46 global $wgCategoryTreeDefaultOptions, $wgCategoryTreeDefaultMode;
47 global $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeCategoryPageMode;
48 global $wgCategoryTreeOmitNamespace;
50 if ( !isset( $wgCategoryTreeDefaultOptions[
'mode'] )
51 || is_null( $wgCategoryTreeDefaultOptions[
'mode'] )
53 $wgCategoryTreeDefaultOptions[
'mode'] = $wgCategoryTreeDefaultMode;
56 if ( !isset( $wgCategoryTreeDefaultOptions[
'hideprefix'] )
57 || is_null( $wgCategoryTreeDefaultOptions[
'hideprefix'] )
59 $wgCategoryTreeDefaultOptions[
'hideprefix'] = $wgCategoryTreeOmitNamespace;
62 if ( !isset( $wgCategoryTreeCategoryPageOptions[
'mode'] )
63 || is_null( $wgCategoryTreeCategoryPageOptions[
'mode'] )
66 $wgCategoryTreeCategoryPageOptions[
'mode'] = ( $mode )
74 public static function setHooks( Parser $parser ) {
75 global $wgCategoryTreeAllowTag;
76 if ( !$wgCategoryTreeAllowTag ) {
79 $parser->setHook(
'categorytree',
'CategoryTreeHooks::parserHook' );
80 $parser->setFunctionHook(
'categorytree',
'CategoryTreeHooks::parserFunction' );
96 $cat = array_shift( $params );
100 foreach ( $params as $p ) {
101 if ( preg_match(
'/^\s*(\S.*?)\s*=\s*(.*?)\s*$/', $p, $m ) ) {
104 $v = preg_replace(
'/^"\s*(.*?)\s*"$/',
'$1', $m[2] );
115 return [ $html,
'noparse' =>
true,
'isHTML' =>
true ];
125 global $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions;
127 if ( !$wgCategoryTreeSidebarRoot ) {
131 $html =
self::parserHook( $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions );
133 $sidebar[
'categorytree-portlet'] = $html;
151 Parser $parser =
null,
152 $allowMissing =
false
155 # flag for use by CategoryTreeHooks::parserOutput
156 $parser->mOutput->mCategoryTreeTag =
true;
161 $attr = Sanitizer::validateTagAttributes( $argv,
'div' );
163 $hideroot = isset( $argv[
'hideroot'] )
165 $onlyroot = isset( $argv[
'onlyroot'] )
167 $depthArg = isset( $argv[
'depth'] ) ? (int)$argv[
'depth'] :
null;
174 return $ct->getTag( $parser, $cat, $hideroot, $attr, $depth, $allowMissing );
186 if ( self::shouldForceHeaders() ) {
190 if ( !empty( $parserOutput->mCategoryTreeTag ) ) {
202 if ( !self::shouldForceHeaders() ) {
232 global $wgCategoryTreePageCategoryOptions, $wgCategoryTreeHijackPageCategories;
234 if ( !$wgCategoryTreeHijackPageCategories ) {
239 foreach ( $categories as $category =>
$type ) {
254 global $wgCategoryTreeCategoryPageOptions;
257 $ct =
new CategoryTree( $wgCategoryTreeCategoryPageOptions );
260 'defaultCtOptions' => $ct->getOptionsAsJsStructure(),
271 SpecialPage $specialPage, array $trackingCategories
273 $categoryDbKeys = [];
274 foreach ( $trackingCategories as $catMsg => $data ) {
275 foreach ( $data[
'cats'] as $catTitle ) {
276 $categoryDbKeys[] = $catTitle->getDbKey();
280 if ( $categoryDbKeys ) {
284 [
'cat_id',
'cat_title',
'cat_pages',
'cat_subcats',
'cat_files' ],
285 [
'cat_title' => array_unique( $categoryDbKeys ) ],
288 foreach (
$res as $row ) {
292 $specialPage->categoryTreeCategories = $categories;
305 if ( !isset( $specialPage->categoryTreeCategories ) ) {
310 if ( isset( $specialPage->categoryTreeCategories[$catTitle->getDbKey()] ) ) {
311 $cat = $specialPage->categoryTreeCategories[$catTitle->getDbKey()];