1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-17 22:28:46 +01:00

[ticket/10824] Use language class for language instead of user class

PHPBB3-10824
This commit is contained in:
Marc Alexander 2020-10-31 14:14:04 +01:00
parent 3b6fc0a4d9
commit 646f9826ec
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995

View File

@ -38,8 +38,8 @@ class acp_styles
/** @var \phpbb\db\driver\driver_interface */ /** @var \phpbb\db\driver\driver_interface */
protected $db; protected $db;
/** @var \phpbb\user */ /** @var \phpbb\language\language */
protected $user; protected $language;
/** @var \phpbb\template\template */ /** @var \phpbb\template\template */
protected $template; protected $template;
@ -67,10 +67,10 @@ class acp_styles
public function main($id, $mode) public function main($id, $mode)
{ {
global $db, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_container; global $db, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_container;
$this->db = $db; $this->db = $db;
$this->user = $user; $this->language = $phpbb_container->get('language');
$this->template = $template; $this->template = $template;
$this->request = $request; $this->request = $request;
$this->cache = $cache; $this->cache = $cache;
@ -89,7 +89,7 @@ class acp_styles
'mode' => $mode, 'mode' => $mode,
); );
$this->user->add_lang('acp/styles'); $this->language->add_lang('acp/styles');
$this->tpl_name = 'acp_styles'; $this->tpl_name = 'acp_styles';
$this->page_title = 'ACP_CAT_STYLES'; $this->page_title = 'ACP_CAT_STYLES';
@ -114,7 +114,7 @@ class acp_styles
if (!$is_valid_request) if (!$is_valid_request)
{ {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
} }
} }
@ -183,7 +183,7 @@ class acp_styles
$this->show_available(); $this->show_available();
return; return;
} }
trigger_error($this->user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MODE') . adm_back_link($this->u_action), E_USER_WARNING);
} }
/** /**
@ -205,7 +205,7 @@ class acp_styles
{ {
if (in_array($dir, $this->reserved_style_names)) if (in_array($dir, $this->reserved_style_names))
{ {
$messages[] = $this->user->lang('STYLE_NAME_RESERVED', htmlspecialchars($dir, ENT_COMPAT)); $messages[] = $this->language->lang('STYLE_NAME_RESERVED', htmlspecialchars($dir, ENT_COMPAT));
continue; continue;
} }
@ -225,12 +225,12 @@ class acp_styles
$found = true; $found = true;
$installed_names[] = $style['style_name']; $installed_names[] = $style['style_name'];
$installed_dirs[] = $style['style_path']; $installed_dirs[] = $style['style_path'];
$messages[] = sprintf($this->user->lang['STYLE_INSTALLED'], htmlspecialchars($style['style_name'], ENT_COMPAT)); $messages[] = $this->language->lang('STYLE_INSTALLED', htmlspecialchars($style['style_name'], ENT_COMPAT));
} }
} }
if (!$found) if (!$found)
{ {
$messages[] = sprintf($this->user->lang['STYLE_NOT_INSTALLED'], htmlspecialchars($dir, ENT_COMPAT)); $messages[] = $this->language->lang('STYLE_NOT_INSTALLED', htmlspecialchars($dir, ENT_COMPAT));
} }
} }
@ -243,11 +243,11 @@ class acp_styles
// Show message // Show message
if (!count($messages)) if (!count($messages))
{ {
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MATCHING_STYLES_FOUND') . adm_back_link($this->u_action), E_USER_WARNING);
} }
$message = implode('<br />', $messages); $message = implode('<br />', $messages);
$message .= '<br /><br /><a href="' . $this->u_base_action . '&amp;mode=style' . '">&laquo; ' . $this->user->lang('STYLE_INSTALLED_RETURN_INSTALLED_STYLES') . '</a>'; $message .= '<br /><br /><a href="' . $this->u_base_action . '&amp;mode=style' . '">&laquo; ' . $this->language->lang('STYLE_INSTALLED_RETURN_INSTALLED_STYLES') . '</a>';
$message .= '<br /><br /><a href="' . $this->u_base_action . '&amp;mode=install' . '">&raquo; ' . $this->user->lang('STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES') . '</a>'; $message .= '<br /><br /><a href="' . $this->u_base_action . '&amp;mode=install' . '">&raquo; ' . $this->language->lang('STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES') . '</a>';
trigger_error($message, E_USER_NOTICE); trigger_error($message, E_USER_NOTICE);
} }
@ -269,7 +269,7 @@ class acp_styles
if ($prosilver_id && in_array($prosilver_id, $ids)) if ($prosilver_id && in_array($prosilver_id, $ids))
{ {
trigger_error($this->user->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING);
} }
// Check if confirmation box was submitted // Check if confirmation box was submitted
@ -286,7 +286,7 @@ class acp_styles
'ids' => $ids 'ids' => $ids
)); ));
$this->template->assign_var('S_CONFIRM_DELETE', true); $this->template->assign_var('S_CONFIRM_DELETE', true);
confirm_box(false, $this->user->lang['CONFIRM_UNINSTALL_STYLES'], $s_hidden, 'acp_styles.html'); confirm_box(false, $this->language->lang('CONFIRM_UNINSTALL_STYLES'), $s_hidden, 'acp_styles.html');
// Canceled - show styles list // Canceled - show styles list
$this->frontend(); $this->frontend();
@ -311,11 +311,11 @@ class acp_styles
{ {
if (!$id) if (!$id)
{ {
trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('INVALID_STYLE_ID') . adm_back_link($this->u_action), E_USER_WARNING);
} }
if ($id == $default) if ($id == $default)
{ {
trigger_error($this->user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('UNINSTALL_DEFAULT') . adm_back_link($this->u_action), E_USER_WARNING);
} }
$uninstalled[$id] = false; $uninstalled[$id] = false;
} }
@ -342,20 +342,20 @@ class acp_styles
$messages[] = $result; $messages[] = $result;
continue; continue;
} }
$messages[] = sprintf($this->user->lang['STYLE_UNINSTALLED'], $style['style_name']); $messages[] = $this->language->lang('STYLE_UNINSTALLED', $style['style_name']);
$uninstalled[] = $style['style_name']; $uninstalled[] = $style['style_name'];
// Attempt to delete files // Attempt to delete files
if ($delete_files) if ($delete_files)
{ {
$messages[] = sprintf($this->user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']); $messages[] = $this->language->lang($this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED', $style['style_name']);
} }
} }
if (empty($messages)) if (empty($messages))
{ {
// Nothing to uninstall? // Nothing to uninstall?
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MATCHING_STYLES_FOUND') . adm_back_link($this->u_action), E_USER_WARNING);
} }
// Log action // Log action
@ -405,7 +405,7 @@ class acp_styles
{ {
if ($id == $this->default_style) if ($id == $this->default_style)
{ {
trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('DEACTIVATE_DEFAULT') . adm_back_link($this->u_action), E_USER_WARNING);
} }
} }
@ -438,7 +438,7 @@ class acp_styles
$id = $this->request->variable('id', 0); $id = $this->request->variable('id', 0);
if (!$id) if (!$id)
{ {
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MATCHING_STYLES_FOUND') . adm_back_link($this->u_action), E_USER_WARNING);
} }
// Get all styles // Get all styles
@ -458,7 +458,7 @@ class acp_styles
if ($style === false) if ($style === false)
{ {
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MATCHING_STYLES_FOUND') . adm_back_link($this->u_action), E_USER_WARNING);
} }
// Read style configuration file // Read style configuration file
@ -476,7 +476,7 @@ class acp_styles
{ {
if (!check_form_key($form_key)) if (!check_form_key($form_key))
{ {
trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
} }
$update = array( $update = array(
@ -491,13 +491,13 @@ class acp_styles
{ {
if (!strlen($update['style_name'])) if (!strlen($update['style_name']))
{ {
trigger_error($this->user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); trigger_error($this->language->lang('STYLE_ERR_STYLE_NAME') . adm_back_link($update_action), E_USER_WARNING);
} }
foreach ($styles as $row) foreach ($styles as $row)
{ {
if ($row['style_name'] == $update['style_name']) if ($row['style_name'] == $update['style_name'])
{ {
trigger_error($this->user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); trigger_error($this->language->lang('STYLE_ERR_NAME_EXIST') . adm_back_link($update_action), E_USER_WARNING);
} }
} }
} }
@ -523,7 +523,7 @@ class acp_styles
} }
if (!$found) if (!$found)
{ {
trigger_error($this->user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); trigger_error($this->language->lang('STYLE_ERR_INVALID_PARENT') . adm_back_link($update_action), E_USER_WARNING);
} }
} }
else else
@ -541,7 +541,7 @@ class acp_styles
{ {
if (!$update['style_active'] && $this->default_style == $style['style_id']) if (!$update['style_active'] && $this->default_style == $style['style_id'])
{ {
trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); trigger_error($this->language->lang('DEACTIVATE_DEFAULT') . adm_back_link($update_action), E_USER_WARNING);
} }
} }
else else
@ -579,7 +579,7 @@ class acp_styles
{ {
if (!$style['style_active']) if (!$style['style_active'])
{ {
trigger_error($this->user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); trigger_error($this->language->lang('STYLE_DEFAULT_CHANGE_INACTIVE') . adm_back_link($update_action), E_USER_WARNING);
} }
$this->config->set('default_style', $id); $this->config->set('default_style', $id);
$this->cache->purge(); $this->cache->purge();
@ -629,7 +629,7 @@ class acp_styles
if (!count($styles)) if (!count($styles))
{ {
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MATCHING_STYLES_FOUND') . adm_back_link($this->u_action), E_USER_WARNING);
} }
usort($styles, array($this, 'sort_styles')); usort($styles, array($this, 'sort_styles'));
@ -656,7 +656,7 @@ class acp_styles
{ {
if (empty($style['_shown'])) if (empty($style['_shown']))
{ {
$style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($style['style_parent_tree'], ENT_COMPAT)); $style['_note'] = $this->language->lang('REQUIRES_STYLE', htmlspecialchars($style['style_parent_tree'], ENT_COMPAT));
$this->list_style($style, 0); $this->list_style($style, 0);
} }
} }
@ -664,13 +664,13 @@ class acp_styles
// Add buttons // Add buttons
$this->template->assign_block_vars('extra_actions', array( $this->template->assign_block_vars('extra_actions', array(
'ACTION_NAME' => 'activate', 'ACTION_NAME' => 'activate',
'L_ACTION' => $this->user->lang['STYLE_ACTIVATE'], 'L_ACTION' => $this->language->lang('STYLE_ACTIVATE'),
) )
); );
$this->template->assign_block_vars('extra_actions', array( $this->template->assign_block_vars('extra_actions', array(
'ACTION_NAME' => 'deactivate', 'ACTION_NAME' => 'deactivate',
'L_ACTION' => $this->user->lang['STYLE_DEACTIVATE'], 'L_ACTION' => $this->language->lang('STYLE_DEACTIVATE'),
) )
); );
@ -678,7 +678,7 @@ class acp_styles
{ {
$this->template->assign_block_vars('extra_actions', array( $this->template->assign_block_vars('extra_actions', array(
'ACTION_NAME' => 'uninstall', 'ACTION_NAME' => 'uninstall',
'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'], 'L_ACTION' => $this->language->lang('STYLE_UNINSTALL'),
) )
); );
} }
@ -695,7 +695,7 @@ class acp_styles
// Show styles // Show styles
if (empty($styles)) if (empty($styles))
{ {
trigger_error($this->user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); trigger_error($this->language->lang('NO_UNINSTALLED_STYLE') . adm_back_link($this->u_base_action), E_USER_NOTICE);
} }
usort($styles, array($this, 'sort_styles')); usort($styles, array($this, 'sort_styles'));
@ -750,7 +750,7 @@ class acp_styles
{ {
$this->template->assign_block_vars('extra_actions', array( $this->template->assign_block_vars('extra_actions', array(
'ACTION_NAME' => 'install', 'ACTION_NAME' => 'install',
'L_ACTION' => $this->user->lang['INSTALL_STYLES'], 'L_ACTION' => $this->language->lang('INSTALL_STYLES'),
) )
); );
} }
@ -842,7 +842,7 @@ class acp_styles
{ {
// Parent style is not installed yet // Parent style is not installed yet
$style['_available'] = false; $style['_available'] = false;
$style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($parent, ENT_COMPAT)); $style['_note'] = $this->language->lang('REQUIRES_STYLE', htmlspecialchars($parent, ENT_COMPAT));
} }
} }
@ -1013,7 +1013,7 @@ class acp_styles
// Details // Details
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&amp;action=details&amp;id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&amp;action=details&amp;id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['DETAILS'] 'L_ACTION' => $this->language->lang('DETAILS')
); );
// Activate/Deactive // Activate/Deactive
@ -1021,7 +1021,7 @@ class acp_styles
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&amp;action=' . $action_name . '&amp;hash=' . generate_link_hash($action_name) . '&amp;id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&amp;action=' . $action_name . '&amp;hash=' . generate_link_hash($action_name) . '&amp;id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] 'L_ACTION' => $this->language->lang('STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE')
); );
/* // Export /* // Export
@ -1035,14 +1035,14 @@ class acp_styles
// Uninstall // Uninstall
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&amp;action=uninstall&amp;hash=' . generate_link_hash('uninstall') . '&amp;id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&amp;action=uninstall&amp;hash=' . generate_link_hash('uninstall') . '&amp;id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] 'L_ACTION' => $this->language->lang('STYLE_UNINSTALL')
); );
} }
// Preview // Preview
$actions[] = array( $actions[] = array(
'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->user->lang['PREVIEW'] 'L_ACTION' => $this->language->lang('PREVIEW')
); );
} }
else else
@ -1051,14 +1051,14 @@ class acp_styles
if (empty($style['_available'])) if (empty($style['_available']))
{ {
$actions[] = array( $actions[] = array(
'HTML' => $this->user->lang['CANNOT_BE_INSTALLED'] 'HTML' => $this->language->lang('CANNOT_BE_INSTALLED')
); );
} }
else else
{ {
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&amp;action=install&amp;hash=' . generate_link_hash('install') . '&amp;dir=' . urlencode($style['style_path']), 'U_ACTION' => $this->u_action . '&amp;action=install&amp;hash=' . generate_link_hash('install') . '&amp;dir=' . urlencode($style['style_path']),
'L_ACTION' => $this->user->lang['INSTALL_STYLE'] 'L_ACTION' => $this->language->lang('INSTALL_STYLE')
); );
} }
} }
@ -1100,13 +1100,13 @@ class acp_styles
$row = array( $row = array(
// Style data // Style data
'STYLE_INVALID' => true, 'STYLE_INVALID' => true,
'STYLE_NAME' => $this->user->lang('INVALID_STYLE_MESSAGE', $style['style_path']), 'STYLE_NAME' => $this->language->lang('INVALID_STYLE_MESSAGE', $style['style_path']),
); );
$this->template->assign_block_vars('styles_list', $row); $this->template->assign_block_vars('styles_list', $row);
$this->template->assign_block_vars('styles_list.actions', array( $this->template->assign_block_vars('styles_list.actions', array(
'HTML' => $this->user->lang['CANNOT_BE_INSTALLED'] 'HTML' => $this->language->lang('CANNOT_BE_INSTALLED')
)); ));
// Increase counters // Increase counters
@ -1133,8 +1133,8 @@ class acp_styles
protected function welcome_message($title, $description) protected function welcome_message($title, $description)
{ {
$this->template->assign_vars(array( $this->template->assign_vars(array(
'L_TITLE' => $this->user->lang[$title], 'L_TITLE' => $this->language->lang($title),
'L_EXPLAIN' => (isset($this->user->lang[$description])) ? $this->user->lang[$description] : '' 'L_EXPLAIN' => $this->language->is_set($description) ? $this->language->lang($description) : ''
) )
); );
} }
@ -1199,7 +1199,7 @@ class acp_styles
// This should never happen, we give them a red warning because of its relevance. // This should never happen, we give them a red warning because of its relevance.
if (!file_exists($this->styles_path . $dir . '/style.json')) if (!file_exists($this->styles_path . $dir . '/style.json'))
{ {
trigger_error($this->user->lang('NO_STYLE_CFG', $dir), E_USER_WARNING); trigger_error($this->language->lang('NO_STYLE_CFG', $dir), E_USER_WARNING);
} }
$json = file_get_contents($this->styles_path . $dir . '/composer.json'); $json = file_get_contents($this->styles_path . $dir . '/composer.json');
@ -1325,7 +1325,7 @@ class acp_styles
if ($conflict !== false) if ($conflict !== false)
{ {
return sprintf($this->user->lang['STYLE_UNINSTALL_DEPENDENT'], $style['style_name']); return $this->language->lang('STYLE_UNINSTALL_DEPENDENT', $style['style_name']);
} }
// Change default style for users // Change default style for users
@ -1414,7 +1414,7 @@ class acp_styles
if ($error && !count($items)) if ($error && !count($items))
{ {
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->language->lang('NO_MATCHING_STYLES_FOUND') . adm_back_link($this->u_action), E_USER_WARNING);
} }
return $items; return $items;