aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_display.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_display.php')
-rw-r--r--phpBB/includes/functions_display.php51
1 files changed, 16 insertions, 35 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index eba123be9d..3aeee5f704 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1278,10 +1278,12 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
*
* @return string Avatar html
*/
-function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = false)
+function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false)
{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
+ static $avatar_manager = null;
+
if (!$config['allow_avatar'] && !$ignore_config)
{
return '';
@@ -1334,48 +1336,27 @@ function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = fals
break;
default:
- $class = 'phpbb_avatar_' . $user_row['user_avatar_type'];
-
- if (!class_exists($class))
+ if (empty($avatar_manager))
{
- $avatar_types = $cache->get('avatar_types');
-
- if (empty($avatar_types))
- {
- $avatar_types = array();
-
- if ($dh = @opendir($phpbb_root_path . 'includes/avatars'))
- {
- while ($file = @readdir($dh))
- {
- if (preg_match("/avatar_(.*)\.$phpEx/", $file, $match))
- {
- $avatar_types[] = $match[1];
- }
- }
-
- @closedir($dh);
+ $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver());
+ }
- sort($avatar_types);
- $cache->put('avatar_types', $avatar_types);
- }
- }
+ $avatar = $avatar_manager->get_singleton($user_row['user_avatar_type']);
- if (in_array($user_row['user_avatar_type'], $avatar_types))
+ if ($avatar)
+ {
+ if ($avatar->custom_html)
{
- require_once($phpbb_root_path . 'includes/avatars/avatar_' . $user_row['user_avatar_type'] . '.' . $phpEx);
+ return $avatar->get_html($user_row, $ignore_config);
}
- }
-
- $avatar = new $class($user_row);
- if ($avatar->custom_html)
+ $avatar_data = $avatar->get_data($user_row, $ignore_config);
+ }
+ else
{
- return $avatar->get_custom_html($ignore_config);
+ $avatar_data['src'] = '';
}
- $avatar_data = $avatar->get_data($ignore_config);
-
break;
}
@@ -1401,7 +1382,7 @@ function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = fals
*
* @return string Avatar html
*/
-function get_group_avatar(&$group_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
+function get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
{
// Kind of abusing this functionality...
$avatar_row = array(