aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-01-17 09:55:52 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-01-17 09:55:52 +0100
commit9653764fb15de3e3126466c98525c121a8a3ac0b (patch)
treeb683891efe0421e4966ad062d8261195be0533a6 /phpBB
parent0bdec35cd4127cd4f1e96b9a77340580c6045423 (diff)
downloadforums-9653764fb15de3e3126466c98525c121a8a3ac0b.tar
forums-9653764fb15de3e3126466c98525c121a8a3ac0b.tar.gz
forums-9653764fb15de3e3126466c98525c121a8a3ac0b.tar.bz2
forums-9653764fb15de3e3126466c98525c121a8a3ac0b.tar.xz
forums-9653764fb15de3e3126466c98525c121a8a3ac0b.zip
[ticket/11201] Move field type depending preparation of the options to class
PHPBB3-11201
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/acp/acp_profile.php35
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php10
-rw-r--r--phpBB/phpbb/profilefields/type/type_date.php8
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php10
-rw-r--r--phpBB/phpbb/profilefields/type/type_int.php8
-rw-r--r--phpBB/phpbb/profilefields/type/type_interface.php9
-rw-r--r--phpBB/phpbb/profilefields/type/type_string_common.php10
7 files changed, 63 insertions, 27 deletions
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 63f5a0e1f5..e682996ba8 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -341,6 +341,7 @@ class acp_profile
$this->edit_lang_id = $field_row['lang_id'];
}
$field_type = $field_row['field_type'];
+ $profile_field = $phpbb_container->get('profilefields.type.' . $cp->profile_types[$field_type]);
// Get language entries
$sql = 'SELECT *
@@ -397,23 +398,6 @@ class acp_profile
3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options')
);
- // Text-based fields require the lang_default_value to be excluded
- if ($field_type == FIELD_STRING || $field_type == FIELD_TEXT)
- {
- $exclude[1][] = 'lang_default_value';
- }
-
- // option-specific fields require lang_options to be excluded
- if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN)
- {
- $exclude[1][] = 'lang_options';
- }
-
- $cp->vars['field_ident'] = ($action == 'create' && $step == 1) ? utf8_clean_string(request_var('field_ident', $field_row['field_ident'], true)) : request_var('field_ident', $field_row['field_ident']);
- $cp->vars['lang_name'] = utf8_normalize_nfc(request_var('lang_name', $field_row['lang_name'], true));
- $cp->vars['lang_explain'] = utf8_normalize_nfc(request_var('lang_explain', $field_row['lang_explain'], true));
- $cp->vars['lang_default_value'] = utf8_normalize_nfc(request_var('lang_default_value', $field_row['lang_default_value'], true));
-
// Visibility Options...
$visibility_ary = array(
'field_required',
@@ -425,6 +409,13 @@ class acp_profile
'field_hide',
);
+ $options = $profile_field->prepare_options_form($exclude, $visibility_ary);
+
+ $cp->vars['field_ident'] = ($action == 'create' && $step == 1) ? utf8_clean_string(request_var('field_ident', $field_row['field_ident'], true)) : request_var('field_ident', $field_row['field_ident']);
+ $cp->vars['lang_name'] = utf8_normalize_nfc(request_var('lang_name', $field_row['lang_name'], true));
+ $cp->vars['lang_explain'] = utf8_normalize_nfc(request_var('lang_explain', $field_row['lang_explain'], true));
+ $cp->vars['lang_default_value'] = utf8_normalize_nfc(request_var('lang_default_value', $field_row['lang_default_value'], true));
+
foreach ($visibility_ary as $val)
{
$cp->vars[$val] = ($submit || $save) ? request_var($val, 0) : $field_row[$val];
@@ -432,16 +423,6 @@ class acp_profile
$cp->vars['field_no_view'] = request_var('field_no_view', (int) $field_row['field_no_view']);
- // A boolean field expects an array as the lang options
- if ($field_type == FIELD_BOOL)
- {
- $options = utf8_normalize_nfc(request_var('lang_options', array(''), true));
- }
- else
- {
- $options = utf8_normalize_nfc(request_var('lang_options', '', true));
- }
-
// If the user has submitted a form with options (i.e. dropdown field)
if ($options)
{
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index a3291d5ce1..f27c5af1ee 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -229,4 +229,14 @@ class type_bool implements type_interface
return $field_data;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options)
+ {
+ $exclude_options[1][] = 'lang_options';
+
+ return $this->request->variable('lang_options', array(''), true);
+ }
}
diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php
index c76c7e1d49..37b8db2779 100644
--- a/phpBB/phpbb/profilefields/type/type_date.php
+++ b/phpBB/phpbb/profilefields/type/type_date.php
@@ -271,4 +271,12 @@ class type_date implements type_interface
return $field_data;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options)
+ {
+ return $this->request->variable('lang_options', '', true);
+ }
}
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index 4313f0e64c..25671c88fa 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -222,4 +222,14 @@ class type_dropdown implements type_interface
return $field_data;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options)
+ {
+ $exclude_options[1][] = 'lang_options';
+
+ return $this->request->variable('lang_options', '', true);
+ }
}
diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php
index 9901f61795..35f021f0fa 100644
--- a/phpBB/phpbb/profilefields/type/type_int.php
+++ b/phpBB/phpbb/profilefields/type/type_int.php
@@ -196,4 +196,12 @@ class type_int implements type_interface
return $field_data;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options)
+ {
+ return $this->request->variable('lang_options', '', true);
+ }
}
diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php
index 9390c4171b..f8d5c46239 100644
--- a/phpBB/phpbb/profilefields/type/type_interface.php
+++ b/phpBB/phpbb/profilefields/type/type_interface.php
@@ -113,4 +113,13 @@ interface type_interface
* @return array Returns the language options we need to generate
*/
public function get_language_options_input($field_data);
+
+ /**
+ * Allows exclusion of options in single steps of the creation process
+ *
+ * @param array $exclude_options Array with options that should be excluded in the steps
+ * @param array $visibility_options Array with options responsible for the fields visibility
+ * @return mixed Returns the provided language options
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options);
}
diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php
index 88ca905aee..a6145e910b 100644
--- a/phpBB/phpbb/profilefields/type/type_string_common.php
+++ b/phpBB/phpbb/profilefields/type/type_string_common.php
@@ -122,4 +122,14 @@ abstract class type_string_common
return $field_data;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function prepare_options_form(&$exclude_options, &$visibility_options)
+ {
+ $exclude_options[1][] = 'lang_default_value';
+
+ return $this->request->variable('lang_options', '', true);
+ }
}