Example #1
0
 public function _corridor()
 {
     if (method_exists($this, 'corridor')) {
         $this->corridor();
     }
     if (!$this->method) {
         $this->method = 'get';
     }
     $processor_arg = false;
     if (isset($this->model_api_processor)) {
         $name = $this->model_api_processor->method;
         $args = $this->model_api_processor->args;
         $api_callback = call_user_func_array(array($this->model(), $name), array($args));
         $this->api_callback = $api_callback;
     }
     if (saloos::is_json_accept()) {
         $this->display = false;
     }
     if (!\lib\router::get_storage('api') && $this->method == 'get' && $this->display) {
         $this->view();
         if (isset($this->view_api_processor)) {
             $name = $this->view_api_processor->method;
             $args = $this->view_api_processor->args;
             if (isset($this->api_callback)) {
                 $args->api_callback = $api_callback;
             }
             call_user_func_array(array($this->view(), $name), array($args));
         }
         if ($this->display) {
             $this->view()->corridor();
         }
     } elseif (router::get_storage('api') || !$this->display) {
         $mycallback = isset($this->api_callback) ? $this->api_callback : null;
         debug::msg('callback', $mycallback);
         $processor_arg = object(array('force_json' => true));
     }
     if ($this->model) {
         $this->model()->_processor($processor_arg);
     }
 }
Example #2
0
 /**
  * [_processor description]
  * @param  boolean $options [description]
  * @return [type]           [description]
  */
 public function _processor($options = false)
 {
     if (is_array($options)) {
         $options = (object) $options;
     }
     $force_json = gettype($options) == 'object' && isset($options->force_json) && $options->force_json ? true : false;
     $force_stop = gettype($options) == 'object' && isset($options->force_stop) && $options->force_stop ? true : false;
     $not_redirect = gettype($options) == 'object' && isset($options->not_redirect) && $options->not_redirect ? true : false;
     if ($not_redirect) {
         $this->controller()->redirector = false;
     }
     if (\saloos::is_json_accept() || $force_json) {
         header('Content-Type: application/json');
         if (isset($this->controller()->redirector) && $this->controller()->redirector) {
             $_SESSION['debug'][md5(strtok($this->redirector()->redirect(true), '?'))] = debug::compile();
             debug::msg("redirect", $this->redirector()->redirect(true));
         }
         echo debug::compile(true);
     } elseif (!\lib\router::get_storage('api') && strtolower($_SERVER['REQUEST_METHOD']) == "post") {
         $this->redirector();
     }
     if (isset($this->controller()->redirector) && $this->controller()->redirector && !\saloos::is_json_accept()) {
         $_SESSION['debug'][md5(strtok($this->redirector()->redirect(true), '?'))] = debug::compile();
         $this->redirector()->redirect();
     }
     if ($force_stop) {
         exit;
     }
 }