[ticket/17153] Remove phpbb_get_avatar()

PHPBB3-17153
This commit is contained in:
Marc Alexander 2023-07-01 09:51:21 +02:00
parent f54bafec29
commit 4db4a5571b
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -3541,91 +3541,6 @@ function phpbb_quoteattr($data, $entities = null)
return $data;
}
/**
* Get avatar
*
* @deprecated 4.0.0 Use \phpbb\avatar\helper::get_avatar() instead
*
* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
* @param bool $lazy If true, will be lazy loaded (requires JS)
*
* @return string Avatar html
*/
function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
{
global $user, $config;
global $phpbb_container, $phpbb_dispatcher;
if (!$config['allow_avatar'] && !$ignore_config)
{
return '';
}
$avatar_data = array(
'src' => $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
/* @var $phpbb_avatar_manager \phpbb\avatar\manager */
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], !$ignore_config);
$html = '';
if ($driver)
{
$html = $driver->get_custom_html($user, $row, $alt);
$avatar_data = $driver->get_data($row);
}
else
{
$avatar_data['src'] = '';
}
if (empty($html) && !empty($avatar_data['src']))
{
if ($lazy)
{
// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
$phpbb_path_helper = $phpbb_container->get('path_helper');
$web_path = $phpbb_path_helper->get_web_root_path();
$theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';
$src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"';
}
else
{
$src = 'src="' . $avatar_data['src'] . '"';
}
$html = '<img class="avatar" ' . $src . ' ' .
($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') .
($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
/**
* Event to modify HTML <img> tag of avatar
*
* @event core.get_avatar_after
* @var array row Row cleaned by \phpbb\avatar\manager::clean_row
* @var string alt Optional language string for alt tag within image, can be a language key or text
* @var bool ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
* @var array avatar_data The HTML attributes for avatar <img> tag
* @var string html The HTML <img> tag of generated avatar
* @since 3.1.6-RC1
*/
$vars = array('row', 'alt', 'ignore_config', 'avatar_data', 'html');
extract($phpbb_dispatcher->trigger_event('core.get_avatar_after', compact($vars)));
return $html;
}
/**
* Generate page header
*/