array( 'it' => 'messaggi', 'en' => 'inbox' ), 'message' => array( 'it' => 'messaggio', 'en' => 'message' ) , 'search' => array( 'it' => 'cerca', 'en' => 'search' ), 'docs' => array( 'it' => 'documenti', 'en' => 'docs' ), 'login' => array( 'it' => 'login', 'en' => 'login' ) ); class routingPages { var $routes = array(); //$this->pageroute = variable to use in links (pageroute = route name, like 'recipes') //$this->pageroute_map = object containing all valid routes (for example {recipes|ricette}) function __construct($lang = 'it') { global $pages; $this->lang = $lang; $this->pages = $pages; $lang_array = array(); foreach($pages as $key => $value) { $this->$key = $value[$lang]; $routekey = $key."_map"; $this->$routekey = "{".$key.":"; $first = true; foreach($value as $route){ if ($first) { $first = false; } else { $this->$routekey.= "|"; } $this->$routekey.= $route; } $this->$routekey.= "}"; } } function route($route){ return $this->pages[$route][$this->lang]; } } ////////////////////////////////////// // // ROUTE INITIALIZATION // ////////////////////////////////////// $routing = new routingPages('it'); use Slim\Http\Request; use Slim\Http\Response; use Slim\Http\UploadedFile; use Mailgun\Mailgun; $container = new \Slim\Container; $container['cache'] = function () { return new \Slim\HttpCache\CacheProvider(); }; $app = new \Slim\App(['settings' => ['debug' => true, 'displayErrorDetails' => true, 'addContentLengthHeader' => false ]]); // Add middleware to the application //$app = new \Slim\App($container); //$app->add(new \Slim\HttpCache\Cache('public', 86400)); //Main frontend and subpages routes //require 'src/routes/passwordless.php'; //require 'src/routes/system_info.php'; require 'src/routes/as.php'; //All Advanced Security custom methods require 'src/routes/panel.php'; //All backend routes require 'src/routes/public.php'; //All public pages require 'src/routes/hydra.php'; //All Hydra, our backoffice, page routes require 'src/routes/hydra_elements.php'; //All Hydra, our backoffice, elements routes require 'src/routes/test.php'; require 'src/routes/documents.php'; require 'src/routes/api.php'; $container = $app->getContainer(); $container['upload_directory'] = __DIR__ . '/uploads'; // Register component on container $container['view'] = function ($container) { $view = new \Slim\Views\Twig('../template', [ 'cache' => false ]); // Instantiate and add Slim specific extension $router = $container->get('router'); $uri = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER)); $view->addExtension(new Slim\Views\TwigExtension($router, $uri)); return $view; }; session_start(); function returnJSON($response,$payload){ return $response->withStatus(200) ->withHeader('Content-Type', 'application/json') ->write($payload); exit; } function customRedirect($response,$route){ return $response->withRedirect($route); } class RouteDumper extends \Slim\Router { public static function getAllRoutes() { $slim = \Slim\Slim::getInstance(); return $slim->router->routes; } } function routeIndex(){ global $app; $routes = $app->getContainer()->router->getRoutes(); $routes_list = []; foreach ($routes as $index => $route) { $group = explode('.', $route->getName()); if (is_array($group) and count($group) > 1) { $sub_group = explode('.', $route->getName()); if (is_array($group) and count($group) > 2) { $routes_list[$group[0]][$group[1]][$index]['name'] = $route->getName(); $routes_list[$group[0]][$group[1]][$index]['pattern'] = $route->getPattern(); $routes_list[$group[0]][$group[1]][$index]['methods'] = $route->getMethods(); } else { $routes_list[$group[0]][$index]['name'] = $route->getName(); $routes_list[$group[0]][$index]['pattern'] = $route->getPattern(); $routes_list[$group[0]][$index]['methods'] = $route->getMethods(); } } else { $routes_list['routes'][$index]['name'] = $route->getName(); $routes_list['routes'][$index]['pattern'] = $route->getPattern(); $routes_list['routes'][$index]['methods'] = $route->getMethods(); } } return $routes_list; } function hydraTwigConst($twigData){ $twigData['AdminPath'] = Config::$AdminPath; $twigData['ASPath'] = Config::$ASPath; /* $user_role = app('current_user')->role_id; $userID = ASSession::get('user_id'); $details = app('user')->getDetails($userID); $first_name = $details['first_name']; $last_name = $details['last_name']; $twigData['CSRF'] = array('name' => ASCsrf::getTokenName(), 'value' => ASCsrf::getToken()); $twigData['user_role'] = $user_role; $twigData['operator_name'] = $first_name." ".$last_name; $twigData['operator_email'] = app('current_user')->email; */ return $twigData; } // Run app $app->run();