Пример #1
0
 /**
  * Do an execution based on a route
  *
  * @param $route The route to be executed
  * @return void
  */
 public static function run($route)
 {
     global $CONTROLLER;
     $controller_name = Ra_StringHelper::camelize($route['controller']) . 'Controller';
     $method = strtolower($route['action']);
     if (!class_exists($controller_name)) {
         dispatch_error(new Exception("Controller {$controller_name} doesn't exists"), 404);
     }
     $controller = new $controller_name($route);
     $controller->_current_route = $route;
     $controller->_params = array_merge($controller->_params, $route['params']);
     $CONTROLLER = $controller;
     $controller->execute($method);
 }
Пример #2
0
//load router configuration
$router_conf = (require_once RA_CONFIG_PATH . '/router.php');
$ROUTER = new UserRouter();
//load slice routes
foreach (glob(RA_SLICES_PATH . "/*/config/router.php") as $router) {
    include_once $router;
}
try {
    $current_route = $ROUTER->match($current_uri);
} catch (Ra_RouterException $e) {
    dispatch_error($e, 404);
}
//disable magic quotes
include_once RA_SYSTEM_CORE_PATH . '/magic_quotes.php';
//transform upload format
include_once RA_SYSTEM_CORE_PATH . '/upload_transform.php';
//load database
require_once RA_SYSTEM_DATABASE_PATH . '/ActiveRecord.php';
$db_conf = (include RA_CONFIG_PATH . '/db.php');
FieldAct::set_upload_path(RA_UPLOAD_PATH . '/');
DBCommand::configure($db_conf->host, $db_conf->user, $db_conf->password, $db_conf->database);
//if your submodules needs to do something, this is the time!
foreach (glob(RA_SLICES_PATH . "/*/config/setup.php") as $setup) {
    include_once $setup;
}
//run!
try {
    Ra_Controller::run($current_route);
} catch (Exception $e) {
    dispatch_error($e);
}