Example #1
0
 /**
  * Index
  *
  * @access	public
  * @return	parsed view
  */
 function index($lang = FALSE)
 {
     if ($lang == FALSE) {
         $lang = Settings::get_lang('default');
     }
     return $this->feed($lang);
 }
Example #2
0
 /**
  * Displays the form
  * Inherits from TagManager_Form the form displaying methods
  * so the view can be slightly the same than the one used for one classical form
  *
  * @param FTL_Binding $tag
  *
  * @return string
  */
 public static function tag_form(FTL_Binding $tag)
 {
     $ajax = $tag->getAttribute('ajax');
     // Ajax form
     if ($ajax == TRUE) {
         // Get form string
         $str = parent::tag_form($tag);
         // No JS  The user will add the JS part in his own JS script
         $nojs = $tag->getAttribute('nojs');
         $form_name = $tag->getAttribute('name');
         $form_submit_id = $tag->getAttribute('submit');
         // $error_tag = $tag->getAttribute('error_tag');
         // $error_tag_class = $tag->getAttribute('error_tag_class');
         // Module settings
         self::$config = Modules()->get_module_config('Ajaxform');
         if (!$nojs) {
             // Add the JS part of the module
             if ($form_name && $form_submit_id) {
                 $data = array('form_name' => $form_name, 'form_submit_id' => $form_submit_id, 'url' => base_url() . Settings::get_lang() . '/' . self::$config['uri'] . '/post');
                 $str .= self::$ci->load->view('ajaxform_js', $data, TRUE);
             } else {
                 log_message('error', 'Ajaxform ERROR : Set the name & submit attributes of the <ion:form name="formName" submit="submitButtonID"> tag');
             }
         }
         return $str;
     } else {
         return parent::tag_form($tag);
     }
 }
Example #3
0
 /**
  * Get all the article_lang data + the page URL of the current language (page_url in the output array)
  *
  * @param	string	String to search
  * @return	array	Array of articles
  *
  */
 function get_articles($realm)
 {
     $realm = '\'%' . $realm . '%\'';
     $this->set_table('article');
     $this->set_lang_table('article_lang');
     $this->set_pk_name('id_article');
     $lang = Settings::get_lang();
     // Page_Article table
     $this->{$this->db_group}->select($this->parent_table . '.*', FALSE);
     $this->{$this->db_group}->join($this->parent_table, $this->parent_table . '.id_article = ' . $this->table . '.id_article', 'left');
     // Page table
     $this->{$this->db_group}->select('page.online');
     $this->{$this->db_group}->join($this->page_table, $this->page_table . '.id_page = ' . $this->parent_table . '.id_page', 'left');
     // Page lang table
     $this->{$this->db_group}->select('page_lang.lang');
     $this->{$this->db_group}->join($this->page_lang_table, $this->page_lang_table . '.id_page = ' . $this->page_table . '.id_page', 'left');
     // Menu table
     $this->{$this->db_group}->select('menu.id_menu, menu.name as menu_name');
     $this->{$this->db_group}->join($this->menu_table, $this->menu_table . '.id_menu = ' . $this->page_table . '.id_menu', 'left');
     // URL table : For Article's URL building
     $this->{$this->db_group}->select('url.path');
     $this->{$this->db_group}->join($this->url_table, $this->url_table . '.id_entity = ' . $this->table . '.id_article' . ' AND ' . $this->url_table . '.active=1 ' . ' AND ' . $this->url_table . '.lang = \'' . $lang . '\'', 'left');
     // Published filter
     $this->filter_on_published(self::$publish_filter, $lang);
     // Add the 'date' field to the query
     $this->{$this->db_group}->select('IF(article.logical_date !=0, article.logical_date, IF(article.publish_on !=0, article.publish_on, article.created )) AS date');
     // Search where
     $this->{$this->db_group}->where('(' . ' article_lang.title LIKE ' . $realm . ' OR article_lang.subtitle LIKE ' . $realm . ' OR article_lang.content LIKE ' . $realm . ')');
     $where = array("page.online" => 1, "article.indexed" => 1, "page_article.online" => 1, "page_article.main_parent" => 1, "article_lang.online" => 1, "article_lang.lang" => $lang, "page_lang.lang" => $lang);
     // Base_model->get_lang_list()
     $articles = parent::get_lang_list($where, $lang);
     return $articles;
 }
 /**
  * Saves a new language
  *
  */
 function save()
 {
     if ($this->input->post('lang_new') != "" && $this->input->post('name_new') != "") {
         // Basic lang data
         $data = array('lang' => $this->input->post('lang_new'), 'name' => $this->input->post('name_new'), 'online' => $this->input->post('online_new'));
         // Ordering : New lang at last position
         $this->db->select_max('ordering', 'ordering');
         $query = $this->db->get('lang');
         if ($query->num_rows() > 0) {
             $row = $query->row();
             $data['ordering'] = $row->ordering + 1;
         }
         // Save to DB
         if ($this->lang_model->exists(array('lang' => $this->input->post('lang_new')))) {
             $this->lang_model->update($this->input->post('lang_new'), $data);
         } else {
             $this->lang_model->insert($data);
             /* Insert in lang tables (page_lang, article_lang) the basic lang data for this new created lang
              * see lang_model->insert_lang_data() for more info.
              */
             $this->lang_model->insert_lang_data(array('page', 'article'), $fields = array('url'), $from = Settings::get_lang('default'), $to = $this->input->post('lang_new'));
         }
         // Update the language config file
         if (false == $this->_update_config_file()) {
             $this->error(lang('ionize_message_lang_file_not_saved'));
         }
         // UI panel to update after saving
         $this->update[] = array('element' => 'mainPanel', 'url' => admin_url() . 'lang');
         // Answer send
         $this->success(lang('ionize_message_lang_saved'));
     } else {
         $this->error(lang('ionize_message_lang_not_saved'));
     }
 }
 /**
  * Returns the array of all definitions which have element defined for the given parent
  *
  * @param      $parent
  * @param bool $id_parent
  *
  * @return array
  */
 function get_definitions_from_parent($parent, $id_parent = FALSE)
 {
     // Loads the element model if it isn't loaded
     if (!isset(self::$ci->element_model)) {
         self::$ci->load->model('element_model');
     }
     // Get definitions
     $definitions = $this->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default'));
     // Get Elements
     $where = array('parent' => $parent, 'order_by' => 'element.ordering ASC');
     if ($id_parent !== FALSE) {
         $where['id_parent'] = $id_parent;
     }
     $elements = self::$ci->element_model->get_elements($where);
     // Add elements to definition
     foreach ($definitions as $key => $definition) {
         $found = FALSE;
         foreach ($elements as $element) {
             // The element match a definition
             if ($element['id_element_definition'] == $definition['id_element_definition']) {
                 $found = TRUE;
             }
         }
         if ($found == FALSE) {
             unset($definitions[$key]);
         }
     }
     return $definitions;
 }
