Code

Macro setting will be saved in Extension_table for asterisk
[gosa.git] / include / class_divlist.inc
1 <?php
3 class divlist {
5         var $a_entries;
6         var $a_header;
7         var $b_displayPageNums;         
8         var $summary;
9         var $cols;
11         // Members for page managment
12         var $i_currentPage;
13         var $i_entriesPerPage;
14         
15         
16         function __construct(){
17                 $this->i_currentPage    =0;
18                 $this->i_entriesPerPage =10;
19                 $this->s_summary                ="";
20                 $this->a_entries                =array();
21                 $this->a_header                 =array();
22                 $this->b_displayPageNums                =true;
23                 $this->cols = 0;
24         }
25         
27         function __destruct(){
28         
29         }
31         function AddEntry($a_entriedata) {
32                 $this->a_entries[] = $a_entriedata;
33         }
35         function DisablePageNums() {
36                 $this->b_displayPageNums =false;
37         }
39         function SetHeader($a_headerdata) {
40                 $this->a_header[] = $a_headerdata ;
41         }
43         function SetEntriesPerPage($i_num){
44                 $this->i_entriesPerPage=$i_num;
45         }
46         
47         function DrawList(){
48                 
49                 $s_return = "";
50                 
51                 $s_return.= "<table summary='".$this->s_summary."' width='600' cellspacing='0'>";
52                 
53                 $s_return.= $this->_generateHeader();
54                 
55                 $s_return.= $this->_generatePage();
56                 //$s_return.= nl2br(htmlentities($this->_generatePage()));
57                 
58                 $s_return.= "</table>";
59                 
60                 return ($s_return);
61         }
62         
63         function _numpages(){
64                 $cnt = count($this->a_entries);
65                 
66                 $tmp    = $cnt % $this->i_entriesPerPage;
67                 $pages  = (int) ($cnt / $this->i_entriesPerPage);
68                 if($tmp) $pages ++;
69                 
70                 return $pages;
71         }
72         
73         function _numentries(){
74                 $cnt = count($this->a_entries);
75                 return $cnt;
76         }
77         
78         function _generateHeader(){
79                 
80                 $s_return = "";
81                 
82                 $s_value        = "";
83                 $s_key          = "";
84                                 
85                 $s_return .= "\n<tr>";
86                 foreach($this->a_header[0] as $s_key => $s_value ){
87                         if(!isset($s_value['attach'])){
88                                 $s_value['attach'] = "";
89                         }
90                         
91                         $s_return .= "\n<td class='listheader' ".$s_value['attach'].">".$s_value['string']."</td>";
92                 }
93                 
94                 $s_return .= "\n</tr>";
95                 return $s_return;
96         }
97         
98         function         SetSummary($msg){
99                 $this->s_summary = $msg;
100         }
102         function  _generatePage(){
103                 
104                 $s_value        = "";
105                 $s_key          = "";
106                 $s_return       = "";
107                 
108                 $i_alternate=0;
109         
110                 if(isset($_GET['start'])){
111                         $start = $_GET['start'];
112                 }else{
113                         $start=0;
114                 }
115                 $stop  = $start + $this->i_entriesPerPage;
116                 
118                 $appendempty = ($this->_numentries() -$start);
120                 for($i = $start ; $i < $stop;$i++){
121                         
122                         if(isset($this->a_entries[$i])){
123                                                         
124                                 $s_value = $this->a_entries[$i];
125                                 
126                                 
127                                 if($i_alternate) $i_alternate=0; else $i_alternate=1;
128                                 
129                                 $s_return .= "\n<tr>";
130                                 
131                                 $cnt = 0;                                       
132                                         
133                                 foreach($s_value as $s_key2 => $s_value2 ){                             
135                                         $this->cols = count($s_value) ;                                         
136                                         $cnt++;                                 
138                                         if(!isset($s_value2['class'])){
139                                                 $class = "list".$i_alternate; 
140                                         }else{
141                                                 $class = $s_value2['class'];
142                                         }
144                                         if(!isset($s_value2['attach'])){
145                                                 $style = "";
146                                         }else{
147                                                 $style = " ".$s_value2['attach']." "    ;
148                                         }
150                                         $s_return .= "\n<td ".$style." class='".$class."'>";
151                                         $s_return .= $s_value2['string'];
152                                         $s_return .= "\n</td>";
153                                 }
154                                 if($cnt == 0 ){
155                                         $s_return.="<td>&nbsp;</td>";
156                                 }
157                                 $s_return .= "\n</tr>";
158                         }       
159                 }
161                 if(!(($stop)<$this->_numentries())){
162                         $nums = $stop - $this->_numentries();// - $stop;
163                         for($i = 0 ; $i < $nums ; $i ++ ){
164                                 $s_return.="<tr>";
165                                 $cnt=0;
166                                 for($a = 0 ; $a < (count($this->a_header[0])) ; $a ++ ) {
167                                         if($a ==(count($this->a_header[0])-1)){
168                                                 $s_return.="<td class='list1' style='border:0px;' height='26'>&nbsp; </td>";
169                                         }else{
170                                                 $s_return.="<td class='list1' height='26'>&nbsp; </td>";
171                                         }
172                                 }
173                                 $s_return.="</tr>";
174                         }       
175                 }
177                 if($this->b_displayPageNums){
178                         $s_return .= "<tr><td colspan='".$this->cols."' align='center'>".range_selector($this->_numentries(),$start,$this->i_entriesPerPage)."</td></tr>";
179                 }
181                 return $s_return;
182         }
183         
184         
186 ?>