Code

Updated template engine
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 07:51:00 +0000 (07:51 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 07:51:00 +0000 (07:51 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19792 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc
gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl

index f0ed51c56d666314f5f4aa769ada8adec2bfa0a2..01d9ecc484e05ce4b70fc30feac0a181ff550eda 100644 (file)
@@ -69,6 +69,7 @@ class DeviceConfig extends plugin
         }';        
 
         $this->itemConfig = json_decode($str, TRUE);
+        $this->TemplateEngine->load($this->itemConfig);
         
         // Check for the root object
         if(!isset($this->itemConfig['root'])){
@@ -142,6 +143,7 @@ class DeviceConfig extends plugin
     {
         $this->currentItemName = $item;
         $this->currentItem = &$this->currentItemValues[$item];
+        $this->currentItemType = $this->currentItem['type'];
         $this->currentItemDescriptor =&$this->itemConfig[$this->currentItem['type']];
     }
 
@@ -159,7 +161,8 @@ class DeviceConfig extends plugin
         
 
 
-        $this->TemplateEngine->load($this->currentItemDescriptor);
+        $this->TemplateEngine->setType($this->currentItemType);
+        $this->TemplateEngine->setValues($this->currentItem);
         $this->TemplateEngine->setTemplate('puppet.tpl');
         $smarty->assign('template',$this->TemplateEngine->render());
         return($smarty->fetch(get_template_path('goto/Config/DeviceConfig.tpl', TRUE)));
index 3d4606796801810477c6e9eff1428ac781c47aad..f976ed51a33c73d9a54b9e63a4cbd6ddcdf56c28 100644 (file)
@@ -6,15 +6,34 @@ class TemplateEngine
     private $data = array();    
     private $template = "";
 
+    private $itemType = '';
+
     function __construct($config)
     {
         $this->config = &$config;
     }
 
+    function setValues($array)
+    {
+#        print_a($array);
+    }
+
+    function setType($name)
+    {
+        $this->itemType = $name;
+        $this->widgets = array();
+
+        $data = $this->data[$this->itemType];
+        if(isset($data['options']) && count($data['options'])){
+            foreach($data['options'] as $name => $item){
+                $this->widgets[] = new TemplateWidget($this->config, $name, $item['value']);
+            }
+        }
+    }
+
     function load($array)
     {
         $this->data = $array;
-
     }
   
     function setTemplate($tmpl)
@@ -24,14 +43,13 @@ class TemplateEngine
     
     function getWidgets()
     {
-        $res = array();
-#        $res[] = new TemplateWidget($this->config, 'name', 'herbert');
-        return($res);
+        return($this->widgets);
     }     
 
     function render()
     {
         $smarty = get_smarty();
+        $smarty->assign("type", $this->itemType);
         foreach($this->getWidgets() as $widget){
             $smarty->assign($widget->getName(), $widget->render());
         }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..92506229e71bba80c4b813b5b43fd900f5c8ca8f 100644 (file)
@@ -0,0 +1,6 @@
+{if $type == 'PuppetModule'}
+   <br>{$dependency}
+   <br>{$version}
+   <br>{$name}
+   <br>{$description}
+{/if}