/** * Return the Pagination lib config array * * @param FTL_Binding $tag * * @return array * */ public static function get_pagination_config(FTL_Binding $tag) { $pagination_config = array(); // CSS class / id $html_class = $tag->getAttribute('class'); if (!is_null($html_class)) { $html_class = ' class="' . $html_class . '" '; } $html_id = $tag->getAttribute('id'); if (!is_null($html_id)) { $html_id = ' class="' . $html_id . '" '; } $cf = Theme::get_theme_path() . 'config/pagination' . '.php'; if (!is_file($cf)) { $cf = APPPATH . 'config/pagination' . '.php'; } if (is_file($cf)) { $config = array(); require $cf; $pagination_config = $config['pagination']; unset($config); } // Pagination config from tag if (!is_null($ptag = $tag->getAttribute('full_tag'))) { $pagination_config['full_tag_open'] = '<' . $ptag . $html_id . $html_class . '>'; $pagination_config['full_tag_close'] = '</' . $ptag . '>'; } if (!is_null($ptag = $tag->getAttribute('first_tag'))) { $pagination_config['first_tag_open'] = '<' . $ptag . '>'; $pagination_config['first_tag_close'] = '</' . $ptag . '>'; } if (!is_null($ptag = $tag->getAttribute('last_tag'))) { $pagination_config['last_tag_open'] = '<' . $ptag . '>'; $pagination_config['last_tag_close'] = '</' . $ptag . '>'; } if (!is_null($ptag = $tag->getAttribute('cur_tag'))) { $pagination_config['cur_tag_open'] = '<' . $ptag . '>'; $pagination_config['cur_tag_close'] = '</' . $ptag . '>'; } if (!is_null($ptag = $tag->getAttribute('next_tag'))) { $pagination_config['next_tag_open'] = '<' . $ptag . '>'; $pagination_config['next_tag_close'] = '</' . $ptag . '>'; } if (!is_null($ptag = $tag->getAttribute('prev_tag'))) { $pagination_config['prev_tag_open'] = '<' . $ptag . '>'; $pagination_config['prev_tag_close'] = '</' . $ptag . '>'; } if (!is_null($ptag = $tag->getAttribute('num_tag'))) { $pagination_config['num_tag_open'] = '<' . $ptag . '>'; $pagination_config['num_tag_close'] = '</' . $ptag . '>'; } return $pagination_config; }
/** * Load View * * This function is used to load a "view" file. * * @access public * @param string The name of the "view" file to be included * @param array An associative array of data to be extracted for use in the view * @param bool TRUE/FALSE - whether to return the data or load it. In * some cases it's advantageous to be able to return data so that * a developer can process it in some way * @return void */ function View($file, $vars = array(), $return = false) { // Set up the finder to also use the theme folder: array_unshift(Finder::$paths, Theme::get_theme_path()); // Set the path to the requested file $files = Finder::find_file($file, 'views', false); // remove the path we added earlier, so it won't cause any disturbances later: array_shift(Finder::$paths); if (empty($files)) { show_error('Unable to load the requested file: ' . $file); } $view = array_shift($files); $loader = Lib('loader'); return $loader->_ci_load(array('_ci_path' => $view, '_ci_vars' => $loader->_ci_object_to_array($vars), '_ci_return' => $return)); }
/** * Return a JSON object of all translation items and one "Lang" object which gives you access * to the translations through "set" and "get" functions. * * @usage Put this tag in the header / footer of your view : * <ion:jslang [framework="jQuery"] /> * * Mootools example : * * <div id="my_div"></div> * * <script> * var my_text = Lang.get('my_translation_item'); * * $('my_div').set('text', my_text); * </script> * * */ public static function tag_jslang($tag) { // Returned Object name $object = !empty($tag->attr['object']) ? $tag->attr['object'] : 'Lang'; // Files from where load the langs $files = !empty($tag->attr['files']) ? explode(',', $tag->attr['files']) : array(Theme::get_theme()); // JS framework $fm = !empty($tag->attr['framework']) ? $tag->attr['framework'] : 'jQuery'; // Returned language array $translations = array(); // If $files doesn't contains the current theme lang name, add it ! if (!in_array(Theme::get_theme(), $files)) { $files[] = Theme::get_theme(); } if (Settings::get_lang() != '' && !empty($files)) { foreach ($files as $file) { $paths = array(APPPATH . 'language/' . Settings::get_lang() . '/' . $file . '_lang' . EXT, Theme::get_theme_path() . 'language/' . Settings::get_lang() . '/' . $file . '_lang' . EXT); foreach ($paths as $path) { if (is_file($path) && '.' . end(explode('.', $path)) == EXT) { include $path; if (!empty($lang)) { $translations = array_merge($translations, $lang); unset($lang); } } } } } $json = json_encode($translations); $js = "var {$object} = {$json};"; /* $.extend(Lang, { get: function(key) { return this[key]; }, set: function(key, value) { this[key] = value;} }); */ switch ($fm) { case 'jQuery': $js .= "\r\n\t\t\t\t\tLang.get = function (key) { return this[key]; };\r\n\t\t\t\t\tLang.set = function(key, value) { this[key] = value;};\r\n\t\t\t\t"; break; case 'mootools': $js .= "\r\n\t\t\t\t\tLang.get = function (key) { return this[key]; };\r\n\t\t\t\t\tLang.set = function(key, value) { this[key] = value;};\r\n\t\t\t\t"; break; } return '<script type="text/javascript">' . $js . '</script>'; }
/** * Get the view for the asked page * * @param array * * @return bool|String * */ private static function _get_page_view($page) { $article = self::registry('article'); if (!empty($article)) { $view = $page['view_single'] != FALSE ? $page['view_single'] : $page['view']; } else { $view = $page['view']; } $view_path = Theme::get_theme_path() . 'views/' . $view . EXT; // Return the Ionize core view if (!file_exists($view_path) or empty($view)) { $view = Theme::get_default_view('page'); } return $view; }
/** * 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'; }
echo theme_url(); ?> javascript/ionize/ionize_tinymce.js"></script> <script type="text/javascript" src="<?php echo theme_url(); ?> javascript/ionize/ionize_tree_xhr.js"></script> <!-- Mootools Filemanager --> <script type="text/javascript" src="<?php echo theme_url(); ?> javascript/mootools-filemanager/Source/FileManager.js"></script> <?php if (is_file(BASEPATH . '../' . Theme::get_theme_path() . 'javascript/mootools-filemanager/Language/Language.' . Settings::get_lang() . '.js')) { ?> <script type="text/javascript" src="<?php echo theme_url(); ?> javascript/mootools-filemanager/Language/Language.<?php echo Settings::get_lang(); ?> .js"></script> <?php } else { ?> <script type="text/javascript" src="<?php echo theme_url(); ?> javascript/mootools-filemanager/Language/Language.en.js"></script>
/** * Returns the article tag content * To be used inside an "articles" tag * * @param FTL_Binding object * @return */ public static function tag_articles_article($tag) { // View : Overwrite each defined article view by the passed one // It is possible to bypass the Article view by set it to '' $view = isset($tag->attr['view']) ? $tag->attr['view'] : FALSE; // Kind of article : Get only the article linked to the given view $type = isset($tag->attr['type']) ? $tag->attr['type'] : FALSE; // paragraph limit ? $paragraph = isset($tag->attr['paragraph']) ? $tag->attr['paragraph'] : FALSE; if (!empty($tag->locals->article)) { // Current article (set by tag_articles() ) $article =& $tag->locals->article; /* * Article View * If no view : First, try to get the pages defined article_list view * Second, get the pages defined article view * Else, get the default view */ if ($view === FALSE) { // The article defined view $view = $article['view']; // If article has no defined view : view to 0, nothing or FALSE if ($view == FALSE or $view == '') { // First and second step : The page defined views for articles // Need to be discussed... $view = $tag->globals->page['article_view'] ? $tag->globals->page['article_view'] : $tag->globals->page['article_list_view']; } } // Paragraph limiter if ($paragraph !== FALSE) { $article['content'] = tag_limiter($article['content'], 'p', $paragraph); } // View rendering if (empty($view)) { $view = Theme::get_default_view('article'); // Returns the default view ('article') if found in the theme folder if (file_exists(Theme::get_theme_path() . 'views/' . $view . EXT)) { return $tag->parse_as_nested(file_get_contents(Theme::get_theme_path() . 'views/' . $view . EXT)); } return $tag->parse_as_nested(file_get_contents(APPPATH . 'views/' . $view . EXT)); } else { if (!file_exists(Theme::get_theme_path() . 'views/' . $view . EXT)) { return self::show_tag_error($tag->name, '<b>Cannot find view file "' . Theme::get_theme_path() . 'views/' . $view . EXT . '".'); } return $tag->parse_as_nested(file_get_contents(Theme::get_theme_path() . 'views/' . $view . EXT)); } } return self::show_tag_error($tag->name, '<b>This article doesn\'t exists</b>'); }
/** * Mootools FileManager loader * Equiv. to the "manager.php" file in mootools-filemanager Demo folder. * * @param String Event to call. Calls Filemanager->on[$event](). Exemple : The URL /media/filemanager/detail calls Filemanager->onDetail() * @param String The directory to upload. Only used if $event is "upload" * @param Boolean Should the picture be resized ? 1 for yes. * @param String Tokken used to check if the user is connected. * */ function filemanager($event = NULL, $resize = FALSE, $uploadAuthData = FALSE) { // Get allowed mimes $allowed_mimes = implode(',', Settings::get_allowed_mimes()); $params = array('URLpath4FileManagedDirTree' => Settings::get('files_path') . '/', 'URLpath4assets' => Theme::get_theme_path() . 'javascript/mootools-filemanager/Assets', 'URLpath4thumbnails' => Settings::get('files_path') . '/.thumbs', 'upload' => TRUE, 'destroy' => TRUE, 'create' => TRUE, 'move' => TRUE, 'download' => FALSE, 'thumbSmallSize' => Settings::get('media_thumb_size') != '' ? Settings::get('media_thumb_size') : 120, 'thumbBigSize' => 500, 'maxImageDimension' => array('width' => Settings::get('picture_max_width') != '' ? Settings::get('picture_max_width') : 2000, 'height' => Settings::get('picture_max_height') != '' ? Settings::get('picture_max_height') : 2000), 'maxUploadSize' => intval(substr(ini_get('upload_max_filesize'), 0, -1)) * 1024 * 1024, 'filter' => $allowed_mimes); // $this->load->library('Filemanager', $params); $this->load->library('Filemanagerwithaliassupport', $params); // Fires the Event called by FileManager.js // The answer of this called id a JSON object // If no event is givven, it will call the "display" event if ($event != 'upload') { // $this->Filemanager->fireEvent(!is_null($event) ? $event : null); $this->Filemanagerwithaliassupport->fireEvent(!is_null($event) ? $event : null); } else { if ($event == 'upload') { // Flash mode (Multiple files) : PHPSESSID is send if (!empty($_POST['PHPSESSID'])) { $session_data = $this->session->switchSession($_POST['PHPSESSID']); } // Get the original session tokken $tokken = $this->session->userdata('uploadTokken'); // Get the sent tokken & compare $sent_tokken = !empty($_POST['uploadTokken']) ? $_POST['uploadTokken'] : ''; // Only upload if tokkens match if ($tokken == $sent_tokken) { // $this->Filemanager->fireEvent($event); $this->Filemanagerwithaliassupport->fireEvent($event); } else { $this->xhr_output(array('status' => 0, 'error' => lang('ionize_session_expired'))); } } } die; }
echo lang('ionize_help_page_url'); ?> " /> <?php if (!empty($id_page)) { ?> <a href="<?php echo base_url(); echo ${$lang}['url']; ?> " target="_blank" title="<?php echo lang('ionize_label_see_online'); ?> "><img src="<?php echo base_url(); echo Theme::get_theme_path(); ?> images/icon_16_right.png" /></a> <?php } ?> </dd> </dl> <!-- Nav title --> <dl> <dt> <label for="nav_title_<?php echo $lang; ?> " title="<?php
function theme_url() { return base_url() . Theme::get_theme_path(); }
/** * Returns the config settings for one form name * * @param $form_name * * @return null */ protected function _get_form_settings($form_name = NULL) { // Get forms settings $forms = config_item('forms'); if (is_file($file = Theme::get_theme_path() . 'config/forms.php')) { include $file; if (!empty($config['forms'])) { $forms = array_merge($forms, $config['forms']); unset($config); } } if (!is_null($form_name) && isset($forms[$form_name])) { return $forms[$form_name]; } return NULL; }
/** * Returns the config settings for one form name * * @param $form_name * * @return null */ public static function get_form_settings($form_name = NULL) { if (is_null(self::$forms)) { // Get forms settings $forms = config_item('forms'); if (is_file($file = Theme::get_theme_path() . 'config/forms.php')) { include $file; if (!empty($config['forms'])) { $forms = array_merge($forms, $config['forms']); unset($config); } } self::$forms = $forms; } if (!is_null($form_name) && isset(self::$forms[$form_name])) { return self::$forms[$form_name]; } return self::$forms; }
/** * 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); } } } } } }
function theme_path() { return ROOTPATH . Theme::get_theme_path() . 'views/'; }
/** * Find and parses the article view * * @param FTL_Binding * @param array * * @return string * */ private static function find_and_parse_article_view(FTL_Binding $tag, $article) { // Registered page $page = self::registry('page'); // Local articles $articles = $tag->get('articles'); // Try to get the view defined for article $tag_view = $tag->getAttribute('view'); $article_view = !is_null($tag_view) ? $tag_view : (!empty($article['view']) ? $article['view'] : NULL); if (!is_null($article_view)) { // Force first the view defined by the tag if (!is_null($tag_view)) { $article['view'] = $tag_view; } else { if (count($articles) == 1) { $article['view'] = $page['article_view']; } else { $article['view'] = $page['article_list_view']; } } } // Default article view if (empty($article['view'])) { $article['view'] = Theme::get_default_view('article'); } // View path $view_path = Theme::get_theme_path() . 'views/' . $article['view'] . EXT; // Return the Ionize default's theme view if (!file_exists($view_path)) { $view_path = Theme::get_theme_path() . 'views/' . Theme::get_default_view('article') . EXT; if (!file_exists($view_path)) { $view_path = APPPATH . 'views/' . Theme::get_default_view('article') . EXT; } } return $tag->parse_as_nested(file_get_contents($view_path)); }
/** * Renders the widget view * As to be used with the FTL library. * The view isn't directly outputed, but returned. * * @param string View name * @param array Widget data array * * @return string Parsed widget view * */ function render($view, $data = array()) { // Add the widget path to the finder, if it not already in if (!in_array(Theme::get_theme_path() . 'widgets/' . $view . '/', Finder::$paths)) { array_unshift(Finder::$paths, Theme::get_theme_path() . 'widgets/' . $view . '/'); } // Add the widget_path to data array $data['widget_path'] = base_url() . 'themes/' . Settings::get('theme') . '/widgets/' . $view . '/'; return $this->load->view($view, $data, true); }