From a53440c745198e2c27e575f2e2042d4837b784b3 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 18 May 2011 13:58:25 +0000 Subject: [PATCH] Updated config mangement git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20861 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../class_newConfigManagement.inc | 34 ++++++++++++++----- .../newConfigManagement/goto/Config/root.json | 20 ++++------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc index eca4fbeb8..517485065 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -34,7 +34,6 @@ class newConfigManagement extends plugin // Load the template engine and tell her what template // to use for the HTML it produces. $this->TemplateEngine = new TemplateEngine($config); - $this->installationMethods = json_decode(file_get_contents(get_template_path('goto/Config/root.json', TRUE)), TRUE); } @@ -57,6 +56,9 @@ class newConfigManagement extends plugin */ function loadInstallationMethods() { + // Get static installation methods. + $this->installationMethods = json_decode(file_get_contents(get_template_path('goto/Config/root.json', TRUE)), TRUE); + // Load configuration via rpc. $rpc = $this->config->getRpcHandle(); $res = $rpc->getSupportedInstallMethods(); @@ -78,7 +80,7 @@ class newConfigManagement extends plugin $this->cfgItemMap = array(); $this->itemConfig = array(); $this->itemsPerMethod = array(); - $rootElements = array(); + $rootElements = array('Release'); foreach($this->installationMethods as $method => $items){ foreach($items['items'] as $itemName => $item){ $this->itemsPerMethod[$method][] = $itemName; @@ -92,15 +94,31 @@ class newConfigManagement extends plugin } } } + } - // Merge in root elements to releases. - foreach($this->itemConfig as $item => $data){ - if(in_array('__CFG_ITEMS__', $data['container'])){ - $this->itemConfig[$item]['container'] = array_merge($this->itemConfig[$item]['container'], $rootElements ); - } + // Fill replacements + $map['%ROOT_CFG_ITEMS'] = &$rootElements; + $map['%INSTALLATION_TYPES'] = array('dep' => 'dep', 'rpm' => 'rpm'); + $map['%INSTALLATION_METHODS'] = array('puppet' => 'puppet'); + $map['%TEMPLATE_METHODS'] = array('preseed' => 'preseed'); + $this->itemConfig = $this->__fillPlaceholder($this->itemConfig, $map); + + return(TRUE); + } + + + function __fillPlaceholder($data, $placeholder) + { + foreach($data as $name => $sData){ + if(is_array($sData)){ + $data[$name] = $this->__fillPlaceholder($data[$name], $placeholder); + }elseif(is_string($sData) && isset($placeholder[$sData])){ + $data[$name] = &$placeholder[$sData]; + echo "Jep {$name}"; } } - return(TRUE); + + return($data); } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.json b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.json index 423df6e21..30a6c4502 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.json +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.json @@ -37,10 +37,7 @@ "required": true, "type": "combobox", "display": "Distribution type", - "values": { - "deb": "deb", - "rpm": "rpm" - }, + "values": "%INSTALLATION_TYPES", "initiallyEditableOnly": true }, "installation_method": { @@ -50,9 +47,7 @@ "required": false, "type": "combobox", "display": "Installation method", - "values": { - "puppet": "Puppet" - }, + "values": "%INSTALLATION_METHODS", "initiallyEditableOnly": true }, "architectures": { @@ -82,10 +77,7 @@ } }, "Release": { - "container": [ - "Release", - "__CFG_ITEMS__" - ], + "container": "%ROOT_CFG_ITEMS", "name": "Release", "description": "Release", "options": { @@ -136,8 +128,10 @@ "default": "", "value": "", "required": true, - "type": "string", - "display": "Methode" + "type": "combobox", + "display": "Method", + "values": "%TEMPLATE_METHODS", + "initiallyEditableOnly": true }, "data": { "description": "Data", -- 2.30.2