예제 #1
0
 public function init()
 {
     /* Initialize action controller here */
     $this->view->headTitle('Setup');
     $this->view->show_navigation = false;
     $this->view->prenavigation_header = "setup/header.phtml";
     $this->view->available_languages = GD_Translate::getAvailableLanguages();
     $setup_session = new Zend_Session_Namespace('gd_setup_session');
     if (!isset($setup_session->language) || $setup_session->language == "") {
         $setup_session->language = "english";
     }
     $this->view->current_language = $setup_session->language;
 }
예제 #2
0
 protected function _initConfig()
 {
     // Default languages
     $use_lang = false;
     if (isset($setup_session->language)) {
         $use_lang = $setup_session->language;
     }
     // Config file
     $cfg_file = APPLICATION_PATH . '/configs/config.ini';
     // Load version
     $version_conf = new Zend_Config_Ini(APPLICATION_PATH . '/configs/version.ini', 'version');
     Zend_Registry::set("gd.version", $version_conf->gd->version);
     // Initialise language to english in case of a "fallback" mode
     // Mainly for using _e and _r if something else fails.
     GD_Translate::init("english");
     // Set default database adapter
     if (file_exists($cfg_file)) {
         $db_conf = new Zend_Config_Ini($cfg_file, 'database');
         $adapter = Zend_Db::factory($db_conf->adapter, $db_conf->toArray());
         Zend_Db_Table::setDefaultAdapter($adapter);
         Zend_Registry::set("db", $db_conf);
         // If we're not on the /error/database page, do a DB test, else
         // we return out to ensure no DB errors later in this Bootstrap fn.
         if (stripos($_SERVER['REQUEST_URI'], '/error/database') === false) {
             // Do a database test to ensure we can run queries on the DB. If not
             // redirect to the error controller in a hacky way.
             try {
                 $adapter->query("SELECT 1");
             } catch (Zend_Db_Adapter_Exception $ex) {
                 header("Location: /error/database");
                 die;
             }
         } else {
             return;
         }
         $lang = GD_Config::get("language");
         if ($lang !== false) {
             $use_lang = $lang;
         }
     }
     if (!$use_lang) {
         $use_lang = "english";
     }
     $translate = GD_Translate::init($use_lang);
 }
예제 #3
0
 /**
  * Load version, database settings and language configurations
  *
  * (non-PHPdoc)
  * @see Zend_Controller_Plugin_Abstract::preDispatch()
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // If a language is in session (from setup), set that first
     // May get overridden later in this file
     $use_lang = false;
     if (isset($setup_session->language)) {
         $use_lang = $setup_session->language;
     }
     // Load version
     $version_conf = new Zend_Config_Ini(APPLICATION_PATH . '/configs/version.ini', 'version');
     Zend_Registry::set("gd.version", $version_conf->gd->version);
     // Set default database adapter
     if (file_exists($this->_config_ini)) {
         $db_conf = new Zend_Config_Ini($this->_config_ini, 'database');
         $adapter = Zend_Db::factory($db_conf->adapter, $db_conf->toArray());
         Zend_Db_Table::setDefaultAdapter($adapter);
         Zend_Registry::set("db", $db_conf);
         // If we're not on the /error/database page, do a DB test, else
         // we return out to ensure no DB errors later in this Bootstrap fn.
         if ($request->controller != "error") {
             try {
                 $adapter->query("SELECT 1");
                 // If we can get the language from the database, use that language
                 $lang = GD_Config::get("language");
                 if ($lang !== false) {
                     $use_lang = $lang;
                 }
             } catch (Exception $ex) {
                 $this->_response->setRedirect('/error/database?e=' . $ex->getCode());
                 $this->_response->sendResponse();
             }
         }
     }
     // If we can't set a language at all, default to english
     if (!$use_lang) {
         $use_lang = "english";
     }
     // Initialise translations now we should have a language to use
     GD_Translate::init($use_lang);
 }
예제 #4
0
 /**
  * Set the current language path from the parameter, or set to default if
  * not specified
  *
  * @param string|null $path
  */
 private static function setLanguagePath($path = null)
 {
     if (!is_null($path)) {
         self::$_languages_path = $path;
     } else {
         self::$_languages_path = APPLICATION_PATH . '/../languages/';
     }
 }