Code

Updated rendering of widgets
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 07:16:06 +0000 (07:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 07:16:06 +0000 (07:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19790 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl
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 2552e2107f360740efd23cd8dd1d660bd8ced47d..97893508f75a22a9f54a941dc2d6d2f1456cfb37 100644 (file)
@@ -1,4 +1,17 @@
 <h3>{t}Device Config{/t}</h3>
 
+{t}Add a new sub-module to the current{/t}
+<select name='subModule'>
+    {html_options output=$subModule values=$subModule}
+</select>
+<button name='addSubModule'>{msgPool type='addButton'}</button>
+
+{$navigator}
+
+<hr>
+
+<h3>{$containerName}</h3>
+{$containerDescription}
+
 {$template}
 
index dc06d32426f6e665e93a4f69e7f4354956db4421..324a51198ff4b90734d603759a689087847ad421 100644 (file)
@@ -54,7 +54,7 @@ class DeviceConfig extends plugin
                     "name": "Module",
                     "description": "Puppet     module"
             },
-                "PuppetRoot": {
+                "root": {
                     "options": {
 
                     },
@@ -66,17 +66,112 @@ class DeviceConfig extends plugin
                 }
         }';        
 
-        $str = json_decode($str, TRUE);
-        $this->TemplateEngine->load($str);
-        $this->TemplateEngine->setTemplate('puppet.tpl');
+        $this->itemConfig = json_decode($str, TRUE);
+        
+        // Check for the root object
+        if(!isset($this->itemConfig['root'])){
+            echo 'No root!';
+        }
+
+        // Set current item to 'root'.
+        $this->currentItemDescriptor = &$this->itemConfig['root'];
+        $this->currentItemValues = array();
+        $this->currentItem = array();
+
+        $this->addItem('root','root',array());
+        $this->setCurrentItem('root');
+        $this->addItem('PuppetModule','test1',
+                array(
+                    'version' => 1,
+                    'name'  => 'test1',
+                    'description' => 'Test Module')
+                );
+        $this->addItem('PuppetModule','test2',
+                array(
+                    'version' => 1,
+                    'name'  => 'test2',
+                    'description' => 'Test Module')
+                );
+        $this->setCurrentItem('test1');
+        $this->addItem('PuppetTemplate','temp1',array('name' => 'temp1', 'file' => 'kekse.tpl'));
+
+        $this->setCurrentItem('root');
+    }
+
+
+    function renderNavigator($array = NULL)
+    {
+        $array = ($array == NULL)? $this->currentItemValues['root']: $array;
+        $str = "<ul>";
+        $plug = $_GET['plug'];
+        $str .= "<a href='?plug={$plug}&amp;item={$array['name']}'>";
+        if($this->currentItemName == $array['name']){
+            $str .= "<b>".$array['name']."</b>";
+        }else{
+            $str .= $array['name'];
+        }
+        $str .= "</a>";
+
+        if(count($array['children'])){
+            foreach($array['children'] as $subItem){
+                $str .= $this->renderNavigator($subItem);
+            } 
+        }
+        $str  .= "</ul>";
+        return($str);
+    }
+
+    function addItem($type,$name, $values)
+    {
+        $current = &$this->currentItem; 
+        $new = array(
+                'children' => array(),
+                'type' => $type, 
+                'name' => $name, 
+                'values' => $values);
+        $this->currentItemValues[$name] = $new;
+        $current['children'][$name] = &$this->currentItemValues[$name];
+    }
+
+    function setCurrentItem($item)
+    {
+        $this->currentItemName = $item;
+        $this->currentItem = &$this->currentItemValues[$item];
+        $this->currentItemDescriptor =&$this->itemConfig[$this->currentItem['type']];
     }
 
 
     function execute()
     {
         $smarty = get_smarty();
+        
+        // Assign possible sub-container objects.
+        $smarty->assign('subModule', $this->currentItemDescriptor['container']);
+        $smarty->assign('containerName', $this->currentItemDescriptor['name']);
+        $smarty->assign('containerDescription', $this->currentItemDescriptor['description']);
+
+        $smarty->assign('navigator', $this->renderNavigator());
+        
+
+
+        $this->TemplateEngine->load($this->currentItemDescriptor);
+        $this->TemplateEngine->setTemplate('puppet.tpl');
         $smarty->assign('template',$this->TemplateEngine->render());
         return($smarty->fetch(get_template_path('goto/Config/DeviceConfig.tpl', TRUE)));
     }
+
+    function save_object()
+    {
+        if(isset($_POST['addSubModule']) && isset($_POST['subModule'])){
+            $sub = get_post('subModule');
+            if(in_array($sub, $this->currentItemDescriptor['container'])){
+                
+            }
+        }
+    
+        if(isset($_GET['item'])){
+            $this->setCurrentItem($_GET['item']);
+        }
+    }
 }
 ?>
index 6654dc47ab2d58d85358f4cc4397ba48d81af436..3d4606796801810477c6e9eff1428ac781c47aad 100644 (file)
@@ -14,6 +14,7 @@ class TemplateEngine
     function load($array)
     {
         $this->data = $array;
+
     }
   
     function setTemplate($tmpl)
@@ -24,7 +25,7 @@ class TemplateEngine
     function getWidgets()
     {
         $res = array();
-        $res[] = new TemplateWidget($this->config, 'name', 'herbert');
+#        $res[] = new TemplateWidget($this->config, 'name', 'herbert');
         return($res);
     }     
 
index 812444e1431664437bb5cc36c9f0c7159c78747f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,3 +0,0 @@
-<h3>{t}Puppet{/t}</h3>
-<hr>
-{$name}