Refactoring in UploadFile.class.php to simplify things.
[timetracker.git] / WEB-INF / lib / form / UploadFile.class.php
index 98fbe0a..50e8aad 100644 (file)
 import('form.FormElement');
        
 class UploadFile extends FormElement {
-    var $mValue;
-    var $cClassName            = "UploadFile";
-    var $mMaxSize              = 100000;       // 100kb
 
-       function __construct($name,$value="")
-       {
-               $this->name                     = $name;
-               $this->mValue                   = $value;
-       }
-       
-       function setMaxSize($value)     { $this->mMaxSize = $value;     }
-       function getMaxSize()   { return $this->mMaxSize; }
-       
-       function toStringControl()      {
-               if (!$this->isRenderable()) return "";
-           
-           if ($this->id=="") $this->id = $this->name;
-           
-               $html = "\n\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".$this->mMaxSize."\"/>";
-               $html .= "\n\t<input";
-               $html .= " name=\"$this->name\" id=\"$this->id\"";
-               
-               $html .= " type=\"file\"";
-               $html .= ">";
+  var $maxSize = 8388608; // 8MB default max size.
+
+  function __construct($name)
+  {
+    $this->class = 'UploadFile';
+    $this->name = $name;
+  }
+
+  function setMaxSize($value) { $this->maxSize = $value; }
+
+  function getHtml() {
+
+    if ($this->id == '') $this->id = $this->name;
 
-                return $html;
-       }
+    $html = "\n\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$this->maxSize\">";
+    $html .= "\n\t<input type=\"file\" id=\"$this->id\" name=\"$this->name\">";
+    return $html;
+  }
 }