From 3da3e62c5b12390d75de9b3320729bcca6e0b458 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 9 Feb 2025 00:42:11 +0100 Subject: [PATCH] Option to reset menus --- admin/pages/menus.php | 72 ++++++++++++++++++++++++++--------- templates/kathrine/config.php | 2 + templates/tibiacom/config.php | 2 + 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/admin/pages/menus.php b/admin/pages/menus.php index e4ff205f..358ccc64 100644 --- a/admin/pages/menus.php +++ b/admin/pages/menus.php @@ -59,11 +59,7 @@ if (isset($_POST['template'])) { } } - $cache = Cache::getInstance(); - if ($cache->enabled()) { - $cache->delete('template_menus'); - } - + onTemplateMenusChange(); success('Saved at ' . date('H:i')); } @@ -93,15 +89,31 @@ if (isset($_POST['template'])) { Menu::where('template', $template)->where('category', $id)->update(['color' => str_replace('#', '', $color)]); } - $cache = Cache::getInstance(); - if ($cache->enabled()) { - $cache->delete('template_menus'); - } + onTemplateMenusChange(); + success('Colors has been reset at ' . date('H:i')); + } - success('Colors has been reset.'); + if (isset($_GET['reset_menus'])) { + $configMenus = config('menus'); + if (isset($configMenus)) { + Plugins::installMenus($template, config('menus'), true); + + onTemplateMenusChange(); + success('Menus has been reset at ' . date('H:i')); + } + else { + error("This template don't support reinstalling menus."); + } } $title = 'Menus - ' . $template; + + $canChangeColor = isset($config['menu_default_color']); + foreach ($config['menu_categories'] as $id => $options) { + if (isset($options['default_links_color'])) { + $canChangeColor = true; + } + } ?>

You are editing:

@@ -109,14 +121,30 @@ if (isset($_POST['template'])) { Hint: Add links to external sites using: http:// or https:// prefix.
Not all templates support blank and colorful links.

- -
- - - -
-
- +
+
+
+
+ +
+ + + +
+
+ + +
+ + + +
+
+ +
+
+
+
$templates )); } + +function onTemplateMenusChange(): void +{ + $cache = Cache::getInstance(); + if ($cache->enabled()) { + $cache->delete('template_menus'); + } +} diff --git a/templates/kathrine/config.php b/templates/kathrine/config.php index 2de3804e..16face59 100644 --- a/templates/kathrine/config.php +++ b/templates/kathrine/config.php @@ -8,3 +8,5 @@ $config['menu_categories'] = array( MENU_CATEGORY_LIBRARY => array('id' => 'library', 'name' => 'Library'), MENU_CATEGORY_SHOP => array('id' => 'shops', 'name' => 'Shop') ); + +$config['menus'] = require __DIR__ . '/menus.php'; diff --git a/templates/tibiacom/config.php b/templates/tibiacom/config.php index 3f3f49d5..8f4e5813 100644 --- a/templates/tibiacom/config.php +++ b/templates/tibiacom/config.php @@ -9,3 +9,5 @@ $config['menu_categories'] = array( MENU_CATEGORY_LIBRARY => array('id' => 'library', 'name' => 'Library'), MENU_CATEGORY_SHOP => array('id' => 'shops', 'name' => 'Shop') ); + +$config['menus'] = require __DIR__ . '/menus.php';