public function deleteAction()
 {
     try {
         $article = new ArticlesModel();
         $article->id = intval($_POST['id']);
         $article->delete();
         $view = new View();
         $view->display('DeletedArticle.php');
     } catch (Exception $e) {
         // echo $e->getMessage();
         $view = new ErrorController();
         $view->error();
     }
 }
 protected function oneAction($id)
 {
     try {
         $single_article = ArticlesModel::findOne($id);
         $twig = new TwigClass('SingleArticle.twig');
         $twig->display($single_article);
         // var_dump($single_article);
     } catch (Twig_Error $e) {
         echo $e->getMessage();
     } catch (Exception $e) {
         // echo $e->getMessage();
         $view = new ErrorController();
         $view->error();
     }
 }
 public static function start()
 {
     $url = !empty($_GET['url']) ? $_GET['url'] : 'Articles/all';
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     $ctrlClass = $url[0] . 'Controller';
     $action = !empty($url[1]) ? $url[1] : 'all';
     $param = isset($url[2]) ? $url[2] : '';
     if (!class_exists($ctrlClass) || !method_exists($ctrlClass, $action . 'Action')) {
         $ctrl = new ErrorController();
         $ctrl->error();
     } else {
         $controller = new $ctrlClass();
         if (!empty($param)) {
             $controller->action($action, $param);
         } else {
             // if ($url[0] === 'Admin') {
             //   header('Location: ../User/SignIn');
             // }
             $controller->action($action);
         }
     }
 }
Exemple #4
0
<?php

define('SITE_PATH', realpath(dirname(__FILE__)) . '/');
// Require necessary files
require_once SITE_PATH . 'application/Request.php';
require_once SITE_PATH . 'application/Router.php';
require_once SITE_PATH . 'application/BaseController.php';
require_once SITE_PATH . 'application/BaseModel.php';
require_once SITE_PATH . 'application/Load.php';
require_once SITE_PATH . 'application/Registry.php';
require_once SITE_PATH . 'controllers/ErrorController.php';
try {
    Router::route(new Request());
} catch (Exception $e) {
    $controller = new ErrorController();
    $controller->error($e->getMessage());
}
Exemple #5
0
 public function __call($name, $arguments)
 {
     $errorController = new \ErrorController();
     $errorController->error("404 unknown method {$name}");
 }
include __DIR__ . '/autoloader.php';
// if ($ctrl == 'Admin') {
// 	header('Location: ?ctrl=User&action=SignIn');
// }
//выводим шапку
require_once dirname(__FILE__) . '/../../../tpl/header.php';
//с роутингом нужно еще поработать, но в целом это уже функционирует
$url = !empty($_GET['url']) ? $_GET['url'] : 'Articles/all';
$url = rtrim($url, '/');
$url = explode('/', $url);
$ctrlClass = $url[0] . 'Controller';
$action = $url[1];
$param = isset($url[2]) ? $url[2] : '';
if (!class_exists($ctrlClass)) {
    $ctrl = new ErrorController();
    $ctrl->error();
} else {
    $controller = new $ctrlClass();
    if (!empty($param)) {
        $controller->action($action($param));
    } else {
        $controller->action($action);
    }
}
////////// Старая версия ///////////////
//создаем новый контроллер и вызываем у него действие
// $ctrlClass = $ctrl . 'Controller';
// if (!class_exists($ctrlClass)) {
// 	$ctrl = new ErrorController;
// 	$ctrl->error();
// } else {
Exemple #7
0
<?php

/**
 * Hook, filter, etc should goes here
 */
/**
 * error handling sample
 */
$app->error(function () use($app) {
    $Controller = new \ErrorController();
    $Controller->error();
});
$app->notFound(function () use($app) {
    $Controller = new \ErrorController();
    $Controller->notFound();
});
/**************************************** CONFIGURATIONS ********************/
$app->config('css.version', '0.1');
$app->config('js.version', '0.1');
$app->config('fe.asset.forceless', false);
$app->config('fe.asset.css', array('bootstrap.min.css', 'app.less'));
$app->config('fe.asset.js', array('bootstrap.min.js'));
/**\.************************************** CONFIGURATIONS ********************/
/**************************************** HOOCKS ********************/
/**
 * hook per le lingue
 * in questo modo nelle rotte nn serve metter nessun riferimento alla lingua
 */
$app->hook('slim.before', function () use($app) {
    $availableLangs = $app->config('languages');
    $env = $app->environment();