/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/DefaultGUIDataList.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/DefaultGUIDataList.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations)
Wed Feb 26 21:41:26 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Changes since 1.6: +8 -6 lines
+ modified image path according to more common path, again
+ moved functions 'decode_column_item_*' to class 'DataBrowser'

1 <?php
2 /**
3 *
4 * This file contains the Default DataList child
5 * that has its specific GUI layout/look/feel
6 *
7 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
8 * @package phpHtmlLib
9 *
10 */
11
12 /**
13 * Need to make sure we have the DataList object
14 */
15 require_once($phphtmllib."/widgets/data_list/DataList.inc");
16
17 /**
18 * This class is the Default phpHtmlLib GUI interface
19 * child of the DataList class. This child simply does
20 * the job of rendering the html/layout for a DataList.
21 * You can use this as an example of how to build your
22 * own look/feel for your DataList.
23 *
24 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
25 * @package phpHtmlLib
26 *
27 */
28 class DefaultGUIDatalist extends DataList {
29
30
31 /**
32 * The overall alignment
33 *
34 * DEFAULT: "center"
35 */
36 var $_align = "center";
37
38 /**
39 * This holds the action column
40 * settings if any.
41 */
42 var $_action_column = array();
43
44 /**
45 * holds the cntr for the action
46 * checkbox name
47 */
48 var $_action_count = 0;
49
50 /**
51 * This array holds the list of
52 * hidden checkbox[] items.
53 *
54 */
55 var $_hidden_checkbox_items = array();
56
57 /**
58 * this array keeps track of the list
59 * of rendered visible checkbox[]
60 * items. So we can not render the
61 * hidden version of it.
62 */
63 var $_visible_checkbox_items = array();
64
65
66 /**
67 * This variable holds the array of default
68 * selected items. This is populated
69 * inside the user_setup() function
70 * to pre-populate the list of selected
71 * items for a the checkbox action column.
72 *
73 */
74 var $_default_checked_items = array();
75
76
77 /**
78 * Do we show action bar row?
79 */
80 var $_show_actionbar = TRUE;
81
82 /**
83 * This variable tells us whether to display select all checkbox
84 */
85 var $_allow_select_all = TRUE;
86
87
88 /**
89 * This function sets a prefix for all
90 * variables that are used in the item list
91 * table on a page. This allows you to have
92 * multiple itemlists on a single html page.
93 *
94 * @param string $prefix - the prefix for all vars.
95 */
96 function set_global_prefix($prefix) {
97 $this->_vars["radioVar"] = "radio";
98 $this->_vars["checkboxVar"] = "checkbox";
99 DataList::set_global_prefix($prefix);
100 }
101
102
103 function gui_init() {
104 $container = container();
105 $container->add( $this->build_tool_link("first"),
106 $this->build_tool_link("prev"),
107 $this->build_tool_link("next"),
108 $this->build_tool_link("last"),
109 $this->build_tool_link("all"),
110 $this->get_page_info() );
111
112 $this->_data_table = html_table($this->get_width(),0,0,0, $this->_align);
113 $this->_data_table->set_class("datalist_border");
114
115 $this->_tool_td = html_td("datalist_title", "right", $container);
116 $this->_tool_td->set_style("padding-top: 5px; padding-right: 5px;");
117
118 //calculate the # of columns depending on if they
119 //have added action columns.
120 $cols = count($this->_columns);
121 if ($this->_has_action_column("FIRST")) $cols++;
122 if ($this->_has_action_column("LAST")) $cols++;
123
124 //$this->_tool_td->set_tag_attribute("colspan", $cols-1);
125
126 $title_table = html_table("100%");
127
128 $title = new TDtag(array("align" => "left",
129 "class" => "datalist_title",
130 "style" => "padding-left: 5px;"),
131 $this->get_title() );
132
133 $title_table->add( new TRtag( array(), $title,
134 $this->_tool_td) );
135
136
137 //add the header tr reference
138 //it will get populated later
139 $this->_header_tr = new TRtag;
140 //$this->_data_table->add( new TRtag(array(), $title, $this->_tool_td) );
141 $this->_data_table->add_row( new TDtag(array("colspan" => $cols),
142 $title_table) );
143 $this->_data_table->add_reference($this->_header_tr);
144
145 //initialize the first date row
146 $this->_data_row = new TRtag;
147
148 //enable search
149 $this->search_enable();
150 $this->set_simple_search_modifier();
151
152 }
153
154 /**
155 * this function is used to set the overall alignment
156 * of the widget
157 *
158 * @param string - the align value
159 */
160 function set_align($align) {
161 $this->_align = $align;
162 }
163
164 function child_build_column_header($name, $col, $cnt) {
165 if (!$this->_cur_col_cntr) {
166 $this->_cur_col_cntr = 1;
167 //lets see if we need to add an action column
168 //as the first column.
169 if ($this->_has_action_column("FIRST")) {
170 //looks like we have a FIRST column actionbar
171 //lets add it
172 $td = $this->_build_action_column("FIRST", TRUE);
173 $this->_header_tr->add( $td );
174 }
175 $td = $this->build_column_header($name, $col, $cnt);
176 $this->_header_tr->add( $td );
177 } else {
178 $td = $this->build_column_header($name, $col, $cnt);
179 $this->_header_tr->add( $td );
180 }
181
182 if ($this->_cur_col_cntr == $cnt) {
183 //lets see if we need to add an action column
184 //as the first column.
185 if ($this->_has_action_column("LAST")) {
186 //looks like we have a FIRST column actionbar
187 //lets add it
188 $td = $this->_build_action_column("LAST", TRUE);
189 $this->_header_tr->add( $td );
190 }
191 unset( $this->_cur_col_cntr );
192 } else {
193 $this->_cur_col_cntr++;
194 }
195 }
196
197 function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) {
198 if (!$this->_cur_col_cntr) {
199 $this->_cur_col_cntr = 1;
200 //lets see if we need to add an action column
201 //as the first column.
202 if ($this->_has_action_column("FIRST")) {
203 //looks like we have a FIRST column actionbar
204 //lets add it
205 $this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data));
206 }
207 $td = $this->wrap_column_item($obj, $col_name);
208 $this->_data_row->add( $td );
209 } else {
210 //show the normal data
211 $td = $this->wrap_column_item($obj, $col_name);
212 $this->_data_row->add( $td );
213 }
214
215
216 if ($last_in_row_flag) {
217 //lets see if we need to add an action column
218 //as the first column.
219 if ($this->_has_action_column("LAST")) {
220 //looks like we have a LAST column actionbar
221 //lets add it
222 $this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data));
223 }
224
225
226
227 $this->_data_table->add_row( $this->_data_row );
228 $this->_data_row = new TRtag;
229 unset( $this->_cur_col_cntr );
230 } else {
231 $this->_cur_col_cntr++;
232 }
233 }
234
235 function child_get_gui() {
236 return container( $this->_data_table,
237 $this->_build_actionbar() );
238 }
239
240 /**
241 * This function builds the object/text
242 * to be used for a column header. It can
243 * either be an href because its sortable,
244 * or it can just be text, because its not
245 * sortable.
246 *
247 * @param string $col_name - the column name
248 * to build from
249 * the headers.
250 * @param array $col_data - the column's data.
251 * @param int the column # we are working on.
252 * @return mixed - either an Atag object or
253 * raw text.
254 */
255 function build_column_header($col_name, $col_data, $col_num) {
256
257 $td = new TDtag(array("class"=>"datalist_col_head",
258 "width" => $col_data["size"]));
259
260 if ($this->_columns[$col_name]["sortable"]) {
261 $col_url = $this->build_column_url($col_name);
262
263 $td->set_tag_attribute("title","Sort By ".$col_name);
264
265 $td->push(html_a($col_url, $col_name,"form_link"));
266
267 if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
268
269 if ($this->reverseorder() == "false") {
270 $alt_title = "Sorted in Ascending Order";
271 $img = html_img($this->get_image_path()."/picto_down.gif",11,11,'',$alt_title);
272 $img->set_tag_attribute("style", "padding-left: 5px;margin-left:5px;vertical-align:middle;");
273 $td->push($img);
274 } else {
275 $alt_title = "Sorted in Descending Order";
276 $img = html_img($this->get_image_path()."/picto_up.gif",11,11,'',$alt_title);
277 $img->set_tag_attribute("style", "padding-left: 5px;margin-left:5px;vertical-align:middle;");
278 $td->push($img);
279 }
280 }
281
282 // we want to highlight the td on mouse over
283 $td->set_tag_attribute("onMouseOver",
284 "javascript:style.cursor='hand';this.className='datalist_col_head_hover';");
285 $td->set_tag_attribute("onMouseOut",
286 "javascript:this.className='datalist_col_head'");
287 $td->set_tag_attribute("onMouseDown",
288 "javascript:this.className='datalist_col_head_clicked'");
289
290
291 if ($this->get_form_method() == "POST") {
292 $td->set_tag_attribute("onClick", $col_url);
293 }
294 else {
295 $td->set_tag_attribute("onClick", "javascript:document.location='".$col_url."';");
296 }
297 } else {
298 $td->push($col_name);
299 $td->set_tag_attribute("style", $style."padding-left:5px;padding-right:5px;white-space:nowrap;");
300 }
301
302 return $td;
303 }
304
305 /**
306 * This function ensures that the data we place
307 * in a column is aligned according to what the
308 * user wants.
309 *
310 * @param mixed - $obj - the data for the td.
311 * @param string - $col_name - the name of the column header
312 * for this row to render.
313 * @param int - $odd_row - tells us if this cell lives in
314 * an odd # row (for alternating row colors)
315 * @param int - the column # we are working on.
316 * @return TDtag object
317 */
318 function wrap_column_item($obj, $col_name) {
319
320 $databrowser = new DataBrowser();
321
322 //make sure its set to something.
323 if ($obj == '') {
324 $obj = "&nbsp;";
325 }
326 // if item is match by expression we will replace it with an link object
327 elseif($databrowser->decode_column_item_expr($obj)) {
328 $obj = $databrowser->decode_column_item_expr($obj);
329 }
330 // if item is an Array we will replace it with an selection form object
331 elseif($databrowser->decode_column_item_array($obj, array( 'form' => 1)) ) {
332 $obj = $databrowser->decode_column_item_array($obj, array( 'form' => 1));
333 }
334
335 //make sure we don't put a right border on the last
336 //column we are working on.
337 //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
338
339
340 if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
341 $style = "background-color: #f4f4f4;";
342 } else {
343 $style = "background-color: #ffffff;";
344 }
345
346 $align = $this->_columns[$col_name]["align"];
347 $td = new TDtag(array("align" => $align,
348 "style" => $style,
349 "class" => "datalist_data_cell"));
350
351 if (is_object($obj) && $obj->_tag == "td") {
352 return $obj;
353 } else {
354 $td->add( $obj );
355 }
356 return $td;
357 }
358
359 /**
360 * This builds the table that holds the search
361 * capability.
362 *
363 * @return TABLEtag object.
364 */
365 function child_build_search_table() {
366 //the search capability is enabled.
367 //lets try and build the table.
368 $td_attributes = array("style" => "padding-left: 5px;padding-bottom:4px;".
369 "padding-right:40px;padding-top:4px;".
370 "background-color: #eeeeee;",
371 "align" => "left",
372 "class" => "font10");
373
374 $table = html_table($this->get_width(),0,0,0,$this->_align);
375
376 //test to see if they want to render the outer borders
377 $table->set_tag_attribute("style", "border-left: 1px solid #a1a1a1;".
378 "border-right: 1px solid #a1a1a1;");
379
380 $td = new TDtag($td_attributes);
381
382 if ($this->search_type() == "advanced") {
383 $td->push($this->_build_advanced_search_form());
384 } else {
385 $td->push($this->_build_simple_search_form());
386 }
387 $table->push_row($td);
388
389 return container($this->_build_search_title(), $table);
390 }
391
392 /**
393 * This function builds the search title table
394 *
395 * @return TABLEtag object
396 */
397 function _build_search_title() {
398 //build the title stacked table
399 $title = html_table($this->get_width(), 0, 0, 0, $this->_align);
400
401 //test to see if they want to render the outer borders
402 $title->set_tag_attribute("style","border: 1px solid #a1a1a1;");
403 $title->push_row(new TDtag(array("class" => "datalist_title",
404 "style" => "color: ".$this->_title_fcolor.";".
405 "background-color: ".$this->_title_color.";"), "&nbsp;Search"));
406
407 return $title;
408 }
409
410
411 /**
412 * This function builds the simple search TD
413 *
414 * @return ContainerWidget
415 */
416 function _build_simple_search_form() {
417
418 //if there is only 1 item enabled for search
419 //then the search looks simple.
420 $fields = $this->_get_searchable_fields();
421 $cnt = count($fields);
422 if ($cnt == 0) {
423 return NULL;
424 }
425
426 $container = new ContainerWidget;
427
428 if ($cnt == 1) {
429 //user only has 1 field to show.
430 list($name, $field) = each($fields);
431 $container->push("Find ".$name."&nbsp;&nbsp;");
432 } else {
433 //user has many fields to show.
434 $container->push("Find ",
435 form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
436 }
437
438 if ($this->get_simple_search_modifier()) {
439 //the user wants the search modifier turned on.
440 $container->push($this->_build_simple_search_modifier());
441 }
442
443 $container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),
444 form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
445
446 if ($this->is_advanced_search_enabled()) {
447 $span = html_span(html_a("ass","Advanced Search", "title"));
448 $container->push("&nbsp;", $span);
449 }
450
451 if ($cnt == 1) {
452 $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
453 }
454
455 $hidden_fields = $this->get_hidden_fields();
456 if(is_array($hidden_fields)) {
457 foreach($hidden_fields as $key => $value) {
458 $container->push(form_hidden($key, $value));
459 }
460 }
461 $container->push(form_close() );
462 return $container;
463 }
464
465
466 /**
467 * This function adds an action column. This
468 * adds a column of either checkboxes or radio
469 * buttons.
470 *
471 * @param string - type of column
472 * 'checkbox' or 'radio'
473 * @param string - which column it lives in
474 * 'FIRST' or 'LAST'
475 * @param string - which db field is associated
476 * with this.
477 * @param string - the title to use for the column.
478 * NOTE: if this is set, then there
479 * will NOT be a global checkbox
480 * that can be used to select/deslect
481 * all at once.
482 *
483 */
484 function add_action_column($type, $col, $db_field, $title=NULL) {
485 $action = array("type" => $type,
486 "dbfield" => $db_field,
487 "title" => $title);
488 $this->_action_column[$col] = $action;
489 }
490
491 /**
492 * This function is used to set the default list
493 * of selected checkbox items. This is used so
494 * the user can pre-populate the list of
495 * checked items in the checkbox action column
496 *
497 * @param array - the array of checked items
498 */
499 function set_default_checked_items($items) {
500 $this->_default_checked_items = $items;
501 }
502
503 /**
504 * This function returns the array of default
505 * checked items to be marked as checked in
506 * the checkbox action column
507 *
508 * @return array
509 */
510 function get_default_checked_items() {
511 return $this->_default_checked_items;
512 }
513
514 /**
515 * set the flag to tell the object to
516 * save the checked items
517 *
518 */
519 function save_checked_items() {
520 $this->_save_checked_items_flag = TRUE;
521 }
522
523 /**
524 * This tests the object flag to
525 * see if the child class wants to
526 * automatically save the checked
527 * items
528 *
529 * @return boolean
530 */
531 function _save_checked_items_enabled() {
532 return $this->_save_checked_items_flag;
533 }
534
535 /**
536 * This function tests to see if the child
537 * wants to render an action column
538 *
539 * @param string - the column to test for
540 * FIRST or LAST
541 * @return boolean
542 */
543 function _has_action_column($col) {
544 if (isset($this->_action_column[$col])) {
545 return TRUE;
546 }
547 else {
548 return FALSE;
549 }
550 }
551
552 /**
553 * This allows the caller to
554 * turn on/off the rendering of
555 * the bottom action bar row
556 *
557 * @param boolean - TRUE = on FALSE = off
558 */
559 function set_actionbar($flag = TRUE) {
560 $this->_show_actionbar = $flag;
561 }
562
563 /**
564 * This function gets the current value
565 * of the show actionbar flag setting.
566 *
567 * @return boolean
568 */
569 function show_actionbar() {
570 return $this->_show_actionbar;
571 }
572
573 /**
574 * Sets the flag for rendering the select all checkbox
575 *
576 * @param bool flag
577 */
578 function allow_select_all($flag) {
579 $this->_allow_select_all = $flag;
580 }
581
582
583 /**
584 * This builds an action column cell
585 *
586 * @param string - the column to test for
587 * FIRST or LAST
588 * @param boolean - lets us know this is for
589 * the header or a cell.
590 * @param array - the row's data.
591 * @return HTMLTag object
592 */
593 function _build_action_column($col, $header_flag=FALSE, $row_data=NULL) {
594
595 $attributes = array("width" => "1%",
596 "align" => "center");
597
598 if ($header_flag) $attributes["class"] = "datalist_col_head";
599 else $attributes["class"] = "datalist_actionbar_data_cell";
600
601 $td = new TDtag($attributes);
602 $form_value = '';
603 if ($header_flag) {
604 //this is for a header item.
605 $form_value = "";
606 } else {
607 $form_value = $row_data[$this->_action_column[$col]["dbfield"]];
608 }
609
610 switch ($this->_action_column[$col]["type"]) {
611 case "radio":
612 if ($header_flag) {
613 //we don't put a header button for radio
614 if ($this->_action_column[$col]["title"])
615 $obj = $this->_action_column[$col]["title"];
616 else $obj = _HTML_SPACE;
617 } else {
618 $name = $this->_vars["radioVar"]."[".$this->_action_count."]";
619 $obj = form_radio($name, $form_value);
620
621 //see if the checkbox should be disabled
622 if (!$this->is_action_enabled($form_value, $row_data)) {
623 $obj->set_tag_attribute("DISABLED");
624 $obj->set_tag_attribute("value","");
625 }
626 }
627
628 break;
629 case "checkbox":
630 if ($header_flag) {
631 //see if the child wants a title instead
632 //of the global check/uncheck checkbox
633 if ($this->_action_column[$col]["title"]) {
634 $obj = $this->_action_column[$col]["title"];
635 break;
636 } else {
637 $name = $this->_vars["checkboxVar"];
638 }
639 } else {
640 $name = $this->_vars["checkboxVar"]."[".$this->_action_count."]";
641 }
642
643 $this->_action_count++;
644 $obj = form_checkbox($name, $form_value);
645 if ($header_flag) {
646 if ($this->_allow_select_all) {
647 $obj->set_tag_attribute("onClick", "javascript:mass(this.form)");
648 } else {
649 $obj = _HTML_SPACE;
650 }
651 }
652
653 //see if the checkbox should be checked
654 if ($this->_is_col_checked($form_value, $row_data)) {
655 $obj->set_tag_attribute("CHECKED");
656 }
657
658 //see if the checkbox should be disabled
659 if (!$header_flag && !$this->is_action_enabled($form_value, $row_data)) {
660 $obj->set_tag_attribute("DISABLED");
661 $obj->set_tag_attribute("value","");
662 }
663
664 //save which items we have rendered visibly.
665 //so we can filter those out in the hidden
666 //items
667 $this->_visible_checkbox_items[$form_value] = TRUE;;
668 break;
669 }
670 $td->push($obj);
671 $td->set_collapse();
672 return $td;
673 }
674
675 /**
676 * This method checks to see if a
677 * particular row has been checked
678 * in the action column
679 *
680 * @param string - the item to look for
681 * @param array - the row's data.
682 * @return boolean.
683 */
684 function _is_col_checked($value, $row_data) {
685 if (count($this->_hidden_checkbox_items) == 0) {
686 if (isset($_REQUEST[$this->_vars["checkboxVar"]]) && is_array($_REQUEST[$this->_vars["checkboxVar"]])) {
687 $this->_hidden_checkbox_items = array_flip($_REQUEST[$this->_vars["checkboxVar"]]);
688 }
689 }
690
691 //call the child function to see if item should
692 //be checked
693 $user_flag = $this->is_action_checked($value, $row_data);
694 $hidden_flag = isset($this->_hidden_checkbox_items[$value]);
695
696 return($user_flag || $hidden_flag);
697
698 if (isset($this->_hidden_checkbox_items[$value])) {
699 return TRUE;
700 }
701 else {
702 return FALSE;
703 }
704 }
705
706 /**
707 * This function is provided to give the child class
708 * the ability to precheck/select a particular
709 * column.
710 *
711 * @param string - the item to look for.
712 * @param array - the row's data.
713 * @return boolean
714 */
715 function is_action_checked($value, $row_data) {
716 return FALSE;
717 }
718
719 /**
720 * This function is provided to give the child
721 * class the ability to enable/disable a particular
722 * checkbox.
723 *
724 * @param string - the item to look for.
725 * @param array - the row's data.
726 * @return boolean
727 */
728 function is_action_enabled($value, $row_data) {
729 return TRUE;
730 }
731
732 /**
733 * This function renders the action bar at the bottom
734 * of the data list.
735 *
736 * @return TABLEtag object
737 */
738 function _build_actionbar() {
739
740 if ($this->show_actionbar()) {
741
742 $table = html_table($this->get_width(),0,0,0,$this->_align);
743 $table->set_class("datalist_actionbar");
744 /*if ($this->show_outer_border()) {
745 $table->set_tag_attribute("style", _CSS_BORDER_LEFT.
746 _CSS_BORDER_RIGHT.
747 _CSS_BORDER_BOTTOM);
748 }
749 else {
750 $table->set_tag_attribute("style", _CSS_BORDER_TOP);
751 }*/
752
753 $td = new TDtag(array("class"=>"datalist_bottom_seperator",
754 "colspan" => 3),
755 _HTML_SPACE);
756 $table->add_row( $td );
757
758 $table->add_row($this->_build_actionbar_arrow_cell("FIRST"),
759 $this->_build_actionbar_data_cell(),
760 $this->_build_actionbar_arrow_cell("LAST") );
761
762 return $table;
763 }
764 else return NULL;
765 }
766
767 /**
768 * This function builds a TD with the
769 * appropriate action arrow.
770 *
771 * @param string - FIRST or LAST
772 * @return TDtag
773 */
774 function _build_actionbar_arrow_cell($col) {
775 $td = new TDtag(array("class" => "datalist_title",
776 "style" => "padding-left:14px;padding-right:14px;".
777 "padding-top:5px;",
778 "width" => "5%")
779 );
780
781 if ($col == "FIRST") {
782 $td->set_tag_attribute("align", "left");
783 if ($this->_has_action_column("FIRST") &&
784 $this->_datasource->get_total_rows()) {
785 $td->push(html_img("img/widgets/arrow_right.gif"));
786 }
787 else {
788 $td->push("&nbsp;");
789 }
790 }
791 else {
792 $td->set_tag_attribute("align", "right");
793 if ($this->_has_action_column("LAST") &&
794 $this->_datasource->get_total_rows()) {
795 $td->push(html_img("img/widgets/arrow_left.gif"));
796 }
797 else {
798 $td->push("&nbsp;");
799 }
800 }
801 return $td;
802 }
803
804 /**
805 * This function builds the user's data cell
806 *
807 * @return TDtag;
808 */
809 function _build_actionbar_data_cell() {
810 $td = new TDtag(array("class" => "datalist_title",
811 "style" => "padding-left:5px;padding-right:5px;".
812 "padding-top:5px;padding-bottom:5px")
813 );
814
815 $flag = FALSE;
816 if ($this->_has_action_column("FIRST")) {
817 $flag = TRUE;
818 $td->set_tag_attribute("align", "left");
819 }
820 else if ($this->_has_action_column("LAST")) {
821 $flag = TRUE;
822 $td->set_tag_attribute("align", "right");
823 }
824
825 if ($flag && $this->_datasource->get_total_rows()) {
826 $td->push($this->actionbar_cell());
827 }
828 else {
829 $td->push("&nbsp;");
830 }
831
832 return $td;
833 }
834
835 /**
836 * this is the method that builds
837 * the contents for the middle actionbar
838 * td cell.
839 * NOTE this function is meant to be overriden
840 * by the child class.
841 *
842 * @return ContainerWidget object
843 */
844 function actionbar_cell() {
845 return _HTML_SPACE;
846 }
847
848 /**
849 * This function builds an action button that will
850 * modify the form action, to post to a different
851 * script to handle the data
852 *
853 * @param string - the button name
854 * @param string - the script that gets called.
855 * @return INPUTtag object
856 */
857 function action_button($name, $action) {
858
859 $submit = form_button("_action", $name);
860
861 // here we make sure that all standard buttons look the same
862 if (strlen($name)<10) $submit->set_tag_attribute("style","width: 80px;");
863
864 $form_name = $this->get_form_name();
865
866 $onclick = "javascript: document.".$form_name.".action='".$action."';";
867 $onclick .= "document.".$form_name.".submit();";
868 $submit->set_tag_attribute("onclick", $onclick);
869 return $submit;
870 }
871
872 /**
873 * This function returns any Javascript required
874 * for this widget
875 *
876 * @return mixed
877 */
878 function _javascript() {
879 if ($this->_has_action_column("FIRST") || $this->_has_action_column("LAST")) {
880 $last = $this->_action_column["LAST"]["type"];
881 $first = $this->_action_column["FIRST"]["type"];
882 if ($last == "checkbox" || $first == "checkbox") {
883 return $this->_checkbox_javascript();
884 }
885 }
886 else {
887 return NULL;
888 }
889 }
890
891 /**
892 * This function builds the JS needed for the checkbox
893 * action column
894 *
895 * @return SCRIPTtag
896 */
897 function _checkbox_javascript() {
898 $script = new SCRIPTtag(array("language" => "Javascript"));
899
900 $var_name = $this->_vars["checkboxVar"];
901
902 $js = "function mass(form) {\n";
903 $js .= " var i=0;\n";
904 $js .= " var value=0;\n\n";
905 $js .= " if (form.$var_name.checked) {\n";
906 $js .= " value=1;\n";
907 $js .= " } else {\n";
908 $js .= " value=0;\n";
909 $js .= " }\n\n";
910 $js .= " for (i = 0; i < form.length; i++) {\n";
911 $js .= " if (form.elements[i].name.substring(0, 8) == '$var_name' && !form.elements[i].disabled) {\n";
912 $js .= " form.elements[i].checked = value;\n";
913 $js .= " }\n";
914 $js .= " }\n";
915 $js .= "}\n";
916
917 $script->push($js);
918 return $script;
919 }
920
921 function get_hidden_fields() {
922 user_error("DefaulGUIDataList::get_hidden_fields() - ".
923 "child class must override this method ".
924 "this function should return a hash for hidden fields, if not needed just return" );
925 }
926
927 function _decode_column_item_array($obj) {
928 user_error("DefaulGUIDataList::_decode_column_item_array() - ".
929 "child class must override this method ".
930 "this function should decode the column_item if it is a (sub-) array,".
931 "array should e.g. replaced by a select form." );
932 }
933
934 function _decode_column_item_expr($obj) {
935 user_error("DefaulGUIDataList::_decode_column_item_expr() - ".
936 "child class must override this method ".
937 "this function should decode the column_item, if it is encoded for e.g. objects" );
938 }
939 }
940
941 /**
942 * This class defines the css used by the
943 * FooterNav Object.
944 *
945 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
946 * @package phpHtmlLib
947 */
948 class DefaultGUIDataListCSS extends CSSBuilder {
949
950 function user_setup() {
951 $this->add_entry(".datalist_col_head", "",
952 array("font-family" => "arial, helvetica, sans-serif",
953 "font-size" => "10pt",
954 "font-weight" => "bold",
955 "color" => "#000000",
956 "background-color" => "#CCCCCC",
957 "text-align" => "left",
958 "white-space" => "nowrap",
959 "height" => "20px",
960 "vertical-align" => "middle",
961 "border-left" => "1px solid white",
962 "border-top" => "1px solid white",
963 "border-right" => "1px solid gray",
964 "border-bottom" => "1px solid gray",
965 "padding-left" => "3px",
966 "padding-right" => "3px") );
967
968 $this->add_entry(".datalist_col_head", "a.form_link:active,a.form_link:visited,a.form_link:link",
969 array("color" => "#000000",
970 "font-family" => "arial, helvetica, sans-serif",
971 "font-size" => "10pt",
972 "font-weight" => "bold",
973 "text-decoration" => "none"));
974
975 $this->add_entry(".datalist_col_head_hover", "",
976 array("font-family" => "arial, helvetica, sans-serif",
977 "font-size" => "10pt",
978 "font-weight" => "bold",
979 "color" => "#000000",
980 "background-color" => "#dcdcdc",
981 "text-align" => "left",
982 "white-space" => "nowrap",
983 "height" => "20px",
984 "vertical-align" => "middle",
985 "border-left" => "1px solid white",
986 "border-top" => "1px solid white",
987 "border-right" => "1px solid gray",
988 "border-bottom" => "1px solid gray",
989 "padding-left" => "3px",
990 "padding-right" => "3px") );
991
992 $this->add_entry(".datalist_col_head_clicked", "",
993 array("font-family" => "arial, helvetica, sans-serif",
994 "font-size" => "10pt",
995 "font-weight" => "bold",
996 "color" => "#000000",
997 "background-color" => "#dddddd",
998 "text-align" => "left",
999 "white-space" => "nowrap",
1000 "height" => "20px",
1001 "vertical-align" => "middle",
1002 "border-left" => "1px solid white",
1003 "border-top" => "1px solid white",
1004 "border-right" => "1px solid gray",
1005 "border-bottom" => "1px solid gray",
1006 "padding-left" => "3px",
1007 "padding-right" => "3px") );
1008
1009 $this->add_entry( ".datalist_border", "",
1010 array("border" => "1px solid #999999"));
1011
1012 $this->add_entry( ".datalist_title", "",
1013 array("font-family" => "arial",
1014 "font-size" => "10pt",
1015 "font-weight" => "bold",
1016 "color" => "#FFFFFF",
1017 "background-color" => "#999999",
1018 "white-space" =>"nowrap"));
1019
1020 $this->add_entry( ".datalist_data_cell", "",
1021 array(
1022 "font-family" => "arial",
1023 "font-size" => "10pt",
1024 "padding-left" => "3px",
1025 "padding-right" => "3px",
1026 "border-top" => "1px solid #dddddd"));
1027
1028 $this->add_entry( ".datalist_actionbar", "",
1029 array(
1030 "border" => "1px solid #999999") );
1031
1032 $this->add_entry( ".datalist_actionbar_data_cell", "",
1033 array(
1034 "font-family" => "arial",
1035 "font-size" => "10pt",
1036 "background" => "#CCCCCC",
1037 "padding-left" => "3px",
1038 "padding-right" => "3px",
1039 "border-top" => "1px solid #dddddd"));
1040
1041 $this->add_entry( ".datalist_bottom_seperator", "",
1042 array(
1043 "font-size" => "5px",
1044 "line-height" => "5px",
1045 "background" => "#CCCCCC",
1046 "text-align" => "left",
1047 "white-space" => "nowrap",
1048 "height" => "5px",
1049 "border-left" => "1px solid #FFFFFF",
1050 "border-top" => "1px solid #FFFFFF",
1051 "border-right" => "1px solid #dddddd",
1052 "border-bottom" => "1px solid #dddddd",
1053 "padding-left" => "3px",
1054 "padding-right" => "3px"));
1055 }
1056 }
1057 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed