mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/avatars] Add function for localizing errors
PHPBB3-10018
This commit is contained in:
parent
111e02395c
commit
41710c745d
5 changed files with 35 additions and 58 deletions
|
@ -550,22 +550,8 @@ class acp_groups
|
||||||
|
|
||||||
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||||
|
|
||||||
/*
|
// Merge any avatar errors into the primary error array
|
||||||
* Merge any avatar errors into the primary error array
|
$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
|
||||||
* Drivers use language constants, so we need to map to the actual strings
|
|
||||||
*/
|
|
||||||
foreach ($avatar_error as $lang)
|
|
||||||
{
|
|
||||||
if (is_array($lang))
|
|
||||||
{
|
|
||||||
$key = array_shift($lang);
|
|
||||||
$error[] = vsprintf($user->lang($key), $lang);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error[] = $user->lang("$lang");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$back_link = request_var('back_link', '');
|
$back_link = request_var('back_link', '');
|
||||||
|
|
||||||
|
|
|
@ -1831,18 +1831,7 @@ class acp_users
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace "error" strings with their real, localised form
|
// Replace "error" strings with their real, localised form
|
||||||
foreach ($error as $key => $lang)
|
$error = $phpbb_avatar_manager->localize_errors($user, $error);
|
||||||
{
|
|
||||||
if (is_array($lang))
|
|
||||||
{
|
|
||||||
$lang_key = array_shift($lang);
|
|
||||||
$error[$key] = vsprintf($user->lang($lang_key), $lang);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error[$key] = $user->lang($lang);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true);
|
$avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true);
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,7 @@ class phpbb_avatar_manager
|
||||||
/**
|
/**
|
||||||
* Construct an avatar manager object
|
* Construct an avatar manager object
|
||||||
*
|
*
|
||||||
* @param string $phpbb_root_path Path to the phpBB root
|
|
||||||
* @param string $phpEx PHP file extension
|
|
||||||
* @param phpbb_config $config phpBB configuration
|
* @param phpbb_config $config phpBB configuration
|
||||||
* @param phpbb_request $request Request object
|
|
||||||
* @param phpbb_cache_driver_interface $cache Cache driver
|
|
||||||
* @param array $avatar_drivers Avatar drivers passed via the service container
|
* @param array $avatar_drivers Avatar drivers passed via the service container
|
||||||
* @param object $container Container object
|
* @param object $container Container object
|
||||||
*/
|
*/
|
||||||
|
@ -260,4 +256,33 @@ class phpbb_avatar_manager
|
||||||
{
|
{
|
||||||
return preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver));
|
return preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace "error" strings with their real, localized form
|
||||||
|
*
|
||||||
|
* @param phpbb_user phpBB User object
|
||||||
|
* @param array $error Array containing error strings
|
||||||
|
* Key values can either be a string with a language key or an array
|
||||||
|
* that will be passed to vsprintf() with the language key in the
|
||||||
|
* first array key.
|
||||||
|
*
|
||||||
|
* @return array Array containing the localized error strings
|
||||||
|
*/
|
||||||
|
public function localize_errors(phpbb_user $user, $error)
|
||||||
|
{
|
||||||
|
foreach ($error as $key => $lang)
|
||||||
|
{
|
||||||
|
if (is_array($lang))
|
||||||
|
{
|
||||||
|
$lang_key = array_shift($lang);
|
||||||
|
$error[$key] = vsprintf($user->lang($lang_key), $lang);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error[$key] = $user->lang("$lang");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,19 +674,7 @@ class ucp_groups
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge any avatars errors into the primary error array
|
// Merge any avatars errors into the primary error array
|
||||||
// Drivers use lang constants, so we need to map to the actual strings
|
$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
|
||||||
foreach ($avatar_error as $lang)
|
|
||||||
{
|
|
||||||
if (is_array($lang))
|
|
||||||
{
|
|
||||||
$key = array_shift($lang);
|
|
||||||
$error[] = vsprintf($user->lang($key), $lang);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error[] = $user->lang("$lang");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'S_EDIT' => true,
|
'S_EDIT' => true,
|
||||||
|
|
|
@ -659,18 +659,7 @@ class ucp_profile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace "error" strings with their real, localised form
|
// Replace "error" strings with their real, localised form
|
||||||
foreach ($error as $key => $lang)
|
$error = $phpbb_avatar_manager->localize_errors($user, $error);
|
||||||
{
|
|
||||||
if (is_array($lang))
|
|
||||||
{
|
|
||||||
$key = array_shift($lang);
|
|
||||||
$error[$key] = vsprintf($user->lang($key), $lang);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error[$key] = $user->lang("$lang");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
|
$avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue