From 2515caea614f88730f125c9dd35a83ecd6cd90cc Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 28 Sep 2010 07:00:36 +0000 Subject: [PATCH] Updated the item navigation git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19822 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/goto/Config/DeviceConfig.tpl | 13 ++-- .../goto/Config/class_DeviceConfig.inc | 59 +++++++++++++++++-- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl b/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl index 97893508f..0bb627e8c 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl +++ b/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig.tpl @@ -1,17 +1,12 @@

{t}Device Config{/t}

- -{t}Add a new sub-module to the current{/t} - +{$navigationList} -{$navigator} -
-

{$containerName}

-{$containerDescription} +{$containerName} ({$containerDescription}) +

{$template} +

diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc index dccca989d..5105f4f44 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc @@ -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 = "".$array['name'].""; + } + $add = '  '; + $str = str_pad('', ($depth*strlen($add)), $add, STR_PAD_LEFT).$str; + + // Add the current entry + $res['data'][] = $array; + $res['lData'][] = array('data' => array($str, "".$array['type']."")); + + // 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']); } } } -- 2.30.2