1 |
jonen |
1.1 |
<?php |
2 |
|
|
|
3 |
|
|
/** |
4 |
|
|
* |
5 |
|
|
* This file contains the Default DataList child |
6 |
|
|
* that has its specific GUI layout/look/feel |
7 |
|
|
* |
8 |
|
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
9 |
|
|
* @package phpHtmlLib |
10 |
|
|
* |
11 |
|
|
*/ |
12 |
|
|
|
13 |
|
|
|
14 |
|
|
/** |
15 |
|
|
* This class is the Default phpHtmlLib GUI interface |
16 |
|
|
* child of the DataList class. This child simply does |
17 |
|
|
* the job of rendering the html/layout for a DataList. |
18 |
|
|
* You can use this as an example of how to build your |
19 |
|
|
* own look/feel for your DataList. |
20 |
|
|
* |
21 |
|
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
22 |
|
|
* @package phpHtmlLib |
23 |
|
|
* |
24 |
|
|
*/ |
25 |
|
|
class DefaultGUIDatalist extends DataList { |
26 |
|
|
|
27 |
|
|
function gui_init() { |
28 |
|
|
$container = container(); |
29 |
|
|
$container->add( $this->build_tool_link("first"), |
30 |
|
|
$this->build_tool_link("prev"), |
31 |
|
|
$this->build_tool_link("next"), |
32 |
|
|
$this->build_tool_link("last"), |
33 |
|
|
$this->build_tool_link("all"), |
34 |
|
|
$this->get_page_info() ); |
35 |
|
|
|
36 |
|
|
$this->_data_table = html_table($this->get_width(),0,0,0,"center"); |
37 |
|
|
$this->_data_table->set_class("datalist_border"); |
38 |
|
|
|
39 |
|
|
$this->_tool_td = html_td("datalist_title", "right", $container); |
40 |
|
|
$this->_tool_td->set_style("padding-top: 5px; padding-right: 5px;"); |
41 |
|
|
$this->_tool_td->set_tag_attribute("colspan", count($this->_columns)-1); |
42 |
|
|
|
43 |
|
|
$title = new TDtag(array("align" => "left", |
44 |
|
|
"class" => "datalist_title", |
45 |
|
|
"style" => "padding-left: 5px;"), |
46 |
|
|
$this->get_title() ); |
47 |
|
|
|
48 |
|
|
//add the header tr reference |
49 |
|
|
//it will get populated later |
50 |
|
|
$this->_header_tr = new TRtag; |
51 |
|
|
$this->_data_table->add( new TRtag(array(), $title, $this->_tool_td) ); |
52 |
|
|
$this->_data_table->add_reference($this->_header_tr); |
53 |
|
|
|
54 |
|
|
//initialize the first date row |
55 |
|
|
$this->_data_row = new TRtag; |
56 |
|
|
|
57 |
|
|
//enable search |
58 |
|
|
$this->search_enable(); |
59 |
|
|
$this->set_simple_search_modifier(); |
60 |
|
|
|
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
function child_build_column_header($name, $col, $cnt) { |
64 |
|
|
$td = $this->build_column_header($name, $col, $cnt); |
65 |
|
|
$this->_header_tr->add( $td ); |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
function child_add_row_cell($obj, $col_name, $last_in_row_flag) { |
69 |
|
|
$td = $this->wrap_column_item($obj, $col_name); |
70 |
|
|
|
71 |
|
|
$this->_data_row->add( $td ); |
72 |
|
|
if ($last_in_row_flag) { |
73 |
|
|
$this->_data_table->add_row( $this->_data_row ); |
74 |
|
|
$this->_data_row = new TRtag; |
75 |
|
|
} |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
function child_get_gui() { |
79 |
|
|
return $this->_data_table; |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
/** |
83 |
|
|
* This function builds the object/text |
84 |
|
|
* to be used for a column header. It can |
85 |
|
|
* either be an href because its sortable, |
86 |
|
|
* or it can just be text, because its not |
87 |
|
|
* sortable. |
88 |
|
|
* |
89 |
|
|
* @param string $col_name - the column name |
90 |
|
|
* to build from |
91 |
|
|
* the headers. |
92 |
|
|
* @param array $col_data - the column's data. |
93 |
|
|
* @param int the column # we are working on. |
94 |
|
|
* @return mixed - either an Atag object or |
95 |
|
|
* raw text. |
96 |
|
|
*/ |
97 |
|
|
function build_column_header($col_name, $col_data, $col_num) { |
98 |
|
|
|
99 |
|
|
$td = new TDtag(array("class"=>"datalist_col_head", |
100 |
|
|
"width" => $col_data["size"])); |
101 |
|
|
|
102 |
|
|
if ($this->_columns[$col_name]["sortable"]) { |
103 |
|
|
$col_url = $this->build_column_url($col_name); |
104 |
|
|
|
105 |
|
|
$td->set_tag_attribute("title","Sort By ".$col_name); |
106 |
|
|
|
107 |
|
|
$td->push(html_a($col_url, $col_name,"form_link")); |
108 |
|
|
|
109 |
|
|
if ($this->_columns[$col_name]["data_name"] == $this->orderby()) { |
110 |
|
|
|
111 |
|
|
if ($this->reverseorder() == "false") { |
112 |
|
|
$alt_title = "Sorted in Ascending Order"; |
113 |
|
|
$img = html_img($this->get_image_path()."/picto_down.gif",11,11,'',$alt_title); |
114 |
|
|
$img->set_tag_attribute("style", "padding-left: 5px;margin-left:5px;vertical-align:middle;"); |
115 |
|
|
$td->push($img); |
116 |
|
|
} else { |
117 |
|
|
$alt_title = "Sorted in Descending Order"; |
118 |
|
|
$img = html_img($this->get_image_path()."/picto_up.gif",11,11,'',$alt_title); |
119 |
|
|
$img->set_tag_attribute("style", "padding-left: 5px;margin-left:5px;vertical-align:middle;"); |
120 |
|
|
$td->push($img); |
121 |
|
|
} |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
// we want to highlight the td on mouse over |
125 |
|
|
$td->set_tag_attribute("onMouseOver", |
126 |
|
|
"javascript:style.cursor='hand';this.className='datalist_col_head_hover';"); |
127 |
|
|
$td->set_tag_attribute("onMouseOut", |
128 |
|
|
"javascript:this.className='datalist_col_head'"); |
129 |
|
|
$td->set_tag_attribute("onMouseDown", |
130 |
|
|
"javascript:this.className='datalist_col_head_clicked'"); |
131 |
|
|
|
132 |
|
|
|
133 |
|
|
if ($this->get_form_method() == "POST") { |
134 |
|
|
$td->set_tag_attribute("onClick", $col_url); |
135 |
|
|
} |
136 |
|
|
else { |
137 |
|
|
$td->set_tag_attribute("onClick", "javascript:document.location='".$col_url."';"); |
138 |
|
|
} |
139 |
|
|
} else { |
140 |
|
|
$td->push($col_name); |
141 |
|
|
$td->set_tag_attribute("style", $style."padding-left:5px;padding-right:5px;white-space:nowrap;"); |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
return $td; |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
/** |
148 |
|
|
* This function ensures that the data we place |
149 |
|
|
* in a column is aligned according to what the |
150 |
|
|
* user wants. |
151 |
|
|
* |
152 |
|
|
* @param mixed - $obj - the data for the td. |
153 |
|
|
* @param string - $col_name - the name of the column header |
154 |
|
|
* for this row to render. |
155 |
|
|
* @param int - $odd_row - tells us if this cell lives in |
156 |
|
|
* an odd # row (for alternating row colors) |
157 |
|
|
* @param int - the column # we are working on. |
158 |
|
|
* @return TDtag object |
159 |
|
|
*/ |
160 |
|
|
function wrap_column_item($obj, $col_name) { |
161 |
|
|
|
162 |
|
|
//make sure its set to something. |
163 |
|
|
if ($obj == '') { |
164 |
|
|
$obj = " "; |
165 |
|
|
} |
166 |
jonen |
1.2 |
// if item is an Array we will replace it with an link or contained form object |
167 |
|
|
elseif( is_array($obj) ) { |
168 |
|
|
$cur_row_index = $this->_datasource->get_cur_data_index(); |
169 |
|
|
$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
170 |
|
|
foreach($obj as $key => $value) { |
171 |
|
|
if(is_numeric($key)) { |
172 |
|
|
$guid = $value['guid']; |
173 |
|
|
$list[$key] = $guid; |
174 |
|
|
} |
175 |
|
|
} |
176 |
|
|
if(is_array($list) ) { |
177 |
|
|
$container = container( |
178 |
|
|
form_open($obj[guid], $_SERVER["PHP_SELF"] ), |
179 |
|
|
form_select("guid", $list), |
180 |
jonen |
1.3 |
form_hidden("ap", "oedit"), |
181 |
|
|
form_hidden("guid", $obj['guid']), |
182 |
|
|
form_hidden("class", $col_name), |
183 |
jonen |
1.2 |
form_submit("submit","view" ), |
184 |
|
|
form_close() |
185 |
|
|
); |
186 |
|
|
$obj = $container; |
187 |
|
|
} else { |
188 |
jonen |
1.3 |
$obj = html_a($_SERVER["PHP_SELF"] . "?ap=oedit&guid=" . $obj['guid'] . "&class=" . $col_name, "view"); |
189 |
jonen |
1.2 |
} |
190 |
|
|
} |
191 |
|
|
|
192 |
jonen |
1.1 |
|
193 |
|
|
//make sure we don't put a right border on the last |
194 |
|
|
//column we are working on. |
195 |
|
|
$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
196 |
|
|
|
197 |
|
|
if ($this->_columns[$col_name]["data_name"] == $this->orderby()) { |
198 |
|
|
$style .= "background-color: #f4f4f4;"; |
199 |
|
|
} else { |
200 |
|
|
$style .= "background-color: #ffffff;"; |
201 |
|
|
} |
202 |
|
|
|
203 |
|
|
$align = $this->_columns[$col_name]["align"]; |
204 |
|
|
$td = new TDtag(array("align" => $align, |
205 |
|
|
"style" => $style, |
206 |
|
|
"class" => "font10")); |
207 |
|
|
|
208 |
|
|
if (is_object($obj) && $obj->_tag == "td") { |
209 |
|
|
return $obj; |
210 |
|
|
} else { |
211 |
|
|
$td->add( $obj ); |
212 |
|
|
} |
213 |
|
|
return $td; |
214 |
|
|
} |
215 |
|
|
|
216 |
|
|
/** |
217 |
|
|
* This builds the table that holds the search |
218 |
|
|
* capability. |
219 |
|
|
* |
220 |
|
|
* @return TABLEtag object. |
221 |
|
|
*/ |
222 |
|
|
function child_build_search_table() { |
223 |
|
|
//the search capability is enabled. |
224 |
|
|
//lets try and build the table. |
225 |
|
|
$td_attributes = array("style" => "padding-left: 5px;padding-bottom:4px;". |
226 |
|
|
"padding-right:40px;padding-top:4px;". |
227 |
|
|
"background-color: #eeeeee;", |
228 |
|
|
"align" => "left", |
229 |
|
|
"class" => "font10"); |
230 |
|
|
|
231 |
|
|
$table = html_table($this->get_width(),0,0,0,"center"); |
232 |
|
|
|
233 |
|
|
//test to see if they want to render the outer borders |
234 |
|
|
$table->set_tag_attribute("style", "border-left: 1px solid #a1a1a1;". |
235 |
|
|
"border-right: 1px solid #a1a1a1;"); |
236 |
|
|
|
237 |
|
|
$td = new TDtag($td_attributes); |
238 |
|
|
|
239 |
|
|
if ($this->search_type() == "advanced") { |
240 |
|
|
$td->push($this->_build_advanced_search_form()); |
241 |
|
|
} else { |
242 |
|
|
$td->push($this->_build_simple_search_form()); |
243 |
|
|
} |
244 |
|
|
$table->push_row($td); |
245 |
|
|
|
246 |
|
|
return container($this->_build_search_title(), $table); |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
/** |
250 |
|
|
* This function builds the search title table |
251 |
|
|
* |
252 |
|
|
* @return TABLEtag object |
253 |
|
|
*/ |
254 |
|
|
function _build_search_title() { |
255 |
|
|
//build the title stacked table |
256 |
|
|
$title = html_table($this->get_width(), 0, 0, 0, "center"); |
257 |
|
|
|
258 |
|
|
//test to see if they want to render the outer borders |
259 |
|
|
$title->set_tag_attribute("style","border: 1px solid #a1a1a1;"); |
260 |
|
|
$title->push_row(new TDtag(array("class" => "datalist_title", |
261 |
|
|
"style" => "color: ".$this->_title_fcolor.";". |
262 |
|
|
"background-color: ".$this->_title_color.";"), " Search")); |
263 |
|
|
|
264 |
|
|
return $title; |
265 |
|
|
} |
266 |
|
|
|
267 |
|
|
|
268 |
|
|
/** |
269 |
|
|
* This function builds the simple search TD |
270 |
|
|
* |
271 |
|
|
* @return ContainerWidget |
272 |
|
|
*/ |
273 |
|
|
function _build_simple_search_form() { |
274 |
|
|
|
275 |
|
|
//if there is only 1 item enabled for search |
276 |
|
|
//then the search looks simple. |
277 |
|
|
$fields = $this->_get_searchable_fields(); |
278 |
|
|
$cnt = count($fields); |
279 |
|
|
if ($cnt == 0) { |
280 |
|
|
return NULL; |
281 |
|
|
} |
282 |
|
|
|
283 |
|
|
$container = new ContainerWidget; |
284 |
|
|
|
285 |
|
|
if ($cnt == 1) { |
286 |
|
|
//user only has 1 field to show. |
287 |
|
|
list($name, $field) = each($fields); |
288 |
|
|
$container->push("Find ".$name." "); |
289 |
|
|
} else { |
290 |
|
|
//user has many fields to show. |
291 |
|
|
$container->push("Find ", |
292 |
|
|
form_select($this->_search_fieldVar, $fields, $this->search_field())); |
293 |
|
|
} |
294 |
|
|
|
295 |
|
|
if ($this->get_simple_search_modifier()) { |
296 |
|
|
//the user wants the search modifier turned on. |
297 |
|
|
$container->push($this->_build_simple_search_modifier()); |
298 |
|
|
} |
299 |
|
|
|
300 |
|
|
$container->push(form_text($this->_search_valueVar, $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")), |
301 |
|
|
form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;"))); |
302 |
|
|
|
303 |
|
|
if ($this->is_advanced_search_enabled()) { |
304 |
|
|
$span = html_span(html_a("ass","Advanced Search", "title")); |
305 |
|
|
$container->push(" ", $span); |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
if ($cnt == 1) { |
309 |
|
|
$container->push(form_hidden($this->_search_fieldVar, $field)); |
310 |
|
|
} |
311 |
jonen |
1.2 |
|
312 |
|
|
$hidden_fields = $this->get_hidden_fields(); |
313 |
|
|
if(is_array($hidden_fields)) { |
314 |
|
|
foreach($hidden_fields as $key => $value) { |
315 |
|
|
$container->push(form_hidden($key, $value)); |
316 |
|
|
} |
317 |
|
|
} |
318 |
|
|
|
319 |
|
|
$container->push(form_close() ); |
320 |
jonen |
1.1 |
|
321 |
|
|
return $container; |
322 |
|
|
} |
323 |
jonen |
1.2 |
|
324 |
|
|
|
325 |
|
|
function get_hidden_fields() { |
326 |
|
|
user_error("DefaulGUIDataList::get_hidden_fields() - ". |
327 |
|
|
"child class must override this method ". |
328 |
|
|
"this function should return a hash for hidden fields, if not needed just return" ); |
329 |
|
|
} |
330 |
|
|
|
331 |
jonen |
1.1 |
} |
332 |
|
|
|
333 |
|
|
/** |
334 |
|
|
* This class defines the css used by the |
335 |
|
|
* FooterNav Object. |
336 |
|
|
* |
337 |
|
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
338 |
|
|
* @package phpHtmlLib |
339 |
|
|
*/ |
340 |
|
|
class DefaultGUIDataListCSS extends CSSBuilder { |
341 |
|
|
|
342 |
|
|
function user_setup() { |
343 |
|
|
$this->add_entry(".datalist_col_head", "", |
344 |
|
|
array("font-family" => "arial, helvetica, sans-serif", |
345 |
|
|
"font-size" => "10pt", |
346 |
|
|
"font-weight" => "bold", |
347 |
|
|
"color" => "#000000", |
348 |
|
|
"background-color" => "#CCCCCC", |
349 |
|
|
"text-align" => "left", |
350 |
|
|
"white-space" => "nowrap", |
351 |
|
|
"height" => "20px", |
352 |
|
|
"vertical-align" => "middle", |
353 |
|
|
"border-left" => "1px solid white", |
354 |
|
|
"border-top" => "1px solid white", |
355 |
|
|
"border-right" => "1px solid gray", |
356 |
|
|
"border-bottom" => "1px solid gray", |
357 |
|
|
"padding-left" => "3px", |
358 |
|
|
"padding-right" => "3px") ); |
359 |
|
|
|
360 |
|
|
$this->add_entry(".datalist_col_head", "a.form_link:active,a.form_link:visited,a.form_link:link", |
361 |
|
|
array("color" => "#000000", |
362 |
|
|
"text-decoration" => "none")); |
363 |
|
|
|
364 |
|
|
$this->add_entry(".datalist_col_head_hover", "", |
365 |
|
|
array("font-family" => "arial, helvetica, sans-serif", |
366 |
|
|
"font-size" => "10pt", |
367 |
|
|
"font-weight" => "bold", |
368 |
|
|
"color" => "#000000", |
369 |
|
|
"background-color" => "#dcdcdc", |
370 |
|
|
"text-align" => "left", |
371 |
|
|
"white-space" => "nowrap", |
372 |
|
|
"height" => "20px", |
373 |
|
|
"vertical-align" => "middle", |
374 |
|
|
"border-left" => "1px solid white", |
375 |
|
|
"border-top" => "1px solid white", |
376 |
|
|
"border-right" => "1px solid gray", |
377 |
|
|
"border-bottom" => "1px solid gray", |
378 |
|
|
"padding-left" => "3px", |
379 |
|
|
"padding-right" => "3px") ); |
380 |
|
|
|
381 |
|
|
$this->add_entry(".datalist_col_head_clicked", "", |
382 |
|
|
array("font-family" => "arial, helvetica, sans-serif", |
383 |
|
|
"font-size" => "10pt", |
384 |
|
|
"font-weight" => "bold", |
385 |
|
|
"color" => "#000000", |
386 |
|
|
"background-color" => "#dddddd", |
387 |
|
|
"text-align" => "left", |
388 |
|
|
"white-space" => "nowrap", |
389 |
|
|
"height" => "20px", |
390 |
|
|
"vertical-align" => "middle", |
391 |
|
|
"border-left" => "1px solid white", |
392 |
|
|
"border-top" => "1px solid white", |
393 |
|
|
"border-right" => "1px solid gray", |
394 |
|
|
"border-bottom" => "1px solid gray", |
395 |
|
|
"padding-left" => "3px", |
396 |
|
|
"padding-right" => "3px") ); |
397 |
|
|
|
398 |
|
|
$this->add_entry( ".datalist_border", "", |
399 |
|
|
array("border" => "1px solid #999999")); |
400 |
|
|
|
401 |
|
|
$this->add_entry( ".datalist_title", "", |
402 |
|
|
array("font-family" => "arial", |
403 |
|
|
"font-size" => "10pt", |
404 |
|
|
"font-weight" => "bold", |
405 |
|
|
"color" => "#FFFFFF", |
406 |
|
|
"background-color" => "#999999", |
407 |
|
|
"white-space" =>"nowrap")); |
408 |
|
|
} |
409 |
|
|
} |
410 |
|
|
?> |