Example #1
0
 public static function dispatch($defaultdispatcher, $components)
 {
     self::$mDispatcher = !empty($GLOBALS['gDispatcher']) ? $GLOBALS['gDispatcher'] : $defaultdispatcher;
     self::$mComponents = $components;
     self::includeDispatcher();
     $class = self::$mDispatcher;
     if (!class_exists($class)) {
         trigger_error("Class " . $class . " not defined.");
         die;
     }
     // instance controller object.
     $obj = new $class();
     //deal with method
     if (!empty($_POST['op']) && ereg("^[A-Za-z0-9]+\$", $_POST['op'])) {
         $method = "op_" . $_POST['op'];
         $u = $class . ".op." . $_POST['op'];
         $tplfile = $class . '_' . $_POST['op'] . '.html';
     } elseif (!empty($_GET['view']) && ereg("^[A-Za-z0-9]+\$", $_GET['view'])) {
         $method = "view_" . $_GET['view'];
         $u = $class . ".view." . $_GET['view'];
         $tplfile = $class . '_' . $_GET['view'] . '.html';
     } else {
         $method = "view_defaults";
         $u = $class . ".view.defaults";
         $tplfile = $class . '_defaults.html';
     }
     if (!method_exists($obj, $method)) {
         trigger_error("Function " . $method . "() not defined.", E_USER_ERROR);
         die;
     }
     // authenticate
     self::authenticate();
     // real function
     $obj->{$method}();
     $GLOBALS['gCurUseMeth'] = $method;
     $GLOBALS['gTplFile'] = $tplfile;
     $GLOBALS['gCurPriv'] = $u;
 }