Example #6
0
 /**
  * Loads a module controller
  * Receives the module name and proccess the URI
  *
  *
  *
  */
 function _remap($module_name)
 {
     // Delete the segments before the module name
     $mod_uri = array_slice($this->uri->segments, 3);
     // Get the controller, the called func name and the args
     $module_controller = $mod_uri[0];
     $module_func = 'index';
     if (isset($mod_uri[1])) {
         $module_func = $mod_uri[1];
     }
     $module_args = array_slice($mod_uri, 2);
     // Module path
     $module_path = MODPATH . ucfirst($module_name) . '/';
     // Add the module path to the finder
     array_unshift(Finder::$paths, $module_path);
     // Includes the module Class file
     if (!class_exists($module_controller) && file_exists($module_path . 'controllers/admin/' . $module_controller . EXT)) {
         include $module_path . 'controllers/admin/' . $module_controller . EXT;
     } else {
         echo 'Class <b>' . ucfirst($module_controller) . '</b> not found in :<br/><b>' . $module_path . 'controllers/admin/</b>';
         die;
     }
     // Create an instance of the module controller
     $obj = new $module_controller($this);
     // Loads module language file, if exists
     //		if (is_file($module_path.'language/'.$this->config->item('default_lang_code').'/'.$module_name.'_lang.php'))
     //		{
     $this->lang->load($module_name, Settings::get_lang('current'));
     //		}
     //		else
     //		{
     //			trace('warning: no language file for this module in : '. $module_path.'language/'.$this->config->item('default_lang_code').'/');
     //		}
     call_user_func_array(array($obj, $module_func), $module_args);
 }
Example #7
0
 /**
  * Returns enhanced media list
  *
  * @param null  $where
  * @param array $filters
  * @param bool  $addon_data
  *
  * @return array
  */
 public function get_list($where = NULL, $filters = array(), $addon_data = TRUE)
 {
     // Pages
     $this->{$this->db_group}->select("group_concat(url.path separator ';') as page_paths");
     $this->{$this->db_group}->join('page_media', 'page_media.id_media = ' . $this->table . '.id_media', 'left');
     $this->{$this->db_group}->join('url', "url.id_entity = page_media.id_page AND url.type='page' and url.active=1 and url.lang='" . Settings::get_lang('default') . "'", 'left');
     // Articles
     $this->{$this->db_group}->select("group_concat(url2.path separator ';') as article_paths");
     $this->{$this->db_group}->join('article_media', 'article_media.id_media = ' . $this->table . '.id_media', 'left');
     $this->{$this->db_group}->join('url as url2', "url2.id_entity = article_media.id_article AND url2.type='article' and url2.active=1 and url2.lang='" . Settings::get_lang('default') . "'", 'left');
     // Filters
     if (in_array('alt_missing', $filters)) {
         $this->{$this->db_group}->join('media_lang', 'media_lang.id_media = ' . $this->table . '.id_media', 'left');
         $this->{$this->db_group}->where("(media_lang.alt is null or media_lang.alt='')");
     }
     if (in_array('used', $filters)) {
         $this->{$this->db_group}->where('(url.path is not null or url2.path is not null)');
     }
     if (in_array('not_used', $filters)) {
         $this->{$this->db_group}->where('(url.path is null and url2.path is null)');
     }
     $this->{$this->db_group}->group_by($this->table . '.id_media');
     $this->{$this->db_group}->order_by($this->table . '.id_media', 'DESC');
     $result = parent::get_list($where, $this->table);
     if ($addon_data) {
         $result = $this->_add_lang_data_to_media_list($result);
     }
     return $result;
 }
