Code

Removed deprecated ereg functions
[gosa.git] / gosa-core / include / class_divSelectBox.inc
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;background:#888888;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-left:solid 2px; ".
61                     "border-top:solid 0px; ".
62                     "border-color:#888888; ".
63                     "'>\n";
64     $s_return.=$this->_generatePage();
65     $s_return.= "</table></div></div>";
66     return ($s_return);
67   }
68         
69         function _numentries(){
70                 $cnt = count($this->a_entries);
71                 return $cnt;
72         }
73         
74         function SetSummary($msg){
75                 $this->s_summary = $msg;
76         }
78         function _generatePage(){
79                 
80                 $s_value        = "";
81                 $s_key          = "";
82                 $s_return       = "";
83                 $i_alternate=0;
84     $str = "";
85         
86     /* If divlist is empty, append a single white entry */
87     if(count($this->a_entries)==0){
88       $str.="<tr class='rowxp1'
89                 ><td class='list1nohighlight' style='height:100%; border-right:0px;'>&nbsp;</td></tr>";
90       return($str);
91     }
93     $i = $this->_numEntries();
94     foreach($this->a_entries as $s_key => $s_value){
95       $i--;
97       if($i_alternate!=0){ 
98         $i_alternate=0; 
99       } else {
100         $i_alternate=1;
101       }
103       $s_return .= "\n<tr class='rowxp".($i_alternate)."'>";
105       $cnt = 0;                                         
106     
107       foreach($s_value as $s_key2 => $s_value2 ){                               
108         $this->cols = count($s_value) ;                                         
109         $cnt++;                                 
111         if(!isset($s_value2['class'])){
112           $class = "list".$i_alternate; 
113         } else {
114           $class = $s_value2['class'];
115         }
117         if(!isset($s_value2['attach'])){
118           $style = "";
119         } else {
120           $style = " ".$s_value2['attach']." "  ;
121         }
123         $s_return .= "\n<td ".$style." class='".$class."'>";
124         $s_return .= $s_value2['string'];
125         $s_return .= "</td>";
126       }
127       $s_return.="\n</tr>";
128     }
129     $s_return.="\n<tr>";
130     for($i = 0 ; $i < ($this->cols) ; $i ++){
131       if($i >= ($this->cols-1)){
132         $s_return .= "<td class='list1nohighlight' style='height:100%;border:0px;'><div style='font-size:1px;'>&nbsp;</div></td>";
133       }else{
134         $s_return .= "<td class='list1nohighlight' style='height:100%;'><div style='font-size:1px;'>&nbsp;</div></td>";
135       }
136       
137     }
138     $s_return.="</tr>";
139     return $s_return;
140   }
142 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
143 ?>