Refactoring in UploadFile.class.php to simplify things.
authorNik Okuntseff <support@anuko.com>
Tue, 16 Apr 2019 16:59:17 +0000 (16:59 +0000)
committerNik Okuntseff <support@anuko.com>
Tue, 16 Apr 2019 16:59:17 +0000 (16:59 +0000)
WEB-INF/lib/form/Form.class.php
WEB-INF/lib/form/UploadFile.class.php
WEB-INF/templates/footer.tpl
project_files.php
time_files.php

index 19dd011..1f77414 100644 (file)
@@ -95,6 +95,12 @@ class Form {
         $el = new Submit($params['name']);
         break;
 
+      case 'upload':
+        import('form.UploadFile');
+        $el = new UploadFile($params['name']);
+        if (isset($params['maxsize'])) $el->setMaxSize($params['maxsize']);
+        break;
+
 // TODO: refactoring ongoing down from here.
                        case "checkboxgroup":
                            import('form.CheckboxGroup');
@@ -129,12 +135,6 @@ class Form {
                            $el->setData(@$params["data"]);
                            $el->setWidth(@$params["width"]);
                            break;
-                           
-                       case "upload":
-                           import('form.UploadFile');
-                           $el = new UploadFile($params["name"]);
-                           if (isset($params["maxsize"])) $el->setMaxSize($params["maxsize"]);
-                           break;
                }
                if ($el!=null) {
                        $el->setFormName($this->name);
index e46f29d..50e8aad 100644 (file)
@@ -29,7 +29,8 @@
 import('form.FormElement');
        
 class UploadFile extends FormElement {
-    var $mMaxSize              = 100000;       // 100kb // TODO: refactor this.
+
+  var $maxSize = 8388608; // 8MB default max size.
 
   function __construct($name)
   {
@@ -37,21 +38,14 @@ class UploadFile extends FormElement {
     $this->name = $name;
   }
 
-// TODO: refactoring ongoing down from here.
-       function setMaxSize($value)     { $this->mMaxSize = $value;     }
-       function getMaxSize()   { return $this->mMaxSize; }
-       
-       function getHtml() {
+  function setMaxSize($value) { $this->maxSize = $value; }
 
-            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 .= ">";
+  function getHtml() {
 
-                return $html;
-       }
+    if ($this->id == '') $this->id = $this->name;
+
+    $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;
+  }
 }
index f584e2d..0cd9a3d 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.65.4948 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.65.4949 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 9ca15e3..6ffe123 100644 (file)
@@ -57,8 +57,7 @@ $files = $fileHelper::getEntityFiles($cl_project_id, 'project');
 
 $form = new Form('fileUploadForm');
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_project_id));
-$form->addInput(array('type'=>'upload','name'=>'newfile','value'=>$i18n->get('button.submit'),'maxsize'=>67108864)); // 64 MB file upload limit.
-// Note: for the above limit to work make sure to set upload_max_filesize and post_max_size in php.ini to at least 64M.
+$form->addInput(array('type'=>'upload','name'=>'newfile','value'=>$i18n->get('button.submit')));
 $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description));
 $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.add')));
 
index c499b25..33273da 100644 (file)
@@ -57,8 +57,7 @@ $files = $fileHelper::getEntityFiles($cl_id, 'time');
 
 $form = new Form('fileUploadForm');
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
-$form->addInput(array('type'=>'upload','name'=>'newfile','value'=>$i18n->get('button.submit'),'maxsize'=>67108864)); // 64 MB file upload limit.
-// Note: for the above limit to work make sure to set upload_max_filesize and post_max_size in php.ini to at least 64M.
+$form->addInput(array('type'=>'upload','name'=>'newfile','value'=>$i18n->get('button.submit')));
 $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description));
 $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.add')));