4 protected $routes = array(),
7 public function __construct (){
8 // adding default routes for css and rss
9 $this->addRoute ('rss');
10 $this->addRoute ('style');
11 $this->addRoute ('index');
14 public function addRoute ($ctrlName, $incRoute = null, $default = null) {
15 if (empty ($ctrlName)) {
19 if (empty ($incRoute))
20 $incRoute = '/'.$ctrlName.'/';
23 $this->defaultRoute
= $ctrlName;
25 $this->routes
[$ctrlName] = $incRoute;
29 public function getController () {
30 $to = urldecode(tsUrl
::getRequest(NAV_VAR
)); // due to bug(?) in lighttpd url rewrite
32 if (empty($this->routes
)) {
33 if ($this->validController ($to))
37 foreach ($this->routes
as $ctrlName => $regex) {
38 // var_dump($to, $ctrlName, $regex,preg_match('/'.$ctrlName.'/i', $to), preg_match($regex, $to,$a));
42 if ( preg_match('/'.$ctrlName.'/i', $to) ||
preg_match($regex, $to)) {
43 return $this->validController ($ctrlName);
46 return $this->validController($this->defaultRoute
);
50 public function validController ($ctrlName) {
51 echo $ctrlName = strtolower($ctrlName);
52 // echo PAGE_PATH . $ctrlName . DIRECTORY_SEPARATOR . $ctrlName . '.php';
53 if (!empty($ctrlName) && is_dir(PAGE_PATH
. $ctrlName) && is_file (PAGE_PATH
. $ctrlName . DIRECTORY_SEPARATOR
. $ctrlName . '.php')) {