Code

Updated Translation Strings.
[gosa.git] / include / class_divlist.inc
index 58591666a0c1724d1c8b3e2a07803026ea12f3ac..ef1c137e9b621157a9f410f412101789aeec2a4b 100644 (file)
@@ -48,23 +48,30 @@ class divlist {
        }
        
        function DrawList(){
-               
                $s_return = "";
-               
-               $s_return.= "<table summary='".$this->s_summary."' width='600' cellspacing='0'>";
-
+               $s_return.= "<table summary='".$this->s_summary."' width='600' height='500' cellspacing='0'>";
     if($this->i_entriesPerPage==0) {
-    
-      $s_return.= "<thead>".$this->_generateHeader()."</thead>";
-
-      // Define an alternate style for IE
-      $s_return.= "<!--[if IE]><style type='text/css'>tbody.scrollcontent {overflow-y:scroll;height:20em;}</style><![endif]-->";
-    
-      $s_return.= "<tbody class='scrollcontent'>".$this->_generatePage()."</tbody>";
+      // TODO: Find a more convenient way to use the same functionality in both
+      // MSIE and non-MSIE browsers. ATM we need to manually set entriesPerPage to
+      // a non-zero value, because MSIE won't scroll the tbody properly.
+      $s_browser = isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:"";
+      if(is_numeric(strpos($s_browser,'Mozilla')) &&
+         !is_numeric(strpos($s_browser,'MSIE')) &&
+         !is_numeric(strpos($s_browser,'KHTML'))
+        ){
+        $s_return.= "<thead>".$this->_generateHeader()."</thead>";
+        // Define an alternate style for IE (not used ATM)
+        // $s_return.= "<!--[if IE]><style type='text/css'>tbody.scrollcontent {overflow-y:scroll;max-height:480px;}</style><![endif]-->";
+        $s_return.= "<tbody style='max-height:480px;overflow:auto;overflow:-moz-scrollbars-vertical;'>".$this->_generatePage()."</tbody>";
+      } else {
+        // Call ourself with i_entriesPerPage set to a default value
+        $this->SetEntriesPerPage(20);
+        $s_return.=$this->_generateHeader();
+        $s_return.=$this->_generatePage();
+      }
     } else {
-      $s_return.=$this->_generateHeader();
-
-      $s_return.=$this->_generatePage();
+        $s_return.=$this->_generateHeader();
+        $s_return.=$this->_generatePage();
     }
                //$s_return.= nl2br(htmlentities($this->_generatePage()));
                
@@ -102,9 +109,9 @@ class divlist {
                        if(!isset($s_value['attach'])){
                                $s_value['attach'] = "";
                        }
-                       
+       
       if($i_count == 0) {
-                       $s_return .= "\n<td class='listheader' style='border-right:0px;border-bottom:1px solid #b0b0b0;'".$s_value['attach'].">".$s_value['string']."</td>";
+                       $s_return .= "\n<td class='listheader' style='border-right:0px;border-bottom:1px solid #b0b0b0;' ".$s_value['attach'].">".$s_value['string']."</td>";
       } else {
                        $s_return .= "\n<td class='listheader' style='border-bottom:1px solid #b0b0b0;'".$s_value['attach'].">".$s_value['string']."</td>";
       }
@@ -113,7 +120,7 @@ class divlist {
                
     // Only create additional column if we're using scrollbars
     if($this->i_entriesPerPage==0) {
-      $s_return .= "<td class='listheader' style='border-right:0px;padding:0px;border-bottom:1px solid #b0b0b0;width:16px;'>&nbsp;</td>";
+      $s_return .= "\n<td class='listheader' style='border-right:0px;padding:0px;border-bottom:1px solid #b0b0b0;width:16px;'>&nbsp;</td>";
     }
                $s_return .= "\n</tr>";
                return $s_return;
@@ -141,7 +148,17 @@ class divlist {
                                $start=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);
+    }
     if ($this->i_entriesPerPage > 0) {
                while($start > $this->_numentries()){
                        $start = $start - $this->i_entriesPerPage;
@@ -214,49 +231,58 @@ class divlist {
                }
     } else {
       // We should display all entries on one page
-               foreach($this->a_entries as $s_key => $s_value){
-                       
-                       if($i_alternate){ 
+
+      $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>";
-                       }
-                       
-        if($cnt == 0 ){
-                               $s_return.="\n<td>&nbsp;</td>";
-                       } else {
-                               //$s_return.="\n<td style='border:0px;padding:0px;' class='list".$i_alternate."'>&nbsp;</td>";
+                                 
+                   $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 .= "\n</tr>";
+                 }
+    }
+
+    // if fewer than 22 Entries (list not full), print row to fill empty space
+    if($this->_numEntries()<22){
+      $fill= "";
+      for ($i= 1; $i <= $this->cols; $i++){
+        if ($i == $this->cols){
+         $fill.= "<td class='list1' style='height:100%;border-right:0px';>&nbsp;</td>";
+        } else {
+         $fill.= "<td class='list1' style='height:100%';>&nbsp;</td>";
         }
-                       $s_return .= "\n</tr>";
-               }
+      }
+      $s_return.="\n<tr>$fill</tr>";
     }
-         
     return $s_return;
   }
 }