diff options
Diffstat (limited to 'handler/admin/PageAdd.php')
-rw-r--r-- | handler/admin/PageAdd.php | 66 |
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 |