aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-05-31 14:02:02 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-09-09 08:26:07 +0200
commitc72d6a71bb71b5abeae05b4a6494ffb166624179 (patch)
treedf7a40516696faa1dc7f75a154c5f1d13533369e /phpBB/phpbb/files
parent[ticket/13904] Add filespec class to files classes (diff)
downloadphpbb-c72d6a71bb71b5abeae05b4a6494ffb166624179.tar.gz
phpbb-c72d6a71bb71b5abeae05b4a6494ffb166624179.tar.bz2
phpbb-c72d6a71bb71b5abeae05b4a6494ffb166624179.zip
[ticket/13904] Modify constructor to be instantiatable by container
PHPBB3-13904
Diffstat (limited to 'phpBB/phpbb/files')
-rw-r--r--phpBB/phpbb/files/filespec.php41
1 files changed, 28 insertions, 13 deletions
diff --git a/phpBB/phpbb/files/filespec.php b/phpBB/phpbb/files/filespec.php
index f74e91b0d5..4e52d13d01 100644
--- a/phpBB/phpbb/files/filespec.php
+++ b/phpBB/phpbb/files/filespec.php
@@ -33,7 +33,6 @@ class filespec
var $destination_path = '';
var $file_moved = false;
- var $init_error = false;
var $local = false;
var $error = array();
@@ -61,14 +60,19 @@ class filespec
* File Class
* @access private
*/
- function filespec($upload_ary, $upload_namespace, \phpbb\filesystem\filesystem_interface $phpbb_filesystem, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
+ function filespec(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
{
- if (!isset($upload_ary))
- {
- $this->init_error = true;
- return;
- }
+ // @todo call this via files
+ //$this->set_upload_ary($upload_ary);
+ //$this->set_upload_namespace($upload_namespace);
+ $this->plupload = $plupload;
+ $this->mimetype_guesser = $mimetype_guesser;
+ $this->filesystem = $phpbb_filesystem;
+ }
+
+ public function set_upload_ary($upload_ary)
+ {
$this->filename = $upload_ary['tmp_name'];
$this->filesize = $upload_ary['size'];
$name = (STRIP) ? stripslashes($upload_ary['name']) : $upload_ary['name'];
@@ -93,10 +97,21 @@ class filespec
$this->file_moved = false;
$this->local = (isset($upload_ary['local_mode'])) ? true : false;
- $this->upload = $upload_namespace;
- $this->plupload = $plupload;
- $this->mimetype_guesser = $mimetype_guesser;
- $this->filesystem = $phpbb_filesystem;
+ }
+
+ public function set_upload_namespace($namespace)
+ {
+ $this->upload = $namespace;
+ }
+
+ /**
+ * Check if class members were not properly initalised yet
+ *
+ * @return bool True if there was an init error, false if not
+ */
+ protected function init_error()
+ {
+ return !isset($upload_ary);
}
/**
@@ -109,7 +124,7 @@ class filespec
*/
function clean_filename($mode = 'unique', $prefix = '', $user_id = '')
{
- if ($this->init_error)
+ if ($this->init_error())
{
return;
}
@@ -154,7 +169,7 @@ class filespec
*/
function get($property)
{
- if ($this->init_error || !isset($this->$property))
+ if ($this->init_error() || !isset($this->$property))
{
return false;
}