Code

Updated list widget
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 11:44:42 +0000 (11:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 27 Sep 2010 11:44:42 +0000 (11:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19797 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget.inc
gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_list.inc

index 0f92ffb185d59f0a531b8ef341c057cfc096a09b..15935ae9068b325dd8feebbb91b4ea54b8525149 100644 (file)
@@ -19,22 +19,20 @@ class TemplateWidget
         $this->required = $required;
         $this->type = $type;
         $this->display = $display;
+        $class = get_class();
+        $this->postName = "{$class}_{$this->name}";
     }
 
 
     function render()
     {
-
-        $class = get_class();
-        return("{$this->display}&nbsp;<input type='text' name=\"{$class}_{$this->name}\" value=\"".set_post($this->value)."\">");
+        return("{$this->display}&nbsp;<input type='text' name=\"{$this->postName}\" value=\"".set_post($this->value)."\">");
     }
 
     function save_object()
     {
-        $class = get_class();
-        $name = "{$class}_{$this->name}";
-        if(isset($_POST[$name])){
-            $this->value = get_post($name);
+        if(isset($_POST[$this->postName])){
+            $this->value = get_post($this->postName);
         }
     }
 
index 549b39cff564e7488d96b1c41d64c3eb0c29d446..a7072ac69eee9eff93fa9085260faf024840f4e3 100644 (file)
@@ -2,15 +2,46 @@
 
 class TemplateWidget_list extends TemplateWidget
 {
+    function __construct(&$config, $name, $value, $description,$required,$type,$display)
+    {
+        parent:: __construct($config, $name, $value, $description,$required,$type,$display);
+
+        $this->listWidget= new sortableListing($this->value);
+        $this->listWidget->setEditable(false);
+        $this->listWidget->setDeleteable(true);
+        $this->listWidget->setColspecs(array('*'));
+        $this->listWidget->setWidth("100%");
+        $this->listWidget->setHeight("70px");
+        $this->listWidget->setAcl("rwcdm");
+    }
+
+
     function render()
     {
-        $str = "";
-        foreach($this->value as $id => $val){
-            $str.= "{$val}, ";
-        }
+        $str = $this->display."&nbsp;";
+        $this->listWidget->setListData($this->value);
+        $this->listWidget->update();
+        $str .= $this->listWidget->render();
+        $str .= "<input type='text' name='{$this->postName}_Input'>";
+        $str .= "<button name='{$this->postName}_Add'>".msgPool::addButton()."</button>";
         return($str);
     }
 
+    function save_object()
+    {
+        $this->listWidget->save_object();
+        $action = $this->listWidget->getAction();
+        if($action['action'] == 'delete'){
+            $id = $this->listWidget->getKey($action['targets'][0]);
+            unset($this->value[$id]);
+            $this->value = array_values($this->value);
+        }
+
+        if(isset($_POST["{$this->postName}_Add"]) && isset($_POST["{$this->postName}_Input"])){
+            $input = get_post("{$this->postName}_Input");
+            $this->value[] = $input;
+        }
+    }
 }