<?php include_once "../vendor/autoload.php"; use tdt\pages\Generator; // Set base URL for public folder $config['baseURL'] = '../public/'; // Create a new generator $generator = new Generator($config); // Set title $generator->setTitle("This is an example page"); // Add a javascript library // $generator->addJS("http://....js"); // Add some CSS // $generator->addCSS("http://....css"); // Add a menu item: title, url, weight, active, open in new window $generator->addMenuItem("This page", "http://thedatatank.com", false, true); $generator->addMenuItem("This page", "#", true, false); $generator->addMenuItem("This page", "#", false, false); // Body $body = ' <h1>Hello World!</h1> <table class="table"> <thead> <th>Subject</th> <th>Object</th> <th>Predicate</th> </thead> <tr> <td>subject</td> <td>object</td> <td>predicate</td>
// Drop the HTTP method from the route foreach ($allroutes as $route => $controller) { $route = preg_replace('/^' . strtoupper($_SERVER['REQUEST_METHOD']) . '(\\s|\\t)*\\|(\\s|\\t)*/', "", trim($route)); $routes[trim($route)] = trim($controller); } //$log->logInfo("The routes we are working with", $routes); try { // This function will do the magic. Glue::stick($routes); } catch (Exception $e) { // Instantiate a Logger $log = new Logger('router'); $log->pushHandler(new StreamHandler(app\core\Config::get("general", "logging", "path") . "/log_" . date('Y-m-d') . ".txt", Logger::ERROR)); // Generator to generate an error page $generator = new Generator(); $generator->setTitle("The DataTank"); if ($e instanceof tdt\exceptions\TDTException) { // DataTank error $log->addError($e->getMessage()); set_error_header($e->getCode(), $e->getShort()); if ($e->getCode() < 500) { $generator->error($e->getCode(), "Sorry, but there seems to be something wrong with the call you've made", $e->getMessage()); } else { $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while."); } } else { // General error $log->addCritical($e->getMessage()); set_error_header(500, "Internal Server Error"); $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while."); }