2 /* Generic Site Classes
3 * 2007/04/09 Joe Presbrey <presbrey@mit.edu>
8 function Call($MODULE, $METHOD) {
10 if (file_exists(strtolower('site/'.$MODULE.'.php'))) {
11 require_once strtolower('site/'.$MODULE.'.php');
12 if (class_exists($MODULE)) {
13 $page = new $MODULE($this, $METHOD);
15 $handlers = $page->get_handlers($METHOD);
19 $argv = array_merge($_COOKIE, $_FILES, $_POST, $_GET, isset($_SESSION)?$_SESSION:array()); break;
23 $argv = array_merge($_COOKIE, $_FILES, $_GET, $_POST, isset($_SESSION)?$_SESSION:array()); break;
25 foreach($handlers as $handler) {
26 if (isset($argv[$handler]) &&
27 false !== $page->Call($handler, $argv)) {
31 if ($nCalls == 0 && is_callable(array($page, '_default'))) {
32 $page->Call('_default', $argv);
45 function __construct($site, $method) {
47 $this->method = $method;
49 function get_handlers() {
50 $handlers = isset($this->handlers[$this->method]) ?
51 $this->handlers[$this->method] : array();
54 function has_handler($handler) {
55 return isset($this->handlers[$this->method]) ? in_array($handler, $this->handlers[$this->method]) : false;
59 function Call($handler, $argv) {
60 if (is_callable(array($this, $handler)))
61 return array(0, call_user_func_array(array($this, $handler), $argv));