From ce0c3e79c06630a949d1b7159cbafce41d8f69ad Mon Sep 17 00:00:00 2001 From: avl Date: Fri, 20 Feb 2009 19:13:16 +0200 Subject: [PATCH] upload settings --- ipf.php | 8 ++++++++ ipf/form/field/file.php | 7 +++---- ipf/form/widget/fileinput.php | 13 +++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ipf.php b/ipf.php index faf9363..49e9b3e 100644 --- a/ipf.php +++ b/ipf.php @@ -151,6 +151,14 @@ final class IPF{ } return $upload_path; } + + public static function getUploadUrl($params=array()){ + $upload_url = IPF::get('upload_url', '/media/upload'); + if (isset($params['upload_url'])) { + $upload_url = $params['upload_url']; + } + return $upload_url; + } } function __($str) diff --git a/ipf/form/field/file.php b/ipf/form/field/file.php index 113cc34..9948a6e 100644 --- a/ipf/form/field/file.php +++ b/ipf/form/field/file.php @@ -18,9 +18,8 @@ class IPF_Form_Field_File extends IPF_Form_Field if ($value['name']=='') return ''; - parent::clean($value); - + $errors = array(); $no_files = false; switch ($value['error']) { @@ -47,7 +46,7 @@ class IPF_Form_Field_File extends IPF_Form_Field throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.')); } if ($value['size'] > $this->max_size) { - throw new IPF_Exception_Form(sprintf(__('The uploaded file is to big (%1$s). Reduce the size to less than %2$s and try again.'), + throw new IPF_Exception_Form(sprintf(__('The uploaded file is to big (%1$s). Reduce the size to less than %2$s and try again.'), IPF_Utils::prettySize($value['size']), IPF_Utils::prettySize($this->max_size))); } @@ -64,7 +63,7 @@ function IPF_Form_Field_moveToUploadFolder($value, $params=array()) $dest = $upload_path.DIRECTORY_SEPARATOR.$name; if (!move_uploaded_file($value['tmp_name'], $dest)) { throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.')); - } + } @chmod($dest, IPF::get('file_permission')); return $name; } diff --git a/ipf/form/widget/fileinput.php b/ipf/form/widget/fileinput.php index 5ae334d..65b033b 100644 --- a/ipf/form/widget/fileinput.php +++ b/ipf/form/widget/fileinput.php @@ -6,6 +6,8 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input public $needs_multipart_form = true; public $allow_extended = true; + public $additional_params = array(); + public function render($name, $value, $extra_attrs=array()) { $sim = ''; @@ -13,7 +15,7 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input $value = $value['data']; if (is_string($value) && $value!=''){ if ($this->allow_extended) - $sim = 'Currently: '.$value.' |  Change:'; + $sim = 'Currently: '.$value.' |  Change:'; else $sim = 'Currently: '.$value.'
Change: '; } @@ -22,8 +24,7 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input return $sim.parent::render($name, $value, $extra_attrs); } - public function valueFromFormData($name, $data) - { + public function valueFromFormData($name, $data){ if (isset($data[$name])) { $remove = false; if (isset($data[$name.'_remove'])) @@ -35,8 +36,7 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input return null; } - public function valueToFormData($name, $data) - { + public function valueToFormData($name, $data){ if (isset($data[$name])) { $remove = false; if (isset($data[$name.'_remove'])) @@ -47,7 +47,4 @@ class IPF_Form_Widget_FileInput extends IPF_Form_Widget_Input } return null; } - - - } \ No newline at end of file -- 2.49.0