/** * The before() method is called before controller action * * @uses Request::param * @uses Theme::set_theme */ public function before() { if ($theme = $this->request->param('theme', FALSE)) { Theme::set_theme($theme); } parent::before(); }
/** * Load the active theme. * * This is called at bootstrap time. * We will only ever have one theme active for any given request. * * @uses Kohana::modules */ public static function load_themes() { $config = Config::load('site'); self::$themes = self::available(FALSE); //set admin theme based on path info $path = ltrim(Request::detect_uri(), '/'); Theme::$is_admin = $path == "admin" || !strncmp($path, "admin/", 6); if (Theme::$is_admin) { // Load the admin theme Theme::$active = $config->get('admin_theme', 'cerber'); } else { // Load the site theme Theme::$active = $config->get('theme', 'cerber'); } //Set mobile theme, if enabled and mobile request if (Request::is_mobile() and $config->get('mobile_theme', FALSE)) { // Load the mobile theme Theme::$active = $config->get('mobile_theme', 'cerber'); } // Admins can override the site theme, temporarily. This lets us preview themes. if (User::is_admin() and isset($_GET['theme']) and $override = Text::plain($_GET['theme'])) { Theme::$active = $override; } //Finally set the active theme Theme::set_theme(); }
private function init() { //load library : email,session //load helper: array('cookie', 'language','url') //load config: ion_auth, 还有语言文件 //权限验证 //$this->load->library(array('ion_auth','form_validation')); //当前请求分组 控制器 方法 $group = substr($this->router->fetch_directory(), 0, -1); //当前分组 $controller = $this->router->fetch_class(); //当前控制器 $this->data['action'] = $this->router->fetch_method(); //当前控制器方法 $this->data['controller'] = $controller . '/'; $this->data['action_url'] = $group . '/' . $controller . '/'; $this->data['action_group'] = $group . '/'; //设置模板 Theme::set_theme('pintuer2'); if (!$this->ion_auth->is_admin() and $this->data['action'] != 'login') { redirect($this->data['action_group'] . 'auth/login'); } $this->load->model(array('base_model', 'setting_model'), '', true); //load config $this->config->load('content_types', 'admin.pagination'); $this->load->helper(array('my', 'html', 'form')); }
/** * Loads the template [View] object. */ public function before() { parent::before(); $this->_model = Model::factory("Codegen"); Theme::set_theme('labyrinth'); $this->title = 'Promo Code Generator'; $this->template->header = View::factory('template/header'); $this->template->header->scripts = array(); $this->template->header->title = $this->title; $this->template->footer = View::factory('template/footer'); $this->limit = $this->request->param('limit', 10); $this->min = $this->_convert_alpha_to_integer('1000'); $this->max = $this->_convert_alpha_to_integer('zzzz'); }
function __construct() { parent::__construct(); $this->load->library('user_agent'); if ($this->agent->is_mobile() or $this->input->get('theme') === 'mobile') { Theme::set_theme('mobile'); } if ($this->data['mobile_state'] === 'yes') { Theme::set_theme('mobile'); } $this->data['noresult'] = '没有内容'; $this->load->library('contentfactory'); //分类 $this->config->load('cache_categories'); $this->cats = $this->config->item('categories'); //类型 $this->types = $this->config->item('types'); }
/** * Constructor * */ public function __construct() { parent::__construct(); $this->load->helper('module_helper'); // Redirect the not authorized user to the login panel. See /application/config/connect.php Connect()->restrict_type_redirect = array('uri' => config_item('admin_url') . '/user/login', 'flash_msg' => 'You have been denied access to %s', 'flash_use_lang' => false, 'flash_var' => 'error'); // $this->output->enable_profiler(true); // PHP standard session is mandatory for FileManager authentication // and other external lib // session_start(); // Librairies $this->connect = Connect::get_instance(); // Current user $this->template['current_user'] = $this->connect->get_current_user(); // Set the admin theme as current theme Theme::set_theme('admin'); /* * Admin languages : Depending on installed translations in /application/languages/ * The Admin translations are only stored in the translation file /application/languages/xx/admin_lang.php * */ // Set admin lang codes array Settings::set('admin_languages', $this->settings_model->get_admin_langs()); Settings::set('displayed_admin_languages', explode(',', Settings::get('displayed_admin_languages'))); // Set Router's found language code as current language Settings::set('current_lang', config_item('language_abbr')); // Load the current language translations file $this->lang->load('admin', Settings::get_lang()); /* * Modules config * */ $this->get_modules_config(); // Including all modules languages files require APPPATH . 'config/modules.php'; $this->modules = $modules; foreach ($this->modules as $module) { $lang_file = MODPATH . $module . '/language/' . Settings::get_lang() . '/' . strtolower($module) . '_lang.php'; if (is_file($lang_file)) { include $lang_file; $this->lang->language = array_merge($this->lang->language, $lang); unset($lang); } } /* * Loads all Module's addons * */ $this->_get_modules_addons(); // Load all modules lang files /* Look how to make Modules translations available in javascript Notice : $yhis->lang object is transmitted to JS through load->view('javascript_lang') if ( ! empty($lang_files)) { foreach($lang_files as $l) { if (is_file($l)) { // $logical_name = substr($l, strripos($l, '/') +1); // $logical_name = str_replace('_lang.php', '', $logical_name); // $this->lang->load($logical_name, Settings::get_lang()); include $l; $this->lang->language = array_merge($this->lang->language, $lang); unset($lang); } } } */ /* * Settings * */ // @TODO : Remove this thing from the global CMS. Not more mandatory, but necessary for compatibility with historical version // Available menus // Each menu was a root node in which you can put several pages, wich are composing a menu. // Was never really implemented in ionize historical version, but already used as : menus[0]... Settings::set('menus', config_item('menus')); // Don't want to cache this content $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate"); $this->output->set_header("Cache-Control: post-check=0, pre-check=0", false); $this->output->set_header("Pragma: no-cache"); }
/** * theme selector * @return [view] */ public function action_license() { $theme = $this->request->param('id', Theme::$theme); // save only changed values if (core::request('license')) { if (Theme::license(core::request('license'), $theme) == TRUE) { //activating a mobile theme if (in_array($theme, array_keys(Theme::get_installed_themes(TRUE)))) { Theme::set_mobile_theme($theme); } else { Theme::set_theme($theme); } Theme::$options = Theme::get_options($theme); Theme::load($theme); Theme::$data['license'] = core::request('license'); Theme::$data['license_date'] = time() + 7 * 24 * 60 * 60; Theme::save($theme); Alert::set(Alert::SUCCESS, __('Theme activated, thanks.')); $this->redirect(Route::url('oc-panel', array('controller' => 'theme', 'action' => 'options'))); } else { Alert::set(Alert::INFO, __('There was an error activating your license.')); } } Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Theme License'))); $this->template->title = __('Theme License'); $this->template->scripts['footer'][] = 'js/oc-panel/license.js'; $this->template->content = View::factory('oc-panel/pages/themes/license', array('theme' => Theme::$theme)); }
/** * Constructor * */ public function __construct() { parent::__construct(); $module_uri = $this->uri->segment(1); // Set Module's config $module_config = Modules()->get_module_config_from_uri($module_uri); foreach ($module_config as $item => $value) { $this->config->set_item($item, $value); } if (!empty($module_config)) { // Languages $online_lang_codes = array(); foreach (Settings::get_online_languages() as $language) { $online_lang_codes[] = $language['lang']; } // If the lang code detected by the Router is not in the DB languages, set it to the DB default one if (!in_array(config_item('detected_lang_code'), $online_lang_codes)) { Settings::set('current_lang', Settings::get_lang('default')); $this->config->set_item('detected_lang_code', Settings::get_lang('default')); } else { // Store the current lang code (found by Router) to Settings Settings::set('current_lang', config_item('detected_lang_code')); } // Set the current theme Theme::set_theme(Settings::get('theme')); // Load Theme Events library if (is_file($file = FCPATH . Theme::get_theme_path() . 'libraries/theme_events.php')) { Event::load_event_library($file); } // Static translations $lang_files = array(); $lang_folder = APPPATH . 'language/' . Settings::get_lang(); // Core languages files : Including except "admin_lang.php" if (is_dir($lang_folder)) { $lang_files = glob($lang_folder . '/*_lang.php', GLOB_BRACE); foreach ($lang_files as $key => $lang_file) { if ($lang_file == $lang_folder . '/admin_lang.php') { unset($lang_files[$key]); } } } // Check if theme lang folder exist $theme_lang_folder = FCPATH . Theme::get_theme_path() . 'language/' . Settings::get_lang() . '/'; if (file_exists($theme_lang_folder)) { // Theme static translations $lf = glob($theme_lang_folder . '*_lang.php'); foreach ($lf as $key => $tlf) { if (basename($tlf) === 'theme_lang.php') { unset($lf[$key]); array_unshift($lf, $tlf); break; } } if (!empty($lf)) { $lang_files = array_merge($lf, (array) $lang_files); } } // Module translation files $lang_file = MODPATH . $module_config['folder'] . '/language/' . Settings::get_lang('current') . '/' . $module_config['key'] . '_lang.php'; if (is_file($lang_file)) { array_push($lang_files, $lang_file); } // Load all 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]) or $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); } } } } } }