From b1800721f8088301dfecc34e7387ff8baa4ac03b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 22 Aug 2025 11:57:09 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Handle=20categories=20in?= =?UTF-8?q?=20MenuHelper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/categories.class.php | 16 ++++++++++++++++ bl-kernel/helpers/menus.class.php | 7 +++++++ bl-plugins/categories/plugin.php | 17 +---------------- bl-themes/defaultTheme/php/header.php | 11 +---------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/bl-kernel/categories.class.php b/bl-kernel/categories.class.php index 17b8c87b..1201aec9 100644 --- a/bl-kernel/categories.class.php +++ b/bl-kernel/categories.class.php @@ -40,4 +40,20 @@ class Categories extends dbList { return $this->save(); } + + public function getLinkList($hideEmpty, $showCount, $class = "", $classActive = "active") + { + $listLink = array(); + foreach ($this->db as $pageKey=>$pageFields) { + $count = count($pageFields['list']); + if ( + (!$hideEmpty || $count > 0) + ) { + $link = DOMAIN_CATEGORIES . $pageKey; + $name = $pageFields['name'] . ($showCount ? ' (' . $count . ')' : ''); + $listLink[] = new Link($name, $link, $class, $classActive); + } + } + return $listLink; + } } \ No newline at end of file diff --git a/bl-kernel/helpers/menus.class.php b/bl-kernel/helpers/menus.class.php index feecc03c..02f228dd 100644 --- a/bl-kernel/helpers/menus.class.php +++ b/bl-kernel/helpers/menus.class.php @@ -8,6 +8,13 @@ class MenuHelper { return MenuHelper::toMenu($archives->getLinkList($monthly, $classLink, $classActive), $classUl); } + + public static function getCategories($showEmpty, $showCount, $classUl = "", $classLink = "", $classActive = "active") + { + global $categories; + return MenuHelper::toMenu($categories->getLinkList($showEmpty, $showCount, $classLink, $classActive), $classUl); + } + private static function toMenu($links, $classUl) { $html = '