Exemplo n.º 1
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();
 }
Exemplo n.º 2
0
 /**
  * _setup
  *
  * Set variables used throughout the app here.
  */
 protected function _setup()
 {
     if (Solar_Config::get('Foresmo', 'dev')) {
         xdebug_start_trace('/var/www/foresmo/tmp/trace');
     }
     if (!isset($this->session)) {
         $this->session = Solar::factory('Solar_Session', array('class' => 'Foresmo_App'));
     }
     $adapter = Solar_Config::get('Solar_Sql', 'adapter');
     $adapter = Solar::factory($adapter);
     try {
         $adapter->connect();
     } catch (Exception $e) {
         $this->connect = false;
         // should display an error page and die.
     }
     if ($this->connect) {
         $this->_adapter = $adapter;
         $this->installed = (bool) Solar_Config::get('Foresmo', 'installed');
         if (!$this->installed && $this->_controller != 'install') {
             $this->_redirect('/install');
         }
         $this->web_root = Solar::$system . '/content/';
         $this->_model = Solar_Registry::get('model_catalog');
         $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);
         }
         $results = $this->_model->options->fetchBlogOptions();
         foreach ($results as $result) {
             switch ($result['name']) {
                 case 'blog_theme':
                     $this->blog_theme = $result['value'];
                     break;
                 case 'blog_admin_theme':
                     $this->blog_admin_theme = $result['value'];
                     break;
                 case 'blog_theme_options':
                     $this->blog_theme_options = unserialize($result['value']);
                     break;
                 case 'blog_admin_theme_options':
                     $this->blog_admin_theme_options = unserialize($result['value']);
                     break;
                 case 'blog_title':
                     $this->blog_title = $result['value'];
                     break;
                 case 'blog_posts_per_page':
                     $this->_model->posts->posts_per_page = (int) $result['value'];
                     break;
                 case 'blog_comment_link_limit':
                     $this->_model->comments->link_count_limit = (int) $result['value'];
                     break;
             }
         }
         $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->_layout_default = $this->blog_theme;
         $this->_setToken();
         $this->_modules = Solar::factory('Foresmo_Modules', array('model' => $this->_model));
         $this->enabled_modules_data = $this->_modules->getEnabledModulesData();
         $this->_registerModuleHooks();
     }
 }