mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/13904] Turn filespec into prototype and improve init methods
PHPBB3-13904
This commit is contained in:
parent
0cbb713cc2
commit
92e49cd0ac
3 changed files with 20 additions and 12 deletions
|
@ -4,6 +4,7 @@ services:
|
||||||
|
|
||||||
files.filespec:
|
files.filespec:
|
||||||
class: phpbb\files\filespec
|
class: phpbb\files\filespec
|
||||||
|
scope: prototype
|
||||||
arguments:
|
arguments:
|
||||||
- @filesystem
|
- @filesystem
|
||||||
- @mimetype.guesser
|
- @mimetype.guesser
|
||||||
|
|
|
@ -155,7 +155,7 @@ class fileupload
|
||||||
*/
|
*/
|
||||||
function form_upload($form_name, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
|
function form_upload($form_name, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
|
||||||
{
|
{
|
||||||
global $user, $request;
|
global $user, $request, $phpbb_container;
|
||||||
|
|
||||||
$upload = $request->file($form_name);
|
$upload = $request->file($form_name);
|
||||||
unset($upload['local_mode']);
|
unset($upload['local_mode']);
|
||||||
|
@ -169,9 +169,10 @@ class fileupload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = new \phpbb\files\filespec($this->filesystem, $mimetype_guesser, $plupload);
|
/** @var \phpbb\files\filespec $file */
|
||||||
$file->set_upload_ary($upload);
|
$file = $phpbb_container->get('files.filespec')
|
||||||
$file->set_upload_namespace($this);
|
->set_upload_ary($upload)
|
||||||
|
->set_upload_namespace($this);
|
||||||
|
|
||||||
if ($file->init_error())
|
if ($file->init_error())
|
||||||
{
|
{
|
||||||
|
@ -233,7 +234,7 @@ class fileupload
|
||||||
*/
|
*/
|
||||||
function local_upload($source_file, $filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null)
|
function local_upload($source_file, $filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null)
|
||||||
{
|
{
|
||||||
global $user, $request;
|
global $user, $request, $phpbb_container;
|
||||||
|
|
||||||
$upload = array();
|
$upload = array();
|
||||||
|
|
||||||
|
@ -252,9 +253,10 @@ class fileupload
|
||||||
$upload['type'] = $filedata['type'];
|
$upload['type'] = $filedata['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = new \phpbb\files\filespec($this->filesystem, $mimetype_guesser);
|
/** @var \phpbb\files\filespec $file */
|
||||||
$file->set_upload_ary($upload);
|
$file = $phpbb_container->get('files.filespec')
|
||||||
$file->set_upload_namespace($this);
|
->set_upload_ary($upload)
|
||||||
|
->set_upload_namespace($this);
|
||||||
|
|
||||||
if ($file->init_error())
|
if ($file->init_error())
|
||||||
{
|
{
|
||||||
|
@ -315,7 +317,7 @@ class fileupload
|
||||||
*/
|
*/
|
||||||
function remote_upload($upload_url, \phpbb\mimetype\guesser $mimetype_guesser = null)
|
function remote_upload($upload_url, \phpbb\mimetype\guesser $mimetype_guesser = null)
|
||||||
{
|
{
|
||||||
global $user, $phpbb_root_path;
|
global $user, $phpbb_root_path, $phpbb_container;
|
||||||
|
|
||||||
$upload_ary = array();
|
$upload_ary = array();
|
||||||
$upload_ary['local_mode'] = true;
|
$upload_ary['local_mode'] = true;
|
||||||
|
@ -492,9 +494,10 @@ class fileupload
|
||||||
|
|
||||||
$upload_ary['tmp_name'] = $filename;
|
$upload_ary['tmp_name'] = $filename;
|
||||||
|
|
||||||
$file = new \phpbb\files\filespec($this->filesystem, $mimetype_guesser);
|
/** @var \phpbb\files\filespec $file */
|
||||||
$file->set_upload_ary($upload_ary);
|
$file = $phpbb_container->get('files.filespec')
|
||||||
$file->set_upload_namespace($this);
|
->set_upload_ary($upload_ary)
|
||||||
|
->set_upload_namespace($this);
|
||||||
$this->common_checks($file);
|
$this->common_checks($file);
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
|
|
|
@ -97,11 +97,15 @@ class filespec
|
||||||
$this->file_moved = false;
|
$this->file_moved = false;
|
||||||
|
|
||||||
$this->local = (isset($upload_ary['local_mode'])) ? true : false;
|
$this->local = (isset($upload_ary['local_mode'])) ? true : false;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_upload_namespace($namespace)
|
public function set_upload_namespace($namespace)
|
||||||
{
|
{
|
||||||
$this->upload = $namespace;
|
$this->upload = $namespace;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue