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;
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 }
27 function __destruct(){
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 }
47 function DrawList(){
49 $s_return = "";
51 $s_return.= "<table summary='".$this->s_summary."' width='600' cellspacing='0'>";
53 $s_return.= $this->_generateHeader();
55 $s_return.= $this->_generatePage();
56 //$s_return.= nl2br(htmlentities($this->_generatePage()));
58 $s_return.= "</table>";
60 return ($s_return);
61 }
63 function _numpages(){
64 $cnt = count($this->a_entries);
66 $tmp = $cnt % $this->i_entriesPerPage;
67 $pages = (int) ($cnt / $this->i_entriesPerPage);
68 if($tmp) $pages ++;
70 return $pages;
71 }
73 function _numentries(){
74 $cnt = count($this->a_entries);
75 return $cnt;
76 }
78 function _generateHeader(){
80 $s_return = "";
82 $s_value = "";
83 $s_key = "";
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 }
91 $s_return .= "\n<td class='listheader' ".$s_value['attach'].">".$s_value['string']."</td>";
92 }
94 $s_return .= "\n</tr>";
95 return $s_return;
96 }
98 function SetSummary($msg){
99 $this->s_summary = $msg;
100 }
102 function _generatePage(){
104 $s_value = "";
105 $s_key = "";
106 $s_return = "";
108 $i_alternate=0;
110 if(isset($_GET['start'])){
111 $start = $_GET['start'];
112 }else{
113 $start=0;
114 }
115 $stop = $start + $this->i_entriesPerPage;
118 $appendempty = ($this->_numentries() -$start);
120 for($i = $start ; $i < $stop;$i++){
122 if(isset($this->a_entries[$i])){
124 $s_value = $this->a_entries[$i];
127 if($i_alternate) $i_alternate=0; else $i_alternate=1;
129 $s_return .= "\n<tr>";
131 $cnt = 0;
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> </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'> </td>";
169 }else{
170 $s_return.="<td class='list1' height='26'> </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 }
185 }
186 ?>