a853d16b2d29188889323ed6a1913e9de84610f1
1 <?php
3 class divSelectBox {
5 var $a_entries;
6 var $summary;
7 var $cols;
9 // Members for page managment
10 var $width= 300;
11 var $height=200;
13 // Added php 4 constructor
14 function divSelectBox(){
15 $this->s_summary = "";
16 $this->a_entries = array();
17 $this->cols = 0;
18 }
20 function setWidth($w){
21 $this->width=$w;
22 }
24 function setHeight($h){
25 $this->height=$h;
26 }
28 function AddEntry($a_entriedata) {
29 $this->a_entries[] = $a_entriedata;
30 }
32 function DrawList(){
33 $s_return = "";
34 $s_return .= "<div style=\"height:2px; overflow:hidden;background:#888888;width:100%;margin-right:18px;\"></div>\n";
35 $s_return .= "<div style=\"padding-right:1px;padding-bottom:2px;\" height='100%' width='100%'>\n";
36 $s_return .= "<div style=\"overflow: auto;height:100%;width:100%;\">\n";
37 $s_return .= "<table ".
38 "summary='".$this->s_summary."' ".
39 "width='100%' ".
40 "height='100%' ".
41 "cellspacing='0' ".
42 "style='overflow:scroll; ".
43 "padding-right:1px; ".
44 "padding-bottom:2px; ".
45 "border-left:solid 2px; ".
46 "border-top:solid 0px; ".
47 "border-color:#888888; ".
48 "'>\n";
49 $s_return.=$this->_generatePage();
50 $s_return.= "</table></div></div>";
51 return ($s_return);
52 }
54 function _numentries(){
55 $cnt = count($this->a_entries);
56 return $cnt;
57 }
59 function SetSummary($msg){
60 $this->s_summary = $msg;
61 }
63 function _generatePage(){
65 $s_value = "";
66 $s_key = "";
67 $s_return = "";
68 $i_alternate=0;
69 $str = "";
71 /* If divlist is empty, append a single white entry */
72 if(count($this->a_entries)==0){
73 $str.="<tr><td class='list1' style='height:100%';> </td></tr>";
74 return($str);
75 }
77 $i = $this->_numEntries();
78 foreach($this->a_entries as $s_key => $s_value){
79 $i--;
81 if($i_alternate!=0){
82 $i_alternate=0;
83 } else {
84 $i_alternate=1;
85 }
87 $s_return .= "\n<tr>";
89 $cnt = 0;
91 foreach($s_value as $s_key2 => $s_value2 ){
92 $this->cols = count($s_value) ;
93 $cnt++;
95 if(!isset($s_value2['class'])){
96 $class = "list".$i_alternate;
97 } else {
98 $class = $s_value2['class'];
99 }
101 if(!isset($s_value2['attach'])){
102 $style = "";
103 } else {
104 $style = " ".$s_value2['attach']." " ;
105 }
107 $s_return .= "\n<td ".$style." class='".$class."'>";
108 $s_return .= $s_value2['string'];
109 $s_return .= "</td>";
110 }
111 $s_return.="\n</tr>";
112 }
113 for($i = 0 ; $i < ($this->cols) ; $i ++){
114 if($i >= ($this->cols-1)){
115 $s_return .= "<td class='list1' height='100%' style='border:0px;'></td>";
116 }else{
117 $s_return .= "<td class='list1' height='100%'></td>";
118 }
120 }
121 $s_return.="</tr>";
122 return $s_return;
123 }
124 }
125 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
126 ?>