aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/profilefields/lang_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/profilefields/lang_helper.php')
-rw-r--r--phpBB/phpbb/profilefields/lang_helper.php76
1 files changed, 43 insertions, 33 deletions
diff --git a/phpBB/phpbb/profilefields/lang_helper.php b/phpBB/phpbb/profilefields/lang_helper.php
index 7bae1bdc18..2e353722b2 100644
--- a/phpBB/phpbb/profilefields/lang_helper.php
+++ b/phpBB/phpbb/profilefields/lang_helper.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2014 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,7 +15,6 @@ namespace phpbb\profilefields;
/**
* Custom Profile Fields
-* @package phpBB3
*/
class lang_helper
{
@@ -23,7 +26,7 @@ class lang_helper
/**
* Database object
- * @var \phpbb\db\driver\driver
+ * @var \phpbb\db\driver\driver_interface
*/
protected $db;
@@ -36,7 +39,7 @@ class lang_helper
/**
* Construct
*
- * @param \phpbb\db\driver\driver $db Database object
+ * @param \phpbb\db\driver\driver_interface $db Database object
* @param string $language_table Table where the language strings are stored
*/
public function __construct($db, $language_table)
@@ -46,43 +49,50 @@ 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;
- foreach ($lang_options as $num => $var)
+ foreach ($lang_options as $num => $var)
+ {
+ if (!isset($this->options_lang[$field_id]))
{
- if (!isset($this->options_lang[$field_id]))
- {
- $this->options_lang[$field_id] = array();
- }
- if (!isset($this->options_lang[$field_id][$lang_id]))
- {
- $this->options_lang[$field_id][$lang_id] = array();
- }
- $this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
+ $this->options_lang[$field_id] = array();
}
+ if (!isset($this->options_lang[$field_id][$lang_id]))
+ {
+ $this->options_lang[$field_id][$lang_id] = array();
+ }
+ $this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
}
- else
- {
- $sql = 'SELECT option_id, lang_value
+ }
+
+ /**
+ * Fetches language entries for options from DB
+ *
+ * @param int $lang_id
+ */
+ public function load_option_lang($lang_id)
+ {
+ $sql = 'SELECT field_id, option_id, lang_value
FROM ' . $this->language_table . '
- WHERE field_id = ' . (int) $field_id . '
- AND lang_id = ' . (int) $lang_id . "
- AND field_type = '" . $this->db->sql_escape($field_type) . "'
+ WHERE lang_id = ' . (int) $lang_id . "
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->db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $this->options_lang[$row['field_id']][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
}
+
+ $this->db->sql_freeresult($result);
}
/**