1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-13 12:22:03 +02:00

[ticket/12759] Allow multiple fields to be loaded via get_option_lang

PHPBB3-12759
This commit is contained in:
Shitiz Garg 2014-06-22 17:55:30 +05:30
parent 18763d7286
commit 6d23cc3a0e
3 changed files with 21 additions and 10 deletions

View File

@ -51,7 +51,7 @@ class lang_helper
/**
* Get language entries for options and store them here for later use
*/
public function get_option_lang($field_id, $lang_id, $field_type, $preview_options)
public function get_option_lang($field_id, $lang_id, $preview_options)
{
if ($preview_options !== false)
{
@ -72,17 +72,28 @@ class lang_helper
}
else
{
$sql = 'SELECT option_id, lang_value
if (is_array($field_id))
{
foreach ($field_id as $k => $id)
{
$field_id[$k] = (int) $id;
}
}
else
{
$field_id = array((int) $field_id);
}
$sql = 'SELECT field_id, option_id, lang_value
FROM ' . $this->language_table . '
WHERE field_id = ' . (int) $field_id . '
WHERE ' . $this->db->sql_in_set('field_id', $field_id) . '
AND lang_id = ' . (int) $lang_id . "
AND field_type = '" . $this->db->sql_escape($field_type) . "'
ORDER BY option_id";
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
$this->options_lang[$row['field_id']][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
}
$this->db->sql_freeresult($result);
}

View File

@ -155,7 +155,7 @@ class type_bool extends type_base
if (!$this->lang_helper->is_set($field_id, $lang_id))
{
$this->lang_helper->get_option_lang($field_id, $lang_id, FIELD_BOOL, false);
$this->lang_helper->get_option_lang($field_id, $lang_id, false);
}
if (!$field_value && $field_data['field_show_novalue'])
@ -203,7 +203,7 @@ class type_bool extends type_base
{
if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1))
{
$this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $this->get_service_name(), $preview_options);
$this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
}
$options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);

View File

@ -135,7 +135,7 @@ class type_dropdown extends type_base
// retrieve option lang data if necessary
if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], 1))
{
$this->lang_helper->get_option_lang($field_data['field_id'], $field_data['lang_id'], $this->get_service_name(), false);
$this->lang_helper->get_option_lang($field_data['field_id'], $field_data['lang_id'], false);
}
if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], $field_value))
@ -160,7 +160,7 @@ class type_dropdown extends type_base
$lang_id = $field_data['lang_id'];
if (!$this->lang_helper->is_set($field_id, $lang_id))
{
$this->lang_helper->get_option_lang($field_id, $lang_id, $this->get_service_name(), false);
$this->lang_helper->get_option_lang($field_id, $lang_id, false);
}
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
@ -199,7 +199,7 @@ class type_dropdown extends type_base
if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1))
{
$this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $this->get_service_name(), $preview_options);
$this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
}
$profile_row['field_value'] = (int) $value;