2016-02-01 22:09:35 +00:00
|
|
|
<?php define('__ROOT__', dirname(__FILE__) );
|
2016-02-12 22:22:14 +00:00
|
|
|
// \manager\session_start();
|
2016-02-03 22:22:18 +00:00
|
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
2016-02-01 22:09:35 +00:00
|
|
|
|
2016-02-02 22:29:30 +00:00
|
|
|
/*******************************************/
|
|
|
|
/* DEBUGGER */
|
|
|
|
/*******************************************/
|
2016-02-04 22:45:03 +00:00
|
|
|
debug();
|
2016-02-02 22:29:30 +00:00
|
|
|
/*******************************************/
|
2016-02-01 22:09:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* [0] On initialise le routeur
|
|
|
|
===================================================*/
|
|
|
|
$R = new router\Router( $_GET['url'] );
|
|
|
|
// var_dump($R);
|
|
|
|
|
|
|
|
/* [1] On cree les regles de routage
|
|
|
|
===================================================*/
|
2016-02-02 22:29:30 +00:00
|
|
|
// Racine -> page d'accueil
|
2016-02-02 10:09:48 +00:00
|
|
|
$R->get('/?', function(){ header('Location: /dashboard/'); });
|
2016-02-01 22:09:35 +00:00
|
|
|
|
2016-02-02 22:29:30 +00:00
|
|
|
// nomPage/arg1/arg2 -> inclusion de la page
|
2016-02-03 11:32:53 +00:00
|
|
|
$R->get('dashboard(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
2016-02-03 22:22:18 +00:00
|
|
|
$R->get('profile(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
2016-02-03 11:32:53 +00:00
|
|
|
$R->get('machines(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
$R->get('users(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
$R->get('analytics(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
$R->get('settings(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
2016-02-02 22:29:30 +00:00
|
|
|
|
|
|
|
// nomPage -> nomPage/
|
2016-02-11 15:00:41 +00:00
|
|
|
|
2016-02-03 22:22:18 +00:00
|
|
|
|
|
|
|
// $R->get('dashboard/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
// $R->get('machines/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
// $R->get('users/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
// $R->get('analytics/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
// $R->get('settings/', function(){ include __ROOT__.'/view.php'; });
|
2016-02-02 22:29:30 +00:00
|
|
|
|
|
|
|
// Dispatcher
|
2016-02-08 21:43:35 +00:00
|
|
|
$R->get('f(?:/([\w-]+))*/?', function(){ new \manager\ResourceDispatcher($_GET['url'], true); });
|
2016-02-02 22:29:30 +00:00
|
|
|
|
2016-02-04 22:45:03 +00:00
|
|
|
// Api
|
|
|
|
$R->post('api/?', function(){
|
2016-02-12 23:04:00 +00:00
|
|
|
$request = \manager\ModuleRequest::fromPost($_POST);
|
2016-02-05 08:10:37 +00:00
|
|
|
$answer = $request->dispatch();
|
|
|
|
|
|
|
|
echo $answer->serialize();
|
2016-02-04 22:45:03 +00:00
|
|
|
});
|
|
|
|
|
2016-02-02 22:29:30 +00:00
|
|
|
// N'importe -> page d'accueil
|
2016-02-02 10:09:48 +00:00
|
|
|
$R->get('.+', function(){ header('Location: /dashboard/'); });
|
2016-02-01 22:09:35 +00:00
|
|
|
|
|
|
|
|
2016-02-04 22:45:03 +00:00
|
|
|
// $R->post('.*', function(){
|
|
|
|
// var_dump( 'Acces POST : '.$_GET['url'] );
|
|
|
|
// var_dump( $_POST );
|
|
|
|
// });
|
2016-02-01 22:09:35 +00:00
|
|
|
|
2016-02-02 10:09:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-01 22:09:35 +00:00
|
|
|
/* [2] On lance le routeur
|
|
|
|
===================================================*/
|
|
|
|
$R->run();
|
|
|
|
|
|
|
|
?>
|