Ejemplo n.º 1
0
 protected function _routeModule()
 {
     $vers = Request::get('vers', 'int', false);
     $showRevision = false;
     $pageCode = $this->_request->getPart(0);
     if (!strlen($pageCode)) {
         $pageCode = 'index';
     }
     $pageData = Model::factory('Page')->getCachedItemByField('code', $pageCode);
     if (empty($pageData)) {
         Response::redirect('/');
     }
     $cacheManager = new Cache_Manager();
     $cache = $cacheManager->get('data');
     $blockManager = false;
     if ($vers) {
         $user = User::getInstance();
         if ($user->isAuthorized() && $user->isAdmin()) {
             $pageData = array_merge($pageData, Model::factory('Vc')->getData('page', $pageData['id'], $vers));
             $showRevision = true;
         } else {
             $vers = false;
         }
     }
     if (!$vers && $cache) {
         Blockmanager::setDefaultCache($cache);
     }
     if ($pageData['published'] == false && !$showRevision) {
         Response::redirect('/');
     }
     $page = Page::getInstance();
     foreach ($pageData as $k => $v) {
         $page->{$k} = $v;
     }
     /**
      * Check if controller attached
      */
     if (strlen($page->func_code)) {
         $fModules = Config::factory(Config::File_Array, $this->_appConfig->get('frontend_modules'));
         if ($fModules->offsetExists($page->func_code)) {
             $controllerConfig = $fModules->get($page->func_code);
             $this->runController($controllerConfig['class'], $this->_request->getPart(1));
         }
     }
     if (!$vers && $cache) {
         Blockmanager::setDefaultCache($cache);
     }
     $blockManager = new Blockmanager();
     if ($page->show_blocks) {
         $blockManager->init($page->id, $page->default_blocks, $vers);
     }
     $this->showPage($page, $blockManager);
 }
Ejemplo n.º 2
0
 /**
  * Run backend application
  */
 protected function _runBackend()
 {
     if ($this->_cache) {
         Blockmanager::setDefaultCache($this->_cache);
     }
     /*
      * Prepare objects
      */
     Db_Object_Builder::useForeignKeys($this->_config->get('foreign_keys'));
     /*
      * Inject Externals exper ino Objects Manager
      */
     if ($this->_config->get('allow_externals')) {
         Db_Object_Manager::setExternalsExpert($this->_getExternalsExpert());
     }
     $cfgBackend = Config::factory(Config::File_Array, $this->_config->get('configs') . 'backend.php');
     Registry::set('backend', $cfgBackend, 'config');
     self::$_templates = $this->_config->get('templates') . 'system/' . $cfgBackend->get('theme') . '/';
     $page = Page::getInstance();
     $page->setTemplatesPath(self::$_templates);
     $user = User::getInstance();
     /*
      * Update "Users Online" statistics
      */
     if ($this->_config->get('usersOnline') && $user->isAuthorized()) {
         Model::factory('Online')->addOnline(session_id(), $user->id);
     }
     /*
      * Start routing
      */
     $router = new Backend_Router();
     $router->route();
     $controller = Request::getInstance()->getPart(1);
     /*
      * Define frontent JS variables
      */
     $res = Resource::getInstance();
     $res->addInlineJs('
         app.wwwRoot = "' . $this->_config->get('wwwroot') . '";
     	app.admin = "' . $this->_config->get('wwwroot') . $this->_config->get('adminPath') . '";
     	app.delimiter = "' . $this->_config->get('urlDelimiter') . '";
     	app.root = "' . $this->_config->get('wwwroot') . $this->_config->get('adminPath') . $this->_config->get('urlDelimiter') . $controller . $this->_config->get('urlDelimiter') . '";
     ');
     /*
      * Load template
      */
     $template = new Template();
     $template->disableCache();
     $template->setProperties(array('wwwRoot' => $this->_config->get('wwwroot'), 'page' => $page, 'urlPath' => $controller, 'resource' => $res, 'path' => self::$_templates, 'adminPath' => $this->_config->get('adminPath'), 'development' => $this->_config->get('development'), 'version' => Config::factory(Config::File_Array, $this->_config->get('configs') . 'versions.php')->get('core'), 'lang' => $this->_config->get('language'), 'modules' => Config::factory(Config::File_Array, $this->_config->get('backend_modules')), 'userModules' => $user->getAvailableModules(), 'useCSRFToken' => $cfgBackend->get('use_csrf_token')));
     Response::put($template->render(self::$_templates . 'layout.php'));
 }