[feature/avatars] Properly implement custom HTML in the interface

Previously the driver class added a variable that defined wether an avatar
driver would return custom HTML. The existence of this variable was
implied in the interface. It's also not needed which is why it has been
removed.

PHPBB3-10018
This commit is contained in:
Marc Alexander 2012-11-29 23:08:29 +01:00
parent cb1d98ab7f
commit 81a1a21185
4 changed files with 7 additions and 17 deletions

View file

@ -57,13 +57,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
*/ */
protected $cache; protected $cache;
/**
* This flag should be set to true if the avatar requires a nonstandard image
* tag, and will generate the html itself.
* @var boolean
*/
public $custom_html = false;
/** /**
* Construct a driver object * Construct a driver object
* *

View file

@ -21,12 +21,10 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
{ {
const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/';
/** /**
* @inheritdoc * The URL for the gravatar service
*/ */
public $custom_html = true; const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/';
/** /**
* @inheritdoc * @inheritdoc

View file

@ -40,8 +40,7 @@ interface phpbb_avatar_driver_interface
public function get_data($row, $ignore_config = false); public function get_data($row, $ignore_config = false);
/** /**
* Returns custom html for displaying this avatar. * Returns custom html if it is needed for displaying this avatar
* Only called if $custom_html is true.
* *
* @param bool $ignore_config Whether this function should respect the users prefs * @param bool $ignore_config Whether this function should respect the users prefs
* and board configuration configuration option, or should just render * and board configuration configuration option, or should just render

View file

@ -1368,12 +1368,14 @@ function get_avatar($row, $alt, $ignore_config = false)
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']);
$html = '';
if ($avatar) if ($avatar)
{ {
if ($avatar->custom_html) $html = $avatar->get_custom_html($row, $ignore_config, $alt);
if (!empty($html))
{ {
return $avatar->get_custom_html($row, $ignore_config, $alt); return $html;
} }
$avatar_data = $avatar->get_data($row, $ignore_config); $avatar_data = $avatar->get_data($row, $ignore_config);
@ -1383,8 +1385,6 @@ function get_avatar($row, $alt, $ignore_config = false)
$avatar_data['src'] = ''; $avatar_data['src'] = '';
} }
$html = '';
if (!empty($avatar_data['src'])) if (!empty($avatar_data['src']))
{ {
$html = '<img src="' . $avatar_data['src'] . '" ' . $html = '<img src="' . $avatar_data['src'] . '" ' .