Example #8
0
 /**
  * Run one widget
  *
  * @param	string	Widget name
  *
  * @return	mixed	Call of the widget "run" method
  *
  */
 function run($name)
 {
     $ci =& get_instance();
     // Get widget args
     $args = func_get_args();
     // Depending on call (direct or from FTL), define args
     if (isset($args[1])) {
         if (is_array($args[1])) {
             $args = $args[1];
         } else {
             array_shift($args);
         }
     }
     // Get the widget class
     require_once APPPATH . '../themes/' . Settings::get('theme') . '/widgets/' . $name . '/' . $name . EXT;
     // Create a new instance of the widget class
     $class_name = ucfirst($name);
     $widget = new $class_name();
     // Loads the widget Languages translation files
     $lang_files = glob(Theme::get_theme_path() . 'widgets/' . $name . '/language/' . Settings::get_lang() . '/*');
     if (!empty($lang_files)) {
         foreach ($lang_files as $lang_file) {
             // Widget language file is optional, so only include if it exists
             if (is_file($lang_file)) {
                 // Include widget language file
                 include $lang_file;
                 // Merge to the Lang array
                 $ci->lang->language = array_merge($ci->lang->language, $lang);
                 unset($lang);
             }
         }
     }
     // Call the widget "run" method
     return call_user_func_array(array(&$widget, 'run'), $args);
 }
Example #9
0
 function admin_url($lang_segment = FALSE)
 {
     $CI =& get_instance();
     if ($lang_segment == TRUE) {
         return base_url() . Settings::get_lang('current') . '/' . $CI->config->slash_item('admin_url');
     }
     return base_url() . $CI->config->slash_item('admin_url');
 }
 /**
  * Get all the article_lang data + the page URL of the current language (page_url in the output array)
  *
  * @param	string	String to search
  * @return	array	Array of articles
  *
  */
 function get_articles($realm)
 {
     $realm = '%' . $realm . '%';
     $sql = "\tSELECT \tarticle_lang.title, article_lang.content, article_lang.url,\r\n\t\t\t\t\t\t\tIF(article.logical_date !=0, article.logical_date, IF(article.publish_on !=0, article.publish_on, article.created )) AS date,\r\n\t\t\t\t\t\t\tpage_lang.url as page_url, \r\n\t\t\t\t\t\t\tpage_lang.title as page_title \r\n\t\t\t\t\tFROM (article)\r\n\t\t\t\t\t\tJOIN article_lang ON article.id_article = article_lang.id_article\r\n\t\t\t\t\t\tJOIN page_article ON article.id_article = page_article.id_article\r\n\t\t\t\t\t\tJOIN page ON page.id_page = page_article.id_page\r\n\t\t\t\t\t\tJOIN page_lang ON page_lang.id_page = page.id_page\r\n\t\t\t\t\tWHERE \r\n\t\t\t\t\t\tpage.online = 1\r\n\t\t\t\t\t\tAND article.indexed = 1\r\n\t\t\t\t\t\tAND page_article.online = 1\r\n\t\t\t\t\t\tAND page_article.main_parent = 1\r\n\t\t\t\t\t\tAND article_lang.online = 1\r\n\t\t\t\t\t\tAND article_lang.lang = ?\r\n\t\t\t\t\t\tAND page_lang.lang = ?\r\n\t\t\t\t\t\tAND (\r\n\t\t\t\t\t\t\tarticle_lang.title LIKE ?\r\n\t\t\t\t\t\t\tOR article_lang.subtitle LIKE ?\r\n\t\t\t\t\t\t\tOR article_lang.summary LIKE ?\r\n\t\t\t\t\t\t\tOR article_lang.content LIKE ?\r\n\t\t\t\t\t\t)\r\n\t\t";
     // Current language
     $lang = Settings::get_lang();
     $query = $this->db->query($sql, array($lang, $lang, $realm, $realm, $realm, $realm));
     return $query->result_array();
 }
Example #11
0
 function create()
 {
     $id_element_definition = $this->input->post('id_element_definition');
     $this->extend_field_model->feed_blank_template($this->template);
     $this->extend_field_model->feed_blank_lang_template($this->template, Settings::get_lang('default'));
     // Get the parent element
     $element = $this->element_definition_model->get(array('id_element_definition' => $id_element_definition));
     $this->template['element'] = $element;
     $this->template['id_parent'] = $id_element_definition;
     $this->output('element/field');
 }
Example #12
0
 public function get_element_fields($id_ui_element)
 {
     $extends = array();
     self::$ci->load->model('extend_field_model');
     $sql = "\r\n\t\t\tselect\r\n\t\t\t\tuie.*,\r\n\t\t\t\tef.*,\r\n\t\t\t\tefl.label,\r\n\t\t\t\teft.*\r\n\t\t\tfrom " . self::$_TBL_LK_EXTEND . " uie\r\n\t\t\tinner join extend_field ef on ef.id_extend_field = uie.id_extend\r\n\t\t\tinner join extend_field_lang efl on efl.id_extend_field = ef.id_extend_field and efl.lang='" . Settings::get_lang('default') . "'\r\n\t\t\tinner join extend_field_type eft on eft.id_extend_field_type = ef.type\r\n\t\t\twhere uie.id_ui_element = " . $id_ui_element . "\r\n\t\t\torder by uie.ordering ASC\r\n\t\t";
     $query = $this->{$this->db_group}->query($sql);
     if ($query->num_rows() > 0) {
         $extends = $query->result_array();
     }
     return $extends;
 }
