diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-02-02 18:00:17 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-02-06 11:32:08 +0100 |
commit | f97d268a79502243c6bf259cde854519eea42391 (patch) | |
tree | b5619524439eba76cdc21e026210d66543308b84 /phpBB/phpbb/profilefields | |
parent | 38608bfa62ff9bed744759969345339bd6c60fbf (diff) | |
download | forums-f97d268a79502243c6bf259cde854519eea42391.tar forums-f97d268a79502243c6bf259cde854519eea42391.tar.gz forums-f97d268a79502243c6bf259cde854519eea42391.tar.bz2 forums-f97d268a79502243c6bf259cde854519eea42391.tar.xz forums-f97d268a79502243c6bf259cde854519eea42391.zip |
[ticket/12115] Translate profile field name before displaying it in errors
PHPBB3-12115
Diffstat (limited to 'phpBB/phpbb/profilefields')
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_base.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_bool.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_date.php | 6 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_dropdown.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_int.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_interface.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/type/type_string_common.php | 12 |
7 files changed, 31 insertions, 14 deletions
diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php index 95e9b8768b..9c363a7b4e 100644 --- a/phpBB/phpbb/profilefields/type/type_base.php +++ b/phpBB/phpbb/profilefields/type/type_base.php @@ -79,6 +79,14 @@ abstract class type_base implements type_interface /** * {@inheritDoc} */ + public function get_field_name($field_name) + { + return isset($this->user->lang[$field_name]) ? $this->user->lang[$field_name] : $field_name; + } + + /** + * {@inheritDoc} + */ public function get_language_options_input($field_data) { $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php index 47a5ed4992..fa9c0a8714 100644 --- a/phpBB/phpbb/profilefields/type/type_bool.php +++ b/phpBB/phpbb/profilefields/type/type_bool.php @@ -136,7 +136,7 @@ class type_bool extends type_base if (!$field_value && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php index 0de80f2baf..fc012dd97a 100644 --- a/phpBB/phpbb/profilefields/type/type_date.php +++ b/phpBB/phpbb/profilefields/type/type_date.php @@ -159,17 +159,17 @@ class type_date extends type_base if ((!$day || !$month || !$year) && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } if ($day < 0 || $day > 31 || $month < 0 || $month > 12 || ($year < 1901 && $year > 0) || $year > gmdate('Y', time()) + 50) { - return $this->user->lang('FIELD_INVALID_DATE', $field_data['lang_name']); + return $this->user->lang('FIELD_INVALID_DATE', $this->get_field_name($field_data['lang_name'])); } if (checkdate($month, $day, $year) === false) { - return $this->user->lang('FIELD_INVALID_DATE', $field_data['lang_name']); + return $this->user->lang('FIELD_INVALID_DATE', $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php index b5b393d91b..bcf0ba05f9 100644 --- a/phpBB/phpbb/profilefields/type/type_dropdown.php +++ b/phpBB/phpbb/profilefields/type/type_dropdown.php @@ -137,12 +137,12 @@ class type_dropdown extends type_base if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], $field_value)) { - return $this->user->lang('FIELD_INVALID_VALUE', $field_data['lang_name']); + return $this->user->lang('FIELD_INVALID_VALUE', $this->get_field_name($field_data['lang_name'])); } if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index 77a4f813da..b89faca018 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -126,11 +126,11 @@ class type_int extends type_base if ($field_value < $field_data['field_minlen']) { - return $this->user->lang('FIELD_TOO_SMALL', (int) $row['field_minlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_SMALL', (int) $field_data['field_minlen'], $this->get_field_name($field_data['lang_name'])); } else if ($field_value > $field_data['field_maxlen']) { - return $this->user->lang('FIELD_TOO_LARGE', (int) $row['field_maxlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_LARGE', (int) $field_data['field_maxlen'], $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index 7d0cf7662f..93020935e9 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -174,4 +174,13 @@ interface type_interface * @return null */ public function display_options(&$template_vars, &$field_data); + + /** + * Return templated value/field. Possible values for $mode are: + * change == user is able to set/enter profile values; preview == just show the value + * @param string $mode + * @param array $profile_row + * @return null + */ + public function process_field_row($mode, $profile_row); } diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index d322099c34..f00a7e6a08 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -52,16 +52,16 @@ abstract class type_string_common extends type_base } else if (trim($field_value) === '' && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } if ($field_data['field_minlen'] && utf8_strlen($field_value) < $field_data['field_minlen']) { - return $this->user->lang('FIELD_TOO_SHORT', (int) $row['field_minlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_SHORT', (int) $field_data['field_minlen'], $this->get_field_name($field_data['lang_name'])); } else if ($field_data['field_maxlen'] && utf8_strlen($field_value) > $field_data['field_maxlen']) { - return $this->user->lang('FIELD_TOO_LONG', (int) $row['field_maxlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_LONG', (int) $field_data['field_maxlen'], $this->get_field_name($field_data['lang_name'])); } if (!empty($field_data['field_validation']) && $field_data['field_validation'] != '.*') @@ -72,13 +72,13 @@ abstract class type_string_common extends type_base switch ($row['field_validation']) { case '[0-9]+': - return $this->user->lang('FIELD_INVALID_CHARS_NUMBERS_ONLY', $row['lang_name']); + return $this->user->lang('FIELD_INVALID_CHARS_NUMBERS_ONLY', $this->get_field_name($field_data['lang_name'])); case '[\w]+': - return $this->user->lang('FIELD_INVALID_CHARS_ALPHA_ONLY', $row['lang_name']); + return $this->user->lang('FIELD_INVALID_CHARS_ALPHA_ONLY', $this->get_field_name($field_data['lang_name'])); case '[\w_\+\. \-\[\]]+': - return $this->user->lang('FIELD_INVALID_CHARS_SPACERS_ONLY', $row['lang_name']); + return $this->user->lang('FIELD_INVALID_CHARS_SPACERS_ONLY', $this->get_field_name($field_data['lang_name'])); } } } |