Code

Added Scrollable Listbox, which works in IE Konqueror Firfox
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 10 Nov 2005 13:22:09 +0000 (13:22 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 10 Nov 2005 13:22:09 +0000 (13:22 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1906 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_divSelectBox.inc [new file with mode: 0644]

diff --git a/include/class_divSelectBox.inc b/include/class_divSelectBox.inc
new file mode 100644 (file)
index 0000000..8942e96
--- /dev/null
@@ -0,0 +1,143 @@
+<?php
+
+class divSelectBox {
+
+       var $a_entries;
+       var $a_header;
+       var $b_displayPageNums;         
+       var $summary;
+       var $cols;
+
+       // Members for page managment
+       var $i_currentPage;
+       var $i_entriesPerPage;
+
+  var $width= 300;
+  var $height=200;
+
+       // Added php 4 constructor
+       function divSelectBox(){
+
+               $this->i_currentPage    = 0;
+               $this->i_entriesPerPage = 10;
+               $this->s_summary                = "";
+               $this->a_entries                = array();
+               $this->a_header                 = array();
+               $this->b_displayPageNums= true;
+               $this->cols                     = 0;
+
+       }
+
+       function __destruct(){
+       
+       }
+
+  function setWidth($w){
+    $this->width=$w;
+  }
+
+  function setHeight($h){
+    $this->height=$h;
+  }
+
+       function AddEntry($a_entriedata) {
+               $this->a_entries[] = $a_entriedata;
+       }
+
+  function DrawList(){
+    $s_return = "
+      <div style=\"background-color:#FFFFFF;".
+                  "padding-right:1px;".
+                  "padding-bottom:2px;".
+                  "border-left:solid 2px;".
+                  "border-top:solid 2px;".
+                  "border-color:#888888;\"".
+                  " height='".($this->height)."' width='".($this->width)."'>".
+      "\n<div style=\"overflow:auto; height:".$this->height."px;width:".($this->width)."px;\">";
+    $s_return.= "<table summary='".$this->s_summary."' width='".($this->width-18)."' height='".($this->height)."' cellspacing='0' style='overflow:scroll''>";
+
+    $s_return.=$this->_generatePage();
+    $s_return.= "</table></div></div>";
+
+    return ($s_return);
+  }
+       
+       function _numentries(){
+               $cnt = count($this->a_entries);
+               return $cnt;
+       }
+       
+       function SetSummary($msg){
+               $this->s_summary = $msg;
+       }
+
+       function _generatePage(){
+               
+               $s_value        = "";
+               $s_key          = "";
+               $s_return       = "";
+               
+               $i_alternate=0;
+       
+    /* If divlist is empty, append a single white entry */
+    if(count($this->a_entries)==0){
+      $str = "<tr>";
+      for($i = 0 ; $i < count($this->a_header[0]); $i++){
+        $str.="<td class='list1' style='height:100%';>&nbsp;</td>";
+      }
+      $str .="</tr>";
+      return($str);
+    }
+
+    $i = $this->_numEntries();
+    foreach($this->a_entries as $s_key => $s_value){
+      $i--;
+
+      if($i_alternate!=0){ 
+        $i_alternate=0; 
+      } else {
+        $i_alternate=1;
+      }
+
+      $s_return .= "\n<tr>";
+
+      $cnt = 0;                                        
+
+      foreach($s_value as $s_key2 => $s_value2 ){                              
+
+        $this->cols = count($s_value) ;                                                
+        $cnt++;                                        
+
+        if(!isset($s_value2['class'])){
+          $class = "list".$i_alternate; 
+        } else {
+          $class = $s_value2['class'];
+        }
+
+        if(!isset($s_value2['attach'])){
+          $style = "";
+        } else {
+          $style = " ".$s_value2['attach']." " ;
+        }
+
+        $s_return .= "\n<td ".$style." class='".$class."'>";
+        $s_return .= $s_value2['string'];
+        $s_return .= "</td>";
+      }
+
+    }
+    $s_return.="<tr>";
+    for($i = 0 ; $i < ($this->cols) ; $i ++){
+      if($i >= ($this->cols-1)){
+        $s_return .= "<td class='list1' height='100%' style='border:0px;'></td>";
+      }else{
+        $s_return .= "<td class='list1' height='100%'></td>";
+      }
+      
+    }
+    $s_return.="</tr>";
+    return $s_return;
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>