1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

Merge pull request #2647 from Dragooon/ticket/12334

[ticket/12334] Add PROFILE_FIELD_VALUE_RAW template var

* Dragooon/ticket/12334:
  [ticket/12334] Remove profile fields test group
  [ticket/12334] Add additional test for type_string
  [ticket/12334] Add string test for type_int
  [ticket/12334] Improve type_dropdown's test description
  [ticket/12334] Group profile fields test
  [ticket/12334] Change get_profile_value_raw_data to profile_value_raw_data
  [ticket/12334] Add get_profile_value_raw unit test for type_bool
  [ticket/12334] Add get_profile_value_raw unit test for type_date
  [ticket/12334] Add get_profile_value_raw unit tests for type_dropdown
  [ticket/12334] Add get_profile_value_raw unit test for type_string
  [ticket/12334] Add get_profile_value_raw unit test for type_url
  [ticket/12334] Add get_profile_value_raw unit tests for type_int
  [ticket/12334] Removed tests
  [ticket/12334] Dropdowns cannot be tested this way
  [ticket/12334] Added test get_profile_value_raw
  [ticket/12334] Changed from valueid to value_raw
  [ticket/12334] Implemented get_profile_valueid method
  [ticket/12334] Added field_novalue fall-back as requested
  [ticket/12334] Add PROFILE_FIELD_VALUEID template var
This commit is contained in:
Joas Schilling
2014-07-03 11:21:16 +02:00
13 changed files with 380 additions and 18 deletions

View File

@@ -389,6 +389,7 @@ class manager
{
$profile_field = $this->type_collection[$ident_ary['data']['field_type']];
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
$value_raw = $profile_field->get_profile_value_raw($ident_ary['value'], $ident_ary['data']);
if ($value === null)
{
@@ -412,26 +413,28 @@ class manager
}
$tpl_fields['row'] += array(
'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident,
'PROFILE_' . strtoupper($ident) . '_VALUE' => $value,
'PROFILE_' . strtoupper($ident) . '_CONTACT'=> $contact_url,
'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc,
'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $this->user->lang($ident_ary['data']['lang_explain']),
'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident,
'PROFILE_' . strtoupper($ident) . '_VALUE' => $value,
'PROFILE_' . strtoupper($ident) . '_VALUE_RAW' => $value_raw,
'PROFILE_' . strtoupper($ident) . '_CONTACT' => $contact_url,
'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc,
'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
'PROFILE_' . strtoupper($ident) . '_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
'S_PROFILE_' . strtoupper($ident) . '_CONTACT' => $ident_ary['data']['field_is_contact'],
'S_PROFILE_' . strtoupper($ident) => true,
);
$tpl_fields['blockrow'][] = array(
'PROFILE_FIELD_IDENT' => $ident,
'PROFILE_FIELD_VALUE' => $value,
'PROFILE_FIELD_CONTACT' => $contact_url,
'PROFILE_FIELD_DESC' => $field_desc,
'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'],
'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
'PROFILE_FIELD_IDENT' => $ident,
'PROFILE_FIELD_VALUE' => $value,
'PROFILE_FIELD_VALUE_RAW' => $value_raw,
'PROFILE_FIELD_CONTACT' => $contact_url,
'PROFILE_FIELD_DESC' => $field_desc,
'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'],
'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'],
'S_PROFILE_' . strtoupper($ident) => true,

View File

@@ -177,6 +177,24 @@ class type_bool extends type_base
}
}
/**
* {@inheritDoc}
*/
public function get_profile_value_raw($field_value, $field_data)
{
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
{
return null;
}
if (!$field_value && $field_data['field_show_novalue'])
{
$field_value = $field_data['field_novalue'];
}
return $field_value;
}
/**
* {@inheritDoc}
*/

View File

@@ -205,6 +205,19 @@ class type_date extends type_base
return $field_value;
}
/**
* {@inheritDoc}
*/
public function get_profile_value_raw($field_value, $field_data)
{
if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
{
return null;
}
return $field_value;
}
/**
* {@inheritDoc}
*/

View File

@@ -186,6 +186,24 @@ class type_dropdown extends type_base
return $this->lang_helper->get($field_id, $lang_id, $field_value);
}
/**
* {@inheritDoc}
*/
public function get_profile_value_raw($field_value, $field_data)
{
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
{
return null;
}
if (!$field_value && $field_data['field_show_novalue'])
{
$field_value = $field_data['field_novalue'];
}
return $field_value;
}
/**
* {@inheritDoc}
*/

View File

@@ -151,6 +151,18 @@ class type_int extends type_base
return (int) $field_value;
}
/**
* {@inheritDoc}
*/
public function get_profile_value_raw($field_value, $field_data)
{
if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
{
return null;
}
return (int) $field_value;
}
/**
* {@inheritDoc}
*/

View File

@@ -93,6 +93,15 @@ interface type_interface
*/
public function get_profile_value($field_value, $field_data);
/**
* Get Profile Value ID for display (the raw, unprocessed user data)
*
* @param mixed $field_value Field value as stored in the database
* @param array $field_data Array with requirements of the field
* @return mixed Field value ID to display
*/
public function get_profile_value_raw($field_value, $field_data);
/**
* Get Profile Value for display
*

View File

@@ -109,6 +109,19 @@ abstract class type_string_common extends type_base
return $field_value;
}
/**
* {@inheritDoc}
*/
public function get_profile_value_raw($field_value, $field_data)
{
if (!$field_value && !$field_data['field_show_novalue'])
{
return null;
}
return $field_value;
}
/**
* {@inheritDoc}
*/