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)) {
33 if ($nCalls == 0 && is_callable($page, '_default')) {
34 $page->Call('_default', $argv);
47 function __construct($site, $method) {
49 $this->method = $method;
51 function get_handlers() {
52 $handlers = isset($this->handlers[$this->method]) ?
53 $this->handlers[$this->method] : array();
56 function has_handler($handler) {
57 return isset($this->handlers[$this->method]) ? in_array($handler, $this->handlers[$this->method]) : false;
61 function Call($handler, $argv) {
62 if (is_callable(array($this, $handler)))
63 return array(0, call_user_func_array(array($this, $handler), $argv));