X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_divlist.inc;h=17176b217b9ce96ffbe8d5f2b743a2a0ecc61291;hb=171bc928e015c158f205fd1089ce489bc7c13a80;hp=887e8419bb79ac437a7ad55302009c1f46319e0e;hpb=e2f16660c2ac670c3927d1d2118f139e50990849;p=gosa.git diff --git a/include/class_divlist.inc b/include/class_divlist.inc index 887e8419b..17176b217 100644 --- a/include/class_divlist.inc +++ b/include/class_divlist.inc @@ -5,32 +5,44 @@ class divlist { var $a_entries; var $a_header; var $b_displayPageNums; - var $summary; + var $s_summary; var $cols; var $pageid; - + //FIXME: Ignoring the fact, that they were missing - height and width are numeric... + var $s_height; + var $s_width; + // Members for page managment var $i_currentPage; var $i_entriesPerPage; + var $force_height = false; + var $list_footer = ""; + // Added php 4 constructor function divlist($pageid){ $this->i_currentPage = 0; $this->i_entriesPerPage = 10; - $this->s_summary = ""; - $this->a_entries = array(); - $this->a_header = array(); + $this->s_height = "450"; + $this->s_width = "600px"; + $this->s_summary = ""; + $this->a_entries = array(); + $this->a_header = array(); $this->b_displayPageNums= true; - $this->cols = 0; - $this->pageid = $pageid ; - + $this->cols = 0; + $this->pageid = $pageid; } function __destruct(){ } + function SetFooter($str) + { + $this->list_footer = $str; + } + function AddEntry($a_entriedata) { $this->a_entries[] = $a_entriedata; } @@ -42,22 +54,38 @@ class divlist { function SetHeader($a_headerdata) { $this->a_header[] = $a_headerdata ; } + + function SetHeight($s_height) { + $this->s_height= $s_height; + $this->force_height = true; + } + + 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){ $this->i_entriesPerPage=$i_num; } function DrawList(){ - $s_return = ""; - - $s_return.= ""; - - $s_return.= "".$this->_generateHeader().""; - - $s_return.= "".$this->_generatePage().""; - //$s_return.= nl2br(htmlentities($this->_generatePage())); - + if(!$this->force_height){ + $s_return.= "
"; + } else { + $s_return.= "
"; + } + + $s_return.= $this->_generateHeader(); + $s_return.= $this->_generatePage(); + $s_return.= $this->_generateFooter(); $s_return.= "
"; return ($s_return); @@ -66,43 +94,81 @@ class divlist { function _numpages(){ $cnt = count($this->a_entries); - $tmp = $cnt % $this->i_entriesPerPage; $pages = (int) ($cnt / $this->i_entriesPerPage); - if($tmp) $pages ++; + if($cnt % $this->i_entriesPerPage){ + $pages++; + } return $pages; } function _numentries(){ - $cnt = count($this->a_entries); - return $cnt; + return count($this->a_entries); } + + function _generateFooter() + { + $s_return = ""; + if(!empty($this->list_footer)){ + + // Using scrolltable? + if($this->i_entriesPerPage == 0) { + if(!$this->force_height) { + $s_return.= "\n"; + } else { + $s_return.= "\n"; + } + + $s_return.= "\n"; + + } + return($s_return); + } function _generateHeader(){ - $s_return = ""; - $s_value = ""; $s_key = ""; - - $s_return .= "\n"; + + // Using scrolltable? + if($this->i_entriesPerPage == 0) { + if(!$this->force_height) { + $s_return.= "\n
"; + } + } + $s_return .= ""; + // Attach a 13px-wide column (used as scrollbar space in body-table), + // but do this only if we are really using scrolltables. + if($this->i_entriesPerPage == 0) { + $s_return.= "\n"; + $s_return.= "\n
".$this->list_footer." 
"; + } else { + $s_return.= "\n"; + } + + $s_return.= "\n"; return $s_return; } @@ -115,9 +181,19 @@ class divlist { $s_value = ""; $s_key = ""; $s_return = ""; - - $i_alternate=0; - + + 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"; + } + $s_return .= ""; + return $s_return; } - - return $s_return; } } + // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>
"; + } + } + + $s_return.= "\n"; - $i_count = count($this->a_header[0])-1; foreach($this->a_header[0] as $s_key => $s_value ){ if(!isset($s_value['attach'])){ $s_value['attach'] = ""; } - - if($i_count == 0) { - $s_return .= "\n"; - } else { - $s_return .= "\n"; - } - $i_count--; + + $s_return.= "\n"; + + // Increment column counter + $this->cols++; + } - $s_return .= ""; - $s_return .= "\n"; + // Attach a 13px-wide column (used as scrollbar space in body-table), + // but do this only if we are really using scrolltables. + if($this->i_entriesPerPage == 0) { + $s_return.= "\n"; + $s_return.= "\n
".$s_value['string']."".$s_value['string']."".$s_value['string']." 
 
