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

[ticket/17151] Adjust code styling

PHPBB3-17151
This commit is contained in:
rxu
2023-10-03 08:28:50 +07:00
parent f28d33726e
commit 3597c15100
6 changed files with 61 additions and 49 deletions

View File

@@ -180,12 +180,12 @@ class acp_attachments
'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'max_attachments' => array('lang' => 'MAX_ATTACHMENTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => false),
'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => false),
'display_order' => array('lang' => 'DISPLAY_ORDER', 'validate' => 'bool', 'type' => 'radio', 'function' => 'build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', ['DESCENDING', 'ASCENDING']], 'explain' => true),
'display_order' => array('lang' => 'DISPLAY_ORDER', 'validate' => 'bool', 'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', ['DESCENDING', 'ASCENDING']], 'explain' => true),
'attachment_quota' => array('lang' => 'ATTACH_QUOTA', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true),
'max_filesize' => array('lang' => 'ATTACH_MAX_FILESIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true),
'max_filesize_pm' => array('lang' => 'ATTACH_MAX_PM_FILESIZE','validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true),
'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'radio', 'function' => 'build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW']], 'explain' => true),
'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW']], 'explain' => true),
'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'check_attachment_content' => array('lang' => 'CHECK_CONTENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@@ -331,7 +331,7 @@ class acp_attachments
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
$content = phpbb_build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
if (empty($content))
{
continue;

View File

@@ -86,8 +86,8 @@ class acp_board
'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true),
'legend2' => 'BOARD_STYLE',
'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'method' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'guest_style' => array('lang' => 'GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'method' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true),
'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'method' => 'phpbb_style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'guest_style' => array('lang' => 'GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'method' => 'phpbb_style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true),
'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'legend3' => 'WARNINGS',
@@ -432,10 +432,10 @@ class acp_board
'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_password_reset' => array('lang' => 'ALLOW_PASSWORD_RESET', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'radio', 'function' => 'build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION']], 'explain' => true),
'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION']], 'explain' => true),
'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'forwarded_for_check' => array('lang' => 'FORWARDED_FOR_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'referer_validation' => array('lang' => 'REFERRER_VALID', 'validate' => 'int:0:3','type' => 'radio', 'function' => 'build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION']], 'explain' => true),
'referer_validation' => array('lang' => 'REFERRER_VALID', 'validate' => 'int:0:3','type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION']], 'explain' => true),
'check_dnsbl' => array('lang' => 'CHECK_DNSBL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'email_check_mx' => array('lang' => 'EMAIL_CHECK_MX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true),
@@ -798,7 +798,7 @@ class acp_board
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
$content = phpbb_build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
if (empty($content))
{
@@ -1110,12 +1110,12 @@ class acp_board
/**
* Wrapper function for style_select()
*
* @param string $default Style ID to be selected in the dropdown list
* @param bool $all Flag indicating if all styles data including inactive should be fetched
* @param int|string $default Style ID to be selected in the dropdown list
* @param bool $all Flag indicating if all styles data including inactive should be fetched
*
* @return array
*/
public function style_select($default, $all): array
public function phpbb_style_select(int|string $default, bool $all): array
{
global $db;
@@ -1127,7 +1127,7 @@ class acp_board
*/
function board_disable($value, $key)
{
$options = build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
$options = phpbb_build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
return [
array_merge(['tag' => 'radio'], $options),
@@ -1178,7 +1178,7 @@ class acp_board
{
global $language;
$options = build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
$options = phpbb_build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
return [
array_merge(['tag' => 'radio', 'append' => '<br><br>'], $options),
@@ -1436,7 +1436,7 @@ class acp_board
$value = ($mod_rewrite === false) ? 0 : $value;
$message = $mod_rewrite === null ? 'MOD_REWRITE_INFORMATION_UNAVAILABLE' : ($mod_rewrite === false ? 'MOD_REWRITE_DISABLED' : false);
$options = build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
$options = phpbb_build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
foreach ($options['buttons'] as $i => $button)
{
$options['buttons'][$i]['disabled'] = $message === 'MOD_REWRITE_DISABLED';

View File

@@ -208,14 +208,19 @@ function adm_back_link($u_action)
}
/**
* Build select field options in acp pages
*/
function build_select($option_ary, $option_default = false): array
* Build select field options in acp pages
*
* @param array $options_ary Configuration options data
* @param int|string|bool $option_default Configuration option selected value
*
* @return array
*/
function build_select(array $options_ary, int|string|bool $option_default = false): array
{
global $language;
$options = [];
foreach ($option_ary as $value => $title)
foreach ($options_ary as $value => $title)
{
$options[] = [
'value' => $value,
@@ -228,21 +233,28 @@ function build_select($option_ary, $option_default = false): array
}
/**
* Build radio fields in acp pages
*/
function build_radio($value, $key, $options)
* Build radio fields in acp pages
*
* @param int|string $value Configuration option value
* @param string $key Configuration option key name
* @param array $options Configuration options data
* representing array of [values => language_keys]
*
* @return array
*/
function phpbb_build_radio(int|string $value, string $key, array $options): array
{
global $language;
$buttons = [];
foreach ($options as $val => $option)
foreach ($options as $val => $title)
{
$buttons[] = [
'type' => 'radio',
'value' => $val,
'name' => 'config[' . $key . ']',
'checked' => $val == $value,
'label' => $language->lang($option),
'label' => $language->lang($title),
];
}
@@ -254,15 +266,15 @@ function build_radio($value, $key, $options)
/**
* Build configuration data arrays or templates for configuration settings
*
* @param array $tpl_type Configuration setting type data
* @param string $key Configuration option name
* @param array $new_ary Updated configuration data
* @param string $config_key Configuration option name
* @param Array $vars Configuration setting data
* @param array $tpl_type Configuration setting type data
* @param string $key Configuration option name
* @param array|object $new_ary Updated configuration data
* @param string $config_key Configuration option name
* @param array $vars Configuration setting data
*
* @return array|string
*/
function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars)
function phpbb_build_cfg_template(array $tpl_type, string $key, array|object &$new_ary, string $config_key, array $vars): array|string
{
global $language, $module, $phpbb_dispatcher;
@@ -380,7 +392,7 @@ function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars)
{
$options = array_reverse(explode('_', strtoupper($tpl_type[1])));
krsort($options);
$tpl_type = array_merge ($tpl_type, build_radio($new_ary[$config_key], $config_key, $options));
$tpl_type = array_merge ($tpl_type, phpbb_build_radio($new_ary[$config_key], $config_key, $options));
}
}
case 'button':

View File

@@ -179,7 +179,7 @@ class ucp_prefs
$lang_options = phpbb_language_select($db, $data['lang'], $lang_row);
$template->assign_vars(array(
$template->assign_vars([
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
'S_NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
@@ -215,9 +215,9 @@ class ucp_prefs
'name' => 'tz',
'options' => $timezone_select,
],
'S_CAN_HIDE_ONLINE' => ($auth->acl_get('u_hideonline')) ? true : false,
'S_SELECT_NOTIFY' => ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')) ? true : false)
);
'S_CAN_HIDE_ONLINE' => (bool) $auth->acl_get('u_hideonline'),
'S_SELECT_NOTIFY' => (bool) ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')),
]);
break;