Example #1
0
 /**
  * This is the launcher, it will check for the first parameter of the url
  * and will try to check if a controller exists, if it does, it will launch it, and
  * the associated function, these parameters come from .htaccess. you should use mod_rewrite
  */
 private function launcher()
 {
     $controller = $this->controller;
     $task = $this->task;
     if (empty($controller)) {
         $controller = 'IndexController';
     } else {
         $controller = ucfirst($controller) . 'Controller';
     }
     if (empty($task)) {
         $task = 'index';
     }
     $c = new $controller();
     $c->smarty = $this->smarty;
     $c->environment = $this->environment;
     $c->app_config = $this->app_config;
     $c->root_folder = $this->root_folder;
     $c->controller = $this->controller;
     $c->task = $this->task;
     $c->object_id = $this->object_id;
     $c->database = $this->environment->db_name;
     $c->autoRender = true;
     $c->requestData = $this->requestData;
     $c->requestUrl = $this->requestUrl;
     $c->postData = $this->postData;
     $c->getData = $this->getData;
     $c->activeController = $controller;
     $c->state = Quantum\Utilities::guid();
     $c->csrf = Quantum\Utilities::genHash($c->state);
     $c->app_root = $this->app_root;
     $c->quantum_root = $this->quantum_root;
     $c->controllers_root = $this->controllers_root;
     $c->models_root = $this->models_root;
     $c->views_root = $this->views_root;
     $c->helpers_root = $this->helpers_root;
     $c->filters_root = $this->filters_root;
     $c->lib_root = $this->lib_root;
     $c->templates_root = $this->templates_root;
     $c->system_root = $this->system_root;
     $c->system_controllers_root = $this->system_controllers_root;
     $c->system_helpers_root = $this->system_helpers_root;
     $c->config_root = $this->config_root;
     $c->tmp_root = $this->tmp_root;
     $c->public_root = $this->public_root;
     $this->activeController = $c;
     if (method_exists($c, $task)) {
         $reflection = new ReflectionMethod($c, $task);
         if ($reflection->isPublic()) {
             call_user_func(array($c, $task));
             $c->mainView = "{$controller}/{$task}.tpl";
             Quantum\Output::setView($this->controller, $task);
         } else {
             call_user_func(array($c, 'index'));
             $c->mainView = "index.tpl";
             Quantum\Output::setView($this->controller, 'index');
         }
     } else {
         call_user_func(array($c, 'index'));
         $c->mainView = "index.tpl";
         Quantum\Output::setView($this->controller, 'index');
     }
 }
Example #2
0
function redirect_to($uri, $boolean = true, $code = 302)
{
    Quantum\Utilities::redirect($uri, $boolean, $code);
}