Ejemplo n.º 1
0
 public function init()
 {
     View::set_global('base_url', Config::get('base_url'));
     View::set_global('controller', Request::active()->controller);
     View::set_global('action', Request::active()->action);
     View::set_global('category', Model_Base_Category::get_all(array('where' => array(array('status', '=', 1)))));
     View::set_global('head', View::forge($this->layout . '/global/head'));
     View::set_global('header', View::forge($this->layout . '/global/header'));
     View::set_global('footer', View::forge($this->layout . '/global/footer'));
     View::set_global('script', View::forge($this->layout . '/global/script'));
 }
Ejemplo n.º 2
0
 /**
  * Override the forge method to fix a bug in the $_SERVER['REQUEST_URI'] when using a Proxy
  *
  * @param   string   The URI of the request
  * @param   mixed    Internal: whether to use the routes; external: driver type or array with settings (driver key must be set)
  * @param   string   request method
  * @return  Request  The new request object
  */
 public static function forge($uri = null, $options = true, $method = null)
 {
     $request_scheme = \Arr::get($_SERVER, 'REQUEST_SCHEME', 'http');
     # The REQUEST_URI key is not set when the request is call from the CLI
     if (array_key_exists('REQUEST_URI', $_SERVER)) {
         $request_uri = \Arr::get($_SERVER, 'REQUEST_URI');
         # Apply the patch only if the request_uri start with http
         if (strpos($request_uri, $request_scheme) === 0) {
             $_SERVER['REQUEST_URI'] = str_replace("{$request_scheme}://" . $_SERVER['SERVER_NAME'], '', $request_uri);
         }
     }
     return parent::forge($uri, $options, $method);
 }
Ejemplo n.º 3
0
 public function before()
 {
     $this->controller = Request::active()->controller;
     $this->action = Request::active()->action;
     static::$method = $this->controller . '/' . $this->action;
     $this->data['success'] = false;
     Lang::load('app');
     $this->render_template();
     parent::before();
     $this->set_title();
     $this->set_path();
     $this->init();
 }
Ejemplo n.º 4
0
 private function _check_permission()
 {
     $user_info = \Fuel\Core\Session::get('login_info');
     $group = $user_info['division_type'];
     $controller = \Fuel\Core\Request::active()->controller;
     $action = \Fuel\Core\Request::active()->action;
     if ($group == 1 || $controller == 'Controller_Default') {
         return true;
     }
     $accept_controller = MyAuth::$roles[$group];
     $accept_action = isset($accept_controller[$controller]) ? $accept_controller[$controller] != '*' ? explode(',', $accept_controller[$controller]) : '*' : '';
     if (!isset($accept_controller[$controller]) || !in_array($controller, array_keys($accept_controller)) || $accept_action != '*' && !in_array($action, $accept_action)) {
         return false;
     }
     return true;
 }
Ejemplo n.º 5
0
 public static function get_params()
 {
     return Request::active()->method_params;
 }
Ejemplo n.º 6
0
 /**
  * This executes the request and sets the output to be used later. 
  * Cleaning up our request after executing \Request::execute()
  * 
  * Usage:
  * 
  * <code>$exec = \Hybrid\Request::connect('PUT controller/method?hello=world')->execute();
  * \Debug::dump($exec);</code>
  * 
  * @param   array|null  $method_params  An array of parameters to pass to the method being executed
  * @return  object      containing $data and HTTP Response $status
  * @see     \Request::execute()
  */
 public function execute($method_params = null)
 {
     // Since this just a imitation of curl request, \Hybrid\Input need to know the
     // request method and data available in the connection.
     Input::connect($this->request_method, $this->request_data);
     $execute = parent::execute($method_params);
     // We need to clean-up any request object transfered to \Hybrid\Input so that
     // any following request to \Hybrid\Input will redirected to \Fuel\Core\Input
     Input::disconnect();
     $this->request_method = '';
     $this->request_data = array();
     return $execute;
 }
Ejemplo n.º 7
0
 public static function transaction()
 {
     $request = Request::active();
     Transaction::add($request->route->translation);
 }