Example #13
0
 public function get_linked_author($parent, $id_parent)
 {
     // Returned data
     $data = array();
     // Conditions
     $where = array('parent' => $parent, 'id_parent' => $id_parent, $this->_author_lang_table . '.lang' => Settings::get_lang('default'));
     $query = $this->{$this->db_group}->where($where)->order_by('ordering ASC')->join($this->_author_table, $this->_author_table . '.id_author = ' . $this->_link_table . '.id_author', 'left')->join($this->_author_lang_table, $this->_author_lang_table . '.id_author = ' . $this->_author_table . '.id_author', 'left')->get($this->_link_table);
     if ($query->num_rows() > 0) {
         $data = $query->result_array();
     }
     return $data;
 }
Example #14
0
    /**
     * Get Extend Fields linked to one UI Element (one tab for example)
     *
     * @param $id_ui_element
     *
     * @return array
     */
    public function get_element_fields($id_ui_element)
    {
        $extends = array();
        self::$ci->load->model('extend_field_model');
        $sql = "\r\n\t\t\tSELECT\r\n\t\t\t\tuie.*,\r\n\t\t\t\tef.*,\r\n\t\t\t\tefl.label,\r\n\t\t\t\teft.*\r\n\t\t\tFROM " . self::$_TBL_LK_EXTEND . " uie\r\n\t\t\tINNER JOIN extend_field ef ON ef.id_extend_field = uie.id_extend\r\n\t\t\tINNER JOIN extend_field_lang efl ON efl.id_extend_field = ef.id_extend_field AND efl.lang='" . Settings::get_lang('default') . "'\r\n\t\t\tINNER JOIN extend_field_type eft ON eft.id_extend_field_type = ef.type\r\n\t\t\tWHERE uie.id_ui_element = " . $id_ui_element . '
			ORDER BY uie.ordering ASC
		';
        $query = $this->{$this->db_group}->query($sql);
        if ($query->num_rows() > 0) {
            $extends = $query->result_array();
        }
        return $extends;
    }
Example #15
0
 /**
  * Edit one item field
  *
  */
 function edit()
 {
     $id_item_definition = $this->input->post('id_item_definition');
     $id_extend_field = $this->input->post('id_extend_field');
     $this->extend_field_model->feed_template($id_extend_field, $this->template);
     $this->extend_field_model->feed_lang_template($id_extend_field, $this->template);
     // Get the parent element
     $item = $this->item_definition_model->get(array('id_item_definition' => $this->template['id_parent']), Settings::get_lang('default'));
     // Pass the parent informations to the template
     $this->template['item'] = $item;
     $this->template['id_item_definition'] = $id_item_definition;
     $this->output('item/definition/field');
 }
Example #16
0
 function get_label($id_extend_field)
 {
     if ($id_extend_field != '') {
         $this->db->select($this->lang_table . '.label');
         $this->db->from($this->table);
         $this->db->join($this->lang_table, $this->table . '.' . $this->pk_name . ' = ' . $this->lang_table . '.' . $this->pk_name, 'inner');
         $this->db->where($this->lang_table . '.lang', Settings::get_lang());
         $this->db->where($this->table . '.' . $this->pk_name, $id_extend_field);
         $label = $this->db->get();
         $label = $label->row_array();
         return !empty($label['label']) ? $label['label'] : '';
     }
     return 'Need a "$id_extend_field"';
 }
 /**
  * Shows standard settings
  *
  */
 function index()
 {
     // All terms
     $this->template['terms'] = $terms = array();
     // Get terms from views files
     $theme_terms = $this->_get_terms_from_theme();
     // Get translated items from theme languages files
     $theme_translations = $this->_get_theme_translations();
     // Get terms form installed modules
     $modules_terms = $this->_get_terms_from_modules();
     // Get translations for installed languages
     $module_translations = $this->_get_modules_translations();
     // Get, for each module, the lang codes for which a default translation file exists
     $module_translation_files = $this->_get_modules_translation_files();
     if (!empty($theme_terms['term'])) {
         $terms = array_fill_keys($theme_terms['term'], '');
     }
     // Add terms from lang file to the terms in views
     if (!empty($theme_translations[Settings::get_lang('default')])) {
         // Simple array of all terms
         $terms = array_keys(array_merge($terms, $theme_translations[Settings::get_lang('default')]));
     } else {
         $terms = array_keys($terms);
     }
     // Natural case sorted
     natcasesort($terms);
     if (!empty($terms)) {
         foreach (Settings::get_languages() as $language) {
             $lang = $language['lang'];
             // Merge
             if (!empty($theme_translations[$lang])) {
                 $theme_translations[$lang] = array_merge($terms, $theme_translations[$lang]);
             }
             foreach ($terms as $term) {
                 if (!empty($theme_translations[$lang][$term])) {
                     $theme_translations[$lang][$term] = stripslashes($theme_translations[$lang][$term]);
                 } else {
                     $theme_translations[$lang][$term] = '';
                 }
             }
         }
     }
     $this->template['terms'] = $terms;
     $this->template['theme_terms'] = $theme_terms;
     $this->template['theme_translations'] = $theme_translations;
     $this->template['modules_terms'] = $modules_terms;
     $this->template['module_translations'] = $module_translations;
     $this->template['module_translation_files'] = $module_translation_files;
     $this->output('translation');
 }
