Exemplo n.º 1
0
 private function __construct()
 {
     // Get/Set the user's timezone
     Utils::setTimezone();
     parent::setUri();
     //broken for the moment - auto install sql if necessary
     self::checkDB();
     // Check to see if we have a sufficient schema installed
     if (AdaptorMysql::query("SHOW TABLES LIKE '" . BLACKBIRD_TABLE_PREFIX . "info'")) {
         if ($q = AdaptorMysql::queryRow("SELECT * FROM " . BLACKBIRD_TABLE_PREFIX . "info WHERE name = 'schema_version'")) {
             if ($q['value'] < REQUIRED_SCHEMA_VERSION) {
                 die('You have an outdated SQL schema [' . $q['value'] . '], please run the update script for [' . REQUIRED_SCHEMA_VERSION . ']');
             }
         }
     } else {
         die('You have an outdated SQL schema, please run the update script for [' . REQUIRED_SCHEMA_VERSION . ']');
     }
     //custom session
     /*
     if(defined(BLACKBIRD_TABLE_PREFIX . 'SESSION_MANAGER')){
     	require_once(CMS_SESSION_MANAGER);
     }else{
     	require_once(INCLUDES.'SessionManager.class.php');
     }
     */
     self::setConfig();
     //create session
     require_once MODELS . 'UserModel.php';
     self::$session = new UserModel();
     //if we're not in the user controller trying to call login logout processlogin
     if (self::$requestA[0] == 'user' && (self::$requestA[1] == 'login' || self::$requestA[1] == 'logout' || self::$requestA[1] == 'loggedout' || self::$requestA[1] == 'processlogin' || self::$requestA[1] == 'processlogout' || self::$requestA[1] == 'reset' || self::$requestA[1] == 'processreset')) {
     } else {
         self::$session->checkSession();
     }
 }
Exemplo n.º 2
0
 protected static function init()
 {
     parent::init();
     /*
      * Если текущий запрос не ajax
      * Происходит привязка глобальных данных для левого меню
      */
     if (!App::isAjax()) {
         // Привязка списка категорий
         $collection = new Collection('Category', App::currentLang()->getId());
         $collection->where("`active` = 1");
         static::templateGlobal('aside_categories', $collection->items());
         // Привязка списка производителей
         $collection = new Collection('Brand', App::currentLang()->getId());
         $collection->where("`active` = 1");
         static::templateGlobal('aside_brands', $collection->items());
         // Привязка данных для фильтра цен
         static::templateGlobal('filter_price', Database::getRow("\n                SELECT\n                    MIN(`price`) AS `min`,\n                    MAX(`price`) AS `max`\n                FROM `product`\n                WHERE `active` = 1\n            "));
     }
 }
Exemplo n.º 3
0
 public static function dispatch($routes)
 {
     $output = '';
     // Find a matching route
     if ($route = self::findRoute($routes)) {
         self::$route = $route;
         //format the file name of the controller - camel case, append Controlller
         $name = ucfirst($route['controller']) . 'Controller';
         $file = CONTROLLERS . $name . '.php';
         if (file_exists($file) && (require_once $file)) {
             //action
             $action = DEFAULT_ACTION;
             if (isset($route['action'])) {
                 $action = $route['action'];
             }
             $action = ucfirst($action);
             $controller = new $name($route);
             //could force index to always exist by using an interface or abstract class
             //however, this needs to be here to catch human error in a route
             if (method_exists($controller, $action)) {
                 $controller->{$action}();
                 $output .= $controller->render();
                 if (function_exists('plugin__pre_render')) {
                     $output = plugin__pre_render($output);
                 }
                 print $output;
                 if (function_exists('plugin__post_render')) {
                     plugin__post_render($output);
                 }
                 //stop matching
                 return;
             } else {
                 //action doesn't exist
                 //self::$error->code = 404;
                 ErrorHandler::message($action . ' action doesn\'t exist in ' . $name);
             }
         } else {
             //self::$error->code = 404;
             ErrorHandler::message($name . ' controller doesn\'t exist');
         }
     } else {
         //self::$error->code = 404;
         //ErrorHandler::message('Router did not match any controllers');
         ErrorHandler::message('No valid route found!');
     }
 }