Code

Updated Config parser
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 May 2011 11:49:44 +0000 (11:49 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 May 2011 11:49:44 +0000 (11:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20854 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc
gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.tpl
gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.xml [new file with mode: 0644]

index 3bbf1f9b3bf81611f1a480892a0009a4dacb0fe4..070e7d123631be7aeb2fc89a68f112f4242e8bcf 100644 (file)
@@ -34,70 +34,7 @@ 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);
-
-        // Preset item config - with Distribution and Release objects.
-        $items = array();
-        $items['root']['container'] = array('Distribution', 'Template');
-        $items['root']['name'] = '/';
-        $items['root']['description'] = _('Root');
-
-        // Define distribution paramters.
-        $dOpt1 = array('description' => _('Name'), 'default' => '', 'value' => '', 'required' => true,
-                'type' => 'string', 'display' => _('Name'), 'initiallyEditableOnly' => TRUE);
-        $dOpt2 = array('description' => _('Distribution type'), 'default' => 'deb', 'value' => 'deb', 'required' => true,
-                'type' => 'combobox', 'display' => _('Distribution type'), 
-                'values' => array("deb" => 'deb', "rpm" => 'rpm'), 'initiallyEditableOnly' => TRUE);
-        $dOpt3 = array('description' => _('Mirror Url'), 'default' => '', 'value' => '', 'required' => false,
-                'type' => 'string', 'display' => _('Mirror Url'),
-                'initiallyEditableOnly' => TRUE);
-        $dOpt4 = array('description' => _('Method'), 'default' => 'puppet', 'value' => 'puppet', 'required' => false,
-                'type' => 'combobox', 'display' => _('Installation method'), 'values'=>array('puppet'=>_('Puppet')),
-                'initiallyEditableOnly' => TRUE);
-        $dOpt5 = array('description' => _('Architecture'), 'default' => '', 'value' => '', 'required' => false,
-                'type' => 'list', 'display' => _('Architecture'));
-        $dOpt6 = array('description' => _('Component'), 'default' => '', 'value' => '', 'required' => false,
-                'type' => 'list', 'display' => _('Component'));
-        $dOpt7 = array('description' => _('Mirror sources'), 'default' => '', 'value' => '', 'required' => false,
-                'type' => 'checkbox', 'display' => _('Mirror sources'));
-
-        // Define release parameters
-        $rOpt1 = array('description' => _('Name'), 'default' => '', 'value' => '', 'required' => true,
-                'type' => 'string', 'display' => _('Name'));
-
-        // Define template parameters
-        $tOpt1 = array('description' => _('Name'), 'default' => '', 'value' => '', 'required' => true,
-                'type' => 'string', 'display' => _('Name'));
-
-        $items['Distribution']['container'] = array('Release');
-        $items['Distribution']['name'] = 'Distribution';
-        $items['Distribution']['description'] = _('Distribution');
-        $items['Distribution']['options']['name'] = $dOpt1;
-        $items['Distribution']['options']['origin'] = $dOpt3;
-        $items['Distribution']['options']['installation_type'] = $dOpt2;
-        $items['Distribution']['options']['installation_method'] = $dOpt4;
-
-        $items['Distribution']['options']['architectures'] = $dOpt5;
-        $items['Distribution']['options']['components'] = $dOpt6;
-        $items['Distribution']['options']['mirror_sources'] = $dOpt7;
-
-        $items['Release']['container'] = array('Release', '__CFG_ITEMS__');
-        $items['Release']['name'] = 'Release';
-        $items['Release']['description'] = _('Release');
-        $items['Release']['options']['name'] = $rOpt1;
-
-        $items['Template']['container'] = array();
-        $items['Template']['name'] = 'Template';
-        $items['Template']['description'] = _('Template');
-        $items['Template']['options']['name'] = $tOpt1;
-
-        $this->installationMethods = array();
-        $this->installationMethods['root']['description'] = _('root');
-        $this->installationMethods['root']['name'] = 'root';
-        $this->installationMethods['root']['title'] = _('root');
-        $this->installationMethods['root']['items']['Distribution'] = &$items['Distribution'];
-        $this->installationMethods['root']['items']['Release'] = &$items['Release'];
-        $this->installationMethods['root']['items']['root'] = &$items['root'];
-        $this->installationMethods['root']['items']['Template'] = &$items['Template'];
+        $this->installationMethods = json_decode(file_get_contents(get_template_path('goto/Config/root.xml', TRUE)), TRUE);
     }
 
     
@@ -185,7 +122,7 @@ class newConfigManagement extends plugin
         } 
         foreach($res as $tName => $tData){
             $tData['name'] = $tName;
-            $this->dataModel->addItem('Template','/root', $tName, $tData);
+            $this->dataModel->addItem('Template','/root', $tName, $tData, '-');
         }
 
 
@@ -642,6 +579,19 @@ class newConfigManagement extends plugin
                     $this->dataModel->setItemValues($item['path'], $item['values']);
                 }
             }