Example #18
0
 public function get_countries()
 {
     $results = array();
     $this->db->select('cl.*, c.default');
     $this->db->from('country_lang cl');
     $this->db->where('cl.lang', Settings::get_lang());
     $this->db->where('c.num <>', '0');
     $this->db->join('country c', 'c.id_country = cl.id_country', 'left');
     $this->db->order_by('c.default', 'desc');
     $this->db->order_by('cl.country_name', 'asc');
     $query = $this->db->get();
     if ($query->num_rows() > 0) {
         $results = $query->result_array();
     }
     return $results;
 }
Example #19
0
 public function get_urls()
 {
     $get_all_lang = FALSE;
     $langs = Settings::get_online_languages();
     if (Settings::get('force_lang_urls') or count($langs) > 1) {
         $get_all_lang = TRUE;
     }
     $sql = "\r\n\t\t\tselect\r\n\t\t\t\tu.lang,\r\n\t\t\t\tu.path,\r\n\t\t\t\tp.priority,\r\n\t\t\t\tp.created,\r\n\t\t\t\tp.updated,\r\n\t\t\t\tp.publish_on,\r\n\t\t\t\tp.publish_off,\r\n\t\t\t\tp.logical_date\r\n\t\t\tfrom url u\r\n\t\t\tinner join page p on p.id_page = u.id_entity and p.has_url = 1\r\n\t\t\twhere\r\n\t\t\t\tu.type = 'page'\r\n\t\t\t\tand u.active = 1\r\n\t\t\t\tand u.canonical = 1\r\n\t\t\t\tand p.priority > 0\r\n\t\t\t\tand (p.publish_off = '0000-00-00 00:00:00' OR p.publish_off > now())\r\n\t\t";
     if (!$get_all_lang) {
         $sql .= "\r\n\t\t\t\tand u.lang='" . Settings::get_lang('default') . "'\r\n\t\t\t";
     }
     $sql .= "\r\n\t\t\tunion\r\n\r\n\t\t\tselect\r\n\t\t\t\tu.lang,\r\n\t\t\t\tu.path,\r\n\t\t\t\ta.priority,\r\n\t\t\t\ta.created,\r\n\t\t\t\ta.updated,\r\n\t\t\t\ta.publish_on,\r\n\t\t\t\ta.publish_off,\r\n\t\t\t\ta.logical_date\r\n\t\t\tfrom url u\r\n\t\t\tinner join article_lang al on al.id_article= u.id_entity and al.lang=u.lang and al.online=1\r\n\t\t\tinner join article a on a.id_article = al.id_article\r\n\t\t\twhere\r\n\t\t\t\tu.type = 'article'\r\n\t\t\t\tand u.active = 1\r\n\t\t\t\tand u.canonical = 1\r\n\t\t\t\tand a.indexed = 1\r\n\t\t\t\tand a.priority > 0\r\n\t\t\t\tand (a.publish_off = '0000-00-00 00:00:00' OR a.publish_off > now())\r\n\t\t";
     if (!$get_all_lang) {
         $sql .= "\r\n\t\t\t\tand u.lang='" . Settings::get_lang('default') . "'\r\n\t\t\t";
     }
     $query = $this->{$this->db_group}->query($sql);
     $data = $query->result_array();
     return $data;
 }
Example #20
0
 function get_articles()
 {
     $data = array();
     // Get all articles
     $this->{$this->db_group}->order_by('page_article.ordering', 'ASC');
     $this->{$this->db_group}->select('article.*', FALSE);
     $this->{$this->db_group}->select('article_lang.title');
     $this->{$this->db_group}->select('page_article.*');
     $this->{$this->db_group}->select('article_type.id_type, article_type.type_flag');
     $this->{$this->db_group}->join('page_article', 'page_article.id_article = article.id_article', 'inner');
     $this->{$this->db_group}->join('article_lang', 'article_lang.id_article = article.id_article', 'inner');
     $this->{$this->db_group}->join('article_type', 'article_type.id_type = page_article.id_type', 'left outer');
     $this->{$this->db_group}->where('article_lang.lang', Settings::get_lang('default'));
     $query = $this->{$this->db_group}->get('article');
     if ($query->num_rows() > 0) {
         $data = $query->result_array();
     }
     return $data;
 }
