From 3e7b257cc6f3a8b3f9fca98648f2f2ad250ca279 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 27 Jul 2005 09:02:25 +0000 Subject: [PATCH] * Added divlist * Added modifications for department length git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1009 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_config.inc | 10 +- include/class_divlist.inc | 188 ++++++++++++++++++++++++++++++++++++++ include/functions.inc | 12 ++- 3 files changed, 202 insertions(+), 8 deletions(-) create mode 100644 include/class_divlist.inc diff --git a/include/class_config.inc b/include/class_config.inc index 064fcc772..bda66489d 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -435,14 +435,18 @@ class config { } } - function make_idepartments() + function make_idepartments($max_size= 40) { $this->idepartments= array(); foreach ($this->departments as $key => $val){ - $this->idepartments[$val]= $key; + if (strlen($key) > $max_size){ + $this->idepartments[$val]= substr($key, 0, $max_size/2 - 3)."...".substr($key, -$max_size/2); + } else { + $this->idepartments[$val]= $key; + } } - ksort($this->idepartments); + asort($this->idepartments); } } diff --git a/include/class_divlist.inc b/include/class_divlist.inc new file mode 100644 index 000000000..ae31f4498 --- /dev/null +++ b/include/class_divlist.inc @@ -0,0 +1,188 @@ +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; + } + + + public function __destruct(){ + + } + + public function AddEntry($a_entriedata) { + $this->a_entries[] = $a_entriedata; + } + + public function DisablePageNums() { + $this->b_displayPageNums =false; + } + + public function SetHeader($a_headerdata) { + $this->a_header[] = $a_headerdata ; + } + + public function SetEntriesPerPage($i_num){ + $this->i_entriesPerPage=$i_num; + } + + public function DrawList(){ + + $s_return = ""; + + $s_return.= ""; + + $s_return.= $this->_generateHeader(); + + $s_return.= $this->_generatePage(); + //$s_return.= nl2br(htmlentities($this->_generatePage())); + + $s_return.= "
"; + + return ($s_return); + } + + private function _numpages(){ + $cnt = count($this->a_entries); + + $tmp = $cnt % $this->i_entriesPerPage; + $pages = (int) ($cnt / $this->i_entriesPerPage); + if($tmp) $pages ++; + + return $pages; + } + + private function _numentries(){ + $cnt = count($this->a_entries); + return $cnt; + } + + private function _generateHeader(){ + + $s_return = ""; + + $s_value = ""; + $s_key = ""; + + $s_return .= "\n"; + foreach($this->a_header[0] as $s_key => $s_value ){ + if(!isset($s_value['attach'])){ + $s_value['attach'] = ""; + } + + $s_return .= "\n".$s_value['string'].""; + } + + $s_return .= "\n"; + return $s_return; + } + + public function SetSummary($msg){ + $this->s_summary = $msg; + } + + private function _generatePage(){ + + $s_value = ""; + $s_key = ""; + $s_return = ""; + + $i_alternate=0; + + if(isset($_GET['start'])){ + $start = $_GET['start']; + }else{ + $start=0; + } + $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.=" "; + } + $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.="  "; + }else{ + $s_return.="  "; + } + } + $s_return.=""; + } + } + + if($this->b_displayPageNums){ + $s_return .= "".range_selector($this->_numentries(),$start,$this->i_entriesPerPage).""; + } + + return $s_return; + } + + +} +?> diff --git a/include/functions.inc b/include/functions.inc index 20d1d490f..0501442da 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1191,14 +1191,12 @@ function range_selector($dcnt,$start,$range=25) } $numpages= (($dcnt / $range)); - - if ((int)$numpages <= 1 ){ - return (""); - } - if(((int)($numpages))!=($numpages)){ $numpages = (int)$numpages + 1; } + if (((int)$numpages) <= 1 ){ + return (""); + } $ppage= (int)(($start / $range) + 0.5); @@ -1219,6 +1217,8 @@ function range_selector($dcnt,$start,$range=25) $begin= $end - $max_entries; } + $output.= "
"; + /* Draw decrement */ if ($start > 0 ) { $output.=" "; } + $output.= "
"; + return($output); } -- 2.30.2