mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge pull request #2636 from Dragooon/ticket/12759
[ticket/12759] Resolve query flooding while displaying large number of custom profile fields * Dragooon/ticket/12759: [ticket/12759] Fix type_bool and type_dropdown's UCP fields [ticket/12759] Remove lang_helper from profilefields_manager [ticket/12759] Cache all lang_options in lang_helper instead [ticket/12759] Extra line in profilefields_manager [ticket/12759] Cache lang_options for pm_viewmessage [ticket/12759] Cache lang_options on memberlist [ticket/12759] Add phpDoc comments to explain get_option_lang [ticket/12759] Little code cleanup [ticket/12759] Make sure $field_id has unique elements [ticket/12759] Cache the lang options earlier [ticket/12759] Cache lang options for all fields while displaying [ticket/12759] Allow multiple fields to be loaded via get_option_lang
This commit is contained in:
commit
b0286bf854
3 changed files with 55 additions and 34 deletions
|
@ -49,11 +49,13 @@ class lang_helper
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get language entries for options and store them here for later use
|
* Loads preview options into language entries for options
|
||||||
|
*
|
||||||
|
* @param int $field_id
|
||||||
|
* @param int $lang_id
|
||||||
|
* @param mixed $preview_options
|
||||||
*/
|
*/
|
||||||
public function get_option_lang($field_id, $lang_id, $field_type, $preview_options)
|
public function load_preview_options($field_id, $lang_id, $preview_options)
|
||||||
{
|
|
||||||
if ($preview_options !== false)
|
|
||||||
{
|
{
|
||||||
$lang_options = (!is_array($preview_options)) ? explode("\n", $preview_options) : $preview_options;
|
$lang_options = (!is_array($preview_options)) ? explode("\n", $preview_options) : $preview_options;
|
||||||
|
|
||||||
|
@ -70,23 +72,28 @@ class lang_helper
|
||||||
$this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
|
$this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/**
|
||||||
|
* Fetches language entries for options from DB
|
||||||
|
*
|
||||||
|
* @param int $lang_id
|
||||||
|
*/
|
||||||
|
public function load_option_lang($lang_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT option_id, lang_value
|
$sql = 'SELECT field_id, option_id, lang_value
|
||||||
FROM ' . $this->language_table . '
|
FROM ' . $this->language_table . '
|
||||||
WHERE field_id = ' . (int) $field_id . '
|
WHERE lang_id = ' . (int) $lang_id . "
|
||||||
AND lang_id = ' . (int) $lang_id . "
|
|
||||||
AND field_type = '" . $this->db->sql_escape($field_type) . "'
|
|
||||||
ORDER BY option_id";
|
ORDER BY option_id";
|
||||||
|
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
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);
|
$this->db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are language options set for this field?
|
* Are language options set for this field?
|
||||||
|
|
|
@ -155,7 +155,7 @@ class type_bool extends type_base
|
||||||
|
|
||||||
if (!$this->lang_helper->is_set($field_id, $lang_id))
|
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->load_option_lang($lang_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$field_value && $field_data['field_show_novalue'])
|
if (!$field_value && $field_data['field_show_novalue'])
|
||||||
|
@ -203,7 +203,14 @@ class type_bool extends type_base
|
||||||
{
|
{
|
||||||
if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1))
|
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);
|
if ($preview_options)
|
||||||
|
{
|
||||||
|
$this->lang_helper->load_preview_options($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->lang_helper->load_option_lang($profile_row['lang_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
|
$options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
|
||||||
|
|
|
@ -135,7 +135,7 @@ class type_dropdown extends type_base
|
||||||
// retrieve option lang data if necessary
|
// retrieve option lang data if necessary
|
||||||
if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], 1))
|
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->load_option_lang($field_data['lang_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], $field_value))
|
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'];
|
$lang_id = $field_data['lang_id'];
|
||||||
if (!$this->lang_helper->is_set($field_id, $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->load_option_lang($lang_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
|
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
|
||||||
|
@ -199,7 +199,14 @@ class type_dropdown extends type_base
|
||||||
|
|
||||||
if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1))
|
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);
|
if ($preview_options)
|
||||||
|
{
|
||||||
|
$this->lang_helper->load_preview_options($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->lang_helper->load_option_lang($profile_row['lang_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_row['field_value'] = (int) $value;
|
$profile_row['field_value'] = (int) $value;
|
||||||
|
|
Loading…
Add table
Reference in a new issue