Changed variables.

This commit is contained in:
2026-07-04 07:43:33 -07:00
parent 7ee47a0b1e
commit 4484f88d8d
21 changed files with 197 additions and 197 deletions
+34 -34
View File
@@ -5,44 +5,44 @@ use Novaconium\Services\TagManager;
$v = new Nickyeoman\Validation\Validate();
$url_error = '/novaconium/page/edit/' . $post->get('id'); // fallback for errors
$url_error = '/novaconium/page/edit/' . $ctx->post->get('id'); // fallback for errors
// -------------------------
// Check login
// -------------------------
if (empty($session->get('username'))) {
$messages->error('You are not logged in');
$redirect->url('/novaconium/login');
if (empty($ctx->session->get('username'))) {
$ctx->messages->error('You are not logged in');
$ctx->redirect->url('/novaconium/login');
makeitso();
}
// -------------------------
// Check CSRF token
// -------------------------
if ($session->get('token') != $post->get('token')) {
$messages->error('Invalid Token');
$redirect->url('/novaconium/pages');
if ($ctx->session->get('token') != $ctx->post->get('token')) {
$ctx->messages->error('Invalid Token');
$ctx->redirect->url('/novaconium/pages');
makeitso();
}
// -------------------------
// Gather POST data
// -------------------------
$id = $post->get('id');
$title = $_POST['title'] ?? '';
$heading = $_POST['heading'] ?? '';
$description = $_POST['description'] ?? '';
$keywords = $_POST['keywords'] ?? '';
$author = $_POST['author'] ?? '';
$slug = $_POST['slug'] ?? '';
$path = $_POST['path'] ?? null;
$intro = $_POST['intro'] ?? '';
$body = $_POST['body'] ?? '';
$notes = $_POST['notes'] ?? '';
$draft = !empty($post->get('draft')) ? 1 : 0;
$changefreq = $_POST['changefreq'] ?? 'monthly';
$priority = $_POST['priority'] ?? 0.0;
$tags_json = $_POST['tags_json'] ?? '[]';
$id = $ctx->post->get('id');
$title = $ctx->post->get('title', '');
$heading = $ctx->post->get('heading', '');
$description = $ctx->post->get('description', '');
$keywords = $ctx->post->get('keywords', '');
$author = $ctx->post->get('author', '');
$slug = $ctx->post->get('slug', '');
$path = $ctx->post->get('path');
$intro = $ctx->post->get('intro', '');
$body = $ctx->post->get('body', '');
$notes = $ctx->post->get('notes', '');
$draft = !empty($ctx->post->get('draft')) ? 1 : 0;
$changefreq = $ctx->post->get('changefreq', 'monthly');
$priority = $ctx->post->get('priority', 0.0);
$tags_json = $ctx->post->get('tags_json', '[]');
// -------------------------
// Decode & sanitize tags
@@ -57,13 +57,13 @@ $tags = array_unique($tags);
// Validate required fields
// -------------------------
if (empty($title) || empty($slug) || empty($body)) {
$messages->error('Title, Slug, and Body are required.');
$redirect->url($url_error);
$ctx->messages->error('Title, Slug, and Body are required.');
$ctx->redirect->url($url_error);
makeitso();
}
try {
$tagManager = new TagManager();
$tagManager = new TagManager($ctx->db);
if ($id == 'newpage') {
// -------------------------
@@ -79,9 +79,9 @@ try {
$slug, $path, $intro, $body, $notes,
$draft, $changefreq, $priority
];
$db->query($query, $params);
$id = $db->lastid;
$messages->notice('Page Created');
$ctx->db->query($query, $params);
$id = $ctx->db->lastid;
$ctx->messages->notice('Page Created');
} else {
// -------------------------
@@ -97,8 +97,8 @@ try {
$slug, $path, $intro, $body, $notes,
$draft, $changefreq, $priority, $id
];
$db->query($query, $params);
$messages->notice('Page Updated');
$ctx->db->query($query, $params);
$ctx->messages->notice('Page Updated');
}
// -------------------------
@@ -106,11 +106,11 @@ try {
// -------------------------
$tagManager->setTagsForPage($id, $tags);
} catch (Exception $e) {
$messages->error($e->getMessage());
$redirect->url($url_error);
} catch (\Exception $e) {
$ctx->messages->error($e->getMessage());
$ctx->redirect->url($url_error);
makeitso();
}
// Redirect back to edit page
$redirect->url('/novaconium/page/edit/' . $id);
$ctx->redirect->url('/novaconium/page/edit/' . $id);