From c22e37423301ec8c33e5b3ff34db723968f0f572 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 21 Sep 2010 13:33:13 +0000 Subject: [PATCH] Added first shot on item configuration git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19788 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/goto/Config/DeviceConfig.tpl | 4 + .../goto/Config/class_DeviceConfig.inc | 82 +++++++++++++++++++ .../goto/Config/class_TemplateEngine.inc | 42 ++++++++++ .../goto/Config/class_TemplateWidget.inc | 40 +++++++++ .../goto/admin/systems/goto/Config/puppet.tpl | 3 + 5 files changed, 171 insertions(+) create mode 100644 gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl create mode 100644 gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc create mode 100644 gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc create mode 100644 gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc create mode 100644 gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl 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 index 000000000..2552e2107 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl @@ -0,0 +1,4 @@ +

{t}Device Config{/t}

+ +{$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 index 000000000..dc06d3242 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc @@ -0,0 +1,82 @@ +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 index 000000000..6654dc47a --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc @@ -0,0 +1,42 @@ +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 index 000000000..d946c3cc1 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc @@ -0,0 +1,40 @@ +name = $name; + $this->value = $value; + $this->config = &$config; + } + + + function render() + { + return("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 index 000000000..812444e14 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl @@ -0,0 +1,3 @@ +

{t}Puppet{/t}

+
+{$name} -- 2.30.2