+        }elseif($item['type'] == 'Template'){
+            if($item['status'] == '-'){
+                $rpc = $this->config->getRpcHandle();
+                $res = $rpc->installGetTemplate($item['name']);
+                if(!$rpc->success()){
+                    msg_dialog::display(_("Error"), sprintf(_("Failed to load template details: %s"), $rpc->get_error()),ERROR_DIALOG);
+                    return;
+                }else{
+                    $item['values'] = $res;
+                    $this->dataModel->setItemStatus($item['path'], 'fetched');
+                    $this->dataModel->setItemValues($item['path'], $item['values']);
+                }
+            }
         }
 
         $this->TemplateEngine->load($this->itemConfig);
index c5318485bde98912772e33cbf662e40de1f64687..e2d8cd532d95f3bdcd8ed0645d6c2a614de8094e 100644 (file)
         <td>{$nameName}</td>
         <td>{$name}</td>
     </tr>
+    <tr>
+        <td>{$descriptionName}</td>
+        <td>{$description}</td>
+    </tr>
+    <tr>
+        <td>{$methodName}</td>
+        <td>{$method}</td>
+    </tr>
+    <tr>
+        <td>{$dataName}</td>
+        <td>{$data}</td>
+    </tr>
 </table>
 {/if}
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.xml b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.xml
new file mode 100644 (file)
index 0000000..d42a7ba
--- /dev/null
@@ -0,0 +1,150 @@
+{
+    "root": {
+        "description": "root",
+        "name": "root",
+        "title": "root",
+        "items": {
+            "Distribution": {
+                "container": [
+                    "Release"
+                ],
+                "name": "Distribution",
+                "description": "Distribution",
+                "options": {
+                    "name": {
+                        "description": "Name",
+                        "default": "",
+                        "value": "",
+                        "required": true,
+                        "type": "string",
+                        "display": "Name",
+                        "initiallyEditableOnly": true
+                    },
+                    "origin": {
+                        "description": "Mirror Url",
+                        "default": "",
+                        "value": "",
+                        "required": false,
+                        "type": "string",
+                        "display": "Mirror Url",
+                        "initiallyEditableOnly": true
+                    },
+                    "installation_type": {
+                        "description": "Distribution type",
+                        "default": "deb",
+                        "value": "deb",
+                        "required": true,
+                        "type": "combobox",
+                        "display": "Distribution type",
+                        "values": {
+                            "deb": "deb",
+                            "rpm": "rpm"
+                        },
+                        "initiallyEditableOnly": true
+                    },
+                    "installation_method": {
+                        "description": "Methode",
+                        "default": "puppet",
+                        "value": "puppet",
+                        "required": false,
+                        "type": "combobox",
+                        "display": "Installation method",
+                        "values": {
+                            "puppet": "Puppet"
+                        },
+                        "initiallyEditableOnly": true
+                    },
+                    "architectures": {
+                        "description": "Architecture",
+                        "default": "",
+                        "value": "",
+                        "required": false,
+                        "type": "list",
+                        "display": "Architecture"
+                    },
+                    "components": {
+                        "description": "Komponente",
+                        "default": "",
+                        "value": "",
+                        "required": false,
+                        "type": "list",
+                        "display": "Komponente"
+                    },
+                    "mirror_sources": {
+                        "description": "Mirror sources",
+                        "default": "",
+                        "value": "",
+                        "required": false,
+                        "type": "checkbox",
+                        "display": "Mirror sources"
+                    }
+                }
+            },
+            "Release": {
+                "container": [
+                    "Release",
+                    "__CFG_ITEMS__"
+                ],
+                "name": "Release",
+                "description": "Release",
+                "options": {
+                    "name": {
+                        "description": "Name",
+                        "default": "",
+                        "value": "",
+                        "required": true,
+                        "type": "string",
+                        "display": "Name"
+                    }
+                }
+            },
+            "root": {
+                "container": [
+                    "Distribution",
+                    "Template"
+                ],
+                "name": "\\/",
+                "description": "Wurzel"
+            },
+            "Template": {
+                "container": [],
+                "name": "Template",
+                "description": "Vorlage",
+                "options": {
+                    "name": {
+                        "description": "Name",
+                        "default": "",
+                        "value": "",
+                        "required": true,
+                        "type": "string",
+                        "display": "Name"
+                    },
+                    "description": {
+                        "description": "Beschreibung",
+                        "default": "",
+                        "value": "",
+                        "required": true,
+                        "type": "string",
+                        "display": "Beschreibung"
+                    },
+                    "method": {
+                        "description": "Methode",
+                        "default": "",
+                        "value": "",
+                        "required": true,
+                        "type": "string",
+                        "display": "Methode"
+                    },
+                    "data": {
+                        "description": "Data",
+                        "default": "",
+                        "value": "",
+                        "required": true,
+                        "type": "text",
+                        "display": "Data"
+                    }
+                }
+            }
+        }
+    }
+}