1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 class divSelectBox {
25 var $a_entries;
26 var $summary;
27 var $cols;
29 // Members for page managment
30 var $height=200;
32 // Added php 4 constructor
33 function divSelectBox(){
34 $this->s_summary = "";
35 $this->a_entries = array();
36 $this->cols = 0;
37 }
39 function setHeight($h){
40 $this->height=$h;
41 }
43 function AddEntry($a_entriedata) {
44 $this->a_entries[] = $a_entriedata;
45 }
47 function DrawList(){
48 $s_return = "";
49 $s_return .= "<div style=\"height:2px; overflow:hidden;width:100%;margin-right:0px;\"></div>\n";
50 $s_return .= "<div style=\"padding-right:1px;padding-bottom:2px;height:".$this->height.";width:100%\">\n";
51 $s_return .= "<div style=\"overflow: auto;width:100%;height:".($this->height)."px;\">\n";
52 $s_return .= "<table ".
53 "summary='".$this->s_summary."' ".
54 "width='100%' ".
55 "cellspacing='0' ".
56 "style='overflow:scroll; ".
57 "height:".($this->height-2)."px;".
58 "padding-right:1px; ".
59 "padding-bottom:2px; ".
60 "border:solid 2px #FF0000; ".
61 "'>\n";
62 $s_return.=$this->_generatePage();
63 $s_return.= "</table></div></div>";
64 return ($s_return);
65 }
67 function _numentries(){
68 $cnt = count($this->a_entries);
69 return $cnt;
70 }
72 function SetSummary($msg){
73 $this->s_summary = $msg;
74 }
76 function _generatePage(){
78 $s_value = "";
79 $s_key = "";
80 $s_return = "";
81 $i_alternate=0;
82 $str = "";
84 /* If divlist is empty, append a single white entry */
85 if(count($this->a_entries)==0){
86 $str.="<tr class='rowxp1'
87 ><td class='list1nohighlight' style='height:100%; border-right:0px;'> </td></tr>";
88 return($str);
89 }
91 $i = $this->_numEntries();
92 foreach($this->a_entries as $s_key => $s_value){
93 $i--;
95 if($i_alternate!=0){
96 $i_alternate=0;
97 } else {
98 $i_alternate=1;
99 }
101 $s_return .= "\n<tr class='rowxp".($i_alternate)."'>";
103 $cnt = 0;
105 foreach($s_value as $s_key2 => $s_value2 ){
106 $this->cols = count($s_value) ;
107 $cnt++;
109 if(!isset($s_value2['class'])){
110 $class = "list".$i_alternate;
111 } else {
112 $class = $s_value2['class'];
113 }
115 if(!isset($s_value2['attach'])){
116 $style = "";
117 } else {
118 $style = " ".$s_value2['attach']." " ;
119 }
121 $s_return .= "\n<td ".$style." class='".$class."'>";
122 $s_return .= $s_value2['string'];
123 $s_return .= "</td>";
124 }
125 $s_return.="\n</tr>";
126 }
127 $s_return.="\n<tr>";
128 for($i = 0 ; $i < ($this->cols) ; $i ++){
129 if($i >= ($this->cols-1)){
130 $s_return .= "<td class='list1nohighlight' style='height:100%;border:0px;'><div style='font-size:1px;'> </div></td>";
131 }else{
132 $s_return .= "<td class='list1nohighlight' style='height:100%;'><div style='font-size:1px;'> </div></td>";
133 }
135 }
136 $s_return.="</tr>";
137 return $s_return;
138 }
139 }
140 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
141 ?>