diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-01-16 16:00:52 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-01-16 16:00:52 +0100 |
commit | 0bdec35cd4127cd4f1e96b9a77340580c6045423 (patch) | |
tree | f3ca5142aa20113fb2ddbad620efd792e6cbb43e /phpBB/phpbb/profilefields | |
parent | 78603bb96d0afa0695b296013dec17485d74ea45 (diff) | |
download | forums-0bdec35cd4127cd4f1e96b9a77340580c6045423.tar forums-0bdec35cd4127cd4f1e96b9a77340580c6045423.tar.gz forums-0bdec35cd4127cd4f1e96b9a77340580c6045423.tar.bz2 forums-0bdec35cd4127cd4f1e96b9a77340580c6045423.tar.xz forums-0bdec35cd4127cd4f1e96b9a77340580c6045423.zip |
[ticket/11201] Move grabbing the input of the language options to type class
PHPBB3-11201
Diffstat (limited to 'phpBB/phpbb/profilefields')
-rw-r--r-- | phpBB/phpbb/profilefields/lang_helper.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_bool.php | 20 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_date.php | 18 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_dropdown.php | 15 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_int.php | 15 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_interface.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_string_common.php | 13 |
7 files changed, 94 insertions, 7 deletions
diff --git a/phpBB/phpbb/profilefields/lang_helper.php b/phpBB/phpbb/profilefields/lang_helper.php index 627c76e76e..569eaaca40 100644 --- a/phpBB/phpbb/profilefields/lang_helper.php +++ b/phpBB/phpbb/profilefields/lang_helper.php @@ -48,6 +48,14 @@ class lang_helper foreach ($lang_options as $num => $var) { + 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; } } @@ -104,7 +112,7 @@ class lang_helper */ public function get($field_id, $lang_id, $field_value = null) { - if (!is_null($field_value)) + if (is_null($field_value)) { return $this->options_lang[$field_id][$lang_id]; } diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php index f4e0ac0f86..a3291d5ce1 100644 --- a/phpBB/phpbb/profilefields/type/type_bool.php +++ b/phpBB/phpbb/profilefields/type/type_bool.php @@ -144,7 +144,7 @@ class type_bool implements type_interface { $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; $field_ident = $profile_row['field_ident']; - $default_value = $profile_row['lang_default_value']; + $default_value = $profile_row['field_default_value']; // checkbox - set the value to "true" if it has been set to 1 if ($profile_row['field_length'] == 2) @@ -211,4 +211,22 @@ class type_bool implements type_interface return $options; } + + /** + * {@inheritDoc} + */ + public function get_language_options_input($field_data) + { + $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); + $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true); + $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true); + + /** + * @todo check if this line is correct... + $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => array('')), true); + */ + $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => array('')), true); + + return $field_data; + } } diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php index d2a10cdd15..c76c7e1d49 100644 --- a/phpBB/phpbb/profilefields/type/type_date.php +++ b/phpBB/phpbb/profilefields/type/type_date.php @@ -177,6 +177,7 @@ class type_date implements type_interface public function generate_field($profile_row, $preview_options = false) { $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; + $field_ident = $profile_row['field_ident']; $now = getdate(); @@ -186,14 +187,14 @@ class type_date implements type_interface { $profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']); } - list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$user_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$user_ident])); + list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$field_ident])); } else { if ($preview_options !== false && $profile_row['field_default_value'] == 'now') { $profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']); - list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$user_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$user_ident])); + list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$field_ident])); } else { @@ -257,4 +258,17 @@ class type_date implements type_interface return $options; } + + /** + * {@inheritDoc} + */ + public function get_language_options_input($field_data) + { + $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); + $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true); + $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true); + $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true); + + return $field_data; + } } diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php index 82c128861a..4313f0e64c 100644 --- a/phpBB/phpbb/profilefields/type/type_dropdown.php +++ b/phpBB/phpbb/profilefields/type/type_dropdown.php @@ -153,7 +153,7 @@ class type_dropdown implements type_interface { $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; $field_ident = $profile_row['field_ident']; - $default_value = $profile_row['lang_default_value']; + $default_value = $profile_row['field_default_value']; $value = ($this->request->is_set($field_ident)) ? $this->request->variable($field_ident, $default_value) : ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $default_value : $this->user->profile_fields[$field_ident]); @@ -209,4 +209,17 @@ class type_dropdown implements type_interface return $options; } + + /** + * {@inheritDoc} + */ + public function get_language_options_input($field_data) + { + $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); + $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true); + $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true); + $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true); + + return $field_data; + } } diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index a2e6f8e663..9901f61795 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -124,7 +124,7 @@ class type_int implements type_interface { $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; $field_ident = $profile_row['field_ident']; - $default_value = $profile_row['lang_default_value']; + $default_value = $profile_row['field_default_value']; if ($this->request->is_set($field_ident)) { @@ -183,4 +183,17 @@ class type_int implements type_interface return $options; } + + /** + * {@inheritDoc} + */ + public function get_language_options_input($field_data) + { + $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); + $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true); + $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true); + $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true); + + return $field_data; + } } diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index f6f6355698..9390c4171b 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -102,7 +102,15 @@ interface type_interface * Get the options we need to display for the language input fields in the ACP * * @param array $field_data Array with data for this field - * @return array Returns the language options we need to generate + * @return array Returns the language options we need to generate */ public function get_language_options($field_data); + + /** + * Get the input for the supplied language options + * + * @param array $field_data Array with data for this field + * @return array Returns the language options we need to generate + */ + public function get_language_options_input($field_data); } diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index 686c50d4db..88ca905aee 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -109,4 +109,17 @@ abstract class type_string_common { return 'pf_' . $field_data['field_ident']; } + + /** + * {@inheritDoc} + */ + public function get_language_options_input($field_data) + { + $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); + $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true); + $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true); + $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true); + + return $field_data; + } } |