mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/11201] Move custom template variable assignment to type class
PHPBB3-11201
This commit is contained in:
@@ -95,4 +95,12 @@ abstract class type_base implements type_interface
|
||||
return $this->request->variable($key, '', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function display_options(&$template_vars, &$field_data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -326,4 +326,25 @@ class type_bool extends type_base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function display_options(&$template_vars, &$field_data)
|
||||
{
|
||||
// Initialize these array elements if we are creating a new field
|
||||
if (!sizeof($field_data['lang_options']))
|
||||
{
|
||||
// No options have been defined for a boolean field.
|
||||
$field_data['lang_options'][0] = '';
|
||||
$field_data['lang_options'][1] = '';
|
||||
}
|
||||
|
||||
$template_vars = array_merge($template_vars, array(
|
||||
'S_BOOL' => true,
|
||||
'L_LANG_OPTIONS_EXPLAIN' => $this->user->lang['BOOL_ENTRIES_EXPLAIN'],
|
||||
'FIRST_LANG_OPTION' => $field_data['lang_options'][0],
|
||||
'SECOND_LANG_OPTION' => $field_data['lang_options'][1],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -314,7 +314,7 @@ class type_date extends type_base
|
||||
{
|
||||
return 'now';
|
||||
}
|
||||
else if ($this->request->is_set'field_default_value_day'))
|
||||
else if ($this->request->is_set('field_default_value_day'))
|
||||
{
|
||||
$field_data['field_default_value_day'] = $this->request->variable('field_default_value_day', 0);
|
||||
$field_data['field_default_value_month'] = $this->request->variable('field_default_value_month', 0);
|
||||
|
@@ -239,4 +239,23 @@ class type_dropdown extends type_base
|
||||
|
||||
return parent::get_excluded_options($key, $action, $current_value, $field_data, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function display_options(&$template_vars, &$field_data)
|
||||
{
|
||||
// Initialize these array elements if we are creating a new field
|
||||
if (!sizeof($field_data['lang_options']))
|
||||
{
|
||||
// No options have been defined for the dropdown menu
|
||||
$field_data['lang_options'] = array();
|
||||
}
|
||||
|
||||
$template_vars = array_merge($template_vars, array(
|
||||
'S_DROPDOWN' => true,
|
||||
'L_LANG_OPTIONS_EXPLAIN' => $this->user->lang['DROPDOWN_ENTRIES_EXPLAIN'],
|
||||
'LANG_OPTIONS' => implode("\n", $field_data['lang_options']),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -11,16 +11,6 @@ namespace phpbb\profilefields\type;
|
||||
|
||||
interface type_interface
|
||||
{
|
||||
/*
|
||||
public function validate(&$value, $validation);
|
||||
|
||||
public function prepare_for_storage($value);
|
||||
|
||||
public function prepare_for_display($value);
|
||||
|
||||
public function prepare_for_edit($value);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get dropdown options for second step in ACP
|
||||
*
|
||||
@@ -154,4 +144,13 @@ interface type_interface
|
||||
* @return mixed Final value of the option
|
||||
*/
|
||||
public function prepare_hidden_fields($step, $key, $action, &$field_data);
|
||||
|
||||
/**
|
||||
* Allows assigning of additional template variables
|
||||
*
|
||||
* @param array $template_vars Template variables we are going to assign
|
||||
* @param array $field_data Array with data for this field
|
||||
* @return null
|
||||
*/
|
||||
public function display_options(&$template_vars, &$field_data);
|
||||
}
|
||||
|
@@ -110,4 +110,16 @@ class type_string extends type_string_common
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function display_options(&$template_vars, &$field_data)
|
||||
{
|
||||
$template_vars = array_merge($template_vars, array(
|
||||
'S_STRING' => true,
|
||||
'L_DEFAULT_VALUE_EXPLAIN' => $this->user->lang['STRING_DEFAULT_VALUE_EXPLAIN'],
|
||||
'LANG_DEFAULT_VALUE' => $field_data['lang_default_value'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -155,4 +155,16 @@ class type_text extends type_string_common
|
||||
|
||||
return parent::prepare_hidden_fields($step, $key, $action, $field_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function display_options(&$template_vars, &$field_data)
|
||||
{
|
||||
$template_vars = array_merge($template_vars, array(
|
||||
'S_TEXT' => true,
|
||||
'L_DEFAULT_VALUE_EXPLAIN' => $this->user->lang['TEXT_DEFAULT_VALUE_EXPLAIN'],
|
||||
'LANG_DEFAULT_VALUE' => $field_data['lang_default_value'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user