mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/11201] Move language option determination into type class
PHPBB3-11201
This commit is contained in:
parent
bd1425d075
commit
78603bb96d
8 changed files with 126 additions and 26 deletions
|
@ -942,7 +942,7 @@ class acp_profile
|
|||
*/
|
||||
function build_language_options(&$cp, $field_type, $action = 'create')
|
||||
{
|
||||
global $user, $config, $db;
|
||||
global $user, $config, $db, $phpbb_container;
|
||||
|
||||
$default_lang_id = (!empty($this->edit_lang_id)) ? $this->edit_lang_id : $this->lang_defs['iso'][$config['default_lang']];
|
||||
|
||||
|
@ -959,31 +959,9 @@ class acp_profile
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$options = array();
|
||||
$options['lang_name'] = 'string';
|
||||
if ($cp->vars['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
switch ($field_type)
|
||||
{
|
||||
case FIELD_BOOL:
|
||||
$options['lang_options'] = 'two_options';
|
||||
break;
|
||||
|
||||
case FIELD_DROPDOWN:
|
||||
$options['lang_options'] = 'optionfield';
|
||||
break;
|
||||
|
||||
case FIELD_TEXT:
|
||||
case FIELD_STRING:
|
||||
if (strlen($cp->vars['lang_default_value']))
|
||||
{
|
||||
$options['lang_default_value'] = ($field_type == FIELD_STRING) ? 'string' : 'text';
|
||||
}
|
||||
break;
|
||||
}
|
||||
$type_collection = $phpbb_container->get('profilefields.type_collection');
|
||||
$profile_type = $type_collection['profilefields.type.' . $cp->profile_types[$field_type]];
|
||||
$options = $profile_type->get_language_options($cp->vars);
|
||||
|
||||
$lang_options = array();
|
||||
|
||||
|
|
|
@ -193,4 +193,22 @@ class type_bool implements type_interface
|
|||
{
|
||||
return 'TINT:2';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options($field_data)
|
||||
{
|
||||
$options = array(
|
||||
'lang_name' => 'string',
|
||||
'lang_options' => 'two_options',
|
||||
);
|
||||
|
||||
if ($field_data['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,4 +240,21 @@ class type_date implements type_interface
|
|||
{
|
||||
return 'VCHAR:10';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options($field_data)
|
||||
{
|
||||
$options = array(
|
||||
'lang_name' => 'string',
|
||||
);
|
||||
|
||||
if ($field_data['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,4 +191,22 @@ class type_dropdown implements type_interface
|
|||
{
|
||||
return 'UINT';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options($field_data)
|
||||
{
|
||||
$options = array(
|
||||
'lang_name' => 'string',
|
||||
'lang_options' => 'optionfield',
|
||||
);
|
||||
|
||||
if ($field_data['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,4 +166,21 @@ class type_int implements type_interface
|
|||
{
|
||||
return 'BINT';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options($field_data)
|
||||
{
|
||||
$options = array(
|
||||
'lang_name' => 'string',
|
||||
);
|
||||
|
||||
if ($field_data['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,4 +97,12 @@ interface type_interface
|
|||
* @return string Returns the database column type
|
||||
*/
|
||||
public function get_database_column_type();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function get_language_options($field_data);
|
||||
}
|
||||
|
|
|
@ -88,4 +88,26 @@ class type_string extends type_string_common implements type_interface
|
|||
{
|
||||
return 'VCHAR';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options($field_data)
|
||||
{
|
||||
$options = array(
|
||||
'lang_name' => 'string',
|
||||
);
|
||||
|
||||
if ($field_data['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
if (strlen($field_data['lang_default_value']))
|
||||
{
|
||||
$options['lang_default_value'] = 'string';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,26 @@ class type_text extends type_string_common implements type_interface
|
|||
{
|
||||
return 'MTEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_language_options($field_data)
|
||||
{
|
||||
$options = array(
|
||||
'lang_name' => 'string',
|
||||
);
|
||||
|
||||
if ($field_data['lang_explain'])
|
||||
{
|
||||
$options['lang_explain'] = 'text';
|
||||
}
|
||||
|
||||
if (strlen($field_data['lang_default_value']))
|
||||
{
|
||||
$options['lang_default_value'] = 'text';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue