Ejemplo n.º 1
0
 public function renderScript($script = "")
 {
     if (empty($script)) {
         $script = $this->view . '.js';
     }
     if (file_exists(SCRIPTS . $script)) {
         echo '<script src="' . Router::buildURL("/scripts/{$script}") . '"></script>';
     }
 }
Ejemplo n.º 2
0
 /**
  * Init done? Continue to the deeper layers for the output.
  */
 public function run()
 {
     $router = new Router();
     $router->route($this->request);
 }
Ejemplo n.º 3
0
<?php

use Routing\Router;
use Routing\MatchedRoute;
use Routing\RouterTrait;
try {
    $router = new Router(RouterTrait::GET_HTTP_HOST());
    //    //Admin
    //    $router->add('adminMain', '/admin', 'Controller_Admin:action_index' , 'GET|POST');
    //    $router->add('adminLogin', '/admin/login', 'Controller_Admin:action_login');
    //    $router->add('adminLogout', '/admin/logout', 'Controller_Admin:action_logout');
    //Main
    $router->add('homepage', '/', 'Controller_Main:action_index', 'GET|POST');
    $router->add('about', '/about', 'Controller_About:action_index', 'GET|POST');
    $router->add('services', '/services', 'Controller_Services:action_index', 'GET|POST');
    //    $router->add('error404', '/404', 'Controller_Main:action_error404' , 'GET|POST');
    //    $router->add('staticPage', '/(slug:str).html', 'Controller_Main:action_staticPage' , 'GET|POST');
    //
    //    //News
    //    $router->add('news', '/news', 'Controller_News:action_index', 'GET|POST');
    //    $router->add('article', '/article/(slug:str)', 'Controller_News:action_article' , 'GET|POST');
    //    $router->add('edit_news', '/edit/(id:num)', 'Controller_News:action_edit' , 'GET|POST');
    //
    //    //Admin
    //    $router->add('adminMain', '/admin', 'Controller_Admin:action_index' , 'GET|POST');
    //    $router->add('adminLogin', '/admin/login', 'Controller_Admin:action_login');
    //    $router->add('adminLogout', '/admin/logout', 'Controller_Admin:action_logout');
    //    $router->add('adminNews', '/admin/news', 'Controller_Admin:action_news' , 'GET|POST');
    //    $router->add('adminArticle', '/admin/article/id(id:num)', 'Controller_Admin:action_article' , 'GET|POST');
    //    $router->add('adminPages', '/admin/pages', 'Controller_Admin:action_pages' , 'GET|POST');
    //    $router->add('adminOnePage', '/admin/page/id(id:num)', 'Controller_Admin:action_onepage' , 'GET|POST');
Ejemplo n.º 4
0
<?php

use Routing\Router;
use Routing\MatchedRoute;
try {
    $router = new Router(GET_HTTP_HOST());
    //Main
    //    $router->add('homepage', '/', 'Controller_Main:action_index');
    //    $router->add('error404', '/404', 'Controller_Main:action_error404');
    //    $router->add('staticPage', '/(slug:str).html', 'Controller_Main:action_staticPage');
    //News
    //    $router->add('news', '/news', 'Controller_News:action_index');
    //    $router->add('article', '/article/(slug:str)', 'Controller_News:action_article');
    // $router->add('about', '/about', 'AppController:aboutAction');
    // $router->add('contacts', '/contacts', 'AppController:contactsAction');
    // $router->add('user', '/user/(id:num)', 'AppController:userAction');
    //Admin
    //    $router->add('adminMain', '/admin', 'Controller_Admin:action_index' , 'GET|POST');
    //    $router->add('adminLogin', '/admin/login', 'Controller_Admin:action_login');
    //    $router->add('adminLogout', '/admin/logout', 'Controller_Admin:action_logout');
    //    $router->add('adminNews', '/admin/news', 'Controller_Admin:action_news' , 'GET|POST');
    //    $router->add('adminArticle', '/admin/article/id(id:num)', 'Controller_Admin:action_article' , 'GET|POST');
    //    $router->add('adminPages', '/admin/pages', 'Controller_Admin:action_pages' , 'GET|POST');
    //    $router->add('adminOnePage', '/admin/page/id(id:num)', 'Controller_Admin:action_onepage' , 'GET|POST');
    //Admin my
    $router->add('adminAutoriz', '/login', 'Controller_Login:action_index', 'GET|POST');
    $router->add('adminLogout', '/logout', 'Controller_Logout:action_index');
    $router->add('adminMain', '/admin', 'Controller_Admin:action_index', 'GET|POST');
    $router->add('adminDelPost', '/admin/delPost', 'Controller_Admin:action_delPost', 'GET|POST');
    $router->add('adminAddPost', '/admin/addPost', 'Controller_Admin:action_addPost', 'GET|POST');
    // Main
Ejemplo n.º 5
0
        if (file_exists(FRAMEWORK . $class . ".php")) {
            include FRAMEWORK . $class . ".php";
        } elseif (file_exists(EXCEPTIONS . $class . ".php")) {
            include EXCEPTIONS . $class . ".php";
        } elseif (file_exists(BASE . $class . ".php")) {
            include BASE . $class . ".php";
        } else {
            throw new FileNotFoundException($class . ".php");
        }
    });
}
function cleanup()
{
    $err = error_get_last();
    if ($err !== null && $err["type"] == E_ERROR) {
        ob_end_clean();
        $response = new ErrorResponse();
        $response->render();
    }
}
if (!DEBUG) {
    register_shutdown_function("cleanup");
}
use Routing\Router;
try {
    header('Content-Type: text/html; charset=utf-8');
    $router = new Router();
    $router->run();
} catch (Exception $e) {
    cleanup();
}
Ejemplo n.º 6
0
 public static function Rows($options = [], $data, $actions = [], $pkey = [], $config = [])
 {
     // carrega as configurações do frame para pegar o idioma
     $language = autoload_config();
     // se houver registros
     if ($data) {
         // prepara os dados para paginação, se solicitado.
         if (self::$paginate) {
             $paginator = new Paginator();
             $paginator->paginate($data);
         }
         // mostra uma mensagem de alerta se existir.
         if (self::$message) {
             self::$table .= "<tr>\n                                    <td colspan='100'>" . self::$message . "</td>\n                                 </tr>";
         }
         $name[0] = $options['id'] ? 'edit-' . $options['id'] : 'edit';
         $name[1] = $options['id'] ? 'del-' . $options['id'] : 'delete';
         // prepara o conteudo dos campos para cada linha
         foreach ($data as $index => $row) {
             // prepara atributos para os elementos tr e td, se solicitado.
             if ($config) {
                 //dd($config);
                 foreach ($config as $key => $configure) {
                     $k = explode(':', $key);
                     //
                     // switch($k[0]) {
                     //     case 'td':
                     //
                     //
                     //
                     //
                     //         foreach($configure as $cfg_key => $cfg_val) {
                     //             if($k[1]) {
                     //
                     //                 $attr_td = $cfg_key.'="'.$cfg_val.'" ';
                     //             } else {
                     //                 $attr_td = $cfg_key.'="'.$cfg_val.'" ';
                     //             }
                     //         }
                     //         //dd($attr_td);
                     //
                     //     break;
                     // }
                     // switch($key) {
                     //     case 'tr':
                     //         foreach($configure as $tr_key => $tr_value) {
                     //             $attr_tr .= $tr_key.'="'.$tr_value.'" ';
                     //         }
                     //     break;
                     //
                     //     case 'td':
                     //     //dd($configure);
                     //         foreach($configure as $td_key => $td_value) {
                     //             //dd($td_key);
                     //             if(is_array($td_value)) {
                     //                 //dd($td_value);
                     //             }
                     //             else {
                     //                 $attr_td .= $td_key.'="'.$td_value.'" ';
                     //             }
                     //
                     //         }
                     //     break;
                     // }
                 }
             }
             // seta atributo para o elemento tr
             self::$table .= "<tr {$attr_tr}>";
             // pega o conteudo de cada campo
             foreach ($row as $field => $value) {
                 // verifica se existe campos para serem eliminados
                 if (self::$ignore) {
                     // remove os campos ignorados
                     if (in_array($field, self::$ignore)) {
                         continue;
                     }
                 } else {
                     if (self::$only) {
                         // remove todos os campos que nao forem passados
                         if (!in_array($field, self::$only)) {
                             continue;
                         }
                     }
                 }
                 // retorna nome do campo limpo
                 $fname = explode('_', $field)[1];
                 if ($v[1]) {
                     if ($field === $v[1]) {
                         self::$table .= "<td data-label='{$fname}' {$attr_td}>{$value}</td>";
                         unset($attr_td);
                     } else {
                         self::$table .= "<td data-label='{$fname}'>{$value}</td>";
                     }
                 } else {
                     self::$table .= "<td data-label='{$fname}' {$attr_td} class='{$field}'>{$value}</td>";
                 }
             }
             // se houver botoes de acoes
             if ($actions) {
                 // verifica se foi passado as chaves da tabela
                 if ($pkey) {
                     // pega todas as chaves passadas
                     foreach ($pkey as $pk) {
                         $arr[] = $row[$pk];
                     }
                     // cria uma string separando por ífen
                     $pk = implode('-', $arr);
                     // limpa o array
                     unset($arr);
                 }
                 // seta o atributo para o elemento td
                 self::$table .= "<td {$attr_td}>";
                 $validarAcesso = true;
                 $link = URL . \Routing\Router::getControllerName();
                 // verifica quais os botoes serao adicionados
                 foreach ($actions as $k => $action) {
                     if (!is_numeric($k)) {
                         if (is_bool($action)) {
                             $validarAcesso = $action;
                         }
                         $action = $k;
                     }
                     switch ($action) {
                         case 'detail':
                             if ($validarAcesso) {
                                 self::$table .= "<a href='{$link}/detail/{$pk}' class='btn btn-primary' alt='" . $language[Session::get('s_locale')]['app']['details'] . "' title='" . $language[Session::get('s_locale')]['app']['details'] . "'>\n                                                        <span class='glyphicon glyphicon-list' aria-hidden='true'></span>\n                                                        " . $language[Session::get('s_locale')]['app']['details'] . "\n                                                     </a> ";
                             }
                             break;
                         case 'edit':
                             if ($validarAcesso) {
                                 self::$table .= "<a href='{$pk}' class='btn btn-warning {$name['0']}' alt='" . $language[Session::get('s_locale')]['app']['edit'] . "' title='" . $language[Session::get('s_locale')]['app']['edit'] . "'>\n                                                    <span class='glyphicon glyphicon-edit' aria-hidden='true'></span>\n                                                 </a> ";
                             }
                             break;
                         case 'delete':
                             if ($validarAcesso) {
                                 self::$table .= "<a href='{$pk}' class='btn btn-danger {$name['1']}' alt='" . $language[Session::get('s_locale')]['app']['delete'] . "' title='" . $language[Session::get('s_locale')]['app']['delete'] . "'>\n                                                        <span class='glyphicon glyphicon-trash' aria-hidden='true'></span>\n                                                     </a> ";
                             }
                             break;
                         case 'print':
                             if ($validarAcesso) {
                                 self::$table .= "<a href='{$pk}' class='btn btn-default' alt='" . $language[Session::get('s_locale')]['app']['print'] . "' title='" . $language[Session::get('s_locale')]['app']['print'] . "'>\n                                                        <span class='glyphicon glyphicon-print' aria-hidden='true'></span>\n                                                     </a> ";
                             }
                             break;
                         default:
                             self::$table .= "<a href='{$pk}' class='btn btn-default' alt='" . $language[Session::get('s_locale')]['app']['btnUnknow'] . "' title='" . $language[Session::get('s_locale')]['app']['btnUnknow'] . "'>\n                                                    <span class='glyphicon' aria-hidden='true'>?</span>\n                                                 </a> ";
                     }
                 }
                 // fecha a coluna dos botoes
                 self::$table .= '</td>';
             }
             // finaliza a linha
             self::$table .= '</tr>';
         }
         if (self::$paginate) {
             self::$table .= "<tr class='tfoot'><td colspan='100' class='nohover'>" . $paginator->pages() . "</td></tr>";
         }
     } else {
         self::$table .= "<tr>\n                                <td colspan='100' align='center' class='nohover' style='padding:30px; font-size:15px'>\n                                    <span class='glyphicon glyphicon-exclamation-sign'></span> " . $language[Session::get('s_locale')]['app']['searchnotfound'] . "\n                                </td>\n                            </tr>";
     }
 }
