Пример #1
0
 /**
  * 
  * Hook for extended setups.
  * 
  * @return void
  * 
  */
 protected function _setup()
 {
     parent::_setup();
     $this->hooks[__FUNCTION__]++;
 }
Пример #2
0
 /**
  * _setup
  *
  * Set variables used throughout the app here.
  */
 protected function _setup()
 {
     parent::_setup();
     $this->web_root = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : Solar::$system . '/docroot/';
     $this->web_root = Solar_Dir::fix($this->web_root);
     if (!isset($this->session)) {
         $this->session = Solar::factory('Solar_Session', array('class' => 'Foresmo_App'));
     }
     // Set CSRF Token
     $this->_setToken();
     $this->csrf_token = $this->_getToken();
     $this->installed = (bool) Solar_Config::get('Foresmo', 'installed');
     if (!$this->installed && $this->_controller != 'install' && $this->_controller != 'ajax') {
         $this->_redirect('/install');
     } elseif (!$this->installed) {
         return;
     }
     $adapter_type = Solar_Config::get('Solar_Sql', 'adapter');
     $adapter = Solar::factory($adapter_type);
     try {
         $adapter->connect();
     } catch (Exception $e) {
         // Display No DB Connection view and exit.
         $this->connect = false;
         $view = Solar::factory('Solar_View', array('template_path' => dirname(__FILE__) . '/Base/View/'));
         $view->assign('adapter_config', Solar_Config::get($adapter_type));
         echo $view->fetch('nodb');
         exit;
     }
     $this->_adapter = $adapter;
     $this->_model = Solar_Registry::get('model_catalog');
     // Set Cache
     $cache_settings = Solar_Config::get('Foresmo', 'cache');
     if (isset($cache_settings['adapter'])) {
         $this->_model->_config['cache'] = $cache_settings;
         $this->_cache = Solar::factory('Solar_Cache', $cache_settings);
     }
     $this->_setBlogOptions();
     $this->page_title = $this->blog_title;
     $time_info = Foresmo::getTimeInfo();
     Foresmo::$date_format = $time_info['blog_date_format'];
     Foresmo::$timezone = $time_info['blog_timezone'];
     $this->_model->posts->published_posts_count = $this->_model->posts->fetchPublishedPostsCount();
     $this->_setPagesCount($this->_model->posts->posts_per_page, $this->_model->posts->published_posts_count);
     //$this->_layout_default = $this->blog_theme;
     // Load Themes
     $this->_themes = Solar::factory('Foresmo_Themes', array('model' => $this->_model));
     // Load Modules
     $this->_modules = Solar::factory('Foresmo_Modules', array('model' => $this->_model));
     $this->_modules->registerModuleHooks();
     $this->enabled_modules = $this->_modules->getEnabledModulesData();
 }