public function route()
{
$this->app->page_orig = $this->app->page;
foreach ($this->links as $page => $args) {
$page = str_replace('/', '_', $page);
// Exact match, no more routing needed
if ($this->app->page == $page) {
return $this;
}
$page .= '_';
if (substr($this->app->page, 0, strlen($page)) == $page) {
$rest = explode('_', substr($this->app->page, strlen($page)));
reset($args);
foreach ($rest as $arg) {
list($key, $match) = each($args);
if (is_numeric($key) || is_null($key)) {
$key = $match;
} else {
if (!preg_match($match, $arg)) {
break 2;
}
}
$_GET[$key] = $arg;
}
$this->app->page = substr($page, 0, -1);
return $this;
}
//$misc=explode()$this->app->page = substr
}
$r = $_SERVER['REQUEST_URI'];
foreach ($this->rules as $rule) {
if (preg_match('/' . $rule[0] . '/', $r, $t)) {
$this->app->page = $rule[1];
if ($rule[2]) {
foreach ($rule[2] as $k => $v) {
$_GET[$v] = $t[$k + 1];
}
}
}
}
}