diff --git a/action.php b/action.php index 754b131..b0952d1 100644 --- a/action.php +++ b/action.php @@ -7,7 +7,6 @@ /** * Make things happen when buttons are pressed and forms submitted. */ - require_once __DIR__ . "/required.php"; if ($VARS['action'] !== "signout") { @@ -32,8 +31,24 @@ function returnToSender($msg, $arg = "") { switch ($VARS['action']) { case "saveedits": - $page = $VARS['page']; + header("Content-Type: application/json"); + $slug = $VARS['slug']; + $site = $VARS['site']; $content = $VARS['content']; + if ($database->has("pages", ["AND" => ["slug" => $slug, "siteid" => $site]])) { + $pageid = $database->get("pages", "pageid", ["AND" => ["slug" => $slug, "siteid" => $site]]); + } else { + die(json_encode(["status" => "ERROR", "msg" => "Invalid page or site"])); + } + foreach ($content as $name => $value) { + if ($database->has("components", ["AND" => ["pageid" => $pageid, "name" => $name]])) { + $database->update("components", ["content" => $value], ["AND" => ["pageid" => $pageid, "name" => $name]]); + } else { + $database->insert("components", ["name" => $name, "content" => $value, "pageid" => $pageid]); + } + } + exit(json_encode(["status" => "OK"])); + break; case "signout": session_destroy(); header('Location: index.php'); diff --git a/database.mwb b/database.mwb index 82f3394..ee286d6 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/lang/en_us.php b/lang/en_us.php index f4d5ddd..3c3e7d2 100644 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -28,7 +28,18 @@ define("STRINGS", [ "login server error" => "The login server returned an error: {arg}", "login server user data error" => "The login server refused to provide account information. Try again or contact technical support.", "captcha error" => "There was a problem with the CAPTCHA (robot test). Try again.", + "actions" => "Actions", "home" => "Home", "more" => "More", - "test" => "Test" + "sites" => "Sites", + "theme" => "Theme", + "name" => "Name", + "site name" => "Site Name", + "url" => "URL", + "editing site" => "Editing {site}", + "theme type" => "Theme type", + "single page" => "Single page", + "multiple page" => "Multiple page", + "templates" => "Templates", + "color styles" => "Color styles" ]); \ No newline at end of file diff --git a/lib/themefunctions.php b/lib/themefunctions.php index b1f19db..63eb70e 100644 --- a/lib/themefunctions.php +++ b/lib/themefunctions.php @@ -59,7 +59,11 @@ function get_page_url($echo = true, $slug = null) { if ($slug == null) { $slug = get_page_slug(false); } - $url = get_site_url(false) . "index.php?id=$slug"; + $edit = ""; + if (isset($_GET['edit'])) { + $edit = "&edit"; + } + $url = get_site_url(false) . "index.php?id=$slug$edit"; if ($echo) { echo $url; } else { diff --git a/pages.php b/pages.php index ad2a84f..d45cdec 100644 --- a/pages.php +++ b/pages.php @@ -11,7 +11,30 @@ define("PAGES", [ "navbar" => true, "icon" => "fas fa-home" ], + "sites" => [ + "title" => "sites", + "navbar" => true, + "icon" => "fas fa-sitemap" + ], + "sitesettings" => [ + "title" => "settings", + "styles" => [ + "static/css/themeselector.css" + ], + "scripts" => [ + "static/js/sitesettings.js" + ] + ], + "editor" => [ + "title" => "editor", + "styles" => [ + "static/css/editorparent.css" + ], + "scripts" => [ + "static/js/editorparent.js" + ] + ], "404" => [ "title" => "404 error" ] -]); \ No newline at end of file +]); diff --git a/pages/editor.php b/pages/editor.php new file mode 100644 index 0000000..d197353 --- /dev/null +++ b/pages/editor.php @@ -0,0 +1,71 @@ +has('sites', ['siteid' => $VARS['siteid']])) { + $sitedata = $database->get( + 'sites', [ + 'siteid', + 'sitename', + 'url', + 'theme', + 'color' + ], [ + 'siteid' => $VARS['siteid'] + ]); + $pagedata = $database->select( + 'pages', [ + "pageid", + "slug", + "title", + "template" + ], ["siteid" => $VARS['siteid']] + ); + $slug = "index"; + if (isset($VARS['slug']) && $database->has('pages', ["AND" => ['slug' => $VARS['slug'], 'siteid' => $VARS['siteid']]])) { + $slug = $VARS['slug']; + } + } else { + header('Location: app.php?page=sites'); + die(); + } +} else { + header('Location: app.php?page=sites'); + die(); +} +?> +