Ejemplo n.º 7
0
<?php

use Routing\Router;
use Routing\MatchedRoute;
use Routing\RouterTrait;
try {
    $router = new Router(RouterTrait::GET_HTTP_HOST());
    //Admin
    $router->add('adminMain', '/admin', 'Controller_Admin:action_index', 'GET|POST');
    $router->add('adminLogin', '/admin/login', 'Controller_Admin:action_login');
    $router->add('adminLogout', '/admin/logout', 'Controller_Admin:action_logout');
    //Main
    $router->add('homepage', '/', 'Controller_Main:action_index', 'GET|POST');
    $router->add('error404', '/404', 'Controller_Main:action_error404', 'GET|POST');
    $router->add('staticPage', '/(slug:str).html', 'Controller_Main:action_staticPage', 'GET|POST');
    //News
    $router->add('news', '/news', 'Controller_News:action_index', 'GET|POST');
    $router->add('article', '/article/(slug:str)', 'Controller_News:action_article', 'GET|POST');
    $router->add('edit_news', '/edit/(id:num)', 'Controller_News:action_edit', 'GET|POST');
    //Admin
    $router->add('adminMain', '/admin', 'Controller_Admin:action_index', 'GET|POST');
    $router->add('adminLogin', '/admin/login', 'Controller_Admin:action_login');
    $router->add('adminLogout', '/admin/logout', 'Controller_Admin:action_logout');
    $router->add('adminNews', '/admin/news', 'Controller_Admin:action_news', 'GET|POST');
    $router->add('adminArticle', '/admin/article/id(id:num)', 'Controller_Admin:action_article', 'GET|POST');
    $router->add('adminPages', '/admin/pages', 'Controller_Admin:action_pages', 'GET|POST');
    $router->add('adminOnePage', '/admin/page/id(id:num)', 'Controller_Admin:action_onepage', 'GET|POST');
    $route = $router->match(RouterTrait::GET_METHOD(), RouterTrait::GET_PATH_INFO());
    if (null == $route) {
        $route = new MatchedRoute('Controller_Main:action_error404');
    }
Ejemplo n.º 8
0
 public static function getInstance()
 {
     self::$config = autoload_config();
     if (!self::$instance) {
         try {
             $controller = Router::getControllerName();
             $loader = new \Twig_Loader_Filesystem([self::$config['app']['TWIG_VIEWS']]);
             $loader->addPath(self::$config['app']['TWIG_VIEWS'], 'view');
             $loader->addPath(__DIR__ . DS . '../Support/Templates/', 'stemplates');
             $loader->addPath(DOC_ROOT . 'app/Support/Templates/', 'templates');
             self::$instance = new \Twig_Environment($loader, ['cache' => self::$config['app']['TWIG_CACHE'], 'auto_reload' => self::$config['app']['TWIG_AUTO_RELOAD'], 'autoescape' => self::$config['app']['TWIG_AUTO_ESCAPE'], 'debug' => self::$config['app']['DEBUG']]);
             Debug::collectorTwig(self::$instance);
             self::$functions[] = new \Twig_SimpleFunction('load_modals', function () {
                 foreach (glob(DOC_ROOT . 'app/Http/Views/_modals/modal.*.twig') as $modal) {
                     if (file_exists($modal)) {
                         require $modal;
                     }
                 }
             });
             self::$functions[] = new \Twig_SimpleFunction('table', function ($id, $fields = [], $actions = []) {
                 //NOME:TABELA.CAMPO:TIPO_PESQUISA
                 foreach ($fields as $key) {
                     $k = explode(':', $key);
                     $arr[$k[0]] = $k[1] . ':' . $k[2];
                 }
                 \Service\HTML\Table::Open();
                 \Service\HTML\Table::Header([], $id, $arr, $actions);
                 if ($id != 'tabela') {
                     $id = 'tabela-' . $id;
                 }
                 \Service\HTML\Table::Body(['id' => $id]);
                 return \Service\HTML\Table::Close();
             });
             self::$functions[] = new \Twig_SimpleFunction('formSearch', function ($id = null, $url = null, $actions = [], $validate = true) {
                 return \Service\HTML\Form::formSearch($id, $url, $actions, $validate);
             });
             self::$functions[] = new \Twig_SimpleFunction('alert', function ($message, $alert = 'info') {
                 return XHR::alert($message, $alert);
             });
             self::$functions[] = new \Twig_SimpleFunction('dd', function ($var) {
                 return dd($var);
             });
             self::$functions[] = new \Twig_SimpleFunction('validate', function ($array, $key) {
                 if (in_array($key, $array)) {
                     return '<span style="color:red">' . self::$config[Session::get('s_locale')]['app']['requiredMsg'] . '</span>';
                 }
             });
             self::$functions[] = new \Twig_SimpleFunction('select2_options', function ($array, $var = null) {
                 $options = "<option value=''></option>";
                 foreach ($array as $index) {
                     $selected = $index['ID'] == $var ? ' selected="selected" ' : false;
                     $options .= "<option value='{$index['ID']}' {$selected}>{$index['TEXT']}</option>";
                 }
                 return $options;
             });
             foreach (self::$functions as $key => $function) {
                 self::$instance->addFunction($function);
             }
             foreach (self::$filters as $key => $filter) {
                 self::$instance->addFilter($filter);
             }
             $lexer = new \Twig_Lexer(self::$instance, ['tag_block' => self::$config['app']['TWIG_TAG_BLOCK'], 'tag_variable' => self::$config['app']['TWIG_TAG_VARIABLE'], 'tag_comment' => self::$config['app']['TWIG_TAG_COMMENT'], 'interpolation' => self::$config['app']['TWIG_TAG_INTERPOLATION']]);
             self::$instance->setLexer($lexer);
             /*
              * Linguagem da aplicação!
              *
              * Se existir um script de idioma para o controlador ativado, carregará na memória!
              */
             // global
             self::$instance->addGlobal('langApp', self::$config[Session::get('s_locale')]['app']);
             // do programa
             self::$instance->addGlobal('lang', self::$config[Session::get('s_locale')][$controller]);
             /*
              * Variáveis Globais
              *
              * São essenciais para o funcionamento basico da aplicação.
              */
             self::$instance->addGlobal('hostname', gethostname());
             self::$instance->addGlobal('URL', URL);
             self::$instance->addGlobal('bower_dir', URL . self::$config['app']['BOWER_COMPONENTS']);
             self::$instance->addGlobal('app_name', self::$config['app']['APP_NAME']);
             self::$instance->addGlobal('app_title', self::$config['app']['APP_TITLE']);
             self::$instance->addGlobal('app_version', self::$config['app']['APP_VERSION']);
             self::$instance->addGlobal('theme', self::$config['app']['DEFAULT_THEME']);
             self::$instance->addGlobal('page_lang', self::$config['app']['TWIG_PAGE_LANG']);
             self::$instance->addGlobal('page_charset', self::$config['app']['TWIG_PAGE_CHARSET']);
             self::$instance->addGlobal('debug', autoload_machines() ? false : self::$config['app']['DEBUG']);
             self::$instance->addGlobal('configure', self::$config);
             $app_js = DOC_ROOT . 'public/app/js/' . $controller . '.js';
             if (file_exists($app_js)) {
                 self::$instance->addGlobal('app_js', "<script type='text/javascript' src='" . URL . 'app/js/' . $controller . ".js'></script>");
             }
             $app_css = DOC_ROOT . 'public/app/css/' . $controller . '.css';
             if (file_exists($app_css)) {
                 self::$instance->addGlobal('app_css', "<link rel='stylesheet' href='" . URL . 'app/css/' . $controller . ".css' type='text/css'/>");
             }
             switch (Session::get('s_environment')) {
                 case 'dev':
                     $env = self::$config[Session::get('s_locale')]['app']['development'];
                     break;
                 case 'hom':
                     $env = self::$config[Session::get('s_locale')]['app']['statement'];
                     break;
                 case 'pro':
                     $env = self::$config[Session::get('s_locale')]['app']['production'];
                     break;
             }
             self::$instance->addGlobal('environment_current', $env);
             self::$instance->addGlobal('server', $_SERVER);
             self::$instance->addGlobal('session', $_SESSION);
             self::$instance->addGlobal('post', $_POST);
             self::$instance->addGlobal('get', $_GET);
             self::$instance->addGlobal('request', $_REQUEST);
             self::$instance->addGlobal('flash', Session::get('flash') ? Session::flash() : false);
             self::$instance->addGlobal('token', Session::get('s_token'));
             self::$instance->addGlobal('controller', $controller);
             self::$instance->addGlobal('method', Router::getMethod());
             self::$instance->addGlobal('debugbar_header', Debug::render()->renderHead());
             self::$instance->addGlobal('debugbar_body', Debug::render()->render());
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
     return self::$instance;
 }
Ejemplo n.º 9
0
<?php

use Routing\Router;
use Routing\MatchedRoute;
use Routing\RouterTrait;
try {
    $router = new Router(RouterTrait::GET_HTTP_HOST());
    //Main
    $router->add('homepage', '/', 'Controller_Main:action_index');
    $router->add('error404', '/404', 'Controller_Main:action_error404');
    $router->add('staticPage', '/(slug:str).html', 'Controller_Main:action_staticPage');
    //CRUD
    $router->add('dashboard', '/dashboard', 'Controller_Crud:action_index');
    $router->add('adminList', '/admin/list/(entity:str)', 'Controller_Crud:action_list');
    $router->add('adminRemove', '/admin/remove/(entity:str)/(id:num)', 'Controller_Crud:action_remove');
    $router->add('adminForm', '/admin/form/(entity:str)/(id:num)', 'Controller_Crud:action_form');
    $router->add('adminSave', '/admin/save/(entity:str)/(id:num)', 'Controller_Crud:action_save', 'POST');
    //REST
    $router->add('prodJson', '/json/product/(id:num)', 'Controller_Rest:action_index');
    $route = $router->match(RouterTrait::GET_METHOD(), RouterTrait::GET_PATH_INFO());
    if (null == $route) {
        $route = new MatchedRoute('Controller_Main:action_error404');
    }
    list($class, $action) = explode(':', $route->getController(), 2);
    call_user_func_array(array(new $class($router), $action), $route->getParameters());
} catch (Exception $e) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
    echo $e->getMessage();
    echo $e->getTraceAsString();
    exit;
}
Ejemplo n.º 10
0
<?php

use Foundation\Application;
use HTTP\Kernel;
use HTTP\Request;
use Routing\Router;
require __DIR__ . '/../vendor/autoload.php';
$application = new Application();
$application->share('i want to see the dashboard', function () {
    echo '<h1>Dashboard</h1>';
});
$router = new Router();
$router->add('/', 'i want to see the dashboard');
$kernel = new Kernel($router, $application);
$request = Request::create('/', 'GET');
$response = $kernel->handle($request);
$response->send();
Ejemplo n.º 11
0
use HTTP\Request;
use HTTP\Session;
use Routing\Router;
require __DIR__ . '/../vendor/autoload.php';
$application = new Application();
$application->share('HTTP\\Session', function () {
    return new Session();
});
$application->share('i want to save to the session', function (Session $session) {
    $session->name = 'Reno Jackson';
    $session->quotes = 'We\'re gonna be rich';
});
$application->share('i want to read the session', function (Session $session) {
    dump($session);
});
$application->share('i want to flash to the session', function (Session $session) {
    // $session->flash->city = 'Nijmegen';
});
$application->share('i want to read the session flash', function (Session $session) {
    dump($session->flash);
});
$router = new Router();
$router->add('/', 'i want to save to the session');
$router->add('/read', 'i want to read the session');
$router->add('/add/flash', 'i want to flash to the session');
$router->add('/read/flash', 'i want to read the session flash');
$kernel = new Kernel($router, $application);
$response = $kernel->handle(Request::create('/read/flash'));
$response->send();
$application->make('HTTP\\Session')->replenish();
dump($_SESSION);
Ejemplo n.º 12
0
<?php

require 'bootstrap.php';
use Routing\Router, Routing\MatchedRoute;
try {
    $router = new Router(GET_HTTP_HOST());
    $router->add('mainPage', '/', 'Views\\MainView:get');
    $router->add('editSection', '/section/edit(id:num)', 'Views\\SectionView:edit');
    $router->add('delSection', '/section/delete(id:num)', 'Views\\SectionView:delete');
    $router->add('getSections', '/sections', 'Views\\SectionView:get');
    $router->add('updateSection', '/section/update', 'Views\\SectionView:update');
    $router->add('insertSection', '/section/insert', 'Views\\SectionView:insert');
    $router->add('editElement', '/element/edit(id:num)', 'Views\\ElementView:edit');
    $router->add('delElement', '/element/delete(id:num)', 'Views\\ElementView:delete');
    $router->add('updateElement', '/element/update', 'Views\\ElementView:update');
    $router->add('insertElement', '/element/insert', 'Views\\ElementView:insert');
    $route = $router->match(GET_METHOD(), GET_PATH_INFO());
    if (null == $route) {
        $route = new MatchedRoute('Views\\MainView:error404');
    }
    list($class, $action) = explode(':', $route->getController(), 2);
    call_user_func_array(array(new $class($router), $action), $route->getParameters());
} catch (Exception $ex) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
    echo $ex->getMessage();
    echo $ex->getTraceAsString();
    exit;
}