]> git.andy128k.dev Git - ipf.git/commitdiff
upload settings
authoravl <alex.litovchenko@gmail.com>
Fri, 20 Feb 2009 17:13:16 +0000 (19:13 +0200)
committeravl <alex.litovchenko@gmail.com>
Fri, 20 Feb 2009 17:13:16 +0000 (19:13 +0200)
ipf.php
ipf/form/field/file.php
ipf/form/widget/fileinput.php

diff --git a/ipf.php b/ipf.php
index faf936319ecfef7d10365ed1ca6f7efe820b730a..49e9b3e0ae38b404edd636ff893193e5a90b4f75 100644 (file)
--- 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)
index 113cc3425f0f4a60d5bcfc983f46bc43f9c7521f..9948a6e5e797ae92a9ef120e2e577eea93c61a35 100644 (file)
@@ -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;
 }
index 5ae334d3428098939c751a2c7583dc4fb5436571..65b033bec8ac1fbe11050495b5f116bbdd631415 100644 (file)
@@ -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 = '<nobr>Currently: <a target="_blank" href="'.IPF::get('upload_url').$value.'">'.$value.'</a>&nbsp;|&nbsp;<input name="'.$name.'_remove" value="1" id="id_'.$name.'_remove" type="checkbox" />&nbsp;<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>&nbsp;|&nbsp;<input name="'.$name.'_remove" value="1" id="id_'.$name.'_remove" type="checkbox" />&nbsp;<label class="file_remove" for="id_'.$name.'_remove">Remove</label></nobr>Change:';
                                else
                        $sim = '<nobr>Currently: <b>'.$value.'</b><br> 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