From 869c3a8d6a3266abb497132f194607bca7fec6a7 Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Sat, 8 Nov 2025 10:28:13 -0800 Subject: [PATCH] Edit Page fixes --- controllers/editpage.php | 2 +- controllers/savepage.php | 35 +++--- skeleton/novaconium/public/css/novaconium.css | 60 +++++++++++ views/editpage.html.twig | 101 ++++++++++++------ 4 files changed, 147 insertions(+), 51 deletions(-) diff --git a/controllers/editpage.php b/controllers/editpage.php index 29bf262..4283866 100644 --- a/controllers/editpage.php +++ b/controllers/editpage.php @@ -50,7 +50,7 @@ EOSQL; if (empty($pageid)) { // New page: set default values for all fields $data['rows'] = [ - 'id' => '', + 'id' => 'newpage', 'title' => '', 'heading' => '', 'description' => '', diff --git a/controllers/savepage.php b/controllers/savepage.php index 2a32921..7b1ef73 100644 --- a/controllers/savepage.php +++ b/controllers/savepage.php @@ -43,21 +43,7 @@ if (empty($title) || empty($slug) || empty($body)) { } try { - if (!empty($id)) { - // Update existing page - $query = "UPDATE `pages` SET - `title` = ?, `heading` = ?, `description` = ?, `keywords` = ?, `author` = ?, - `slug` = ?, `path` = ?, `intro` = ?, `body` = ?, `notes` = ?, - `draft` = ?, `changefreq` = ?, `priority` = ?, `updated` = NOW() - WHERE `id` = ?"; - $params = [ - $title, $heading, $description, $keywords, $author, - $slug, $path, $intro, $body, $notes, - $draft, $changefreq, $priority, $id - ]; - $db->query($query, $params); - $messages->notice('Page Updated'); - } else { + if ($id == 'newpage') { // Create new page $query = "INSERT INTO `pages` (`title`, `heading`, `description`, `keywords`, `author`, @@ -72,7 +58,26 @@ try { $db->query($query, $params); $id = $db->lastid; // Get new page ID $messages->notice('Page Created'); + $newpage = true; + } else { + $newpage = false; } + + if (!empty($id) && !$newpage) { + // Update existing page + $query = "UPDATE `pages` SET + `title` = ?, `heading` = ?, `description` = ?, `keywords` = ?, `author` = ?, + `slug` = ?, `path` = ?, `intro` = ?, `body` = ?, `notes` = ?, + `draft` = ?, `changefreq` = ?, `priority` = ?, `updated` = NOW() + WHERE `id` = ?"; + $params = [ + $title, $heading, $description, $keywords, $author, + $slug, $path, $intro, $body, $notes, + $draft, $changefreq, $priority, $id + ]; + $db->query($query, $params); + $messages->notice('Page Updated'); + } } catch (Exception $e) { $messages->error($e->getMessage()); $redirect->url($url_error); diff --git a/skeleton/novaconium/public/css/novaconium.css b/skeleton/novaconium/public/css/novaconium.css index 304c3ba..2d2a9b8 100644 --- a/skeleton/novaconium/public/css/novaconium.css +++ b/skeleton/novaconium/public/css/novaconium.css @@ -112,3 +112,63 @@ div#debug { .pages-table th { font-weight: bold; } + +/* ============================================================ + DARK MODE STYLES — edit-page-form-novaconium + ============================================================ */ +@media (prefers-color-scheme: dark) { + + #edit-page-form-novaconium input[type="text"], + #edit-page-form-novaconium input[type="number"], + #edit-page-form-novaconium textarea, + #edit-page-form-novaconium select { + background: #2a2a2a; + border: 1px solid #444; + color: #eee; + } + + #edit-page-form-novaconium input:focus, + #edit-page-form-novaconium textarea:focus, + #edit-page-form-novaconium select:focus { + border-color: #3399ff; + box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.25); + } + + #edit-page-form-novaconium input[type="checkbox"] { + accent-color: #3399ff; + } + + #edit-page-form-novaconium button[type="submit"] { + background: #3399ff; + color: #fff; + } + + #edit-page-form-novaconium button[type="submit"]:hover { + background: #1d7fd4; + } + + #edit-page-form-novaconium p { + color: #aaa; + } + + #edit-page-form-novaconium a { + color: #66b3ff; + } + + #edit-page-form-novaconium a:hover { + color: #99ccff; + } + + #edit-page-form-novaconium .form-group { + margin-bottom: 1.2rem; + } + + #edit-page-form-novaconium .form-group.fullwidth textarea { + width: 100%; + resize: vertical; + } + + #edit-page-form-novaconium .checkbox-group { + margin-top: 1.5rem; + } +} diff --git a/views/editpage.html.twig b/views/editpage.html.twig index 499c339..54f98db 100644 --- a/views/editpage.html.twig +++ b/views/editpage.html.twig @@ -3,59 +3,90 @@ {% block content %}

Edit Page - {{ title }}

-
+ + - - +
+ + +
- - +
+ + +
- - +
+ + +
+ +

Metadata

- - +
+ + +
- - +
+ + +
- - +
+ + +
- - +

CMS Info

+ +
+ + +
- - +
+ + +
- - +
+ + +
- - +
+ + +
- +

Page Data

+
+ + +
- - - - - +
+ + +

Created: {{ rows.created|date("Y-m-d H:i:s") }}

Last Updated: {{ rows.updated|date("Y-m-d H:i:s") }}

+
+ {% endblock %}