public function __construct()
 {
     parent::__construct();
     if (Brightery::SuperInstance()->Config->get('Config.elite_session')) {
         $this->Input->eliteSession();
     }
     // CONFIGURATIONS
     foreach ($this->database->query("SELECT * FROM `settings`")->result() as $setting) {
         if ($setting->key == 'timezone') {
             date_default_timezone_set($setting->value);
         } else {
             Brightery::SuperInstance()->Config->set($setting->key, $setting->value);
         }
     }
     $doc = new ReflectionClass($this);
     $docs = [];
     preg_match_all("/@([a-zA-Z]+) ([a-zA-Z0-9_\\/.\\- ]+)/", $doc->getDocComment(), $res, PREG_SET_ORDER);
     for ($i = 0; $i < count($res); $i++) {
         $docs[$res[$i][1]] = $res[$i][2];
     }
     if (isset($docs['module'])) {
         $this->_module = $docs['module'];
     }
     if (isset($docs['version'])) {
         $this->version = $docs['version'];
     }
     if (isset($docs['interface'])) {
         $this->interface = $docs['interface'];
     }
     if (isset($docs['module'])) {
         $this->_module = $docs['module'];
     }
     if (isset($docs['controller'])) {
         $this->_controller = $docs['controller'];
     }
     Brightery::$RunningModule = $this->_module;
     $this->layoutParams['languages'] = $this->database->query("SELECT * FROM `languages`")->result();
     //        if($user = $this->permissions->getUserInformation())
     //        $this->layoutParams['notifications'] = $this->database->query("SELECT * FROM `notifications` WHERE user_id = '$user->user_id'")->result();
     if (function_exists($this->_module)) {
         $this->_data = call_user_func($this->_module);
     }
     //        if($this->_module == 'commerce'){
     //            $cat_model = new \modules\commerce\models\Commerce_categories();
     //            $this->load->library('cart');
     //            $this->_data = array('categories' => $cat_model->tree(), 'cart' => $this->cart);
     //        }
 }
Exemplo n.º 2
0
 /**
  * DETECT THE CURRENT ROUTE
  */
 public function detect()
 {
     // IT'S NOT THE DEFAULT ROUTE, FIND THE MENTIONED CONTROLLER
     $Route = $this->findController();
     if (!$Route) {
         return Brightery::error404();
     }
     if (preg_match("/" . str_replace(['/', '*'], ['\\' . '/', '([a-zA-Z0-9_-]+)'], $this->controllerPaths->modules) . "/", $Route['path'], $res)) {
         Brightery::$RunningModule = $res[1];
     }
     // MAKE INSTANCE
     require_once $Route['path'];
     $controllerInstance = new $Route['controller']();
     // GET ACTION TO RUN
     $method = isset($this->segments[$Route['method'] + 1]) ? $this->segments[$Route['method'] + 1] . "Action" : 'indexAction';
     if (!method_exists($controllerInstance, $method)) {
         return Brightery::error404();
     }
     // GET PARAMS
     $params = array_slice($this->segments, $Route['method'] + 2, count($this->segments) - 1);
     // RUN
     echo call_user_func_array([$controllerInstance, $method], $params);
     //        exit(200);
 }