From 729fc7552cbd24b5bc2d9d718655edc60d7821e5 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 22 Aug 2025 11:36:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20archive=20list?= =?UTF-8?q?=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/archives.class.php | 15 ++++++++++++ bl-kernel/boot/init.php | 5 ++++ bl-kernel/class/link.class.php | 40 +++++++++++++++++++++++++++++++ bl-kernel/helpers/menus.class.php | 21 ++++++++++++++++ bl-plugins/archive/plugin.php | 18 +------------- 5 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 bl-kernel/class/link.class.php create mode 100644 bl-kernel/helpers/menus.class.php diff --git a/bl-kernel/archives.class.php b/bl-kernel/archives.class.php index 5b5c79d1..c1e487d5 100644 --- a/bl-kernel/archives.class.php +++ b/bl-kernel/archives.class.php @@ -46,4 +46,19 @@ class Archives extends dbList { return $this->save(); } + public function getLinkList($month, $class = "", $classActive = "active") + { + $listLink = array(); + foreach ($this->db as $pageKey=>$pageFields) { + if ( + ($month && strlen($pageKey) != 4) + || (!$month && strlen($pageKey) == 4) + ) { + $link = DOMAIN_ARCHIVES . $pageKey; + $listLink[] = new Link($pageFields['name'], $link, $class, $classActive); + } + } + return $listLink; + } + } \ No newline at end of file diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index d9df020f..5fa6acaa 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -41,6 +41,7 @@ define('PATH_CONTENT', PATH_ROOT . 'bl-content' . DS); define('PATH_ABSTRACT', PATH_KERNEL . 'abstract' . DS); define('PATH_RULES', PATH_KERNEL . 'boot' . DS . 'rules' . DS); define('PATH_HELPERS', PATH_KERNEL . 'helpers' . DS); +define('PATH_CLASSES', PATH_KERNEL . 'class' . DS); define('PATH_AJAX', PATH_KERNEL . 'ajax' . DS); define('PATH_CORE_JS', PATH_KERNEL . 'js' . DS); @@ -116,6 +117,9 @@ include(PATH_KERNEL . 'social.class.php'); // Include functions include(PATH_KERNEL . 'functions.php'); +// Include classes +include(PATH_CLASSES . 'link.class.php'); + // Include Helpers Classes include(PATH_HELPERS . 'text.class.php'); include(PATH_HELPERS . 'log.class.php'); @@ -131,6 +135,7 @@ include(PATH_HELPERS . 'alert.class.php'); include(PATH_HELPERS . 'paginator.class.php'); include(PATH_HELPERS . 'image.class.php'); include(PATH_HELPERS . 'media.class.php'); +include(PATH_HELPERS . 'menus.class.php'); include(PATH_HELPERS . 'tcp.class.php'); include(PATH_HELPERS . 'dom.class.php'); include(PATH_HELPERS . 'cookie.class.php'); diff --git a/bl-kernel/class/link.class.php b/bl-kernel/class/link.class.php new file mode 100644 index 00000000..f2c6ba68 --- /dev/null +++ b/bl-kernel/class/link.class.php @@ -0,0 +1,40 @@ +label = $label; + $this->href = $href; + $this->class = $class; + $this->classActive = $classActive; + } + + function isActive() + { + return false; + } + + function haveClass() + { + return ($this->getClasses() != ""); + } + + function getClasses() + { + return $this->class . ($this->isActive() ? " " . $this->classActive : ""); + } + + function toHTML() + { + return "haveClass() ? "class='" . $this->getClasses() . "'" : "" ) . " >".$this->label.""; + } +} \ No newline at end of file diff --git a/bl-kernel/helpers/menus.class.php b/bl-kernel/helpers/menus.class.php new file mode 100644 index 00000000..feecc03c --- /dev/null +++ b/bl-kernel/helpers/menus.class.php @@ -0,0 +1,21 @@ +getLinkList($monthly, $classLink, $classActive), $classUl); + } + + private static function toMenu($links, $classUl) + { + $html = '"; + return $html; + } + +} \ No newline at end of file diff --git a/bl-plugins/archive/plugin.php b/bl-plugins/archive/plugin.php index 3cd00920..62d20992 100644 --- a/bl-plugins/archive/plugin.php +++ b/bl-plugins/archive/plugin.php @@ -44,23 +44,7 @@ class pluginArchives extends Plugin $html = '
'; $html .= '

' . $this->getValue('label') . '

'; $html .= '
'; - $html .= '
    '; - - // By default the database of tags are alphanumeric sorted - foreach ($archives->db as $key => $fields) { - if ( - ($this->getValue('monthly') && strlen($key) != 4) - || (!$this->getValue('monthly') && strlen($key) == 4) - ) { - $html .= '
  • '; - $html .= ''; - $html .= $fields['name']; - $html .= ''; - $html .= '
  • '; - } - } - - $html .= '
'; + $html .= MenuHelper::getArchive($this->getValue('monthly'), "flat-list"); $html .= '
'; $html .= '
';