mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-11 03:04:09 +02:00
[feature/avatars] Use request object in avatar drivers
PHPBB3-10018
This commit is contained in:
@@ -26,7 +26,13 @@ abstract class phpbb_avatar_driver
|
||||
* @type phpbb_config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
||||
/**
|
||||
* Current board configuration
|
||||
* @type phpbb_config
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Current $phpbb_root_path
|
||||
* @type string
|
||||
@@ -62,13 +68,15 @@ abstract class phpbb_avatar_driver
|
||||
* Construct an driver object
|
||||
*
|
||||
* @param $config The phpBB configuration
|
||||
* @param $request The request object
|
||||
* @param $phpbb_root_path The path to the phpBB root
|
||||
* @param $phpEx The php file extension
|
||||
* @param $cache A cache driver
|
||||
*/
|
||||
public function __construct(phpbb_config $config, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null)
|
||||
public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->cache = $cache;
|
||||
|
@@ -50,7 +50,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
|
||||
public function prepare_form($template, $row, &$error)
|
||||
{
|
||||
$avatar_list = $this->get_avatar_list();
|
||||
$category = request_var('av_local_cat', '');
|
||||
$category = $this->request->variable('av_local_cat', '');
|
||||
|
||||
$categories = array_keys($avatar_list);
|
||||
|
||||
@@ -110,9 +110,9 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
|
||||
public function process_form($template, $row, &$error)
|
||||
{
|
||||
$avatar_list = $this->get_avatar_list();
|
||||
$category = request_var('av_local_cat', '');
|
||||
|
||||
$file = request_var('av_local_file', '');
|
||||
$category = $this->request->variable('av_local_cat', '');
|
||||
|
||||
$file = $this->request->variable('av_local_file', '');
|
||||
if (!isset($avatar_list[$category][urldecode($file)]))
|
||||
{
|
||||
$error[] = 'AVATAR_URL_NOT_FOUND';
|
||||
|
@@ -50,8 +50,8 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
||||
public function prepare_form($template, $row, &$error)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : request_var('av_local_width', 0),
|
||||
'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : request_var('av_local_width', 0),
|
||||
'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('av_local_width', 0),
|
||||
'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('av_local_width', 0),
|
||||
'AV_REMOTE_URL' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar']) ? $row['avatar'] : '',
|
||||
));
|
||||
|
||||
@@ -63,10 +63,10 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
||||
*/
|
||||
public function process_form($template, $row, &$error)
|
||||
{
|
||||
$url = request_var('av_remote_url', '');
|
||||
$width = request_var('av_remote_width', 0);
|
||||
$height = request_var('av_remote_height', 0);
|
||||
|
||||
$url = $this->request->variable('av_remote_url', '');
|
||||
$width = $this->request->variable('av_remote_width', 0);
|
||||
$height = $this->request->variable('av_remote_height', 0);
|
||||
|
||||
if (!preg_match('#^(http|https|ftp)://#i', $url))
|
||||
{
|
||||
$url = 'http://' . $url;
|
||||
|
@@ -76,7 +76,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
|
||||
|
||||
$upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false));
|
||||
|
||||
$url = request_var('av_upload_url', '');
|
||||
$url = $this->request->variable('av_upload_url', '');
|
||||
|
||||
if (!empty($_FILES['av_upload_file']['name']))
|
||||
{
|
||||
|
@@ -23,17 +23,19 @@ class phpbb_avatar_manager
|
||||
private $phpbb_root_path;
|
||||
private $phpEx;
|
||||
private $config;
|
||||
private $request;
|
||||
private $cache;
|
||||
private static $valid_drivers = false;
|
||||
|
||||
/**
|
||||
* @TODO
|
||||
**/
|
||||
public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_cache_driver_interface $cache = null)
|
||||
public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
@@ -66,7 +68,7 @@ class phpbb_avatar_manager
|
||||
if ($new || !is_object(self::$valid_drivers[$avatar_type]))
|
||||
{
|
||||
$class_name = 'phpbb_avatar_driver_' . $avatar_type;
|
||||
self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->phpbb_root_path, $this->phpEx, $this->cache);
|
||||
self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->request, $this->phpbb_root_path, $this->phpEx, $this->cache);
|
||||
}
|
||||
|
||||
return self::$valid_drivers[$avatar_type];
|
||||
|
Reference in New Issue
Block a user