/[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.8 - (show annotations)
Thu Mar 20 04:25:43 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Changes since 1.7: +14 -32 lines
+ removed custom decode functions
+ added var '_hidden_items', which holds natural vars
   needed at link or form rendering

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

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