Code

Updated listing to dynamically update the action menu
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Apr 2011 12:20:18 +0000 (12:20 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Apr 2011 12:20:18 +0000 (12:20 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20656 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc

index ef0705cba199d441349004b550803edfecf5060f..cc59dc7cf9bcbf6c692a4df852cbdc0c5d7f5107 100644 (file)
@@ -160,7 +160,42 @@ class ConfigManagementListing extends management
         // Load service xml file and fill in placeholders
         $contents = file_get_contents(get_template_path("DeviceConfig-list.xml", true));
         $contents = preg_replace("/%TYPES%/", $this->objectTypeStr, $contents);
-        $contents = preg_replace("/%ITEMS%/", "", $contents);
+
+        // A list of dummy images
+        $images = array();
+        $images[] = 'images/lists/edit.png';
+        $images[] = 'images/caps.png';
+        $images[] = 'images/lists/trash.png';
+        $images[] = 'images/filter.png';
+        $images[] = 'images/find.png';
+
+
+        $items = "";
+        $i = 0;
+        foreach($this->parent->addableContainerItems as $item){
+            $desc = $this->parent->itemConfig[$item]['description'];
+            $img = $images[$i++];
+            $items .=
+                "<action>".
+                "    <name>add_{$item}</name>".
+                "    <type>entry</type>".
+                "    <image>{$img}</image>".
+                "    <label>{$desc}</label>".
+                "</action>";
+        }
+
+        if(!empty($items)){
+            $items =
+
+                "<action>".
+                " <type>sub</type>".
+                " <image>images/lists/element.png[new]</image>".
+                " <label>Create</label>".
+                " {$items}".
+                "</action>";
+        }
+
+        $contents = preg_replace("/%ITEMS%/", $items, $contents);
 
         $headpage = new listing($contents,TRUE);
         $headpage->setBase($this->base);
index 615c01a014b2e0798a8f4cdd399cfacdcfbe9584..bf29fc9e9fb2541d033195379ddf098938d0fd97 100644 (file)
@@ -203,6 +203,7 @@ class newConfigManagement extends plugin
      */
     function setCurrentContainer($cont)
     {
+
         $this->selectedContainer = $cont;
 
         // Update list of items within the selected container. 
@@ -217,6 +218,14 @@ class newConfigManagement extends plugin
             $method = $this->cfgTypeMap[$cont];
             $this->setInstallMethod($method);
         }
+
+        // Update the list of addable sub objects
+        $item = $this->dataModel->getItemByPath($cont);
+        if(isset($this->itemConfig[$item['type']]['container'])){
+            $this->addableContainerItems = $this->itemConfig[$item['type']]['container'];
+        }else{
+            $this->addableContainerItems = array();
+        }
     }