[ticket/11201] Remove remaining type depending code to type class

PHPBB3-11201
This commit is contained in:
Joas Schilling 2014-01-14 15:08:33 +01:00
parent 9dec023632
commit cd6bdc7b27
7 changed files with 55 additions and 6 deletions

View file

@ -72,17 +72,15 @@ class profilefields
{ {
// Return templated field // Return templated field
$tpl_snippet = $this->process_field_row('change', $row); $tpl_snippet = $this->process_field_row('change', $row);
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]);
// Some types are multivalue, we can't give them a field_id as we would not know which to pick
$type = (int) $row['field_type'];
$this->template->assign_block_vars('profile_fields', array( $this->template->assign_block_vars('profile_fields', array(
'LANG_NAME' => $row['lang_name'], 'LANG_NAME' => $row['lang_name'],
'LANG_EXPLAIN' => $row['lang_explain'], 'LANG_EXPLAIN' => $row['lang_explain'],
'FIELD' => $tpl_snippet, 'FIELD' => $tpl_snippet,
'FIELD_ID' => ($type == FIELD_DATE || ($type == FIELD_BOOL && $row['field_length'] == '1')) ? '' : 'pf_' . $row['field_ident'], 'FIELD_ID' => $profile_field->get_field_ident($row),
'S_REQUIRED' => ($row['field_required']) ? true : false) 'S_REQUIRED' => ($row['field_required']) ? true : false,
); ));
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
} }

View file

@ -176,4 +176,12 @@ class type_bool implements type_interface
} }
} }
} }
/**
* {@inheritDoc}
*/
public function get_field_ident($field_data)
{
return ($field_data['field_length'] == '1') ? '' : 'pf_' . $field_data['field_ident'];
}
} }

View file

@ -224,4 +224,12 @@ class type_date implements type_interface
$profile_row['field_value'] = 0; $profile_row['field_value'] = 0;
$this->template->assign_block_vars('date', array_change_key_case($profile_row, CASE_UPPER)); $this->template->assign_block_vars('date', array_change_key_case($profile_row, CASE_UPPER));
} }
/**
* {@inheritDoc}
*/
public function get_field_ident($field_data)
{
return '';
}
} }

View file

@ -173,4 +173,12 @@ class type_dropdown implements type_interface
); );
} }
} }
/**
* {@inheritDoc}
*/
public function get_field_ident($field_data)
{
return 'pf_' . $field_data['field_ident'];
}
} }

View file

@ -150,4 +150,12 @@ class type_int implements type_interface
$this->template->assign_block_vars('int', array_change_key_case($profile_row, CASE_UPPER)); $this->template->assign_block_vars('int', array_change_key_case($profile_row, CASE_UPPER));
} }
/**
* {@inheritDoc}
*/
public function get_field_ident($field_data)
{
return 'pf_' . $field_data['field_ident'];
}
} }

View file

@ -79,4 +79,15 @@ interface type_interface
* @return null * @return null
*/ */
public function generate_field($profile_row, $preview = false); public function generate_field($profile_row, $preview = false);
/**
* Get the ident of the field
*
* Some types are multivalue, we can't give them a field_id
* as we would not know which to pick.
*
* @param array $field_data Array with data for this field
* @return string ident of the field
*/
public function get_field_ident($field_data);
} }

View file

@ -101,4 +101,12 @@ abstract class type_string_common
$field_value = bbcode_nl2br($field_value); $field_value = bbcode_nl2br($field_value);
return $field_value; return $field_value;
} }
/**
* {@inheritDoc}
*/
public function get_field_ident($field_data)
{
return 'pf_' . $field_data['field_ident'];
}
} }