summaryrefslogtreecommitdiff
path: root/handler/admin/PageAdd.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-31 06:11:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-31 20:45:40 +0300
commitc0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch)
tree2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /handler/admin/PageAdd.php
parent48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff)
make it simple, but not simpler
Diffstat (limited to 'handler/admin/PageAdd.php')
-rw-r--r--handler/admin/PageAdd.php66
1 files changed, 0 insertions, 66 deletions
diff --git a/handler/admin/PageAdd.php b/handler/admin/PageAdd.php
deleted file mode 100644
index 42a9911..0000000
--- a/handler/admin/PageAdd.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-namespace handler\admin;
-
-use csrf;
-use NotFoundException;
-use pages;
-use RedirectResponse;
-use Response;
-
-class PageAdd extends AutoAddOrEdit {
-
- public function get(): Response {
- list($name) = $this->input('short_name');
- $page = pages::getPageByName($name);
- if ($page)
- throw new NotFoundException();
-
- return $this->_get_pageAdd($name);
- }
-
- public function post(): Response {
- csrf::check('addpage');
-
- list($name) = $this->input('short_name');
- $page = pages::getPageByName($name);
- if ($page)
- throw new NotFoundException();
-
- $text = trim($_POST['text'] ?? '');
- $title = trim($_POST['title'] ?? '');
- $error_code = null;
-
- if (!$title) {
- $error_code = 'no_title';
- } else if (!$text) {
- $error_code = 'no_text';
- }
-
- if ($error_code) {
- return $this->_get_pageAdd(
- name: $name,
- title: $title,
- text: $text,
- error_code: $error_code
- );
- }
-
- if (!pages::add([
- 'short_name' => $name,
- 'title' => $title,
- 'md' => $text
- ])) {
- return $this->_get_pageAdd(
- name: $name,
- title: $title,
- text: $text,
- error_code: 'db_err'
- );
- }
-
- $page = pages::getPageByName($name);
- return new RedirectResponse($page->getUrl());
- }
-
-} \ No newline at end of file