Restore category link to sidebar

Bug: T272705
Change-Id: I2911562a902aab82783d696282bbbdd2a287e962
This commit is contained in:
jdlrobson 2021-06-15 11:48:48 -07:00
parent f6c6a8341a
commit 46d2de89da
2 changed files with 31 additions and 8 deletions

View file

@ -92,6 +92,7 @@
"ArticleFromTitle": "default",
"SpecialTrackingCategories::preprocess": "default",
"SpecialTrackingCategories::generateCatLink": "default",
"SkinAfterPortlet": "default",
"SkinBuildSidebar": "default",
"ParserFirstCallInit": "default",
"OutputPageMakeCategoryLinks": "default",

View file

@ -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()