示例#1
0
 /**
  * The routing engines entry. This method analyses the URL and implements
  * the routing engine.
  */
 public static function route()
 {
     // Implement the routing engine
     Ntentan::$requestedRoute = $_GET["q"];
     if (Ntentan::$route == '') {
         Ntentan::$route = Ntentan::$requestedRoute;
     }
     unset($_GET["q"]);
     unset($_REQUEST["q"]);
     if (Ntentan::$route == "") {
         Ntentan::$route = Ntentan::$defaultRoute;
     } else {
         foreach (Ntentan::$routes as $route) {
             if (preg_match($route["pattern"], Ntentan::$route, $matches) == 1) {
                 $parts = array();
                 if (isset($route["route"])) {
                     $newRoute = $route["route"];
                     foreach ($matches as $key => $value) {
                         $newRoute = str_replace("::{$key}", $value, $newRoute);
                         $parts["::{$key}"] = $value;
                     }
                     Ntentan::$route = $newRoute;
                 }
                 if (is_array($route["globals"])) {
                     foreach ($route["globals"] as $key => $value) {
                         $GLOBALS["ROUTE_{$key}"] = str_replace(array_keys($parts), $parts, $value);
                     }
                 }
                 break;
             }
         }
     }
     if (Ntentan::$route == "") {
         Ntentan::$route = isset($route['default']) ? $route['default'] : Ntentan::$postRoutingDefaultRoute;
     }
     controllers\Controller::load(Ntentan::$route);
     // Store all camelisations into the cache;
     if (count(Ntentan::$camelisations) > $camelisations) {
         Cache::add('nt_camelisations', Ntentan::$camelisations);
     }
 }