Qual: Try to remove warning on private properties
This commit is contained in:
parent
520aaa2238
commit
c92dbe7e61
@ -53,9 +53,9 @@ $element = GETPOST('element');
|
|||||||
*/
|
*/
|
||||||
class UploadHandler
|
class UploadHandler
|
||||||
{
|
{
|
||||||
private $options;
|
private $_options;
|
||||||
private $fk_elment;
|
private $_fk_element;
|
||||||
private $element;
|
private $_element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,10 +70,10 @@ class UploadHandler
|
|||||||
|
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$this->fk_element=$fk_element;
|
$this->_fk_element=$fk_element;
|
||||||
$this->element=$element;
|
$this->_element=$element;
|
||||||
|
|
||||||
$this->options = array(
|
$this->_options = array(
|
||||||
'script_url' => $_SERVER['PHP_SELF'],
|
'script_url' => $_SERVER['PHP_SELF'],
|
||||||
'upload_dir' => $conf->$element->dir_output . '/' . $fk_element . '/',
|
'upload_dir' => $conf->$element->dir_output . '/' . $fk_element . '/',
|
||||||
'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$fk_element.'/',
|
'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$fk_element.'/',
|
||||||
@ -102,7 +102,7 @@ class UploadHandler
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($options) {
|
if ($options) {
|
||||||
$this->options = array_merge_recursive($this->options, $options);
|
$this->_options = array_merge_recursive($this->_options, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,22 +114,22 @@ class UploadHandler
|
|||||||
*/
|
*/
|
||||||
private function get_file_object($file_name)
|
private function get_file_object($file_name)
|
||||||
{
|
{
|
||||||
$file_path = $this->options['upload_dir'].$file_name;
|
$file_path = $this->_options['upload_dir'].$file_name;
|
||||||
if (is_file($file_path) && $file_name[0] !== '.')
|
if (is_file($file_path) && $file_name[0] !== '.')
|
||||||
{
|
{
|
||||||
$file = new stdClass();
|
$file = new stdClass();
|
||||||
$file->name = $file_name;
|
$file->name = $file_name;
|
||||||
$file->mime = dol_mimetype($file_name,'',2);
|
$file->mime = dol_mimetype($file_name,'',2);
|
||||||
$file->size = filesize($file_path);
|
$file->size = filesize($file_path);
|
||||||
$file->url = $this->options['upload_url'].rawurlencode($file->name);
|
$file->url = $this->_options['upload_url'].rawurlencode($file->name);
|
||||||
foreach($this->options['image_versions'] as $version => $options) {
|
foreach($this->_options['image_versions'] as $version => $options) {
|
||||||
if (is_file($options['upload_dir'].$file_name)) {
|
if (is_file($options['upload_dir'].$file_name)) {
|
||||||
$tmp=explode('.',$file->name);
|
$tmp=explode('.',$file->name);
|
||||||
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
|
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$file->delete_url = $this->options['script_url']
|
$file->delete_url = $this->_options['script_url']
|
||||||
.'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
|
.'?file='.rawurlencode($file->name).'&fk_element='.$this->_fk_element.'&element='.$this->_element;
|
||||||
$file->delete_type = 'DELETE';
|
$file->delete_type = 'DELETE';
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ class UploadHandler
|
|||||||
*/
|
*/
|
||||||
private function get_file_objects()
|
private function get_file_objects()
|
||||||
{
|
{
|
||||||
return array_values(array_filter(array_map(array($this, 'get_file_object'), scandir($this->options['upload_dir']))));
|
return array_values(array_filter(array_map(array($this, 'get_file_object'), scandir($this->_options['upload_dir']))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,7 +156,7 @@ class UploadHandler
|
|||||||
private function create_scaled_image($file_name, $options)
|
private function create_scaled_image($file_name, $options)
|
||||||
{
|
{
|
||||||
global $maxwidthmini, $maxheightmini;
|
global $maxwidthmini, $maxheightmini;
|
||||||
$file_path = $this->options['upload_dir'].$file_name;
|
$file_path = $this->_options['upload_dir'].$file_name;
|
||||||
$new_file_path = $options['upload_dir'].$file_name;
|
$new_file_path = $options['upload_dir'].$file_name;
|
||||||
|
|
||||||
if (create_exdir($options['upload_dir']) >= 0)
|
if (create_exdir($options['upload_dir']) >= 0)
|
||||||
@ -191,7 +191,7 @@ class UploadHandler
|
|||||||
if ($error) {
|
if ($error) {
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
if (!preg_match($this->options['accept_file_types'], $file->name)) {
|
if (!preg_match($this->_options['accept_file_types'], $file->name)) {
|
||||||
return 'acceptFileTypes';
|
return 'acceptFileTypes';
|
||||||
}
|
}
|
||||||
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
|
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
|
||||||
@ -199,18 +199,18 @@ class UploadHandler
|
|||||||
} else {
|
} else {
|
||||||
$file_size = $_SERVER['CONTENT_LENGTH'];
|
$file_size = $_SERVER['CONTENT_LENGTH'];
|
||||||
}
|
}
|
||||||
if ($this->options['max_file_size'] && (
|
if ($this->_options['max_file_size'] && (
|
||||||
$file_size > $this->options['max_file_size'] ||
|
$file_size > $this->_options['max_file_size'] ||
|
||||||
$file->size > $this->options['max_file_size'])
|
$file->size > $this->_options['max_file_size'])
|
||||||
) {
|
) {
|
||||||
return 'maxFileSize';
|
return 'maxFileSize';
|
||||||
}
|
}
|
||||||
if ($this->options['min_file_size'] &&
|
if ($this->_options['min_file_size'] &&
|
||||||
$file_size < $this->options['min_file_size']) {
|
$file_size < $this->_options['min_file_size']) {
|
||||||
return 'minFileSize';
|
return 'minFileSize';
|
||||||
}
|
}
|
||||||
if (is_int($this->options['max_number_of_files']) && (
|
if (is_int($this->_options['max_number_of_files']) && (
|
||||||
count($this->get_file_objects()) >= $this->options['max_number_of_files'])
|
count($this->get_file_objects()) >= $this->_options['max_number_of_files'])
|
||||||
) {
|
) {
|
||||||
return 'maxNumberOfFiles';
|
return 'maxNumberOfFiles';
|
||||||
}
|
}
|
||||||
@ -235,11 +235,11 @@ class UploadHandler
|
|||||||
$file->size = intval($size);
|
$file->size = intval($size);
|
||||||
$file->type = $type;
|
$file->type = $type;
|
||||||
$error = $this->has_error($uploaded_file, $file, $error);
|
$error = $this->has_error($uploaded_file, $file, $error);
|
||||||
if (!$error && $file->name && create_exdir($this->options['upload_dir']) >= 0) {
|
if (!$error && $file->name && create_exdir($this->_options['upload_dir']) >= 0) {
|
||||||
if ($file->name[0] === '.') {
|
if ($file->name[0] === '.') {
|
||||||
$file->name = substr($file->name, 1);
|
$file->name = substr($file->name, 1);
|
||||||
}
|
}
|
||||||
$file_path = $this->options['upload_dir'].$file->name;
|
$file_path = $this->_options['upload_dir'].$file->name;
|
||||||
$append_file = is_file($file_path) && $file->size > filesize($file_path);
|
$append_file = is_file($file_path) && $file->size > filesize($file_path);
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
|
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
|
||||||
@ -264,8 +264,8 @@ class UploadHandler
|
|||||||
}
|
}
|
||||||
$file_size = filesize($file_path);
|
$file_size = filesize($file_path);
|
||||||
if ($file_size === $file->size) {
|
if ($file_size === $file->size) {
|
||||||
$file->url = $this->options['upload_url'].rawurlencode($file->name);
|
$file->url = $this->_options['upload_url'].rawurlencode($file->name);
|
||||||
foreach($this->options['image_versions'] as $version => $options)
|
foreach($this->_options['image_versions'] as $version => $options)
|
||||||
{
|
{
|
||||||
if ($this->create_scaled_image($file->name, $options))
|
if ($this->create_scaled_image($file->name, $options))
|
||||||
{
|
{
|
||||||
@ -273,13 +273,13 @@ class UploadHandler
|
|||||||
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
|
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($this->options['discard_aborted_uploads']) {
|
} else if ($this->_options['discard_aborted_uploads']) {
|
||||||
unlink($file_path);
|
unlink($file_path);
|
||||||
$file->error = 'abort';
|
$file->error = 'abort';
|
||||||
}
|
}
|
||||||
$file->size = $file_size;
|
$file->size = $file_size;
|
||||||
$file->delete_url = $this->options['script_url']
|
$file->delete_url = $this->_options['script_url']
|
||||||
.'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
|
.'?file='.rawurlencode($file->name).'&fk_element='.$this->_fk_element.'&element='.$this->_element;
|
||||||
$file->delete_type = 'DELETE';
|
$file->delete_type = 'DELETE';
|
||||||
} else {
|
} else {
|
||||||
$file->error = $error;
|
$file->error = $error;
|
||||||
@ -312,8 +312,8 @@ class UploadHandler
|
|||||||
*/
|
*/
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
$upload = isset($_FILES[$this->options['param_name']]) ?
|
$upload = isset($_FILES[$this->_options['param_name']]) ?
|
||||||
$_FILES[$this->options['param_name']] : array(
|
$_FILES[$this->_options['param_name']] : array(
|
||||||
'tmp_name' => null,
|
'tmp_name' => null,
|
||||||
'name' => null,
|
'name' => null,
|
||||||
'size' => null,
|
'size' => null,
|
||||||
@ -359,10 +359,10 @@ class UploadHandler
|
|||||||
{
|
{
|
||||||
$file_name = isset($_REQUEST['file']) ?
|
$file_name = isset($_REQUEST['file']) ?
|
||||||
basename(stripslashes($_REQUEST['file'])) : null;
|
basename(stripslashes($_REQUEST['file'])) : null;
|
||||||
$file_path = $this->options['upload_dir'].$file_name;
|
$file_path = $this->_options['upload_dir'].$file_name;
|
||||||
$success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
|
$success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
|
||||||
if ($success) {
|
if ($success) {
|
||||||
foreach($this->options['image_versions'] as $version => $options) {
|
foreach($this->_options['image_versions'] as $version => $options) {
|
||||||
$file = $options['upload_dir'].$file_name;
|
$file = $options['upload_dir'].$file_name;
|
||||||
if (is_file($file)) {
|
if (is_file($file)) {
|
||||||
unlink($file);
|
unlink($file);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user