}
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)
if ($value['name']=='')
return '';
-
parent::clean($value);
-
+
$errors = array();
$no_files = false;
switch ($value['error']) {
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)));
}
$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;
}
public $needs_multipart_form = true;
public $allow_extended = true;
+ public $additional_params = array();
+
public function render($name, $value, $extra_attrs=array())
{
$sim = '';
$value = $value['data'];
if (is_string($value) && $value!=''){
if ($this->allow_extended)
- $sim = '<nobr>Currently: <a target="_blank" href="'.IPF::get('upload_url').$value.'">'.$value.'</a> | <input name="'.$name.'_remove" value="1" id="id_'.$name.'_remove" type="checkbox" /> <label class="file_remove" for="id_'.$name.'_remove">Remove</label></nobr>Change:';
+ $sim = '<nobr>Currently: <a target="_blank" href="'.IPF::getUploadUrl($this->additional_params).$value.'">'.$value.'</a> | <input name="'.$name.'_remove" value="1" id="id_'.$name.'_remove" type="checkbox" /> <label class="file_remove" for="id_'.$name.'_remove">Remove</label></nobr>Change:';
else
$sim = '<nobr>Currently: <b>'.$value.'</b><br> Change: ';
}
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']))
return null;
}
- public function valueToFormData($name, $data)
- {
+ public function valueToFormData($name, $data){
if (isset($data[$name])) {
$remove = false;
if (isset($data[$name.'_remove']))
}
return null;
}
-
-
-
}
\ No newline at end of file