path = Get::_get('p', null); $this->__mods = array(); $this->__hooks = array(); $this->menu = array(); foreach (glob(dirname(__FILE__).'/../modules/*.php') as $module) { $module = basename($module, '.php'); $m =& PLModule::factory($this, $module); $this->__mods[$module] =& $m; $this->__hooks += $m->handlers(); $this->menu = array_merge($this->menu, $m->menu_entries()); } krsort($this->__hooks); usort($this->menu, array($this, '_menu_cmp')); } function load_class($cls) { require_once dirname(__FILE__).'/../classes/'.$cls.'.php'; } function _menu_cmp($a, $b) { return strcasecmp($a['path'], $b['path']); } function call_hook(&$page) { $p = $this->path; while ($path) { if (array_key_exists($p, $this->__hooks)) break; $p = substr($p, 0, strrpos($p, '/')); } if (empty($this->__hooks[$p])) { return PL_NOT_FOUND; } $args = array_merge(array(&$page), explode('/', substr($this->path, strlen($p) + 1))); $hook = $this->__hooks[$p]; if ($hook['auth'] > Session::get('auth', AUTH_PUBLIC)) { $_SESSION['session']->doAuth($page); } return call_user_func_array($hook['hook'], $args); } function run() { global $page; new_skinned_page('index.tpl', AUTH_PUBLIC); if (empty($this->path)) { $page->run(); } switch ($this->call_hook($page)) { case PL_FORBIDDEN: $this->__mods['core']->handler_403($page); break; case PL_NOT_FOUND: $this->__mods['core']->handler_404($page); break; } $page->run(); } } ?>