"; + $s_return .= ""; + } else { + $s_return .= "\n"; + } + return($str); + } else { + + //FIXME: Ahrg. I'd like to read this code without wasting my time. + if ($this->i_entriesPerPage > 0) { + while($start > $this->_numentries()){ + $start = $start - $this->i_entriesPerPage; + } + + $stop = $start + $this->i_entriesPerPage; + + $appendempty = ($this->_numentries() -$start); + + for($i = $start ; $i < $stop;$i++){ + + if(isset($this->a_entries[$i])){ + + $s_value = $this->a_entries[$i]; + + // Alternation of background color + if($i_alternate) $i_alternate=0; else $i_alternate=1; + + $s_return .= "\n"; + + $cnt = 0; + + foreach($s_value as $s_key2 => $s_value2 ){ + + $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"; + } + if($cnt == 0 ){ + $s_return.="\n"; + } - for($i = $start ; $i < $stop;$i++){ - - if(isset($this->a_entries[$i])){ - - $s_value = $this->a_entries[$i]; - - - if($i_alternate) $i_alternate=0; else $i_alternate=1; - - $s_return .= "\n"; - - $cnt = 0; - - foreach($s_value as $s_key2 => $s_value2 ){ + $s_return .= "\n"; + } + } + + if(!(($stop)<$this->_numentries())){ + $nums = $stop - $this->_numentries();// - $stop; + for($i = 0 ; $i < $nums ; $i ++ ){ + $s_return.=""; + $cnt=0; + for($a = 0 ; $a < (count($this->a_header[0])) ; $a ++ ) { + if($a ==(count($this->a_header[0])-1)){ + $s_return.="\n"; + } else { + $s_return.="\n"; + } + } + $s_return.="\n"; + } + } + + if($this->b_displayPageNums){ + $s_return .= ""; + } + } else { + // $this->i_entriesPerPage <= 0 + // We should display all entries on one page - $this->cols = count($s_value) ; - $cnt++; + $i = $this->_numEntries(); + foreach($this->a_entries as $s_key => $s_value){ + $i--; - if(!isset($s_value2['class'])){ - $class = "list".$i_alternate; - }else{ - $class = $s_value2['class']; - } + if($i_alternate!=0){ + $i_alternate=0; + } else { + $i_alternate=1; + } + + $s_return .= "\n"; + + $cnt = 0; + + foreach($s_value as $s_key2 => $s_value2 ){ - if(!isset($s_value2['attach'])){ - $style = ""; - }else{ - $style = " ".$s_value2['attach']." " ; - } + $this->cols = count($s_value) ; + $cnt++; - $s_return .= "\n"; - } - if($cnt == 0 ){ - $s_return.=""; - } - $s_return .= "\n"; - } - } + if(!isset($s_value2['class'])){ + $class = "list".$i_alternate; + } else { + $class = $s_value2['class']; + } - if(!(($stop)<$this->_numentries())){ - $nums = $stop - $this->_numentries();// - $stop; - for($i = 0 ; $i < $nums ; $i ++ ){ - $s_return.=""; - $cnt=0; - for($a = 0 ; $a < (count($this->a_header[0])) ; $a ++ ) { - if($a ==(count($this->a_header[0])-1)){ - $s_return.=""; - } else { - $s_return.=""; - } - } - $s_return.=""; - } - } + if(!isset($s_value2['attach'])){ + $style = ""; + } else { + $style = " ".$s_value2['attach']." " ; + } + + $s_return .= "\n"; + } + $s_return .= "\n"; + } + } - if($this->b_displayPageNums){ - $s_return .= ""; - } - } else { - // We should display all entries on one page - foreach($this->a_entries as $s_key => $s_value){ - - if($i_alternate){ - $i_alternate=0; - } else { - $i_alternate=1; + // if fewer than 22 Entries (list not full), print row to fill empty space + //FIXME: Why 22? Isn't the size dynamic + if($this->_numEntries()<=22){ + $fill= ""; + for ($i= 1; $i <= $this->cols; $i++){ + if ($i == $this->cols){ + $fill.= ""; + } else { + $fill.= ""; + } } - - $s_return .= "\n"; - - $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"; - } - - if($cnt == 0 ){ - $s_return.=""; - } - $s_return .= "\n"; - } + $s_return.="\n$fill"; + } + if($this->i_entriesPerPage == 0) { + $s_return .= "\n
"; + $s_return .= ""; + } + } + + $i_alternate=0; if(isset($_GET['start'])){ $_SESSION['start'.$this->pageid]=$_GET['start']; $start = $_GET['start']; @@ -128,121 +204,152 @@ class divlist { $start=0; } } - - if ($this->i_entriesPerPage > 0) { - while($start > $this->_numentries()){ - $start = $start - $this->i_entriesPerPage; - } - - $stop = $start + $this->i_entriesPerPage; - - $appendempty = ($this->_numentries() -$start); + + /* If divlist is empty, append a single white entry */ + if(count($this->a_entries)==0){ + $str = $s_return.""; + $str.=""; + $str.=""; + if($this->i_entriesPerPage == 0) { + $str.="
 
"; + $s_return .= $s_value2['string']; + $s_return .= "\n 
  
".range_selector($this->_numentries(),$start,$this->i_entriesPerPage)."
"; - $s_return .= $s_value2['string']; - $s_return .= "\n 
   
"; + $s_return .= $s_value2['string']; + $s_return .= "
".range_selector($this->_numentries(),$start,$this->i_entriesPerPage)."
  
"; - $s_return .= $s_value2['string']; - $s_return .= "\n