Example #21
0
 public function get_extend_link_list_from_content($content, $lang = NULL)
 {
     $data = array();
     if ($lang == NULL) {
         $lang = Settings::get_lang('current');
     }
     if (strlen($content) > 0) {
         $values = explode(',', $content);
         $types = array();
         foreach ($values as $val) {
             $arr = explode(':', $val);
             if (!empty($arr[1])) {
                 if (!isset($types[$arr[0]])) {
                     $types[$arr[0]] = array();
                 }
                 $types[$arr[0]][] = array_pop(explode('.', $arr[1]));
             }
         }
         $types_names = array_keys($types);
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tCOALESCE(" . implode('_lang.title,', $types_names) . '_lang.title' . ") as title,\n\t\t\t\t\turl.id_entity,\n\t\t\t\t\turl.type,\n\t\t\t\t\turl.full_path_ids,\n\t\t\t\t\turl.path,\n\t\t\t\t\tREPLACE(url.full_path_ids, '/', '.' ) as rel\n\t\t\t\tfrom url\n\t\t\t";
         $join = "";
         $where_arr = array();
         foreach ($types as $type => $entities) {
             $join .= "\n\t\t\t\t\tleft join " . $type . " on (" . $type . ".id_" . $type . " = url.id_entity and url.type = '" . $type . "')\n\t\t\t\t\tleft join " . $type . "_lang on " . $type . "_lang.id_" . $type . " = " . $type . ".id_" . $type . " and " . $type . "_lang.lang = '" . $lang . "'\n\t\t\t\t";
             $where_arr[] = "(type='" . $type . "' and id_entity in (" . implode(',', $entities) . "))";
         }
         $sql .= $join;
         $sql .= "where (" . implode(' or ', $where_arr) . ")";
         $sql .= "\n\t\t\t\tand url.lang = '" . $lang . "'\n\t\t\t\tand active = 1\n\t\t\t";
         $query = $this->{$this->db_group}->query($sql);
         if ($query->num_rows() > 0) {
             $data = $query->result_array();
         }
         $query->free_result();
     }
     return $data;
 }
