[ticket/10824] Clean up coding style in list_style

PHPBB3-10824
This commit is contained in:
Marc Alexander 2021-01-14 22:15:28 +01:00
parent 10151ae642
commit 5bff0c0761
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -965,7 +965,7 @@ class acp_styles
* @param array $style style row * @param array $style style row
* @param int $level style inheritance level * @param int $level style inheritance level
*/ */
protected function list_style(&$style, $level) protected function list_style(array &$style, int $level) : void
{ {
// Mark row as shown // Mark row as shown
if (!empty($style['_shown'])) if (!empty($style['_shown']))
@ -978,8 +978,8 @@ class acp_styles
$style_cfg = $this->read_style_composer_file($style['style_path']); $style_cfg = $this->read_style_composer_file($style['style_path']);
// Generate template variables // Generate template variables
$actions = array(); $actions = [];
$row = array( $row = [
// Style data // Style data
'STYLE_ID' => $style['style_id'], 'STYLE_ID' => $style['style_id'],
'STYLE_NAME' => htmlspecialchars($style['style_name'], ENT_COMPAT), 'STYLE_NAME' => htmlspecialchars($style['style_name'], ENT_COMPAT),
@ -991,19 +991,19 @@ class acp_styles
// Additional data // Additional data
'DEFAULT' => ($style['style_id'] && $style['style_id'] == $this->default_style), 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $this->default_style),
'USERS' => (isset($style['_users'])) ? $style['_users'] : '', 'USERS' => $style['_users'] ?? '',
'LEVEL' => $level, 'LEVEL' => $level,
'PADDING' => (4 + 16 * $level), 'PADDING' => (4 + 16 * $level),
'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true, 'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true,
'STYLE_PATH_FULL' => htmlspecialchars($this->styles_path_absolute . '/' . $style['style_path'], ENT_COMPAT) . '/', 'STYLE_PATH_FULL' => htmlspecialchars($this->styles_path_absolute . '/' . $style['style_path'], ENT_COMPAT) . '/',
// Comment to show below style // Comment to show below style
'COMMENT' => (isset($style['_note'])) ? $style['_note'] : '', 'COMMENT' => $style['_note'] ?? '',
// The following variables should be used by hooks to add custom HTML code // The following variables should be used by hooks to add custom HTML code
'EXTRA' => '', 'EXTRA' => '',
'EXTRA_OPTIONS' => '' 'EXTRA_OPTIONS' => ''
); ];
// Status specific data // Status specific data
if ($style['style_id']) if ($style['style_id'])
@ -1011,60 +1011,52 @@ class acp_styles
// Style is installed // Style is installed
// Details // Details
$actions[] = array( $actions[] = [
'U_ACTION' => $this->u_action . '&action=details&id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&action=details&id=' . $style['style_id'],
'L_ACTION' => $this->language->lang('DETAILS') 'L_ACTION' => $this->language->lang('DETAILS')
); ];
// Activate/Deactive // Activate/Deactivate
$action_name = ($style['style_active'] ? 'de' : '') . 'activate'; $action_name = ($style['style_active'] ? 'de' : '') . 'activate';
$actions[] = array( $actions[] = [
'U_ACTION' => $this->u_action . '&action=' . $action_name . '&hash=' . generate_link_hash($action_name) . '&id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&action=' . $action_name . '&hash=' . generate_link_hash($action_name) . '&id=' . $style['style_id'],
'L_ACTION' => $this->language->lang('STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE') 'L_ACTION' => $this->language->lang('STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE')
); ];
/* // Export
$actions[] = array(
'U_ACTION' => $this->u_action . '&action=export&hash=' . generate_link_hash('export') . '&id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['EXPORT']
); */
if ($style['style_name'] !== 'prosilver') if ($style['style_name'] !== 'prosilver')
{ {
// Uninstall // Uninstall
$actions[] = array( $actions[] = [
'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'],
'L_ACTION' => $this->language->lang('STYLE_UNINSTALL') 'L_ACTION' => $this->language->lang('STYLE_UNINSTALL')
); ];
} }
// Preview // Preview
$actions[] = array( $actions[] = [
'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'style=' . $style['style_id']), 'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'style=' . $style['style_id']),
'L_ACTION' => $this->language->lang('PREVIEW') 'L_ACTION' => $this->language->lang('PREVIEW')
); ];
} }
else else
{ {
// Style is not installed // Style is not installed
if (empty($style['_available'])) if (empty($style['_available']))
{ {
$actions[] = array( $actions[] = [
'HTML' => $this->language->lang('CANNOT_BE_INSTALLED') 'HTML' => $this->language->lang('CANNOT_BE_INSTALLED')
); ];
} }
else else
{ {
$actions[] = array( $actions[] = [
'U_ACTION' => $this->u_action . '&action=install&hash=' . generate_link_hash('install') . '&dir=' . urlencode($style['style_path']), 'U_ACTION' => $this->u_action . '&action=install&hash=' . generate_link_hash('install') . '&dir=' . urlencode($style['style_path']),
'L_ACTION' => $this->language->lang('INSTALL_STYLE') 'L_ACTION' => $this->language->lang('INSTALL_STYLE')
); ];
} }
} }
// todo: add hook
// Assign template variables // Assign template variables
$this->template->assign_block_vars('styles_list', $row); $this->template->assign_block_vars('styles_list', $row);
foreach ($actions as $action) foreach ($actions as $action)
@ -1076,13 +1068,13 @@ class acp_styles
$counter = ($style['style_id']) ? ($style['style_active'] ? 'active' : 'inactive') : (empty($style['_available']) ? 'cannotinstall' : 'caninstall'); $counter = ($style['style_id']) ? ($style['style_active'] ? 'active' : 'inactive') : (empty($style['_available']) ? 'cannotinstall' : 'caninstall');
if (!isset($this->style_counters)) if (!isset($this->style_counters))
{ {
$this->style_counters = array( $this->style_counters = [
'total' => 0, 'total' => 0,
'active' => 0, 'active' => 0,
'inactive' => 0, 'inactive' => 0,
'caninstall' => 0, 'caninstall' => 0,
'cannotinstall' => 0 'cannotinstall' => 0
); ];
} }
$this->style_counters[$counter]++; $this->style_counters[$counter]++;
$this->style_counters['total']++; $this->style_counters['total']++;