diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml index 3b9b1a60a0..4fac8bed9b 100644 --- a/phpBB/config/profilefields.yml +++ b/phpBB/config/profilefields.yml @@ -12,6 +12,7 @@ services: class: \phpbb\profilefields\admin arguments: - @auth + - @config - @dbal.conn - @request - @template diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 510239a837..3c2e6448ce 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -849,7 +849,7 @@ class acp_profile // Build options based on profile type $function = 'get_' . $cp->profile_types[$field_type] . '_options'; - $options = $cp->$function(); + $options = $cp->$function($this->lang_defs); foreach ($options as $num => $option_ary) { diff --git a/phpBB/phpbb/profilefields/admin.php b/phpBB/phpbb/profilefields/admin.php index b784b91c55..1cca496265 100644 --- a/phpBB/phpbb/profilefields/admin.php +++ b/phpBB/phpbb/profilefields/admin.php @@ -17,20 +17,31 @@ class admin extends profilefields { var $vars = array(); + /** + * + */ + public function __construct($auth, $config, $db, $request, $template, $user) + { + $this->auth = $auth; + $this->config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + } + /** * Return possible validation options */ function validate_options() { - global $user; - $validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+'); $validate_options = ''; foreach ($validate_ary as $lang => $value) { $selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : ''; - $validate_options .= ''; + $validate_options .= ''; } return $validate_options; @@ -39,15 +50,13 @@ class admin extends profilefields /** * Get string options for second step in ACP */ - function get_string_options() + function get_string_options($lang_defs) { - global $user; - $options = array( - 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ''), - 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), - 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), - 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '') + 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => ''), + 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), + 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), + 3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '') ); return $options; @@ -56,15 +65,13 @@ class admin extends profilefields /** * Get text options for second step in ACP */ - function get_text_options() + function get_text_options($lang_defs) { - global $user; - $options = array( - 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ' ' . $user->lang['ROWS'] . '
' . $user->lang['COLUMNS'] . ' '), - 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), - 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), - 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '') + 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => ' ' . $user->lang['ROWS'] . '
' . $user->lang['COLUMNS'] . ' '), + 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), + 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), + 3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '') ); return $options; @@ -73,15 +80,13 @@ class admin extends profilefields /** * Get int options for second step in ACP */ - function get_int_options() + function get_int_options($lang_defs) { - global $user; - $options = array( - 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ''), - 1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'], 'FIELD' => ''), - 2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'], 'FIELD' => ''), - 3 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => '') + 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => ''), + 1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => ''), + 2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => ''), + 3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => '') ); return $options; @@ -90,11 +95,9 @@ class admin extends profilefields /** * Get bool options for second step in ACP */ - function get_bool_options() + function get_bool_options($lang_defs) { - global $user, $config, $lang_defs; - - $default_lang_id = $lang_defs['iso'][$config['default_lang']]; + $default_lang_id = $lang_defs['iso'][$this->config['default_lang']]; $profile_row = array( 'var_name' => 'field_default_value', @@ -110,8 +113,8 @@ class admin extends profilefields ); $options = array( - 0 => array('TITLE' => $user->lang['FIELD_TYPE'], 'EXPLAIN' => $user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => ''), - 1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)) + 0 => array('TITLE' => $this->user->lang['FIELD_TYPE'], 'EXPLAIN' => $this->user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => ''), + 1 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)) ); return $options; @@ -120,11 +123,9 @@ class admin extends profilefields /** * Get dropdown options for second step in ACP */ - function get_dropdown_options() + function get_dropdown_options($lang_defs) { - global $user, $config, $lang_defs; - - $default_lang_id = $lang_defs['iso'][$config['default_lang']]; + $default_lang_id = $lang_defs['iso'][$this->config['default_lang']]; $profile_row[0] = array( 'var_name' => 'field_default_value', @@ -144,8 +145,8 @@ class admin extends profilefields $profile_row[1]['field_default_value'] = $this->vars['field_novalue']; $options = array( - 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])), - 1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1])) + 0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])), + 1 => array('TITLE' => $this->user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $this->user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1])) ); return $options; @@ -154,11 +155,9 @@ class admin extends profilefields /** * Get date options for second step in ACP */ - function get_date_options() + function get_date_options($lang_defs) { - global $user, $config, $lang_defs; - - $default_lang_id = $lang_defs['iso'][$config['default_lang']]; + $default_lang_id = $lang_defs['iso'][$this->config['default_lang']]; $profile_row = array( 'var_name' => 'field_default_value', @@ -182,8 +181,8 @@ class admin extends profilefields } $options = array( - 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)), - 1 => array('TITLE' => $user->lang['ALWAYS_TODAY'], 'FIELD' => ''), + 0 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)), + 1 => array('TITLE' => $this->user->lang['ALWAYS_TODAY'], 'FIELD' => ''), ); return $options;