Example #22
0
    public function get_extend_link_list_from_content($content, $lang = NULL)
    {
        $data = array();
        if ($lang == NULL) {
            $lang = Settings::get_lang('current');
        }
        if (strlen($content) > 0) {
            $values = explode(',', $content);
            $types = array();
            foreach ($values as $val) {
                $arr = explode(':', $val);
                if (!empty($arr[1])) {
                    if (!isset($types[$arr[0]])) {
                        $types[$arr[0]] = array();
                    }
                    $types[$arr[0]][] = array_pop(explode('.', $arr[1]));
                }
            }
            $types_names = array_keys($types);
            $sql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOALESCE(" . implode('_lang.title,', $types_names) . '_lang.title' . ") AS title,\n\t\t\t\t\turl.id_entity,\n\t\t\t\t\turl.type,\n\t\t\t\t\turl.full_path_ids,\n\t\t\t\t\turl.path,\n\t\t\t\t\tREPLACE(url.full_path_ids, '/', '.' ) as rel\n\t\t\t\tFROM url\n\t\t\t";
            $join = '';
            $where_arr = array();
            foreach ($types as $type => $entities) {
                $join .= '
					LEFT JOIN ' . $type . ' ON (' . $type . '.id_' . $type . " = url.id_entity AND url.type = '" . $type . "')\n\t\t\t\t\tLEFT JOIN " . $type . '_lang ON ' . $type . '_lang.id_' . $type . ' = ' . $type . '.id_' . $type . ' AND ' . $type . "_lang.lang = '" . $lang . "'\n\t\t\t\t";
                $where_arr[] = "(type='" . $type . "' AND id_entity IN (" . implode(',', $entities) . '))';
            }
            $sql .= $join . 'WHERE (' . implode(' OR ', $where_arr) . ")\n\t\t\t\t   AND url.lang = '" . $lang . "'\n\t\t\t \t   AND active = 1\n\t\t\t";
            $query = $this->{$this->db_group}->query($sql);
            if ($query->num_rows() > 0) {
                $data = $query->result_array();
            }
            $query->free_result();
        }
        return $data;
    }
Example #23
0
 /**
  * Returns JSON object of one entity
  *
  */
 public function get_entity()
 {
     // Contains ether a page dot article string, ether one page or article ID
     $rel = $this->input->post('rel');
     $type = $this->input->post('type');
     $rel = explode('.', $rel);
     $id_article = !empty($rel[1]) ? $rel[1] : NULL;
     $id_page = $rel[0];
     // returned entity array
     $entity = array();
     $page = array();
     switch ($type) {
         case 'article':
             if ($id_article) {
                 // Get article
                 $article = $this->article_model->get(array('id_page' => $id_page, 'id_article' => $id_article), Settings::get_lang('default'));
                 // Get the corresponding page
                 if (!empty($article)) {
                     $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default'));
                 }
                 if (!empty($article) && !empty($page)) {
                     $entity = array('page' => $page, 'article' => $article);
                 }
             }
             break;
         case 'page':
             $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default'));
             $entity = array('page' => $page);
             break;
     }
     $this->response($entity);
 }
Example #24
0
 function index()
 {
     // Articles
     $articles = $this->article_model->get_list(array('order_by' => 'updated DESC'));
     // Last 5 articles
     $last_articles = array();
     $max = count($articles) > 4 ? 5 : count($articles);
     if (!empty($articles)) {
         for ($i = 0; $i < $max; $i++) {
             $last_articles[] = $articles[$i];
         }
     }
     // Get all contexts : links between pages and articles
     $page_article = $this->article_model->get_all_context();
     // Get pages
     $pages = $this->page_model->get_lang_list(false, Settings::get_lang('default'));
     // Add page name to each context & feed the linked articles array
     $linked_articles = array();
     foreach ($page_article as &$pa) {
         if (array_search($pa['id_article'], $linked_articles) === FALSE) {
             $linked_articles[] = $pa['id_article'];
         }
         $page = array_values(array_filter($pages, create_function('$row', 'return $row["id_page"] == "' . $pa['id_page'] . '";')));
         $pa['page'] = !empty($page) ? $page[0] : array();
     }
     // Orphan articles
     $orphan_articles = array();
     foreach ($articles as $article) {
         if (array_search($article['id_article'], $linked_articles) === FALSE) {
             $orphan_articles[] = $article;
         }
     }
     // Orphan pages
     $orphan_pages = $this->page_model->get_lang_list(array('id_menu' => '0', 'order_by' => 'name ASC'), Settings::get_lang('default'));
     // Last connected users
     //		$users = array_filter($this->connect->model->get_users(array('limit'=>'10', 'level > ' => '999'), array($this, '_filter_users'));
     $users = $this->connect->model->get_users(array('limit' => '10', 'order_by' => 'last_visit DESC', 'last_visit <>' => ''));
     $last_registered_users = $this->connect->model->get_users(array('limit' => '10', 'order_by' => 'join_date DESC'));
     // Updates on last articles
     foreach ($last_articles as &$article) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $article['updater']) {
                 $article['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $article['author']) {
                 $article['author'] = $user['screen_name'];
             }
         }
         // Article's pages...
         $article['pages'] = array_values(array_filter($page_article, create_function('$row', 'return $row["id_article"] == "' . $article['id_article'] . '";')));
     }
     // Updates on orphan pages
     foreach ($orphan_pages as &$page) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $page['updater']) {
                 $page['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $page['author']) {
                 $page['author'] = $user['screen_name'];
             }
         }
     }
     // Updates on orphan articles
     foreach ($orphan_articles as &$article) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $article['updater']) {
                 $article['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $article['author']) {
                 $article['author'] = $user['screen_name'];
             }
         }
     }
     // Flags
     $settings = Settings::get_settings();
     $flags = array();
     foreach ($settings as $key => $setting) {
         if (strpos($key, 'flag') !== FALSE && $setting != '') {
             $flags[substr($key, -1)] = $setting;
         }
     }
     // Modules
     $modules = array();
     include APPPATH . 'config/modules.php';
     $config_files = glob(MODPATH . '*/config.xml');
     // Module data to put to template
     $moddata = array();
     // Get all modules from folders
     if (!empty($config_files)) {
         foreach ($config_files as $file) {
             $xml = simplexml_load_file($file);
             // Module folder
             preg_match('/\\/([^\\/]*)\\/config.xml$/i', $file, $matches);
             $folder = $matches[1];
             $uri = (string) $xml->uri_segment;
             // Only add
             // - installed modules (in $module var of config/modules.php)
             // - module with admin part
             if (in_array($folder, $modules) && $xml->has_admin == 'true') {
                 // Store data
                 $moddata[$uri] = array('name' => (string) $xml->name, 'uri_segment' => (string) $xml->uri_segment, 'description' => (string) $xml->description, 'folder' => $folder, 'file' => $file, 'access_group' => (string) $xml->access_group);
                 // Get the user segment
                 foreach ($modules as $segment => $f) {
                     if ($f == $folder) {
                         $moddata[$uri]['uri_segment'] = $segment;
                     }
                 }
             }
         }
     }
     // Put installed module list to template
     $this->template['modules'] = $moddata;
     $this->template['flags'] = $flags;
     $this->template['last_articles'] = $last_articles;
     $this->template['orphan_pages'] = $orphan_pages;
     $this->template['orphan_articles'] = $orphan_articles;
     $this->template['users'] = $users;
     $this->template['last_registered_users'] = $last_registered_users;
     $this->output('dashboard');
 }
Example #25
0
 /**
  * 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 article ordering array from a givven page
  *
  * @param	Integer		ID of the page
  * @return	Array		Array of articles ID
  *
  */
 function get_articles_ordering($id_page)
 {
     $articles = $this->get_lang_list(array('id_page' => $id_page), Settings::get_lang('default'), FALSE, FALSE, $this->parent_table . '.ordering ASC');
     $order_list = array();
     if (!empty($articles)) {
         foreach ($articles as $a) {
             $order_list[] = $a['id_article'];
         }
     }
     return $order_list;
 }
