767a11a2f9caf7f181fe5cf82a83074e71ef8154
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
23 define('PL_NEEDLOGIN', 1);
24 define('PL_FORBIDDEN', 403);
25 define('PL_NOT_FOUND', 404);
37 $this->path
= trim(Get
::_get('p', null
), '/');
39 $this->__mods
= array();
40 $this->__hooks
= array();
42 foreach (glob(dirname(__FILE__
).'/../modules/*.php') as $module) {
43 $module = basename($module, '.php');
44 $m =& PLModule
::factory($this, $module);
45 $this->__mods
[$module] =& $m;
46 $this->__hooks +
= $m->handlers();
49 krsort($this->__hooks
);
52 function load_class($cls)
54 require_once dirname(__FILE__
).'/../classes/'.$cls.'.php';
57 function call_hook(&$page)
62 if (array_key_exists($p, $this->__hooks
))
65 $p = substr($p, 0, strrpos($p, '/'));
67 if (empty($this->__hooks
[$p])) {
71 $hook = $this->__hooks
[$p];
73 if (!is_callable($hook['hook'])) {
77 $args = explode('/', substr($this->path
, strlen($p)));
80 if ($hook['auth'] > Session
::get('auth', AUTH_PUBLIC
)) {
81 $_SESSION['session']->doAuth($page);
83 return call_user_func_array($hook['hook'], $args);
90 new_skinned_page('index.tpl', AUTH_PUBLIC
);
92 if (empty($this->path
)) {
96 switch ($this->call_hook($page)) {
98 $this->__mods
['core']->handler_403($page);
102 $this->__mods
['core']->handler_404($page);