FusionDirectory
 All Data Structures Files Functions Variables
class_divSelectBox.inc
Go to the documentation of this file.
1 <?php
2 
3 /*
4  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
5  Copyright (C) 2003-2010 Cajus Pollmeier
6  Copyright (C) 2011-2016 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
33 {
34  var $headers = FALSE;
35  var $a_entries;
36  var $summary;
37  var $cols;
38 
39  private $id;
40 
41  // Members for page managment
42  var $height = '200px';
43 
47  function __construct($id)
48  {
49  $this->s_summary = '';
50  $this->a_entries = array();
51  $this->cols = 0;
52  $this->id = $id;
53  }
54 
60  function setHeight($h)
61  {
62  if (is_numeric($h)) {
63  $this->height = $h.'px';
64  } else {
65  $this->height = $h;
66  }
67  }
68 
74  function AddEntry($a_entriedata)
75  {
76  $this->a_entries[] = $a_entriedata;
77  }
78 
84  function SetHeaders($headers)
85  {
86  $this->headers = $headers;
87  }
88 
92  function DrawList()
93  {
94  $s_return = '';
95  $s_return .= '<div style="border:1px solid rgb(170,170,170);padding-right:1px;height:'.$this->height.';width:100%">'."\n";
96  $s_return .= '<div style="overflow:auto; width:100%; height:100%;">'."\n";
97  $s_return .= '<table '.
98  'class="listingTable" '.
99  'id="'.$this->id.'" '.
100  'style="overflow:scroll; '.
101  'height:98%; '.
102  'width:100%; '.
103  'border:none; '.
104  '"'.
105  ">\n";
106  $s_return .= $this->_generatePage();
107  $s_return .= '</table></div></div>';
108  return $s_return;
109  }
110 
114  function _numentries()
115  {
116  $cnt = count($this->a_entries);
117  return $cnt;
118  }
119 
125  function SetSummary($msg)
126  {
127  $this->s_summary = $msg;
128  }
129 
133  function _generatePage()
134  {
135  $display = '';
136  if ($this->headers !== FALSE) {
137  $display .= '<thead><tr>';
138  foreach ($this->headers as $header) {
139  if ($header === '') {
140  $header = '&nbsp;';
141  }
142  $display .= '<th>'.$header.'</th>';
143  }
144  $display .= '</tr></thead>'."\n";
145  }
146  return $display.'<tbody>'.$this->_generateBody().'</tbody>';
147  }
148 
152  function _generateBody()
153  {
154  $s_value = '';
155  $s_key = '';
156  $s_return = '';
157  $str = '';
158 
159  /* If divselectbox is empty, append a single white entry */
160  if (count($this->a_entries) == 0) {
161  if ($this->headers !== FALSE) {
162  $this->cols = count($this->headers);
163  $str .= '<tr>';
164  for ($i = 0; $i < ($this->cols); $i++) {
165  if ($i >= ($this->cols - 1)) {
166  $str .= '<td style="height:100%;border:0px;">&nbsp;</td>';
167  } else {
168  $str .= '<td style="height:100%;">&nbsp;</td>';
169  }
170  }
171  $str .= '</tr>';
172  } else {
173  $str .= '<tr><td style="height:100%; border-right:0px;">&nbsp;</td></tr>';
174  }
175  return $str;
176  }
177 
178  $i = $this->_numEntries();
179  foreach ($this->a_entries as $s_key => $s_value) {
180  $i--;
181 
182  $s_return .= "\n<tr>";
183 
184  $cnt = 0;
185 
186  $this->cols = count($s_value);
187  foreach ($s_value as $s_value2) {
188  $cnt++;
189 
190  if (!isset($s_value2['class'])) {
191  $class = "";
192  } else {
193  $class = "class='".$s_value2['class']."'";
194  }
195 
196  if (!isset($s_value2['attach'])) {
197  $style = "";
198  } else {
199  $style = " ".$s_value2['attach']." ";
200  }
201 
202  $s_return .= "\n<td".$style.$class.">";
203  if (isset($s_value2['string'])) {
204  if ($s_value2['string'] === '') {
205  $s_return .= '&nbsp;';
206  } else {
207  $s_return .= htmlentities($s_value2['string'], ENT_COMPAT, 'UTF-8');
208  }
209  } else {
210  $s_return .= $s_value2['html'];
211  }
212  $s_return .= '</td>';
213  }
214  $s_return .= "\n</tr>";
215  }
216  $s_return .= "\n<tr>";
217  for ($i = 0; $i < ($this->cols); $i++) {
218  if ($i >= ($this->cols - 1)) {
219  $s_return .= '<td style="height:100%;border:0px;"><div style="font-size:1px;">&nbsp;</div></td>';
220  } else {
221  $s_return .= '<td style="height:100%;"><div style="font-size:1px;">&nbsp;</div></td>';
222  }
223  }
224  $s_return .= '</tr>';
225  return $s_return;
226  }
227 }
228 ?>
setHeight($h)
Set new height value.
SetHeaders($headers)
Set column headers.
AddEntry($a_entriedata)
Add an entry.
DrawList()
Draw the list.
__construct($id)
Default divSelectBox constructor.
SetSummary($msg)
Set summary.
_numentries()
Get the number of entries.
_generatePage()
Generate the page.
_generateBody()
Generate the body.
This class contains all the functions to manage select box.