Exemple #1
0
 public function getSettings($module)
 {
     $module = Brightery::SuperInstance()->Database->where('raw_name', $module)->get('modules')->row();
     if (isset($module->settings)) {
         return json_decode($module->settings);
     }
 }
Exemple #2
0
 function get()
 {
     // GLOBAL ASSETS
     $interface =& Brightery::SuperInstance()->Twig->interface;
     foreach ($this->config->get('Autoload.assets.' . $interface . '.js') as $js) {
         if (!isset($js['module'])) {
             $js['module'] = 'global';
         }
         $this->add($js['file'], $js['storage'], $js['module'], 'js', 'autoload');
     }
     foreach ($this->config->get('Autoload.assets.' . $interface . '.css') as $css) {
         if (!isset($css['module'])) {
             $css['module'] = 'global';
         }
         $this->add($css['file'], $css['storage'], $css['module'], 'css', 'autoload');
     }
     $output = null;
     foreach (array_merge($this->autoload_css, $this->css) as $link) {
         $output .= "<link rel=\"stylesheet\" href=\"{$link}\" />\n";
     }
     foreach (array_merge($this->autoload_js, $this->js) as $link) {
         $output .= "<script src=\"{$link}\"></script>\n";
     }
     return $output;
 }
Exemple #3
0
 /**
  * __get magic
  *
  * return super instance's objects
  *
  * @param string $key
  * @return mixed
  */
 public function __get($key)
 {
     $SI =& Brightery::SuperInstance();
     if (isset($SI->{ucfirst($key)})) {
         return $SI->{ucfirst($key)};
     } elseif (isset($this->attributes[$key])) {
         return $this->attributes[$key];
     }
 }
 static function url()
 {
     $url = func_get_args();
     if (is_array($url) && count($url)) {
         $url = implode('/', $url);
     } else {
         $url = null;
     }
     return BASE_URL . Brightery::SuperInstance()->Language->getDefaultLanguage() . "/" . $url;
 }
 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);
     //        }
 }
Exemple #6
0
 /**
  * Handles uncaught PHP exceptions.
  *
  * This method is implemented as a PHP exception handler.
  *
  * @param \Exception $exception the exception that is not caught
  */
 public function handleException($exception)
 {
     if ($exception instanceof ExitException) {
         print_r($exception);
         return;
     }
     // disable error capturing to avoid recursive errors while handling exceptions
     $this->unregister();
     if ($exception instanceof PDOException) {
         $last_query = null;
         if (method_exists(Brightery::SuperInstance()->Database, 'getLastQuery')) {
             $last_query = Brightery::SuperInstance()->Database->getLastQuery();
         }
         Brightery::loadFile([ROOT, 'styles', 'system', 'database_error.php'], false, ['exception' => $exception, 'last_query' => $last_query]);
     } else {
         //            print_r($exception);
         Brightery::loadFile([ROOT, 'styles', 'system', 'exceptions.php'], false, ['exception' => $exception]);
     }
     $this->exception = $exception;
     print_r($exception);
     exit(500);
     //        try {
     //            $this->logException($exception);
     //            if ($this->discardExistingOutput) {
     //                $this->clearOutput();
     //            }
     //            $this->renderException($exception);
     //            if (!YII_ENV_TEST) {
     //                exit(1);
     //            }
     //        } catch (\Exception $e) {
     //            // an other exception could be thrown while displaying the exception
     //            $msg = (string) $e;
     //            $msg .= "\nPrevious exception:\n";
     //            $msg .= (string) $exception;
     //            if (YII_DEBUG) {
     //                if (PHP_SAPI === 'cli') {
     //                    echo $msg . "\n";
     //                } else {
     //                    echo '<pre>' . htmlspecialchars($msg, ENT_QUOTES, Yii::$app->charset) . '</pre>';
     //                }
     //            }
     //            $msg .= "\n\$_SERVER = " . var_dump($_SERVER);
     //            error_log($msg);
     //            exit(1);
     //        }
     $this->exception = null;
 }
