/** * */ private function handleRequest() { $view = new View(); switch ($_POST['action']) { case "sendTestMail": $mail = new Mail(); $mail->sendMail("TestMail from cunity", "Cunity - Testmail", ["name" => "Cunity Admin", "email" => $_POST['mail']]); $view->setStatus(true); break; case "loadPages": $pages = new Pages(); $res = $pages->loadPages(); $view->setStatus($res !== null); $view->addData(["pages" => $res->toArray()]); break; case "deletePage": if (isset($_POST['id']) && !empty($_POST['id'])) { $pages = new Pages(); $status = $pages->deletePage($_POST['id']); if ($status !== false && false) { $comments = new Comments(); $status = $comments->removeAllComments($_POST['id'], "page"); } else { $status = true; } $view->setStatus($status); $view->sendResponse(); } else { $view->setStatus(false); } break; case 'addPage': $pages = new Pages(); $res = $pages->addPage($_POST); $page = $pages->getPage($res); $view->setStatus($res !== null && $res !== false); $page->content = html_entity_decode($page->content); $view->addData(["page" => $page->toArray()]); break; } $view->sendResponse(); }