mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
Restore category link to sidebar
Bug: T272705 Change-Id: I2911562a902aab82783d696282bbbdd2a287e962
This commit is contained in:
parent
f6c6a8341a
commit
46d2de89da
|
@ -92,6 +92,7 @@
|
|||
"ArticleFromTitle": "default",
|
||||
"SpecialTrackingCategories::preprocess": "default",
|
||||
"SpecialTrackingCategories::generateCatLink": "default",
|
||||
"SkinAfterPortlet": "default",
|
||||
"SkinBuildSidebar": "default",
|
||||
"ParserFirstCallInit": "default",
|
||||
"OutputPageMakeCategoryLinks": "default",
|
||||
|
|
|
@ -169,6 +169,18 @@ class Hooks implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a category sidebar link based on config
|
||||
* @return bool|string of link
|
||||
*/
|
||||
private function getCategorySidebarBox() {
|
||||
global $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions;
|
||||
if ( !$wgCategoryTreeSidebarRoot ) {
|
||||
return false;
|
||||
}
|
||||
return self::parserHook( $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook implementation for injecting a category tree into the sidebar.
|
||||
* Only does anything if $wgCategoryTreeSidebarRoot is set to a category name.
|
||||
|
@ -176,19 +188,29 @@ class Hooks implements
|
|||
* @param array &$sidebar
|
||||
*/
|
||||
public function onSkinBuildSidebar( $skin, &$sidebar ) {
|
||||
global $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions;
|
||||
|
||||
if ( !$wgCategoryTreeSidebarRoot ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$html = self::parserHook( $wgCategoryTreeSidebarRoot, $wgCategoryTreeSidebarOptions );
|
||||
$html = $this->getCategorySidebarBox();
|
||||
if ( $html ) {
|
||||
$sidebar['categorytree-portlet'] = $html;
|
||||
$sidebar['categorytree-portlet'] = [];
|
||||
CategoryTree::setHeaders( $skin->getOutput() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook implementation for injecting a category tree link into the sidebar.
|
||||
* Only does anything if $wgCategoryTreeSidebarRoot is set to a category name.
|
||||
* @param Skin $skin
|
||||
* @param string $portlet
|
||||
* @param string &$html
|
||||
*/
|
||||
public function onSkinAfterPortlet( $skin, $portlet, &$html ) {
|
||||
if ( $portlet === 'categorytree-portlet' ) {
|
||||
$box = $this->getCategorySidebarBox();
|
||||
if ( $box ) {
|
||||
$html .= $box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for the <categorytree> tag parser hook.
|
||||
* This loads CategoryTreeFunctions.php and calls CategoryTree::getTag()
|
||||
|
|
Loading…
Reference in a new issue