Code

Added divlist to FAIscript dialog, with sorting parameter
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 6 Aug 2007 08:23:02 +0000 (08:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 6 Aug 2007 08:23:02 +0000 (08:23 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6964 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_divlist.inc
plugins/admin/fai/class_faiScript.inc
plugins/admin/fai/faiScript.tpl

index cd12a5ebdf206bce265b25f4900e6dc206bd33eb..2c28bc7cfa37525ec75cbddcefd96ffaff19c502 100644 (file)
@@ -24,7 +24,7 @@ class divlist {
                $this->i_currentPage    = 0;
                $this->i_entriesPerPage = 10;
     $this->s_height         = "450";
-    $this->s_width          = "600";
+    $this->s_width          = "600px";
                $this->s_summary        = "";
                $this->a_entries        = array();
                $this->a_header         = array();
@@ -56,6 +56,9 @@ class divlist {
   
   function SetWidth($s_width) {
                $this->s_width= $s_width;
+    if(preg_match("/^[0-9]*$/",$this->s_width)){
+      $this->s_width .="px";
+    }
        }
 
        function SetEntriesPerPage($i_num){
@@ -66,11 +69,11 @@ class divlist {
                $s_return = "";
     if(!$this->force_height){
                  $s_return.= "<table summary='".$this->s_summary."' style='width:".
-                  $this->s_width."px;height:".$this->s_height.
+                  $this->s_width.";height:".$this->s_height.
                   "px;' cellspacing='0' id='t_scrolltable'>";
     } else {
                  $s_return.= "<table summary='".$this->s_summary."' style='width:".
-                  $this->s_width."px;height:".$this->s_height.
+                  $this->s_width.";height:".$this->s_height.
                   "px;' cellspacing='0' id='t_scrolltable_onlywidth'>";
     }
 
@@ -105,9 +108,9 @@ class divlist {
     // Using scrolltable?
     if($this->i_entriesPerPage == 0) {
       if(!$this->force_height) {
-        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead'>";
+        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width.";' cellspacing='0' id='t_scrollhead'>";
       } else {
-        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead_onlywidth'>";
+        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width.";' cellspacing='0' id='t_scrollhead_onlywidth'>";
       }
     }
 
@@ -149,10 +152,10 @@ class divlist {
     if($this->i_entriesPerPage == 0) {
       // We need to construct a "body"-table that is width-of-scrollbar thinner than the "head"-table.
       if(!$this->force_height) {
-        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody' class='scrollbody'>";
+        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width.";height:".($this->s_height-20)."px;' id='d_scrollbody' class='scrollbody'>";
         $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>";
       } else {
-        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody_onlywidth' class='scrollbody'>";
+        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width.";height:".($this->s_height-20)."px;' id='d_scrollbody_onlywidth' class='scrollbody'>";
         $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody_onlywidth'>";
       }
        }
index 537c35318581a4a114a813f821fa46af558921b0..3f9d0612e075105a2c3e76fc2867f32eefbb3088 100644 (file)
@@ -31,7 +31,9 @@ class faiScript extends plugin
   var $dialog           = NULL;     // a dialog, e.g. new disk dialog
   var $SubObjects       = array();  // All leafobjects of this object
 
-  var $FAIstate         ="";
+  var $FAIstate         = "";
+  var $sort_by          = "name";
+  var $sort_order       = "up";
 
   var $base             ="";
   var $release          ="";
@@ -213,11 +215,24 @@ class faiScript extends plugin
 
     /* Sort entries */
     $tmp = $keys = array();
-    foreach($this->SubObjects as $key => $entry){
-      $keys[$key]=$key;
+
+    if($this->sort_by == "name"){
+      foreach($this->SubObjects as $key => $entry){
+        $keys[$key]=$entry['cn'];
+      }
+    }elseif($this->sort_by == "priority"){
+      foreach($this->SubObjects as $key => $entry){
+        $keys[$key]=$entry['FAIpriority'];
+      }
     }
+
     natcasesort($keys);
-    foreach($keys as $key){
+
+    if($this->sort_order == "down"){
+      $keys =array_reverse($keys);
+    }
+
+    foreach($keys as $key => $order_var){
       $tmp[$key]=$this->SubObjects[$key];
     }
     $this->SubObjects = $tmp;
@@ -239,8 +254,16 @@ class faiScript extends plugin
     /* Divlist            added 23.02.2006 
        Containing FAIscripts 
      */
-    $divlist = new divSelectBox("FAIscripts");
-    $divlist->setHeight(400);
+    $divlist = new divlist("FAIscripts");
+    $plug = $_GET['plug'];
+
+    $divlist->SetHeader(array(  array("string"=>"<a href='?plug=".$plug."&amp;sort=name'>"._("Name")."</a>"),
+          array("string"=>"<a href='?plug=".$plug."&amp;sort=priority'>"._("Priority")."</a>"),
+          array("string"=>_("Download")),
+          array("string"=>_("Action"))));
+    $divlist->SetHeight(300);
+    $divlist->SetWidth("100%");
+
     if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){
       $img_edit = "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
       $img_remo = "";
@@ -260,6 +283,7 @@ class faiScript extends plugin
       } 
 
       $divlist->AddEntry(array( array("string"=>$name['name']),
+            array("string"=>$name['FAIpriority'] , "attach" => "style='width:20px;'"),
             array("string"=>$down , "attach" => "style='width:20px;'"),
             array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo),
               "attach"=>"style='border-right: 0px;width:50px;text-align:right;'")));
@@ -298,6 +322,7 @@ class faiScript extends plugin
             $a_return[$obj['cn']]['name']= $obj['cn'];
           }
           $a_return[$obj['cn']]['dn']= $obj['dn'];
+          $a_return[$obj['cn']]['FAIpriority']= $obj['FAIpriority'];
         }else{
           if((isset($obj['description']))&&(!empty($obj['description']))){
             $a_return[$obj['cn']]= $obj['cn']." [".stripslashes($obj['description'])."]";
@@ -334,6 +359,18 @@ class faiScript extends plugin
         }
       }
     }
+    
+    /* Get sort order */
+    if(isset($_GET['sort']) && in_array($_GET['sort'],array("name","priority"))){
+      if($this->sort_by == $_GET['sort']){
+        if($this->sort_order == "up"){
+          $this->sort_order = "down";
+        }elseif($this->sort_order == "down"){
+          $this->sort_order = "up";
+        }
+      }
+      $this->sort_by = $_GET['sort'];
+    }
   }
 
 
index cc5b1fe4ea09bc225edf27b648f045d7dc89897e..2d518cc316a757e571651ef429308fb94260b209 100644 (file)
        <tr>
                <td>
                                <h2><img class="center" alt="" src="images/fai_script.png" align="middle" title="{t}Objects{/t}">&nbsp;
-                                       <LABEL for="SubObject">
                                                {t}List of scripts{/t}
-                                       </LABEL>
                                </h2>
-                               <table width="100%" summary="">
+                               <table width="100%" summary="" style="border:1px solid #B0B0B0; " cellspacing=0 cellpadding=0>
                                <tr>
                                        <td>
+                                               
                                                {$Entry_divlist}
                                                <input type="submit" name="AddSubObject"     value="{t}Add{/t}"         title="{t}Add{/t}" {$cnACL}>
                                        </td>