/[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.9 - (show annotations)
Thu Apr 3 23:56:17 2003 UTC (21 years, 5 months ago) by jonen
Branch: MAIN
Changes since 1.8: +0 -12 lines
+ removed old code

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

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