[ticket/11201] Add a method to return the translated full name of the type

PHPBB3-11201
This commit is contained in:
Joas Schilling 2014-01-18 13:08:15 +01:00
parent df85364baa
commit 197e026699
10 changed files with 28 additions and 13 deletions

View file

@ -625,7 +625,7 @@ class acp_profile
'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false, 'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false,
'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']), 'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']),
'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($profile_field->get_name())], 'FIELD_TYPE' => $profile_field->get_name(),
'FIELD_IDENT' => $cp->vars['field_ident'], 'FIELD_IDENT' => $cp->vars['field_ident'],
'LANG_NAME' => $cp->vars['lang_name'], 'LANG_NAME' => $cp->vars['lang_name'],
'LANG_EXPLAIN' => $cp->vars['lang_explain'], 'LANG_EXPLAIN' => $cp->vars['lang_explain'],
@ -712,7 +712,7 @@ class acp_profile
$profile_field = $this->type_collection[$row['field_type']]; $profile_field = $this->type_collection[$row['field_type']];
$template->assign_block_vars('fields', array( $template->assign_block_vars('fields', array(
'FIELD_IDENT' => $row['field_ident'], 'FIELD_IDENT' => $row['field_ident'],
'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($profile_field->get_name())], 'FIELD_TYPE' => $profile_field->get_name(),
'L_ACTIVATE_DEACTIVATE' => $user->lang[$active_lang], 'L_ACTIVATE_DEACTIVATE' => $user->lang[$active_lang],
'U_ACTIVATE_DEACTIVATE' => $this->u_action . "&action=$active_value&field_id=$id", 'U_ACTIVATE_DEACTIVATE' => $this->u_action . "&action=$active_value&field_id=$id",
@ -736,7 +736,7 @@ class acp_profile
$s_select_type = ''; $s_select_type = '';
foreach ($this->type_collection as $key => $profile_field) foreach ($this->type_collection as $key => $profile_field)
{ {
$s_select_type .= '<option value="' . $key . '">' . $user->lang['FIELD_' . strtoupper($profile_field->get_name())] . '</option>'; $s_select_type .= '<option value="' . $key . '">' . $profile_field->get_name() . '</option>';
} }
$template->assign_vars(array( $template->assign_vars(array(

View file

@ -322,7 +322,7 @@ class profilefields
// empty previously filled blockvars // empty previously filled blockvars
foreach ($this->type_collection as $field_key => $field_type) foreach ($this->type_collection as $field_key => $field_type)
{ {
$this->template->destroy_block_vars($field_type->get_name()); $this->template->destroy_block_vars($field_type->get_name_short());
} }
// Assign template variables // Assign template variables

View file

@ -44,12 +44,20 @@ abstract class type_base implements type_interface
$this->user = $user; $this->user = $user;
} }
/**
* {@inheritDoc}
*/
public function get_name()
{
return $this->user->lang('FIELD_' . strtoupper($this->get_name_short()));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_service_name() public function get_service_name()
{ {
return 'profilefields.type.' . $this->get_name(); return 'profilefields.type.' . $this->get_name_short();
} }
/** /**

View file

@ -63,7 +63,7 @@ class type_bool extends type_base
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_name() public function get_name_short()
{ {
return 'bool'; return 'bool';
} }

View file

@ -55,7 +55,7 @@ class type_date extends type_base
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_name() public function get_name_short()
{ {
return 'date'; return 'date';
} }

View file

@ -63,7 +63,7 @@ class type_dropdown extends type_base
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_name() public function get_name_short()
{ {
return 'dropdown'; return 'dropdown';
} }

View file

@ -47,7 +47,7 @@ class type_int extends type_base
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_name() public function get_name_short()
{ {
return 'int'; return 'int';
} }

View file

@ -12,11 +12,18 @@ namespace phpbb\profilefields\type;
interface type_interface interface type_interface
{ {
/** /**
* Get the name of the type, used for error messages and template loops * Get the translated name of the type
*
* @return string Translated name of the field type
*/
public function get_name();
/**
* Get the short name of the type, used for error messages and template loops
* *
* @return string lowercase version of the fields type * @return string lowercase version of the fields type
*/ */
public function get_name(); public function get_name_short();
/** /**
* Get the name of service representing the type * Get the name of service representing the type

View file

@ -47,7 +47,7 @@ class type_string extends type_string_common
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_name() public function get_name_short()
{ {
return 'string'; return 'string';
} }

View file

@ -47,7 +47,7 @@ class type_text extends type_string_common
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function get_name() public function get_name_short()
{ {
return 'text'; return 'text';
} }