/** * Constructor * */ public function __construct() { parent::__construct(); // Check the database settings if ($this->test_database_config() === FALSE) { redirect(base_url() . 'install/'); die; } $this->load->database(); if (!$this->db->db_select()) { $error =& load_class('Exceptions', 'core'); echo $error->show_error('Database Error', 'Unable to connect to the specified database : ' . $this->db->database, 'error_db'); exit; } // Models $this->load->model(array('base_model', 'settings_model'), '', TRUE); // Helpers $this->load->helper('file'); $this->load->helper('trace'); // Get all the website languages from DB and store them into config file "languages" key $languages = $this->settings_model->get_languages(); Settings::set_languages($languages); // Settings : google analytics string, filemanager, etc. // Each setting is accessible through Settings::get('setting_name'); Settings::set_settings_from_list($this->settings_model->get_settings(), 'name', 'content'); Settings::set_settings_from_list($this->settings_model->get_lang_settings(config_item('detected_lang_code')), 'name', 'content'); if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { Settings::set_all_languages_online(); } // Try to find the installer class : No access if install folder is already there $installer = glob(BASEPATH . '../*/class/installer' . EXT); // If installer class is already here, avoid site access if (!empty($installer)) { // Get languages codes from available languages folder/translation file $languages = $this->settings_model->get_admin_langs(); if (!in_array(config_item('detected_lang_code'), $languages)) { $this->config->set_item('detected_lang_code', config_item('default_admin_lang')); } $this->lang->load('admin', config_item('detected_lang_code')); Theme::set_theme('admin'); // Set the view to output $this->output('system/delete_installer'); // Display the view directly $this->output->_display(); // Don't do anything more die; } }
/** * Returns the Home URL * * @return string * */ public static function get_home_url() { // Set all languages online if connected as editor or more if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { Settings::set_all_languages_online(); } if (count(Settings::get_online_languages()) > 1) { // if the current lang is the default one : don't return the lang code if (Settings::get_lang() != Settings::get_lang('default')) { return base_url() . Settings::get_lang() . '/'; } } return base_url(); }
/** * Returns the base URL of the website, with or without lang code in the URL * */ public static function tag_base_url($tag) { // don't display the lang URL (by default) $lang_url = false; // The lang code in the URL is forced by the tag $force_lang = isset($tag->attr['force_lang']) ? true : false; // Set all languages online if connected as editor or more if (Connect()->is('editors', true)) { Settings::set_all_languages_online(); } if (isset($tag->attr['lang']) && strtolower($tag->attr['lang']) == 'true' or $force_lang === true) { if (count(Settings::get_online_languages()) > 1) { // forces the lang code to be in the URL, for each language // if ($force_lang === true) // { return base_url() . Settings::get_lang() . '/'; // } // More intelligent : Detects if the current lang is the default one and don't return the lang code /* else { if (Settings::get_lang() != Settings::get_lang('default')) { return base_url() . Settings::get_lang() .'/'; } } */ } } return base_url(); }
/** * Constructor * */ public function __construct() { parent::__construct(); // $this->output->enable_profiler(true); // Unlock filtering if admin or editor users is logged in // $this->load->library('connect'); $this->connect = Connect::get_instance(); // Libraries $this->load->library('structure'); $this->load->library('widget'); // FTL parser // require_once APPPATH.'libraries/ftl/parser.php'; // Models // $this->load->model('structure_model', '', true); $this->load->model('menu_model', '', true); // Modules config $this->get_modules_config(); /* * Installed modules * */ require APPPATH . 'config/modules.php'; $installed_modules = $modules; foreach ($installed_modules as $module) { // Path to Module Finder::add_path(MODPATH . $module . '/'); } /* * Theme * */ // Set the current theme Theme::set_theme(Settings::get('theme')); // Theme config file // Overwrite Ionize standard config. if (is_file($file = Theme::get_theme_path() . 'config/config.php')) { include $file; if (!empty($config)) { foreach ($config as $k => $v) { $this->config->set_item($k, $v); } unset($config); } } /* * Menus * */ Settings::set('menus', $this->menu_model->get_list()); /* * Language * */ // Get all the website languages from DB and store them into config file "languages" key $languages = $this->settings_model->get_languages(); // Put all DB languages array to Settings Settings::set_languages($languages); // Set all languages online if conected as editor or more if (Connect()->is('editors', true)) { Settings::set_all_languages_online(); } // Simple languages code array, used to detect if Routers found language is in DB languages $online_lang_codes = array(); foreach (Settings::get_online_languages() as $language) { $online_lang_codes[] = $language['lang']; } // If Router detected that the lang code is not in DB languages, set it to the DB default one if (!in_array(config_item('language_abbr'), $online_lang_codes)) { // Settings::get_lang('default') returns the DB default lang code Settings::set('current_lang', Settings::get_lang('default')); $this->config->set_item('language_abbr', Settings::get_lang('default')); } else { // Store the current lang code (found by Router) to Settings Settings::set('current_lang', config_item('language_abbr')); } // Lang dependant settings for the current language : Meta, etc. Settings::set_settings_from_list($this->settings_model->get_lang_settings(config_item('language_abbr')), 'name', 'content'); /* * Static language * */ $lang_folder = Theme::get_theme_path() . 'language/' . Settings::get_lang() . '/'; $lang_files = array(); // Core languages files : Including except "admin_lang.php" if (is_dir(APPPATH . 'language/' . Settings::get_lang())) { $lang_files = glob(APPPATH . 'language/' . Settings::get_lang() . '/*_lang.php', GLOB_BRACE); foreach ($lang_files as $key => $lang_file) { if ($lang_file == APPPATH . 'language/' . Settings::get_lang() . '/admin_lang.php') { unset($lang_files[$key]); } } } // Theme languages files : Including. Can be empty $lf = glob(FCPATH . Theme::get_theme_path() . 'language/' . Settings::get_lang() . '/*_lang.php'); if (!empty($lf)) { $lang_files = array_merge($lf, (array) $lang_files); } // Modules foreach ($installed_modules as $module) { // Languages files : Including. Can be empty $lang_file = MODPATH . $module . '/language/' . Settings::get_lang() . '/' . strtolower($module) . '_lang.php'; array_push($lang_files, $lang_file); } // Widgets languages translations loading // Now done by the Widget library // Load all modules lang files if (!empty($lang_files)) { foreach ($lang_files as $l) { if (is_file($l) && '.' . end(explode('.', $l)) == EXT) { include $l; if (!empty($lang)) { foreach ($lang as $key => $translation) { // If the term doesn't exists if (!isset($this->lang->language[$key])) { $this->lang->language[$key] = $translation; } else { // Only replace by default (theme vs. module) if the translation is empty if (empty($this->lang->language[$key])) { $this->lang->language[$key] = $translation; } } } unset($lang); } } } } require_once APPPATH . 'libraries/Tagmanager.php'; }
public static function get_base_url() { if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { Settings::set_all_languages_online(); } if (count(Settings::get_online_languages()) > 1) { return base_url() . Settings::get_lang() . '/'; } return base_url(); }
/** * Returns the base URL of the website, with or without lang code in the URL * */ public static function tag_base_url($tag) { // don't display the lang URL (by default) $lang_url = false; // Set all languages online if connected as editor or more if (Connect()->is('editors', true)) { Settings::set_all_languages_online(); } if (isset($tag->attr['lang']) && strtolower($tag->attr['lang']) == 'true') { if (count(Settings::get_online_languages()) > 1) { // if the current lang is the default one : don't return the lang code if (Settings::get_lang() != Settings::get_lang('default')) { return base_url() . Settings::get_lang() . '/'; } } } return base_url(); }