public function actionUpdate() { if (isset($_POST['submit'])) { if (empty($_POST['title']) || empty($_POST['text'])) { echo 'Title or text could not be empty'; echo '<br><a href="/home2/admin">Back to admin panel</a>'; exit; } $article = News::GetOne($_POST['id']); $article->title = $_POST['title']; $article->text = $_POST['text']; if (true === $article->Save()) { echo 'Article was updated'; echo '<br><a href="/home2/admin">Back to admin panel</a>'; exit; } else { echo 'Error updateing database'; echo '<br><a href="/home2/admin">Back to admin panel</a>'; exit; } } if (!isset($_GET['id'])) { echo 'Could not found the article'; echo '<br><a href="/home2/admin">Back to admin panel</a>'; exit; } $view = new ViewConstuctor(); $view->article = News::GetOne($_GET['id']); $view->Display('Admin/Update'); }
public function actionGetOne() { if (empty($_GET['id'])) { throw new \E404Exception('Could not find the page'); } try { $view = new ViewConstuctor(); $view->article = NewsModel::GetOne($_GET['id']); $view->Display('News/DisplayArticle'); } catch (\E404Exception $e) { header('HTTP/1.0 404 Not Found'); include __DIR__ . '/../content/NotFound.php'; } }