/** * Constructor * * @param $path * @param $controller_root * @param $view_root * @param $use_routes * @param $force_routes */ public function __construct($path=null,$controller_root=null,$view_root=null,$use_routes=true,$force_routes=false) { if ($path==null) { $path = (isset ($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @ getenv('PATH_INFO'); $path = rtrim(strtolower($path), '/'); } else { $query_pos = strpos($path,'?'); if ($query_pos) { $query = substr($path,$query_pos+1); $this->query = new Query($query); $path = substr($path,0,$query_pos); // remove query part for Dispatcher } } // fetch the view conf $viewconf=Config::Get('request_types'); $default_engine=$viewconf->default; // set the default extension $extension=EXT; // if request type hasn't been specified // run it through the map to see if we get a hit. $req_type=$default_engine; try { foreach($viewconf->map as $item) { switch($item->test) { case 'server': $array=&$_SERVER; break; case 'get': $array=&$_GET; break; case 'post': $array=&$_POST; break; case 'env': $array=&$_ENV; break; } if (isset($array[$item->key])) { if ($item->matches) { if (preg_match("#{$item->matches}#",$array[$item->key])) { $req_type=$item->type; break; } } else { $req_type=$item->type; break; } } } } catch (ConfigInvalidFormatException $fex) { throw $fex; } catch (ConfigException $ex) { } self::$req_type=$req_type; parent::__construct($path,$controller_root,$view_root,$use_routes,$force_routes); }