Code

Added first shot on item configuration
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 21 Sep 2010 13:33:13 +0000 (13:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 21 Sep 2010 13:33:13 +0000 (13:33 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19788 594d385d-05f5-0310-b6e9-bd551577e9d8

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

diff --git a/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl b/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl
new file mode 100644 (file)
index 0000000..2552e21
--- /dev/null
@@ -0,0 +1,4 @@
+<h3>{t}Device Config{/t}</h3>
+
+{$template}
+
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
new file mode 100644 (file)
index 0000000..dc06d32
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+
+class DeviceConfig extends plugin
+{
+    private $TemplateEngine = NULL;
+
+    function __construct(&$config, $dn)
+    {
+        $this->TemplateEngine = new TemplateEngine($config);
+        $this->config = $config;
+
+        $str = '{
+            "PuppetModule": {
+                "options": {
+                    "dependency": {
+                        "description": "Modules that are needed to be installed for this module",
+                            "required": false,
+                            "value": [
+
+                                ],
+                            "syntax": "^[a-zA-Z0-9_+\\\\./-]+(\\\\[[<=>]+[a-zA-Z0-9_+\\\\.-]+\\\\])?$",
+                            "type": "list",
+                            "display": "Module dependencies"
+                    },
+                        "version": {
+                            "description": "The version of the puppet module",
+                            "required": true,
+                            "value": "",
+                            "syntax": "^[a-zA-Z0-9_+.-]+$",
+                            "type": "string",
+                            "display": "Module  version"
+                        },
+                        "name": {
+                            "description": "The name of the puppet module",
+                            "required": true,
+                            "value": "",
+                            "syntax": "^[a-zA-Z0-9_+.-]+$",
+                            "type": "string",
+                            "display": "Module name"
+                        },
+                        "description": {
+                            "required": false,
+                            "type": "string",
+                            "display": "Module description",
+                            "value": "",
+                            "description": "Text       briefly describing the module contents"
+                        }
+                },
+                    "container": [
+                        "PuppetManifest",
+                    "PuppetFile",
+                    "PuppetTemplate"
+                        ],
+                    "name": "Module",
+                    "description": "Puppet     module"
+            },
+                "PuppetRoot": {
+                    "options": {
+
+                    },
+                    "container": [
+                        "PuppetModule"
+                        ],
+                    "name": "Root",
+                    "description": "The root item"
+                }
+        }';        
+
+        $str = json_decode($str, TRUE);
+        $this->TemplateEngine->load($str);
+        $this->TemplateEngine->setTemplate('puppet.tpl');
+    }
+
+
+    function execute()
+    {
+        $smarty = get_smarty();
+        $smarty->assign('template',$this->TemplateEngine->render());
+        return($smarty->fetch(get_template_path('goto/Config/DeviceConfig.tpl', TRUE)));
+    }
+}
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc
new file mode 100644 (file)
index 0000000..6654dc4
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+class TemplateEngine
+{
+    private $config;
+    private $data = array();    
+    private $template = "";
+
+    function __construct($config)
+    {
+        $this->config = &$config;
+    }
+
+    function load($array)
+    {
+        $this->data = $array;
+    }
+  
+    function setTemplate($tmpl)
+    {
+        $this->template = $tmpl;
+    }
+    
+    function getWidgets()
+    {
+        $res = array();
+        $res[] = new TemplateWidget($this->config, 'name', 'herbert');
+        return($res);
+    }     
+
+    function render()
+    {
+        $smarty = get_smarty();
+        foreach($this->getWidgets() as $widget){
+            $smarty->assign($widget->getName(), $widget->render());
+        }
+        return($smarty->fetch(get_template_path("goto/Config/{$this->template}", TRUE)));
+    }
+}
+
+
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc
new file mode 100644 (file)
index 0000000..d946c3c
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+class TemplateWidget
+{
+    private $name = "unnamed";
+    private $value = "";
+
+    function __construct(&$config, $name, $value)
+    {
+        $this->name = $name;
+        $this->value = $value;
+        $this->config = &$config;
+    }
+
+
+    function render()
+    {
+        return("<input type='text' name=\"{$this->name}\" value=\"".set_post($this->value)."\">");
+    }
+
+    function save_object()
+    {
+    }
+
+    function getValue()
+    {
+    }
+
+    function getName()
+    {
+        return($this->name);
+    }
+
+    function setValue()
+    {
+    }
+
+}
+
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl b/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl
new file mode 100644 (file)
index 0000000..812444e
--- /dev/null
@@ -0,0 +1,3 @@
+<h3>{t}Puppet{/t}</h3>
+<hr>
+{$name}