Code

Updated config mangement
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 May 2011 13:58:25 +0000 (13:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 May 2011 13:58:25 +0000 (13:58 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20861 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc
gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.json

index eca4fbeb844cc86bd5d1b6ea777a25f175799d69..5174850653f7df3ae1cfc636ba530822a4609a35 100644 (file)
@@ -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);
     }
 
 
index 423df6e218b961a7ffbac976949a62b9ed0234d8..30a6c450240c869ad9f9b322ecf0d15e5068c47f 100644 (file)
                         "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": {
                 }
             },
             "Release": {
-                "container": [
-                    "Release",
-                    "__CFG_ITEMS__"
-                ],
+                "container": "%ROOT_CFG_ITEMS",
                 "name": "Release",
                 "description": "Release",
                 "options": {
                         "default": "",
                         "value": "",
                         "required": true,
-                        "type": "string",
-                        "display": "Methode"
+                        "type": "combobox",
+                        "display": "Method",
+                        "values": "%TEMPLATE_METHODS",
+                        "initiallyEditableOnly": true
                     },
                     "data": {
                         "description": "Data",