Add site creation
This commit is contained in:
parent
b62e6dc000
commit
b98a18adac
17
action.php
17
action.php
@ -31,8 +31,10 @@ function returnToSender($msg, $arg = "") {
|
|||||||
|
|
||||||
switch ($VARS['action']) {
|
switch ($VARS['action']) {
|
||||||
case "sitesettings":
|
case "sitesettings":
|
||||||
if (!$database->has("sites", ["siteid" => $VARS['siteid']])) {
|
if (!is_empty($VARS['siteid'])) {
|
||||||
returnToSender("invalid_parameters");
|
if (!$database->has("sites", ["siteid" => $VARS['siteid']])) {
|
||||||
|
returnToSender("invalid_parameters");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (is_empty($VARS['name'])) {
|
if (is_empty($VARS['name'])) {
|
||||||
returnToSender("invalid_parameters");
|
returnToSender("invalid_parameters");
|
||||||
@ -54,9 +56,14 @@ switch ($VARS['action']) {
|
|||||||
if ($color != "default" && !file_exists(__DIR__ . "/public/themes/$theme/colors/$color")) {
|
if ($color != "default" && !file_exists(__DIR__ . "/public/themes/$theme/colors/$color")) {
|
||||||
returnToSender("invalid_parameters");
|
returnToSender("invalid_parameters");
|
||||||
}
|
}
|
||||||
$database->update('sites',
|
if (is_empty($VARS['siteid'])) {
|
||||||
["sitename" => $VARS['name'], "url" => $VARS['url'], "theme" => $theme, "color" => $color],
|
$database->insert('sites', ["sitename" => $VARS['name'], "url" => $VARS['url'], "theme" => $theme, "color" => $color]);
|
||||||
["siteid" => $VARS['siteid']]);
|
$siteid = $database->id();
|
||||||
|
$template = (file_exists(__DIR__ . "/public/themes/$theme/home.php") ? "home" : "default");
|
||||||
|
$database->insert('pages', ["slug" => "index", "siteid" => $siteid, "title" => "Home", "nav" => "Home", "navorder" => 1, "template" => "template"]);
|
||||||
|
} else {
|
||||||
|
$database->update('sites', ["sitename" => $VARS['name'], "url" => $VARS['url'], "theme" => $theme, "color" => $color], ["siteid" => $VARS['siteid']]);
|
||||||
|
}
|
||||||
returnToSender("settings_saved");
|
returnToSender("settings_saved");
|
||||||
break;
|
break;
|
||||||
case "saveedits":
|
case "saveedits":
|
||||||
|
@ -37,6 +37,7 @@ define("STRINGS", [
|
|||||||
"new site" => "New Site",
|
"new site" => "New Site",
|
||||||
"site name" => "Site Name",
|
"site name" => "Site Name",
|
||||||
"url" => "URL",
|
"url" => "URL",
|
||||||
|
"adding site" => "Creating site {site}",
|
||||||
"editing site" => "Editing {site}",
|
"editing site" => "Editing {site}",
|
||||||
"theme type" => "Theme type",
|
"theme type" => "Theme type",
|
||||||
"single page" => "Single page",
|
"single page" => "Single page",
|
||||||
|
@ -8,7 +8,7 @@ require_once __DIR__ . '/../required.php';
|
|||||||
redirectifnotloggedin();
|
redirectifnotloggedin();
|
||||||
?>
|
?>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a href="app.php?page=addsite" class="btn btn-success"><i class="fas fa-plus"></i> <?php lang("new site"); ?></a>
|
<a href="app.php?page=sitesettings" class="btn btn-success"><i class="fas fa-plus"></i> <?php lang("new site"); ?></a>
|
||||||
</div>
|
</div>
|
||||||
<table id="cattable" class="table table-bordered table-hover table-sm">
|
<table id="cattable" class="table table-bordered table-hover table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -7,8 +7,15 @@ require_once __DIR__ . '/../required.php';
|
|||||||
|
|
||||||
redirectifnotloggedin();
|
redirectifnotloggedin();
|
||||||
|
|
||||||
|
$editing = true;
|
||||||
|
|
||||||
|
$siteid = "";
|
||||||
|
$sitedata = [];
|
||||||
|
|
||||||
|
|
||||||
if (!is_empty($VARS['siteid'])) {
|
if (!is_empty($VARS['siteid'])) {
|
||||||
if ($database->has('sites', ['siteid' => $VARS['siteid']])) {
|
if ($database->has('sites', ['siteid' => $VARS['siteid']])) {
|
||||||
|
$siteid = $VARS['siteid'];
|
||||||
$sitedata = $database->select(
|
$sitedata = $database->select(
|
||||||
'sites', [
|
'sites', [
|
||||||
'siteid',
|
'siteid',
|
||||||
@ -17,20 +24,31 @@ if (!is_empty($VARS['siteid'])) {
|
|||||||
'theme',
|
'theme',
|
||||||
'color'
|
'color'
|
||||||
], [
|
], [
|
||||||
'siteid' => $VARS['siteid']
|
'siteid' => $siteid
|
||||||
])[0];
|
])[0];
|
||||||
} else {
|
} else {
|
||||||
header('Location: app.php?page=sites');
|
header('Location: app.php?page=sites');
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header('Location: app.php?page=sites');
|
$editing = false;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<form role="form" action="action.php" method="POST">
|
<form role="form" action="action.php" method="POST">
|
||||||
<div class="card border-light-blue">
|
<div class="card border-light-blue">
|
||||||
<h3 class="card-header text-light-blue">
|
<h3 class="card-header text-light-blue">
|
||||||
<i class="fas fa-edit"></i> <?php lang2("editing site", ['site' => "<span id=\"name_title\">" . htmlspecialchars($sitedata['sitename']) . "</span>"]); ?>
|
<?php
|
||||||
|
if ($editing) {
|
||||||
|
?>
|
||||||
|
<i class="fas fa-edit"></i> <?php lang2("editing site", ['site' => "<span id=\"name_title\">" . htmlspecialchars($sitedata['sitename']) . "</span>"]); ?>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
<i class="fas fa-plus"></i> <?php lang2("adding site", ['site' => "<span id=\"name_title\">" . htmlspecialchars($sitedata['sitename']) . "</span>"]); ?>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -62,7 +80,7 @@ if (!is_empty($VARS['siteid'])) {
|
|||||||
<div class="card-body m-0 p-1">
|
<div class="card-body m-0 p-1">
|
||||||
<span class="d-flex">
|
<span class="d-flex">
|
||||||
<h4 class="mr-auto"><?php echo $info['name']; ?></h4>
|
<h4 class="mr-auto"><?php echo $info['name']; ?></h4>
|
||||||
<a href="public/index.php?page=index&siteid=<?php echo $VARS['siteid']; ?>&theme=<?php echo $t; ?>" target="_BLANK">
|
<a href="public/index.php?page=index&siteid=<?php echo $siteid; ?>&theme=<?php echo $t; ?>" target="_BLANK">
|
||||||
<i class="fas fa-eye"></i> <?php lang("preview"); ?>
|
<i class="fas fa-eye"></i> <?php lang("preview"); ?>
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
@ -103,7 +121,7 @@ if (!is_empty($VARS['siteid'])) {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a href="public/index.php?page=index&siteid=<?php echo $VARS['siteid']; ?>&theme=<?php echo $t; ?>&color=<?php echo $c; ?>" target="_BLANK">
|
<a href="public/index.php?page=index&siteid=<?php echo $siteid; ?>&theme=<?php echo $t; ?>&color=<?php echo $c; ?>" target="_BLANK">
|
||||||
<i class="fas fa-eye"></i>
|
<i class="fas fa-eye"></i>
|
||||||
<?php lang("preview"); ?>
|
<?php lang("preview"); ?>
|
||||||
</a>
|
</a>
|
||||||
@ -125,7 +143,7 @@ if (!is_empty($VARS['siteid'])) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" name="siteid" value="<?php echo $VARS['siteid']; ?>" />
|
<input type="hidden" name="siteid" value="<?php echo $siteid; ?>" />
|
||||||
<input type="hidden" name="action" value="sitesettings" />
|
<input type="hidden" name="action" value="sitesettings" />
|
||||||
<input type="hidden" name="source" value="sites" />
|
<input type="hidden" name="source" value="sites" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user