1
0
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:
Igor Wiedler
2012-04-07 19:19:13 +02:00
parent 3b0e0dba32
commit e861bb0e04
9 changed files with 33 additions and 21 deletions

View File

@@ -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;

View File

@@ -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';

View File

@@ -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;

View File

@@ -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']))
{