public function actionEdit()
 {
     $RecId = isset($_GET['id']) ? (int) $_GET['id'] : null;
     $record = News::findOne($RecId);
     $view = new View();
     //echo 'header='.$record->NewsHeader;
     $view->assign('item', $record);
     $template = 'news/news_edit_view.php';
     $view->display($template);
     //header('Location: ./index.php');
 }
Пример #2
0
 public function actionOne()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : null;
     //Если id статьи не задан, то извещаем об этом
     if (is_null($id)) {
         header("HTTP/1.0 404 Not Found");
         throw new \E404Exception('Id cannot be null');
     }
     $item = News::findOne($id);
     //Если не найдено статьи с соответствующим id,то сообщаем об этом
     if ($item == false) {
         header("HTTP/1.0 404 Not Found");
         throw new E404Exception('Record not found');
     }
     $view = new View();
     $view->assign('item', $item);
     $template = 'news/news_one_view.php';
     $view->display($template);
 }
Пример #3
0
require './autoload.php';
use App\includes\View;
use App\includes\E404Exception;
use App\includes\ErrLogger;
$controller = isset($_GET['controller']) ? 'App\\controllers\\' . $_GET['controller'] . 'Controller' : 'App\\controllers' . '\\NewsController';
$action = isset($_GET['action']) ? $_GET['action'] : 'All';
try {
    $ctrl = new $controller();
    $method = 'action' . $action;
    $ctrl->{$method}();
} catch (E404Exception $err404) {
    $view = new View();
    $ErrMessage = $err404->getMessage();
    $view->assign('ErrMessage', $ErrMessage);
    $template = 'ErrPages/404Err.php';
    $view->display($template);
    $err = new ErrLogger('PageNotFound');
    $err->assignError($err404->getMessage() . '__file:' . $err404->getFile() . '__Line:' . $err404->getLine() . '__Trace:' . $err404->getTraceAsString());
    $err->writeLog();
} catch (PDOException $dbe) {
    $view = new View();
    $DbErrMessage = 'Произошла ошибка при работе с БД';
    $view->assign('DbError', $DbErrMessage);
    $template = 'ErrPages/403Err.php';
    $view->display($template);
    $err = new ErrLogger('DbError');
    $err->assignError($dbe->getMessage() . '__file:' . $dbe->getFile() . '__Line:' . $dbe->getLine() . '__Trace:' . $dbe->getTraceAsString());
    $err->writeLog();
} catch (Exception $e) {
    die('Something was wrong' . $e->getMessage());
}