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 function __construct(){
33 $this->s_summary = "";
34 $this->a_entries = array();
35 $this->cols = 0;
36 }
38 function setHeight($h){
39 $this->height=$h;
40 }
42 function AddEntry($a_entriedata) {
43 $this->a_entries[] = $a_entriedata;
44 }
46 function DrawList(){
47 $s_return = "";
48 $s_return .= "<div style=\"height:2px; overflow:hidden;background:#888888;width:100%;margin-right:0px;\"></div>\n";
49 $s_return .= "<div style=\"padding-right:1px;padding-bottom:2px;height:".$this->height.";width:100%\">\n";
50 $s_return .= "<div style=\"overflow: auto;width:100%;height:".($this->height)."px;\">\n";
51 $s_return .= "<table ".
52 "summary='".$this->s_summary."' ".
53 "width='100%' ".
54 "cellspacing='0' ".
55 "style='overflow:scroll; ".
56 "height:".($this->height-2)."px;".
57 "padding-right:1px; ".
58 "padding-bottom:2px; ".
59 "border-left:solid 2px; ".
60 "border-top:solid 0px; ".
61 "border-color:#888888; ".
62 "'>\n";
63 $s_return.=$this->_generatePage();
64 $s_return.= "</table></div></div>";
65 return ($s_return);
66 }
68 function _numentries(){
69 $cnt = count($this->a_entries);
70 return $cnt;
71 }
73 function SetSummary($msg){
74 $this->s_summary = $msg;
75 }
77 function _generatePage(){
79 $s_value = "";
80 $s_key = "";
81 $s_return = "";
82 $i_alternate=0;
83 $str = "";
85 /* If divlist is empty, append a single white entry */
86 if(count($this->a_entries)==0){
87 $str.="<tr class='rowxp1'
88 ><td class='list1nohighlight' style='height:100%; border-right:0px;'> </td></tr>";
89 return($str);
90 }
92 $i = $this->_numEntries();
93 foreach($this->a_entries as $s_key => $s_value){
94 $i--;
96 if($i_alternate!=0){
97 $i_alternate=0;
98 } else {
99 $i_alternate=1;
100 }
102 $s_return .= "\n<tr class='rowxp".($i_alternate)."'>";
104 $cnt = 0;
106 foreach($s_value as $s_key2 => $s_value2 ){
107 $this->cols = count($s_value) ;
108 $cnt++;
110 if(!isset($s_value2['class'])){
111 $class = "list".$i_alternate;
112 } else {
113 $class = $s_value2['class'];
114 }
116 if(!isset($s_value2['attach'])){
117 $style = "";
118 } else {
119 $style = " ".$s_value2['attach']." " ;
120 }
122 $s_return .= "\n<td ".$style." class='".$class."'>";
123 $s_return .= $s_value2['string'];
124 $s_return .= "</td>";
125 }
126 $s_return.="\n</tr>";
127 }
128 $s_return.="\n<tr>";
129 for($i = 0 ; $i < ($this->cols) ; $i ++){
130 if($i >= ($this->cols-1)){
131 $s_return .= "<td class='list1nohighlight' style='height:100%;border:0px;'><div style='font-size:1px;'> </div></td>";
132 }else{
133 $s_return .= "<td class='list1nohighlight' style='height:100%;'><div style='font-size:1px;'> </div></td>";
134 }
136 }
137 $s_return.="</tr>";
138 return $s_return;
139 }
140 }
141 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
142 ?>