本文整理汇总了PHP中Settings::get_languages方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::get_languages方法的具体用法?PHP Settings::get_languages怎么用?PHP Settings::get_languages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::get_languages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_lang
public function check_lang()
{
$result = array('title' => lang('ionize_title_check_lang'), 'status' => 'success', 'message' => lang('ionize_message_check_ok'));
// Get the languages : DB + config/language.php
$db_languages = Settings::get_languages();
$config_available_languages = config_item('available_languages');
// Check differences between DB and config/language.php file
$result_status = TRUE;
foreach ($db_languages as $lang) {
if (!array_key_exists($lang['lang'], $config_available_languages)) {
$result_status = FALSE;
}
}
// Correct if needed
if ($result_status == FALSE) {
// Default language
$def_lang = '';
// Available languages array
$available_languages = array();
foreach ($db_languages as $l) {
// Set default lang code
if ($l['def'] == '1') {
$def_lang = $l['lang'];
}
$available_languages[$l['lang']] = $l['name'];
}
$this->config_model->change('language.php', 'default_lang_code', $def_lang);
if (!empty($available_languages)) {
$this->config_model->change('language.php', 'available_languages', $available_languages);
}
$result['message'] = lang('ionize_message_check_corrected');
}
$this->xhr_output($result);
}
示例2: get_element_extend_fields
/**
* Get the current extend fields and their values for one parent element
* Used by backend, as all the languages data are also got
*
* @param string parent name
* @param int parent ID
*
*/
function get_element_extend_fields($parent, $id_parent = null)
{
$data = array();
$extend_fields = array();
// Element extend fields
$where = array('parent' => $parent);
$extend_fields = $this->get_list($where);
// Current element extend field
$this->db->where(array('extend_field.parent' => $parent, $this->elements_table . '.id_parent' => $id_parent));
$this->db->join($this->elements_table, $this->elements_table . '.id_' . $this->table . ' = ' . $this->table . '.id_' . $this->table, 'inner');
$query = $this->db->get($this->table);
$result = array();
if ($query->num_rows() > 0) {
$result = $query->result_array();
}
$langs = Settings::get_languages();
$element_fields = $this->db->list_fields($this->elements_table);
foreach ($extend_fields as $k => &$extend_field) {
// A not tranlated extend field...
if ($extend_field['translated'] != '1') {
// fill the base data with empty values
$extend_field = array_merge(array_fill_keys($element_fields, ''), $extend_field);
foreach ($result as $row) {
if ($row['id_extend_field'] == $extend_field['id_extend_field']) {
$extend_field = array_merge($extend_field, $row);
}
}
} else {
foreach ($langs as $language) {
// Lang code
$lang = $language['lang'];
// Feed lang key with blank array
$extend_field[$lang] = array();
$extend_field[$lang]['content'] = '';
// Feeding of template languages elements
foreach ($result as $row) {
if ($row['id_extend_field'] == $extend_field['id_extend_field'] && $row['lang'] == $lang) {
$extend_field[$lang] = $row;
}
}
}
}
}
return $extend_fields;
}
示例3: get_element_definition_list
/**
* Returns the element definition list
* Used to admin elements (elements_definition_list and element_definition views)
*
* XHR call
*
*/
function get_element_definition_list()
{
$elements = $this->element_definition_model->get_list(array('order_by' => 'ordering ASC'));
$elements_lang = $this->element_definition_model->get_lang();
// Elements
foreach ($elements as &$element) {
// Translated elements.
$langs = array_values(array_filter($elements_lang, create_function('$row', 'return $row["id_element_definition"] == "' . $element['id_element_definition'] . '";')));
foreach (Settings::get_languages() as $lang) {
$element[$lang['lang']] = array_pop(array_filter($langs, create_function('$row', 'return $row["lang"] == "' . $lang['lang'] . '";')));
}
// Element's fields
$element['fields'] = $this->extend_field_model->get_list(array('id_element_definition' => $element['id_element_definition']));
// Name of the field type ("checkbox", "input", ...)
foreach ($element['fields'] as &$field) {
$field['type_name'] = self::$type_names[$field['type']];
}
}
$this->template['elements'] = $elements;
$this->output('element_definition_list');
}
示例4: get_element_definition_list
/**
* Returns the element definition list
* Used to admin elements (elements_definition_list and element_definition views)
*
* XHR call
*
*/
function get_element_definition_list()
{
$elements = $this->element_definition_model->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default'));
$elements_lang = $this->element_definition_model->get_all('element_definition_lang');
// Elements
foreach ($elements as &$element) {
$element['languages'] = array();
// Translated elements.
foreach (Settings::get_languages() as $lang) {
$element['languages'][$lang['lang']] = array('title' => '');
foreach ($elements_lang as $ld) {
if ($ld['id_element_definition'] == $element['id_element_definition'] && $ld['lang'] == $lang['lang']) {
$element['languages'][$lang['lang']] = $ld;
}
}
}
// Element's fields
$element['fields'] = $this->extend_field_model->get_list(array('parent' => 'element', 'id_parent' => $element['id_element_definition']), Settings::get_lang('default'));
}
$this->template['elements'] = $elements;
$this->output('element/definition/list');
}
示例5: save
public function save($inputs)
{
// Arrays of data which will be saved
$data = $data_lang = array();
// Fields of the author table
$fields = $this->list_fields();
// Set the data to the posted value.
foreach ($fields as $field) {
$data[$field] = $inputs[$field];
}
$lang_fields = $this->list_fields($this->_author_lang_table);
foreach (Settings::get_languages() as $language) {
foreach ($lang_fields as $field) {
if ($field != $this->pk_name && $field != 'lang') {
$input_field = $field . '_' . $language['lang'];
if ($inputs[$input_field] !== FALSE) {
$data_lang[$language['lang']][$field] = $inputs[$input_field];
}
}
}
}
return parent::save($data, $data_lang);
}
示例6: _get_theme_translations
/**
* Gets already translated items from language files
*
* @return array Array of already translated terms
*
*/
function _get_theme_translations()
{
$items = array();
$this->load->helper('file');
// Theme folder
$path = FCPATH . 'themes/' . Settings::get('theme');
// Read the template language directory
foreach (Settings::get_languages() as $language) {
$lang_files = array();
$lang_code = $language['lang'];
$items[$lang_code] = array();
// Translation file name. Named [theme_name]_lang.php
$file = $path . '/language/' . $lang_code . '/' . Settings::get('theme') . '_lang.php';
// Include the file if it exists
if (file_exists($file)) {
include $file;
if (isset($lang)) {
$items[$lang_code] = $lang;
unset($lang);
}
}
}
return $items;
}
示例7: _save_settings
/**
* Saves settings according to the passed settings tables
*
* @param array Settings keys array
* @param array Lang Settings keys array
*
*/
function _save_settings($settings = array(), $lang_settings = array())
{
/*
* Save the lang settings first
*/
if (!empty($lang_settings)) {
foreach (Settings::get_languages() as $language) {
foreach ($lang_settings as $setting) {
$data = array('name' => $setting, 'content' => ($content = $this->input->post($setting . '_' . $language['lang'])) ? $content : '', 'lang' => $language['lang']);
$this->settings_model->save_setting($data);
}
}
}
/*
* Saves settings
*/
foreach ($settings as $setting) {
$content = '';
if ($this->input->post($setting)) {
// Avoid or not security XSS filter
if (!in_array($setting, $this->no_xss_filter)) {
$content = $this->input->post($setting);
} else {
$content = stripslashes($_REQUEST[$setting]);
}
}
$data = array('name' => $setting, 'content' => $content);
$this->settings_model->save_setting($data);
}
}
示例8: add_lang_data
/**
* Add lang content to each article in the article list.
* This function is used for backend
*
* @param Array by ref. Array of articles
*
*/
function add_lang_data(&$articles = array())
{
if (!empty($articles)) {
// Add lang content to each article
$articles_lang = $this->get_lang();
foreach ($articles as &$article) {
$article['langs'] = array();
// $langs = array_values(array_filter($articles_lang, create_function('$row','return $row["id_article"] == "'. $article['id_article'] .'";')));
$langs = array();
foreach ($articles_lang as $al) {
if ($al['id_article'] == $article['id_article']) {
$langs[] = $al;
}
}
foreach (Settings::get_languages() as $lang) {
// $article['langs'][$lang['lang']] = array_pop(array_filter($langs, create_function('$row','return $row["lang"] == "'. $lang['lang'] .'";')));
foreach ($langs as $l) {
if ($l['lang'] == $lang['lang']) {
$article['langs'][$lang['lang']] = $l;
}
}
}
}
}
}
示例9: add_item
/**
* Add item windows
* Purpose : Create one item (backend)
* At this state, the item isn't added
*
*/
public function add_item()
{
$id_definition = $this->input->post('id_item_definition');
$item_definition = $this->item_definition_model->get(array('id_item_definition' => $id_definition), Settings::get_lang('default'));
// Element's fields
$fields = $this->extend_field_model->get_lang_list(array('parent' => 'item', 'id_parent' => $id_definition, 'order_by' => 'ordering ASC'), Settings::get_lang('default'));
$fields_lang = $this->extend_field_model->get_all('extend_field_lang');
foreach ($fields as &$field) {
foreach (Settings::get_languages() as $lang) {
$langs = array_values(array_filter($fields_lang, create_function('$row', 'return $row["id_extend_field"] == "' . $field['id_extend_field'] . '";')));
$field['langs'][$lang['lang']] = array_pop(array_filter($langs, create_function('$row', 'return $row["lang"] == "' . $lang['lang'] . '";')));
}
}
$this->template['item_definition'] = $item_definition;
$this->template['fields'] = $fields;
$lang_fields = array_values(array_filter($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 ($fields as $f) {
if ($f['type'] == 8) {
$has_media_fields = TRUE;
}
}
$this->template['has_media_fields'] = $has_media_fields;
$this->output('item/instance/edit');
}
示例10: clean_lang_settings
/**
* Clean unused language depending settings -- Kochin
*
* When a language is deleted, language depending settings are left untouched.
* This function cleans up any unused language depending settings.
*
* @return Int number of rows deleted
*/
function clean_lang_settings()
{
// Get the existing languages
$languages = Settings::get_languages();
$lang_codes = array();
foreach ($languages as $lang) {
$lang_codes[] = $lang['lang'];
}
// Execute the cleaning request
$nb_affected_rows = 0;
if (!empty($lang_codes)) {
$this->{$this->db_group}->where("NOT(lang IS NULL OR lang='')")->where_not_in('lang', $lang_codes);
$nb_affected_rows = $this->{$this->db_group}->delete($this->table);
}
return $nb_affected_rows;
}
示例11: _add_lang_data_to_media_list
/**
* Adds info about each media
*
* @param $medias
*
* @return mixed
*/
private function _add_lang_data_to_media_list($medias)
{
if (!empty($medias)) {
$media_ids = array();
foreach ($medias as $media) {
$media_ids[] = $media['id_media'];
}
// Fields of media_lang
$media_lang_fields = $this->list_fields('media_lang');
// Get media lang data
$this->{$this->db_group}->where_in('id_media', $media_ids);
$query = $this->{$this->db_group}->get('media_lang');
$medias_lang = array();
if ($query->num_rows() > 0) {
$medias_lang = $query->result_array();
}
// Enrich each media
foreach ($medias as &$media) {
$media['alt_missing'] = FALSE;
$media['is_used'] = TRUE;
$media['has_source'] = empty($media['provider']) ? file_exists(DOCPATH . $media['path']) : TRUE;
$media['lang'] = array();
// Is linked to page or article
if (empty($media['page_paths']) && empty($media['article_paths'])) {
$media['is_used'] = FALSE;
}
foreach (Settings::get_languages() as $lang) {
$media['lang'][$lang['lang']] = array_fill_keys($media_lang_fields, '');
$media['lang'][$lang['lang']]['id_media'] = $media['id_media'];
}
foreach ($medias_lang as $media_lang) {
if ($media_lang['id_media'] == $media['id_media']) {
$media['lang'][$media_lang['lang']] = $media_lang;
}
}
// Alt missing
foreach (Settings::get_languages() as $lang) {
if (empty($media['lang'][$lang['lang']]['alt'])) {
$media['alt_missing'] = TRUE;
}
}
}
}
return $medias;
}
示例12: feed_blank_lang_template
/**
* Feed the template array with blank data for each field in language table
*
* @param array By ref, the template array
*
*/
function feed_blank_lang_template(&$template = FALSE)
{
if ($template == FALSE) {
$template = array();
}
$fields = $this->{$this->db_group}->list_fields($this->lang_table);
$fields_data = $this->field_data($this->lang_table);
foreach (Settings::get_languages() as $language) {
$lang = $language['lang'];
foreach ($fields as $field) {
$field_data = array_values(array_filter($fields_data, create_function('$row', 'return $row["Field"] == "' . $field . '";')));
$field_data = isset($field_data[0]) ? $field_data[0] : false;
$template[$lang][$field] = isset($field_data['Default']) ? $field_data['Default'] : '';
}
}
return $template;
}
示例13: get_fields_from_parent
function get_fields_from_parent($parent, $id_parent, $lang, $id_definition = FALSE, $id_element = FALSE)
{
// Loads the element model if it isn't loaded
$CI =& get_instance();
if (!isset($CI->element_definition_model)) {
$CI->load->model('element_definition_model');
}
if (!isset($CI->extend_field_model)) {
$CI->load->model('extend_field_model');
}
// Get definitions
$cond = array();
if ($id_definition != FALSE) {
$cond['element_definition.id_element_definition'] = $id_definition;
}
$definitions = $CI->element_definition_model->get_lang_list($cond, $lang);
// Get definitions fields
$cond = array('id_element_definition <>' => '0', 'order_by' => 'ordering ASC');
$definitions_fields = $CI->extend_field_model->get_lang_list($cond, $lang);
// Get Elements
$cond = array('order_by' => 'element.ordering ASC');
if ($id_element) {
$cond['id_element'] = $id_element;
} else {
$cond['parent'] = $parent;
$cond['id_parent'] = $id_parent;
}
$elements = $this->get_elements($cond);
// Get fields instances
$where = ' where extend_fields.id_element in (
select id_element from element
where parent= \'' . $parent . '\'
and id_parent= \'' . $id_parent . '\'
)';
if ($id_element) {
$where = ' where extend_fields.id_element = \'' . $id_element . '\'';
}
$sql = 'select extend_field.*, extend_fields.*
from extend_fields
join extend_field on extend_field.id_extend_field = extend_fields.id_extend_field' . $where;
$query = $this->{$this->db_group}->query($sql);
$result = array();
if ($query->num_rows() > 0) {
$result = $query->result_array();
}
$query->free_result();
$langs = Settings::get_languages();
$extend_field_fields = $this->{$this->db_group}->list_fields('extend_field');
$extend_fields_fields = $this->{$this->db_group}->list_fields('extend_fields');
foreach ($definitions as $key => &$definition) {
$definition['elements'] = array();
foreach ($elements as $element) {
// The element match a definition
if ($element['id_element_definition'] == $definition['id_element_definition']) {
$element['fields'] = array();
foreach ($definitions_fields as $df) {
if ($df['id_element_definition'] == $definition['id_element_definition']) {
$el = array_merge(array_fill_keys($extend_fields_fields, ''), $df);
foreach ($result as $row) {
if ($row['id_element'] == $element['id_element'] && $row['id_extend_field'] == $df['id_extend_field']) {
$el = array_merge($el, $row);
if ($df['translated'] == '1') {
foreach ($langs as $language) {
$lang = $language['lang'];
if ($row['lang'] == $lang) {
$el[$lang] = $row;
}
}
}
}
}
$element['fields'][$df['name']] = $el;
}
}
$definition['elements'][] = $element;
}
}
if (empty($definition['elements'])) {
unset($definitions[$key]);
}
}
if (count($definitions) == 1) {
$definitions = array_shift($definitions);
}
return $definitions;
}
示例14: get_list_from_definition
/**
* Get item definitions with nested fields
*
* @param $id_item_definition
* @param $lang
*
* @return array
*/
public function get_list_from_definition($id_item_definition, $lang)
{
self::$ci->load->model('item_definition_model');
self::$ci->load->model('extend_field_model');
// Definitions Fields : Extend Field Types
$definitions_fields = self::$ci->extend_field_model->get_lang_list(array('parent' => 'item', 'id_parent' => $id_item_definition), $lang);
// Items Instances
$items = $this->get_lang_list(array('id_item_definition' => $id_item_definition, 'order_by' => 'ordering ASC'), $lang);
// Fields
$sql = "\r\n\t\t\tSELECT\r\n\t\t\t\textend_fields.*\r\n\t\t\tFROM\r\n\t\t\t\textend_fields\r\n\t\t\tWHERE\r\n\t\t\t\textend_fields.parent = 'item' AND\r\n \t\t\t\textend_fields.id_parent in (\r\n\t\t\t\t\tSELECT id_item from item\r\n\t\t\t\t\tWHERE id_item_definition= " . $id_item_definition . '
)
';
$query = $this->{$this->db_group}->query($sql);
$fields = array();
if ($query->num_rows() > 0) {
$fields = $query->result_array();
}
$query->free_result();
// Extend Fields DB fields
$extend_fields_fields = $this->{$this->db_group}->list_fields('extend_fields');
// Languages
$langs = Settings::get_languages();
// Feed each item with its fields
foreach ($items as &$item) {
$item['fields'] = array();
foreach ($definitions_fields as $df) {
// Create one empty field for each definition extend field, to have data, even empty
$el = array_merge(array_fill_keys($extend_fields_fields, NULL), $df);
$el['lang_data'] = array();
foreach ($fields as $row) {
if ($row['id_parent'] == $item['id_item'] && $row['id_extend_field'] == $df['id_extend_field']) {
if ($df['translated'] == '1') {
foreach ($langs as $language) {
$lang_code = $language['lang'];
if ($row['lang'] == $lang_code) {
if ($lang_code == $lang) {
$el = array_merge($el, $row);
}
$el['lang_data'][$lang_code] = $row;
}
}
} else {
$el = array_merge($el, $row);
$el['data'] = $row;
}
}
}
$item['fields'][$df['name']] = $el;
}
}
return $items;
}
示例15: check_lang
/**
* Check if all langs defined in DB are set in the config file
*
*/
function check_lang()
{
$result = array('title' => lang('ionize_title_check_lang'), 'result_status' => 'success', 'result_text' => lang('ionize_message_check_ok'));
// Get the languages : DB + config/language.php
$db_languages = Settings::get_languages();
$config_languages = config_item('lang_uri_abbr');
// Check differences between DB and config/language.php file
$result_status = TRUE;
foreach ($db_languages as $lang) {
if (!array_key_exists($lang['lang'], $config_languages)) {
$result_status = FALSE;
}
}
// Correct if needed
if ($result_status == FALSE) {
// Default language
$def_lang = '';
// Available languages array
$lang_uri_abbr = array();
foreach ($db_languages as $l) {
// Set default lang code
if ($l['def'] == '1') {
$def_lang = $l['lang'];
}
$lang_uri_abbr[$l['lang']] = $l['name'];
}
$this->config_model->change('language.php', 'language_abbr', $def_lang);
if (!empty($lang_uri_abbr)) {
$this->config_model->change('language.php', 'lang_uri_abbr', $lang_uri_abbr);
}
$result['result_text'] = lang('ionize_message_check_corrected');
}
// Result view
$view = $this->load->view('system_check_result', $result, TRUE);
$this->callback = array(array('fn' => 'ION.appendDomElement', 'args' => array('system_check_report', $view)), array('fn' => 'ION.JSON', 'args' => array('system_check/check_page_level')));
$this->response();
}