Code

Added file upload widget
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 12:44:58 +0000 (12:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 12:44:58 +0000 (12:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19800 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_file.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_textarea.inc
gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl

index 317313c3396ff70b959a4ac79842ccf60849ecef..263b88d242b34d093d96ddd27f38063ff4e0e647 100644 (file)
@@ -19,11 +19,9 @@ class DeviceConfig extends plugin
                     "dependency": {
                         "description": "Modules that are needed to be installed for this module",
                             "required": false,
-                            "value": [
-
-                                ],
+                            "value": "0x002",
                             "syntax": "^[a-zA-Z0-9_+\\\\./-]+(\\\\[[<=>]+[a-zA-Z0-9_+\\\\.-]+\\\\])?$",
-                            "type": "list",
+                            "type": "file",
                             "display": "Module dependencies"
                     },
                         "version": {
@@ -31,7 +29,7 @@ class DeviceConfig extends plugin
                             "required": true,
                             "value": "",
                             "syntax": "^[a-zA-Z0-9_+.-]+$",
-                            "type": "textarea",
+                            "type": "string",
                             "display": "Module  version"
                         },
                         "name": {
@@ -87,7 +85,7 @@ class DeviceConfig extends plugin
         $this->setCurrentItem('root');
         $this->addItem('PuppetModule','test1',
                 array(
-                    'dependency' => array('mozilla-2','toaster-2.0'),
+                    'dependency' => '',
                     'version' => '2.4-f',
                     'name'  => 'Thundebird',
                     'description' => 'Mozilla mail client')
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_file.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_file.inc
new file mode 100644 (file)
index 0000000..4c26fe3
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+class TemplateWidget_file extends TemplateWidget
+{
+    function render()
+    {
+        $title = set_post($this->description);
+        if(mb_strlen($this->value) == 0){   
+            $ret = "<i>"._("No file uploaded yet")."</i>";
+            $ret.= "<br> <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000000\">
+                <input id=\"{$this->postName}\" 
+                name=\"{$this->postName}\" 
+                type=\"file\" 
+                size=\"20\" 
+                maxlength=\"255\" 
+                accept=\"*.*\">&nbsp;";
+            $ret.= "<button name='{$this->postName}_Upload'>"._("Upload")."</button>";
+        }else{
+            $ret = "<i>"._("File uploaded").": ".mb_strlen($this->value)." "._("Bytes");
+            $ret.= "&nbsp;<button name='{$this->postName}_Remove'>".msgPool::delButton()."</button>";
+        }
+        return($ret);
+    }
+
+    function save_object()
+    {
+        if(isset($_POST["{$this->postName}_Upload"]) && isset($_FILES[$this->postName]['tmp_name'])){
+            $this->value = file_get_contents($_FILES[$this->postName]['tmp_name']);
+        }
+        if(isset($_POST["{$this->postName}_Remove"])) $this->value ="";
+    }
+}
+
+?>
index 26c733c476e8970d752aeb38ed77133bc6f428a2..030dd1156e2331f3f7c5ae1585dc997923b5c644 100644 (file)
@@ -4,7 +4,11 @@ class TemplateWidget_textarea extends TemplateWidget
 {
     function render()
     {
-        return("<textarea type='text' name=\"{$this->postName}\">".set_post($this->value)."</textarea>");
+        $title = set_post($this->description);
+        return("<textarea   title=\"{$title}\"
+                            style='width:100%' 
+                            rows=4 type='text' 
+                            name=\"{$this->postName}\">".set_post($this->value)."</textarea>");
     }
 
 }
index 78a90826ccdd59c38687b30d9c778a865c71fc0c..a5d6787a79c421f77c87b9219220df88cb84961a 100644 (file)
@@ -18,7 +18,7 @@
                 </table>
             </td>
             <td style="width:50%; vertical-align: top;">
-                {$dependencyName}
+                {$dependencyName}:<br>
                 {$dependency}
             </td>
         </tr>