From 594df048cf54511d68f2afbf42f324c3d988ec80 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 16 Apr 2021 22:14:14 -0700 Subject: [PATCH] updating menu items in settings when pages is saved --- brain/data/Book.inc.php | 3 +++ brain/data/Settings.inc.php | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/brain/data/Book.inc.php b/brain/data/Book.inc.php index 243f8cd..efc2f44 100644 --- a/brain/data/Book.inc.php +++ b/brain/data/Book.inc.php @@ -183,6 +183,9 @@ class Book if ($task == "create") { Settings::updateIndex(); } + //once saved, update menu + $body["path"] = $path; + Settings::updateMenu($body); } else { $response = [ "message" => "Uh oh. File save problem. Don't panic", diff --git a/brain/data/Settings.inc.php b/brain/data/Settings.inc.php index 950e312..ed26523 100644 --- a/brain/data/Settings.inc.php +++ b/brain/data/Settings.inc.php @@ -1,5 +1,7 @@ $body["title"], + "id" => $body["id"], + "uuid" => $body["uuid"], + "slug" => $body["slug"], + "path" => $body["path"], + ]; + if ($body["menu"] == "true") { + if (!find($settings["menu"], ["uuid" => $item["uuid"]])) { + array_push($settings["menu"], $item); + } + } else { + if (find($settings["menu"], ["uuid" => $item["uuid"]])) { + pull($settings["menu"], $item); + } + } + DocTools::writeSettings("../config/settings.json", $settings); + } }