Exemple #7
0
 /**
  * START RUNNING THE ROUTE TRIP ...
  */
 public function run()
 {
     if (!($segments = trim($_SERVER['PATH_INFO'] ? $_SERVER['PATH_INFO'] : $_SERVER['ORIG_PATH_INFO'], '/'))) {
         $this->segments = explode('/', trim(Brightery::SuperInstance()->Config->get('Route.default'), '/'));
     } else {
         $this->segments = explode('/', $segments);
     }
     $this->current = implode('/', $this->segments);
     foreach ($this->route as $pattern => $real_route) {
         $pattern = "/^" . str_replace(array_keys($this->replace), array_values($this->replace), $pattern) . "\$/";
         if (preg_match($pattern, $this->current, $match)) {
             $this->segments = explode('/', preg_replace($pattern, $real_route, $this->current));
         }
     }
     return $this->detect();
 }
Exemple #8
0
 function eliteSession()
 {
     $userInfo = Brightery::SuperInstance()->permissions->getUserInformation();
     if ($session_id = $this->cookie('session_id')) {
         if ($row = Brightery::SuperInstance()->Database->query("SELECT * FROM `sessions` WHERE `session_id`='{$session_id}'")->row()) {
             Brightery::SuperInstance()->Database->where('session_id', $session_id)->update("sessions", ['latest_activity' => date('Y-m-d H:i:s'), 'user_id' => $userInfo->user_id]);
             session_id($session_id);
             return $row;
         }
     } else {
         $session_id = session_id();
         $this->cookie('session_id', $session_id);
         Brightery::SuperInstance()->Database->insert('sessions', ['session_id' => $session_id, 'user_id' => $userInfo->user_id, 'ip' => $_SERVER['REMOTE_ADDR'], 'agent' => $_SERVER['HTTP_USER_AGENT'], 'latest_activity' => date('Y-m-d H:i:s')]);
         if ($row = Brightery::SuperInstance()->Database->query("SELECT * FROM `sessions` WHERE `session_id`='{$session_id}' ")->row()) {
             return $row;
         }
     }
 }
 /**
  * RENDER
  */
 public function render($view, $params = [])
 {
     if (isset(Brightery::SuperInstance()->Language)) {
         $params['lang'] =& Brightery::SuperInstance()->Language->phrases;
     }
     // CHECK THE REQUEST TYPE
     if ($this->input->get('api')) {
         // API RESPONSE
         header("Access-Control-Allow-Origin: *");
         header('Content-Type: application/json');
         if (Brightery::SuperInstance()->Validation->errors()) {
             $params['error'] = Brightery::SuperInstance()->Validation->errors_array();
         }
         return json_encode($params);
     } else {
         $params['config'] =& Brightery::SuperInstance()->Config;
         $params['input'] =& Brightery::SuperInstance()->input;
         $params['helper'] =& Brightery::SuperInstance()->Helper;
         if (Brightery::SuperInstance()->Validation->errors()) {
             $params['error'] = Brightery::SuperInstance()->Validation->errors();
         }
         $params['debug'] = new tdebug();
         // NORMAL RESPONSE
         if ($this->interface) {
             $this->Twig->interface = $this->interface;
         }
         if ($this->layout) {
             $this->Twig->layout = $this->layout;
         }
         if ($this->Menu) {
             $params[$this->interface . '_menu'] = $this->Menu->getMenu($this->interface);
         }
         if ($this->_data) {
             $params['_data'] = $this->_data;
         }
         Brightery::$load->getInstance('Style');
         $params['assets'] = $this->Assets;
         $this->Twig->layoutParams = $this->layoutParams;
         return $this->Twig->render($view, $params);
     }
 }
Exemple #10
0
 /**
  * Render
  * @param string $template
  * @param array $params
  * @return mixed
  */
 public function render($template, $params = [])
 {
     if (!$this->twig) {
         $this->stylePath = STYLES . '/' . $this->interface . '/' . $this->styleName . '/';
         $this->moduleStylePath = APPLICATION . '/' . 'modules' . '/' . Brightery::$RunningModule . '/' . 'views' . '/' . $this->interface . '/';
         $viewPath[] = ROOT;
         // CHECK IF THERE'S A MAIN TEMPLATE
         if ($base = file_exists($this->stylePath . $template . '.twig')) {
             $viewPath[] = $this->stylePath;
         }
         if ($modules = file_exists($this->moduleStylePath . $template . '.twig')) {
             $viewPath[] = $this->moduleStylePath;
         }
         if (!$modules && !$base) {
             Brightery::error_message("The view file " . $template . " doesn't exist.");
         }
         $loader = new Twig_Loader_Filesystem($viewPath);
         $this->twig = new Twig_Environment($loader, ['autoescape' => false]);
         $this->twig->addExtension(new Twig_Extension_Text());
         $this->twig->addExtension(new Twig_Extension_Debug());
         $this->twig->addFilter(new Twig_SimpleFilter('cast_to_array', function ($stdClassObject) {
             $response = [];
             foreach ($stdClassObject as $key => $value) {
                 $response[$key] = $value;
             }
             return $response;
         }));
         $this->twig->addFilter(new Twig_SimpleFilter('debug', function ($stdClassObject) {
             print_r($stdClassObject);
         }));
     }
     $params['this'] = Brightery::SuperInstance();
     $params = array_merge($params, $this->layoutParams);
     $layout = $this->twig->render('styles/' . $this->interface . '/' . $this->styleName . '/layout/' . $this->layout . '.twig', $params);
     return str_replace("{layout}", $this->twig->render($template . '.twig', $params), $layout);
 }
 function __construct($controller)
 {
     $this->controller = $controller;
     $this->db = Brightery::SuperInstance()->Database;
 }
