From a8355b2da4f41e73380dc3a06da844997a4bd31c Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 17 Nov 2021 16:59:53 -0800 Subject: [PATCH] created new Theme data class for theme stuff, added custom page view, added view select for page edit screen --- brain/App.inc.php | 1 + brain/controller/DashControl.inc.php | 5 ++- brain/data/Settings.inc.php | 14 ------- brain/data/Themes.inc.php | 41 +++++++++++++++++++ brain/views/dash/partials/options.twig | 11 +++++ .../themes/fipamo-default/page-custom.twig | 35 ++++++++++++++++ 6 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 brain/data/Themes.inc.php create mode 100644 content/themes/fipamo-default/page-custom.twig diff --git a/brain/App.inc.php b/brain/App.inc.php index 5cef56c..3e18c59 100644 --- a/brain/App.inc.php +++ b/brain/App.inc.php @@ -12,6 +12,7 @@ include "../brain/data/Session.inc.php"; include "../brain/data/Member.inc.php"; include "../brain/data/Auth.inc.php"; include "../brain/data/Render.inc.php"; +include "../brain/data/Themes.inc.php"; include "../brain/utility/StringTools.inc.php"; include "../brain/utility/FileUploader.inc.php"; include "../brain/utility/DocTools.inc.php"; diff --git a/brain/controller/DashControl.inc.php b/brain/controller/DashControl.inc.php index 98d25af..7ded135 100644 --- a/brain/controller/DashControl.inc.php +++ b/brain/controller/DashControl.inc.php @@ -21,7 +21,7 @@ class DashControl if (Session::active()) { $config = new Settings(); $settings = $config->getSettings(); - $themes = $config->getThemes(); + $themes = (new Themes())->getThemes(); //$config->getThemes(); $template = "dash/settings.twig"; $member = Session::get("member"); $form_token = Session::get("form_token"); @@ -103,13 +103,14 @@ class DashControl $mode = $args["third"]; if ($mode == "edit") { $uuid = $args["fourth"]; - + $customPages = (new Themes())->getCustomViews(); $pageOptions = [ "title" => "Fipamo | Edit Page", "page" => (new Book("../content/pages"))->findPageById($uuid), "mode" => $mode, "token" => Session::get("form_token"), "status" => Session::active(), + "views" => $customPages, ]; } else { $pageOptions = [ diff --git a/brain/data/Settings.inc.php b/brain/data/Settings.inc.php index 3770fba..ff25452 100644 --- a/brain/data/Settings.inc.php +++ b/brain/data/Settings.inc.php @@ -6,7 +6,6 @@ class Settings { private $folks; private static $tags; - private $themes = []; private static $settings; public function __construct() @@ -18,14 +17,6 @@ class Settings file_get_contents("../config/settings.json"), true ); - - $_themes = glob("../content/themes/*", GLOB_ONLYDIR); - foreach ($_themes as $theme) { - array_push( - $this->themes, - json_decode(file_get_contents($theme . "/theme.json"), true) - ); - } } public static function sync($data) @@ -101,11 +92,6 @@ class Settings DocTools::writeSettings("../config/settings.json", $settings); } - public function getThemes() - { - return $this->themes; - } - public function getFolks($key = null) { if (isset($key)) { diff --git a/brain/data/Themes.inc.php b/brain/data/Themes.inc.php new file mode 100644 index 0000000..fbfe4a8 --- /dev/null +++ b/brain/data/Themes.inc.php @@ -0,0 +1,41 @@ +themes, + json_decode(file_get_contents($theme . "/theme.json"), true) + ); + } + } + + public function getThemes() + { + return $this->themes; + } + + public function getCustomViews() + { + $settings = (new Settings())->getSettings(); + $currentTheme = $settings["global"]["theme"]; + $folder = "../content/themes/" . $currentTheme; + $files = array_filter(glob("$folder/*twig"), "is_file"); + $views = []; + + foreach ($files as $file) { + $path = explode("/", $file); + $fileName = $path[4]; + if (str_contains($fileName, "page")) { + $page = explode(".", $fileName); + $views[] = $page[0]; + } + } + return $views; + } +} diff --git a/brain/views/dash/partials/options.twig b/brain/views/dash/partials/options.twig index 8df7bd1..e5eff67 100644 --- a/brain/views/dash/partials/options.twig +++ b/brain/views/dash/partials/options.twig @@ -32,4 +32,15 @@ + + \ No newline at end of file diff --git a/content/themes/fipamo-default/page-custom.twig b/content/themes/fipamo-default/page-custom.twig new file mode 100644 index 0000000..ab941ce --- /dev/null +++ b/content/themes/fipamo-default/page-custom.twig @@ -0,0 +1,35 @@ +{% extends "fipamo-default/frame.twig" %} + +{% block title %} + {{ title }} +{% endblock %} + + {% block mainContent %} +
+
+ {{title}} +
+
+
+
+

{{content | raw}}

+
+ + {{meta['who']}} dropped this {{ meta['when'] }}
+ tags: + {% for tag in meta['tags'] %} + {% if dynamicRender is defined %} + {% if dynamicRender %} + {{ tag.label }} + {% else %} + {{ tag.label }} + {% endif %} + {% else %} + {{ tag.label }} + {% endif %} + + {% endfor %} +
+
+
+ {% endblock %} \ No newline at end of file