Example #27
0
 /**
  * Displays the breacrumb : You are here !
  *
  * @param	FTL_Binding object
  * @return	String	The parsed view
  *
  * @usage	<ion:breadcrumb [level="2" separator=" &bull; " tag="ul" class="breadcrumb" child-tag="li" child-class="breadcrump-item"] />
  *
  */
 public static function tag_breadcrumb(FTL_Binding $tag)
 {
     // Child tag : HTML tag for each element
     $child_tag = $tag->getAttribute('child-tag');
     $child_class = $tag->getAttribute('child-class');
     $child_class = !is_null($child_class) ? ' class="' . $child_class . '"' : '';
     // Child tag cosmetic
     $child_tag_open = !is_null($child_tag) ? '<' . $child_tag . $child_class . '>' : '';
     $child_tag_close = !is_null($child_tag) ? '</' . $child_tag . '>' : '';
     $separator = $tag->getAttribute('separator', '&nbsp;&raquo;&nbsp;');
     $separator_tag = $tag->getAttribute('separator_tag');
     $separator_class = $tag->getAttribute('separator_class');
     $separator_class = !is_null($separator_class) ? ' class="' . $separator_class . '"' : '';
     if (!is_null($separator_tag)) {
         $separator = '<' . $separator_tag . $separator_class . '>' . $separator . '</' . $separator_tag . '>';
     }
     $level = $tag->getAttribute('level', FALSE);
     // Pages && page
     $pages = self::$context->registry('pages');
     $page = self::$context->registry('page');
     // Get the Breadcrumbs array
     $lang = Settings::get_lang();
     $breadcrumb = self::get_breadcrumb_array($page, $pages, $lang);
     // Filter appearing pages
     $breadcrumb = array_values(array_filter($breadcrumb, array(__CLASS__, '_filter_appearing_pages')));
     if ($level != FALSE) {
         $new_breadcrumb = array();
         foreach ($breadcrumb as $b) {
             if ($b['level'] >= $level) {
                 $new_breadcrumb[] = $b;
             }
         }
         $breadcrumb = $new_breadcrumb;
     }
     // Build the links
     $return = '';
     // Add Home page ?
     if ($tag->getAttribute('home') == TRUE && $page['home'] == 0) {
         $home_page = self::get_home_page();
         $url = $home_page['absolute_url'];
         $return .= $child_tag_open . '<a href="' . $url . '">' . $home_page['title'] . '</a>' . $separator . $child_tag_close;
     }
     // Pages
     $nb_pages = count($breadcrumb);
     for ($i = 0; $i < $nb_pages; $i++) {
         $url = $breadcrumb[$i]['absolute_url'];
         // Adds the suffix if defined
         if (config_item('url_suffix') != '') {
             $url .= config_item('url_suffix');
         }
         $return .= $child_tag_open . '<a href="' . $url . '">' . $breadcrumb[$i]['title'] . '</a>';
         if ($i < $nb_pages - 1) {
             $return .= $separator;
         }
         $return .= $child_tag_close;
     }
     // Current Article ?
     if ($tag->getAttribute('article') == TRUE) {
         $article = self::registry('article');
         if ($article) {
             $separator = $return != '' ? $separator : '';
             $return .= $child_tag_open . $separator . $article['title'] . $child_tag_close;
         }
     }
     // Prefix process
     $return = self::prefix_suffix_process($return, $tag->getAttribute('prefix'));
     return self::wrap($tag, $return);
 }
Example #28
0
 /**
  * Edits an instance of element to a parent
  *
  */
 function edit()
 {
     $id_element = $this->input->post('id_element');
     // Element
     $element = $this->element_model->get(array('id_element' => $id_element));
     // Element definition
     $element_definition = $this->element_definition_model->get(array('id_element_definition' => $element['id_element_definition']), Settings::get_lang('default'));
     // Element's fields
     $element_fields = $this->element_model->get_element_fields($id_element);
     $this->template['element'] = $element;
     $this->template['element_definition'] = $element_definition;
     $this->template['fields'] = $element_fields;
     $lang_fields = array_values(array_filter($element_fields, create_function('$row', 'return $row["translated"] == 1;')));
     $this->template['lang_fields'] = $lang_fields;
     // Check for langs fields different from
     $has_lang_fields = FALSE;
     foreach ($lang_fields as $lf) {
         if ($lf['type'] != 8) {
             $has_lang_fields = TRUE;
         }
     }
     $this->template['has_lang_fields'] = $has_lang_fields;
     // Check for Media type
     $has_media_fields = FALSE;
     foreach ($element_fields as $f) {
         if ($f['type'] == 8) {
             $has_media_fields = TRUE;
         }
     }
     $this->template['has_media_fields'] = $has_media_fields;
     $this->template['parent'] = $element['parent'];
     $this->template['id_parent'] = $element['id_parent'];
     $this->template['ordering'] = $element['ordering'];
     $this->template['id_element'] = $id_element;
     $this->output('element/detail');
 }
 /**
  * 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>';
 }
Example #30
0
		var str = this.language[args[0]];

		if (args.length > 1)
		{
			if (typeOf(args[1]) == 'array')
				str = vsprintf(str, args[1]);
			else
				str = sprintf(str, args[1]);
		}
		return str;
	},
	'current': '<?php 
echo $this->config->item('detected_lang_code');
?>
',
	'first': '<?php 
echo Settings::get_lang('first');
?>
',
	'default': '<?php 
echo Settings::get_lang('default');
?>
',

	'languages': new Array('<?php 
echo implode("','", array_keys($this->config->item('available_languages')));
?>
')
});