X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_divlist.inc;h=ef1c137e9b621157a9f410f412101789aeec2a4b;hb=e4bf3ecc1b431adcb5b9ad1bdf58d7e3739f6849;hp=7b62d34c50c2a2d352ca1e348dc1a561feeadeac;hpb=05a70113feca1d8aa9964c07d58b86916ecb61ff;p=gosa.git diff --git a/include/class_divlist.inc b/include/class_divlist.inc index 7b62d34c5..ef1c137e9 100644 --- a/include/class_divlist.inc +++ b/include/class_divlist.inc @@ -12,17 +12,19 @@ class divlist { // Members for page managment var $i_currentPage; var $i_entriesPerPage; - - - function __construct($pageid){ - $this->i_currentPage = 0; - $this->i_entriesPerPage = 10; - $this->s_summary = ""; - $this->a_entries = array(); - $this->a_header = array(); + + // 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->b_displayPageNums= true; - $this->cols = 0; - $this->pageid = $pageid ; + $this->cols = 0; + $this->pageid = $pageid ; + } function __destruct(){ @@ -46,14 +48,31 @@ class divlist { } function DrawList(){ - $s_return = ""; - - $s_return.= ""; - - $s_return.= $this->_generateHeader(); - - $s_return.= $this->_generatePage(); + $s_return.= "
"; + if($this->i_entriesPerPage==0) { + // 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.= "".$this->_generateHeader().""; + // Define an alternate style for IE (not used ATM) + // $s_return.= ""; + $s_return.= "".$this->_generatePage().""; + } 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.= nl2br(htmlentities($this->_generatePage())); $s_return.= "
"; @@ -84,23 +103,34 @@ class divlist { $s_key = ""; $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'] = ""; } - - $s_return .= "\n".$s_value['string'].""; + + if($i_count == 0) { + $s_return .= "\n".$s_value['string'].""; + } else { + $s_return .= "\n".$s_value['string'].""; + } + $i_count--; } + // Only create additional column if we're using scrollbars + if($this->i_entriesPerPage==0) { + $s_return .= "\n "; + } $s_return .= "\n"; return $s_return; } - function SetSummary($msg){ + function SetSummary($msg){ $this->s_summary = $msg; } - function _generatePage(){ + function _generatePage(){ $s_value = ""; $s_key = ""; @@ -111,86 +141,150 @@ class divlist { if(isset($_GET['start'])){ $_SESSION['start'.$this->pageid]=$_GET['start']; $start = $_GET['start']; - }else{ + } else { if(isset($_SESSION['start'.$this->pageid])){ $start = $_SESSION['start'.$this->pageid]; - }else{ + } else { $start=0; } } - - while($start > $this->_numentries()){ - $start = $start - $this->i_entriesPerPage; - } - $stop = $start + $this->i_entriesPerPage; + /* If divlist is empty, append a single white entry */ + if(count($this->a_entries)==0){ + $str = ""; + for($i = 0 ; $i < count($this->a_header[0]); $i++){ + $str.=" "; + } + $str .=""; + return($str); + } + + 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]; + + + if($i_alternate) $i_alternate=0; else $i_alternate=1; + + $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"; + $s_return .= $s_value2['string']; + $s_return .= "\n"; + } + if($cnt == 0 ){ + $s_return.="\n "; + } - $appendempty = ($this->_numentries() -$start); + $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 .= "".range_selector($this->_numentries(),$start,$this->i_entriesPerPage).""; + } + } else { + // We should display all entries on one page - 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 ){ - - $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"; - $s_return .= $s_value2['string']; - $s_return .= "\n"; - } - if($cnt == 0 ){ - $s_return.=" "; - } - $s_return .= "\n"; - } - } + $i = $this->_numEntries(); + foreach($this->a_entries as $s_key => $s_value){ + $i--; - 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($i_alternate!=0){ + $i_alternate=0; + } else { + $i_alternate=1; + } + + $s_return .= "\n"; + + $cnt = 0; + + foreach($s_value as $s_key2 => $s_value2 ){ - if($this->b_displayPageNums){ - $s_return .= "".range_selector($this->_numentries(),$start,$this->i_entriesPerPage).""; - } + $this->cols = count($s_value) ; + $cnt++; - return $s_return; - } - - + 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"; + $s_return .= $s_value2['string']; + $s_return .= ""; + } + $s_return .= "\n"; + } + } + + // 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.= " "; + } else { + $fill.= " "; + } + } + $s_return.="\n$fill"; + } + return $s_return; + } } +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>