mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-28 10:40:28 +02:00
[ticket/11201] Move grabbing the input of the language options to type class
PHPBB3-11201
This commit is contained in:
@@ -48,6 +48,14 @@ class lang_helper
|
||||
|
||||
foreach ($lang_options as $num => $var)
|
||||
{
|
||||
if (!isset($this->options_lang[$field_id]))
|
||||
{
|
||||
$this->options_lang[$field_id] = array();
|
||||
}
|
||||
if (!isset($this->options_lang[$field_id][$lang_id]))
|
||||
{
|
||||
$this->options_lang[$field_id][$lang_id] = array();
|
||||
}
|
||||
$this->options_lang[$field_id][$lang_id][($num + 1)] = $var;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +112,7 @@ class lang_helper
|
||||
*/
|
||||
public function get($field_id, $lang_id, $field_value = null)
|
||||
{
|
||||
if (!is_null($field_value))
|
||||
if (is_null($field_value))
|
||||
{
|
||||
return $this->options_lang[$field_id][$lang_id];
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ class type_bool implements type_interface
|
||||
{
|
||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||
$field_ident = $profile_row['field_ident'];
|
||||
$default_value = $profile_row['lang_default_value'];
|
||||
$default_value = $profile_row['field_default_value'];
|
||||
|
||||
// checkbox - set the value to "true" if it has been set to 1
|
||||
if ($profile_row['field_length'] == 2)
|
||||
@@ -211,4 +211,22 @@ class type_bool implements type_interface
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options_input($field_data)
|
||||
{
|
||||
$field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
|
||||
$field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
|
||||
$field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
|
||||
|
||||
/**
|
||||
* @todo check if this line is correct...
|
||||
$field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => array('')), true);
|
||||
*/
|
||||
$field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => array('')), true);
|
||||
|
||||
return $field_data;
|
||||
}
|
||||
}
|
||||
|
@@ -177,6 +177,7 @@ class type_date implements type_interface
|
||||
public function generate_field($profile_row, $preview_options = false)
|
||||
{
|
||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||
$field_ident = $profile_row['field_ident'];
|
||||
|
||||
$now = getdate();
|
||||
|
||||
@@ -186,14 +187,14 @@ class type_date implements type_interface
|
||||
{
|
||||
$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
|
||||
}
|
||||
list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$user_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$user_ident]));
|
||||
list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$field_ident]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($preview_options !== false && $profile_row['field_default_value'] == 'now')
|
||||
{
|
||||
$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
|
||||
list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$user_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$user_ident]));
|
||||
list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $profile_row['field_default_value'] : $this->user->profile_fields[$field_ident]));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -257,4 +258,17 @@ class type_date implements type_interface
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options_input($field_data)
|
||||
{
|
||||
$field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
|
||||
$field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
|
||||
$field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
|
||||
$field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
|
||||
|
||||
return $field_data;
|
||||
}
|
||||
}
|
||||
|
@@ -153,7 +153,7 @@ class type_dropdown implements type_interface
|
||||
{
|
||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||
$field_ident = $profile_row['field_ident'];
|
||||
$default_value = $profile_row['lang_default_value'];
|
||||
$default_value = $profile_row['field_default_value'];
|
||||
|
||||
$value = ($this->request->is_set($field_ident)) ? $this->request->variable($field_ident, $default_value) : ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $default_value : $this->user->profile_fields[$field_ident]);
|
||||
|
||||
@@ -209,4 +209,17 @@ class type_dropdown implements type_interface
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options_input($field_data)
|
||||
{
|
||||
$field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
|
||||
$field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
|
||||
$field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
|
||||
$field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
|
||||
|
||||
return $field_data;
|
||||
}
|
||||
}
|
||||
|
@@ -124,7 +124,7 @@ class type_int implements type_interface
|
||||
{
|
||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||
$field_ident = $profile_row['field_ident'];
|
||||
$default_value = $profile_row['lang_default_value'];
|
||||
$default_value = $profile_row['field_default_value'];
|
||||
|
||||
if ($this->request->is_set($field_ident))
|
||||
{
|
||||
@@ -183,4 +183,17 @@ class type_int implements type_interface
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options_input($field_data)
|
||||
{
|
||||
$field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
|
||||
$field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
|
||||
$field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
|
||||
$field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
|
||||
|
||||
return $field_data;
|
||||
}
|
||||
}
|
||||
|
@@ -102,7 +102,15 @@ interface type_interface
|
||||
* Get the options we need to display for the language input fields in the ACP
|
||||
*
|
||||
* @param array $field_data Array with data for this field
|
||||
* @return array Returns the language options we need to generate
|
||||
* @return array Returns the language options we need to generate
|
||||
*/
|
||||
public function get_language_options($field_data);
|
||||
|
||||
/**
|
||||
* Get the input for the supplied language options
|
||||
*
|
||||
* @param array $field_data Array with data for this field
|
||||
* @return array Returns the language options we need to generate
|
||||
*/
|
||||
public function get_language_options_input($field_data);
|
||||
}
|
||||
|
@@ -109,4 +109,17 @@ abstract class type_string_common
|
||||
{
|
||||
return 'pf_' . $field_data['field_ident'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options_input($field_data)
|
||||
{
|
||||
$field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
|
||||
$field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
|
||||
$field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
|
||||
$field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
|
||||
|
||||
return $field_data;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user