Exemple #12
0
 public function __construct()
 {
     foreach (Brightery::SuperInstance()->Database->query("SELECT `key`, `value` FROM settings")->result() as $setting) {
         Brightery::SuperInstance()->Config->set($setting->key, $setting->value);
     }
 }
Exemple #13
0
 private function _file($str, $config = null)
 {
     if (!isset($config['required']) || $config['required'] == FALSE) {
         if (!isset($_FILES[$str]) || $_FILES[$str]['error'] !== 0) {
             return true;
         }
     }
     $this->upload =& Brightery::SuperInstance()->upload;
     $this->upload->initialize($config);
     if ($this->upload->do_upload($str)) {
         $this->model->{$str . '_result'} = $this->upload->data();
         $this->model->{$str} = $this->upload->data('file_name');
         return true;
     } else {
         return false;
     }
 }
Exemple #14
0
 private function getTitle($str)
 {
     $res = Brightery::SuperInstance()->Language->phrase('menu_' . $str);
     return $res !== 'menu_' . $str ? $res : $str;
 }
Exemple #15
0
 public function getMacAddress()
 {
     return Brightery::SuperInstance()->license->_get_mac_address();
 }
 function __construct()
 {
     $this->db = Brightery::SuperInstance()->Database;
 }
 public static function fullqueryToDropdown($query, $key, $value, $selectFromMenuText = null)
 {
     $menu = Brightery::SuperInstance()->Database->query($query)->result();
     $resultMenu = [];
     if ($selectFromMenuText !== NULL) {
         $resultMenu[''] = Brightery::SuperInstance()->Language->phrase('select_from_menu');
     }
     foreach ($menu as $mItem) {
         $resultMenu[$mItem->{$key}] = $mItem->{$value};
     }
     return $resultMenu;
 }
Exemple #18
0
 /**
  * List of Mime Types
  *
  * This is a list of mime types.  We use it to validate
  * the "allowed types" set by the developer
  *
  * @param    string
  * @return    string
  */
 public function mimes_types($mime)
 {
     global $mimes;
     if (count($this->mimes) == 0) {
         $this->mimes = Brightery::SuperInstance()->config->get('Mimes');
     }
     return !isset($this->mimes[$mime]) ? FALSE : $this->mimes[$mime];
 }
Exemple #19
0
 public function getItemsCount()
 {
     return Brightery::SuperInstance()->Database->select('count(*) as count')->where('session_id', $this->session_id)->join('commerce_products', 'commerce_cart.commerce_product_id = commerce_products.commerce_product_id', 'inner')->get('commerce_cart')->row()->count;
 }
 public function __construct()
 {
     $this->db =& Brightery::SuperInstance()->Database;
     $this->input =& Brightery::SuperInstance()->Input;
 }
Exemple #21
0
function commerce()
{
    $cat_model = new \modules\commerce\models\Commerce_categories();
    Brightery::SuperInstance()->load->library('cart');
    return ['categories' => $cat_model->tree(), 'cart' => Brightery::SuperInstance()->cart];
}
Exemple #22
0
 public function __construct()
 {
     Log::set("Initialize Pagination Class");
     $this->config = array_merge($this->config, Brightery::SuperInstance()->Config->get('Pagination'));
 }
Exemple #23
0
 public function __construct()
 {
     Log::set('Initialize Style class');
     $this->instance =& Brightery::SuperInstance();
     $this->initialize();
 }