Code

Updated the item navigation
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Sep 2010 07:00:36 +0000 (07:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Sep 2010 07:00:36 +0000 (07:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19822 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 97893508f75a22a9f54a941dc2d6d2f1456cfb37..0bb627e8cac208877fc05eeabcfef6680a0fd3e8 100644 (file)
@@ -1,17 +1,12 @@
 <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>
+{$navigationList}
 <button name='addSubModule'>{msgPool type='addButton'}</button>
 
-{$navigator}
-
 <hr>
 
-<h3>{$containerName}</h3>
-{$containerDescription}
+<b>{$containerName}</b>&nbsp;<i>({$containerDescription})</i>
 
+<p>
 {$template}
+</p>
 
index dccca989dc43051d97c53266e65b1f7265cd0ad8..5105f4f44d7760f189930220b6427dd138b43ad9 100644 (file)
@@ -10,6 +10,8 @@ class DeviceConfig extends plugin
     private $currentItemValues = array();
     private $currentItem = array();
 
+    private $navigationList = NULL;
+    
 
     /*! \brief  Constructs the device configuration plugin 
      *  @param  Config  The GOsa configuration object.
@@ -22,6 +24,16 @@ class DeviceConfig extends plugin
         $this->TemplateEngine->setTemplate('puppet.tpl');
         $this->config = $config;
 
+        $this->navigationList= new sortableListing();
+        $this->navigationList->setDeleteable(true);
+        $this->navigationList->setEditable(true);
+        $this->navigationList->setColspecs(array('*'));
+        $this->navigationList->setWidth("100%");
+        $this->navigationList->setHeight("140px");
+        $this->navigationList->setAcl("rwcdm");
+        $this->navigationList->sortingEnabled(FALSE);
+
+
         // CREATE Dummy entry 
 
         $str = '{
@@ -145,6 +157,37 @@ class DeviceConfig extends plugin
         return($str);
     }
 
+    function getItemList($array=NULL,&$res = NULL, $depth = 0)
+    {
+        // Prepare values.
+        $array = ($array == NULL)? $this->currentItemValues['root']: $array;
+        if(!$res){
+            $res = array('data' => array(), 'lData' => array());
+        }
+
+        // Prepare the entry name
+        $str = $array['name'];
+        if($this->currentItemName == $array['name']){
+            $str = "<b>".$array['name']."</b>";
+        }
+        $add = '&nbsp;&nbsp;';
+        $str = str_pad('', ($depth*strlen($add)), $add, STR_PAD_LEFT).$str;
+
+        // Add the current entry
+        $res['data'][] = $array;
+        $res['lData'][] = array('data' => array($str, "<i>".$array['type']."</i>"));
+
+        // Add sub-entries
+        if(count($array['children'])){
+            $depth ++;
+            foreach($array['children'] as $subItem){
+                $this->getItemList($subItem, $res, $depth);
+            } 
+        }
+
+        return($res);
+    }
+
 
     /*! \brief      Add a new child-item to the currently selected one. 
      *               
@@ -203,6 +246,12 @@ class DeviceConfig extends plugin
     {
         $smarty = get_smarty();
 
+        // Generate item list
+        $list = $this->getItemList();
+        $this->navigationList->setListData($list['data'],$list['lData']);
+        $this->navigationList->update();
+        $smarty->assign('navigationList',$this->navigationList->render());
+
         // Assign the navigation bar.
         $smarty->assign('navigator', $this->renderNavigator());
 
@@ -246,10 +295,12 @@ class DeviceConfig extends plugin
             }
         }
 
-        // Module switched
-        if(isset($_GET['item'])){
-            $name = $this->idToName[$_GET['item']];
-            $this->setCurrentItem($name);
+        // Another item selected?
+        $this->navigationList->save_object();
+        $action = $this->navigationList->getAction();
+        if($action['action'] == 'edit'){
+            $item = $this->navigationList->getData($action['targets'][0]);
+            $this->setCurrentItem($item['name']);
         }
     }
 }