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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations)
Sat Feb 22 21:08:37 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Changes since 1.4: +673 -56 lines
+ updated whole lib to version 2.2.1 (new FormProcessing since 2.2.0!)

1 jonen 1.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 jonen 1.5 /**
13     * Need to make sure we have the DataList object
14     */
15     require_once($phphtmllib."/widgets/data_list/DataList.inc");
16 jonen 1.1
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 jonen 1.5
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 jonen 1.1 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 jonen 1.5 $this->_data_table = html_table($this->get_width(),0,0,0, $this->_align);
113 jonen 1.1 $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 jonen 1.5
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 jonen 1.1
128     $title = new TDtag(array("align" => "left",
129     "class" => "datalist_title",
130     "style" => "padding-left: 5px;"),
131     $this->get_title() );
132    
133 jonen 1.5 $title_table->add( new TRtag( array(), $title,
134     $this->_tool_td) );
135    
136    
137 jonen 1.1 //add the header tr reference
138     //it will get populated later
139     $this->_header_tr = new TRtag;
140 jonen 1.5 //$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 jonen 1.1 $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 jonen 1.5 /**
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 jonen 1.1 function child_build_column_header($name, $col, $cnt) {
165 jonen 1.5 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 jonen 1.1 }
196    
197 jonen 1.5 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 jonen 1.1
215 jonen 1.5
216 jonen 1.1 if ($last_in_row_flag) {
217 jonen 1.5 //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 jonen 1.1 $this->_data_table->add_row( $this->_data_row );
228     $this->_data_row = new TRtag;
229 jonen 1.5 unset( $this->_cur_col_cntr );
230     } else {
231     $this->_cur_col_cntr++;
232     }
233 jonen 1.1 }
234    
235     function child_get_gui() {
236 jonen 1.5 return container( $this->_data_table,
237     $this->_build_actionbar() );
238 jonen 1.1 }
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     //make sure its set to something.
321     if ($obj == '') {
322     $obj = "&nbsp;";
323 jonen 1.2 }
324 jonen 1.1
325     //make sure we don't put a right border on the last
326     //column we are working on.
327 jonen 1.5 //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
328    
329 jonen 1.1
330     if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
331 jonen 1.5 $style = "background-color: #f4f4f4;";
332 jonen 1.1 } else {
333 jonen 1.5 $style = "background-color: #ffffff;";
334 jonen 1.1 }
335    
336     $align = $this->_columns[$col_name]["align"];
337     $td = new TDtag(array("align" => $align,
338     "style" => $style,
339 jonen 1.5 "class" => "datalist_data_cell"));
340 jonen 1.1
341     if (is_object($obj) && $obj->_tag == "td") {
342     return $obj;
343     } else {
344     $td->add( $obj );
345     }
346     return $td;
347     }
348    
349     /**
350     * This builds the table that holds the search
351     * capability.
352     *
353     * @return TABLEtag object.
354     */
355     function child_build_search_table() {
356     //the search capability is enabled.
357     //lets try and build the table.
358     $td_attributes = array("style" => "padding-left: 5px;padding-bottom:4px;".
359     "padding-right:40px;padding-top:4px;".
360     "background-color: #eeeeee;",
361     "align" => "left",
362     "class" => "font10");
363    
364 jonen 1.5 $table = html_table($this->get_width(),0,0,0,$this->_align);
365 jonen 1.1
366     //test to see if they want to render the outer borders
367     $table->set_tag_attribute("style", "border-left: 1px solid #a1a1a1;".
368     "border-right: 1px solid #a1a1a1;");
369    
370     $td = new TDtag($td_attributes);
371    
372     if ($this->search_type() == "advanced") {
373     $td->push($this->_build_advanced_search_form());
374     } else {
375     $td->push($this->_build_simple_search_form());
376     }
377     $table->push_row($td);
378    
379     return container($this->_build_search_title(), $table);
380     }
381    
382     /**
383     * This function builds the search title table
384     *
385     * @return TABLEtag object
386     */
387     function _build_search_title() {
388     //build the title stacked table
389 jonen 1.5 $title = html_table($this->get_width(), 0, 0, 0, $this->_align);
390 jonen 1.1
391     //test to see if they want to render the outer borders
392     $title->set_tag_attribute("style","border: 1px solid #a1a1a1;");
393     $title->push_row(new TDtag(array("class" => "datalist_title",
394     "style" => "color: ".$this->_title_fcolor.";".
395     "background-color: ".$this->_title_color.";"), "&nbsp;Search"));
396    
397     return $title;
398     }
399    
400    
401     /**
402     * This function builds the simple search TD
403     *
404     * @return ContainerWidget
405     */
406     function _build_simple_search_form() {
407    
408     //if there is only 1 item enabled for search
409     //then the search looks simple.
410     $fields = $this->_get_searchable_fields();
411     $cnt = count($fields);
412     if ($cnt == 0) {
413     return NULL;
414     }
415    
416     $container = new ContainerWidget;
417    
418     if ($cnt == 1) {
419     //user only has 1 field to show.
420     list($name, $field) = each($fields);
421     $container->push("Find ".$name."&nbsp;&nbsp;");
422     } else {
423     //user has many fields to show.
424     $container->push("Find ",
425 jonen 1.5 form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
426 jonen 1.1 }
427    
428     if ($this->get_simple_search_modifier()) {
429     //the user wants the search modifier turned on.
430     $container->push($this->_build_simple_search_modifier());
431     }
432    
433 jonen 1.5 $container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),
434 jonen 1.1 form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
435    
436     if ($this->is_advanced_search_enabled()) {
437     $span = html_span(html_a("ass","Advanced Search", "title"));
438     $container->push("&nbsp;", $span);
439     }
440    
441     if ($cnt == 1) {
442 jonen 1.5 $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
443     }
444    
445     return $container;
446     }
447    
448    
449     /**
450     * This function adds an action column. This
451     * adds a column of either checkboxes or radio
452     * buttons.
453     *
454     * @param string - type of column
455     * 'checkbox' or 'radio'
456     * @param string - which column it lives in
457     * 'FIRST' or 'LAST'
458     * @param string - which db field is associated
459     * with this.
460     * @param string - the title to use for the column.
461     * NOTE: if this is set, then there
462     * will NOT be a global checkbox
463     * that can be used to select/deslect
464     * all at once.
465     *
466     */
467     function add_action_column($type, $col, $db_field, $title=NULL) {
468     $action = array("type" => $type,
469     "dbfield" => $db_field,
470     "title" => $title);
471     $this->_action_column[$col] = $action;
472     }
473    
474     /**
475     * This function is used to set the default list
476     * of selected checkbox items. This is used so
477     * the user can pre-populate the list of
478     * checked items in the checkbox action column
479     *
480     * @param array - the array of checked items
481     */
482     function set_default_checked_items($items) {
483     $this->_default_checked_items = $items;
484     }
485    
486     /**
487     * This function returns the array of default
488     * checked items to be marked as checked in
489     * the checkbox action column
490     *
491     * @return array
492     */
493     function get_default_checked_items() {
494     return $this->_default_checked_items;
495     }
496    
497     /**
498     * set the flag to tell the object to
499     * save the checked items
500     *
501     */
502     function save_checked_items() {
503     $this->_save_checked_items_flag = TRUE;
504     }
505    
506     /**
507     * This tests the object flag to
508     * see if the child class wants to
509     * automatically save the checked
510     * items
511     *
512     * @return boolean
513     */
514     function _save_checked_items_enabled() {
515     return $this->_save_checked_items_flag;
516     }
517    
518     /**
519     * This function tests to see if the child
520     * wants to render an action column
521     *
522     * @param string - the column to test for
523     * FIRST or LAST
524     * @return boolean
525     */
526     function _has_action_column($col) {
527     if (isset($this->_action_column[$col])) {
528     return TRUE;
529     }
530     else {
531     return FALSE;
532     }
533     }
534    
535     /**
536     * This allows the caller to
537     * turn on/off the rendering of
538     * the bottom action bar row
539     *
540     * @param boolean - TRUE = on FALSE = off
541     */
542     function set_actionbar($flag = TRUE) {
543     $this->_show_actionbar = $flag;
544     }
545    
546     /**
547     * This function gets the current value
548     * of the show actionbar flag setting.
549     *
550     * @return boolean
551     */
552     function show_actionbar() {
553     return $this->_show_actionbar;
554     }
555    
556     /**
557     * Sets the flag for rendering the select all checkbox
558     *
559     * @param bool flag
560     */
561     function allow_select_all($flag) {
562     $this->_allow_select_all = $flag;
563     }
564    
565    
566     /**
567     * This builds an action column cell
568     *
569     * @param string - the column to test for
570     * FIRST or LAST
571     * @param boolean - lets us know this is for
572     * the header or a cell.
573     * @param array - the row's data.
574     * @return HTMLTag object
575     */
576     function _build_action_column($col, $header_flag=FALSE, $row_data=NULL) {
577    
578     $attributes = array("width" => "1%",
579     "align" => "center");
580    
581     if ($header_flag) $attributes["class"] = "datalist_col_head";
582     else $attributes["class"] = "datalist_actionbar_data_cell";
583    
584     $td = new TDtag($attributes);
585     $form_value = '';
586     if ($header_flag) {
587     //this is for a header item.
588     $form_value = "";
589     } else {
590     $form_value = $row_data[$this->_action_column[$col]["dbfield"]];
591     }
592    
593     switch ($this->_action_column[$col]["type"]) {
594     case "radio":
595     if ($header_flag) {
596     //we don't put a header button for radio
597     if ($this->_action_column[$col]["title"])
598     $obj = $this->_action_column[$col]["title"];
599     else $obj = _HTML_SPACE;
600     } else {
601     $name = $this->_vars["radioVar"]."[".$this->_action_count."]";
602     $obj = form_radio($name, $form_value);
603    
604     //see if the checkbox should be disabled
605     if (!$this->is_action_enabled($form_value, $row_data)) {
606     $obj->set_tag_attribute("DISABLED");
607     $obj->set_tag_attribute("value","");
608     }
609     }
610    
611     break;
612     case "checkbox":
613     if ($header_flag) {
614     //see if the child wants a title instead
615     //of the global check/uncheck checkbox
616     if ($this->_action_column[$col]["title"]) {
617     $obj = $this->_action_column[$col]["title"];
618     break;
619     } else {
620     $name = $this->_vars["checkboxVar"];
621     }
622     } else {
623     $name = $this->_vars["checkboxVar"]."[".$this->_action_count."]";
624     }
625    
626     $this->_action_count++;
627     $obj = form_checkbox($name, $form_value);
628     if ($header_flag) {
629     if ($this->_allow_select_all) {
630     $obj->set_tag_attribute("onClick", "javascript:mass(this.form)");
631     } else {
632     $obj = _HTML_SPACE;
633     }
634     }
635    
636     //see if the checkbox should be checked
637     if ($this->_is_col_checked($form_value, $row_data)) {
638     $obj->set_tag_attribute("CHECKED");
639     }
640    
641     //see if the checkbox should be disabled
642     if (!$header_flag && !$this->is_action_enabled($form_value, $row_data)) {
643     $obj->set_tag_attribute("DISABLED");
644     $obj->set_tag_attribute("value","");
645     }
646    
647     //save which items we have rendered visibly.
648     //so we can filter those out in the hidden
649     //items
650     $this->_visible_checkbox_items[$form_value] = TRUE;;
651     break;
652     }
653     $td->push($obj);
654     $td->set_collapse();
655     return $td;
656     }
657    
658     /**
659     * This method checks to see if a
660     * particular row has been checked
661     * in the action column
662     *
663     * @param string - the item to look for
664     * @param array - the row's data.
665     * @return boolean.
666     */
667     function _is_col_checked($value, $row_data) {
668     if (count($this->_hidden_checkbox_items) == 0) {
669     if (isset($_REQUEST[$this->_vars["checkboxVar"]]) && is_array($_REQUEST[$this->_vars["checkboxVar"]])) {
670     $this->_hidden_checkbox_items = array_flip($_REQUEST[$this->_vars["checkboxVar"]]);
671     }
672     }
673    
674     //call the child function to see if item should
675     //be checked
676     $user_flag = $this->is_action_checked($value, $row_data);
677     $hidden_flag = isset($this->_hidden_checkbox_items[$value]);
678    
679     return($user_flag || $hidden_flag);
680    
681     if (isset($this->_hidden_checkbox_items[$value])) {
682     return TRUE;
683     }
684     else {
685     return FALSE;
686     }
687     }
688    
689     /**
690     * This function is provided to give the child class
691     * the ability to precheck/select a particular
692     * column.
693     *
694     * @param string - the item to look for.
695     * @param array - the row's data.
696     * @return boolean
697     */
698     function is_action_checked($value, $row_data) {
699     return FALSE;
700     }
701    
702     /**
703     * This function is provided to give the child
704     * class the ability to enable/disable a particular
705     * checkbox.
706     *
707     * @param string - the item to look for.
708     * @param array - the row's data.
709     * @return boolean
710     */
711     function is_action_enabled($value, $row_data) {
712     return TRUE;
713     }
714    
715     /**
716     * This function renders the action bar at the bottom
717     * of the data list.
718     *
719     * @return TABLEtag object
720     */
721     function _build_actionbar() {
722    
723     if ($this->show_actionbar()) {
724    
725     $table = html_table($this->get_width(),0,0,0,$this->_align);
726     $table->set_class("datalist_actionbar");
727     /*if ($this->show_outer_border()) {
728     $table->set_tag_attribute("style", _CSS_BORDER_LEFT.
729     _CSS_BORDER_RIGHT.
730     _CSS_BORDER_BOTTOM);
731     }
732     else {
733     $table->set_tag_attribute("style", _CSS_BORDER_TOP);
734     }*/
735    
736     $td = new TDtag(array("class"=>"datalist_bottom_seperator",
737     "colspan" => 3),
738     _HTML_SPACE);
739     $table->add_row( $td );
740    
741     $table->add_row($this->_build_actionbar_arrow_cell("FIRST"),
742     $this->_build_actionbar_data_cell(),
743     $this->_build_actionbar_arrow_cell("LAST") );
744    
745     return $table;
746     }
747     else return NULL;
748     }
749    
750     /**
751     * This function builds a TD with the
752     * appropriate action arrow.
753     *
754     * @param string - FIRST or LAST
755     * @return TDtag
756     */
757     function _build_actionbar_arrow_cell($col) {
758     $td = new TDtag(array("class" => "datalist_title",
759     "style" => "padding-left:14px;padding-right:14px;".
760     "padding-top:5px;",
761     "width" => "5%")
762     );
763    
764     if ($col == "FIRST") {
765     $td->set_tag_attribute("align", "left");
766     if ($this->_has_action_column("FIRST") &&
767     $this->_datasource->get_total_rows()) {
768     $td->push(html_img("/phphtmllib/images/widgets/arrow_right.gif"));
769     }
770     else {
771     $td->push("&nbsp;");
772     }
773     }
774     else {
775     $td->set_tag_attribute("align", "right");
776     if ($this->_has_action_column("LAST") &&
777     $this->_datasource->get_total_rows()) {
778     $td->push(html_img("/phphtmllib/images/widgets/arrow_left.gif"));
779     }
780     else {
781     $td->push("&nbsp;");
782     }
783 jonen 1.1 }
784 jonen 1.5 return $td;
785     }
786    
787     /**
788     * This function builds the user's data cell
789     *
790     * @return TDtag;
791     */
792     function _build_actionbar_data_cell() {
793     $td = new TDtag(array("class" => "datalist_title",
794     "style" => "padding-left:5px;padding-right:5px;".
795     "padding-top:5px;padding-bottom:5px")
796     );
797    
798     $flag = FALSE;
799     if ($this->_has_action_column("FIRST")) {
800     $flag = TRUE;
801     $td->set_tag_attribute("align", "left");
802     }
803     else if ($this->_has_action_column("LAST")) {
804     $flag = TRUE;
805     $td->set_tag_attribute("align", "right");
806     }
807    
808     if ($flag && $this->_datasource->get_total_rows()) {
809     $td->push($this->actionbar_cell());
810     }
811     else {
812     $td->push("&nbsp;");
813 jonen 1.2 }
814 jonen 1.1
815 jonen 1.5 return $td;
816     }
817    
818     /**
819     * this is the method that builds
820     * the contents for the middle actionbar
821     * td cell.
822     * NOTE this function is meant to be overriden
823     * by the child class.
824     *
825     * @return ContainerWidget object
826     */
827     function actionbar_cell() {
828     return _HTML_SPACE;
829     }
830    
831     /**
832     * This function builds an action button that will
833     * modify the form action, to post to a different
834     * script to handle the data
835     *
836     * @param string - the button name
837     * @param string - the script that gets called.
838     * @return INPUTtag object
839     */
840     function action_button($name, $action) {
841    
842     $submit = form_button("_action", $name);
843    
844     // here we make sure that all standard buttons look the same
845     if (strlen($name)<10) $submit->set_tag_attribute("style","width: 80px;");
846    
847     $form_name = $this->get_form_name();
848    
849     $onclick = "javascript: document.".$form_name.".action='".$action."';";
850     $onclick .= "document.".$form_name.".submit();";
851     $submit->set_tag_attribute("onclick", $onclick);
852     return $submit;
853     }
854    
855     /**
856     * This function returns any Javascript required
857     * for this widget
858     *
859     * @return mixed
860     */
861     function _javascript() {
862     if ($this->_has_action_column("FIRST") || $this->_has_action_column("LAST")) {
863     $last = $this->_action_column["LAST"]["type"];
864     $first = $this->_action_column["FIRST"]["type"];
865     if ($last == "checkbox" || $first == "checkbox") {
866     return $this->_checkbox_javascript();
867     }
868     }
869     else {
870     return NULL;
871     }
872 jonen 1.1 }
873 jonen 1.2
874 jonen 1.5 /**
875     * This function builds the JS needed for the checkbox
876     * action column
877     *
878     * @return SCRIPTtag
879     */
880     function _checkbox_javascript() {
881     $script = new SCRIPTtag(array("language" => "Javascript"));
882    
883     $var_name = $this->_vars["checkboxVar"];
884    
885     $js = "function mass(form) {\n";
886     $js .= " var i=0;\n";
887     $js .= " var value=0;\n\n";
888     $js .= " if (form.$var_name.checked) {\n";
889     $js .= " value=1;\n";
890     $js .= " } else {\n";
891     $js .= " value=0;\n";
892     $js .= " }\n\n";
893     $js .= " for (i = 0; i < form.length; i++) {\n";
894     $js .= " if (form.elements[i].name.substring(0, 8) == '$var_name' && !form.elements[i].disabled) {\n";
895     $js .= " form.elements[i].checked = value;\n";
896     $js .= " }\n";
897     $js .= " }\n";
898     $js .= "}\n";
899 jonen 1.2
900 jonen 1.5 $script->push($js);
901     return $script;
902 jonen 1.4 }
903 jonen 1.5
904    
905 jonen 1.1 }
906    
907     /**
908     * This class defines the css used by the
909     * FooterNav Object.
910     *
911     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
912     * @package phpHtmlLib
913     */
914     class DefaultGUIDataListCSS extends CSSBuilder {
915    
916     function user_setup() {
917     $this->add_entry(".datalist_col_head", "",
918     array("font-family" => "arial, helvetica, sans-serif",
919     "font-size" => "10pt",
920     "font-weight" => "bold",
921     "color" => "#000000",
922     "background-color" => "#CCCCCC",
923     "text-align" => "left",
924     "white-space" => "nowrap",
925     "height" => "20px",
926     "vertical-align" => "middle",
927     "border-left" => "1px solid white",
928     "border-top" => "1px solid white",
929     "border-right" => "1px solid gray",
930     "border-bottom" => "1px solid gray",
931     "padding-left" => "3px",
932     "padding-right" => "3px") );
933    
934     $this->add_entry(".datalist_col_head", "a.form_link:active,a.form_link:visited,a.form_link:link",
935     array("color" => "#000000",
936 jonen 1.5 "font-family" => "arial, helvetica, sans-serif",
937     "font-size" => "10pt",
938     "font-weight" => "bold",
939 jonen 1.1 "text-decoration" => "none"));
940    
941     $this->add_entry(".datalist_col_head_hover", "",
942     array("font-family" => "arial, helvetica, sans-serif",
943     "font-size" => "10pt",
944     "font-weight" => "bold",
945     "color" => "#000000",
946     "background-color" => "#dcdcdc",
947     "text-align" => "left",
948     "white-space" => "nowrap",
949     "height" => "20px",
950     "vertical-align" => "middle",
951     "border-left" => "1px solid white",
952     "border-top" => "1px solid white",
953     "border-right" => "1px solid gray",
954     "border-bottom" => "1px solid gray",
955     "padding-left" => "3px",
956     "padding-right" => "3px") );
957    
958     $this->add_entry(".datalist_col_head_clicked", "",
959     array("font-family" => "arial, helvetica, sans-serif",
960     "font-size" => "10pt",
961     "font-weight" => "bold",
962     "color" => "#000000",
963     "background-color" => "#dddddd",
964     "text-align" => "left",
965     "white-space" => "nowrap",
966     "height" => "20px",
967     "vertical-align" => "middle",
968     "border-left" => "1px solid white",
969     "border-top" => "1px solid white",
970     "border-right" => "1px solid gray",
971     "border-bottom" => "1px solid gray",
972     "padding-left" => "3px",
973     "padding-right" => "3px") );
974    
975     $this->add_entry( ".datalist_border", "",
976     array("border" => "1px solid #999999"));
977    
978     $this->add_entry( ".datalist_title", "",
979     array("font-family" => "arial",
980     "font-size" => "10pt",
981     "font-weight" => "bold",
982     "color" => "#FFFFFF",
983     "background-color" => "#999999",
984     "white-space" =>"nowrap"));
985 jonen 1.5
986     $this->add_entry( ".datalist_data_cell", "",
987     array(
988     "font-family" => "arial",
989     "font-size" => "10pt",
990     "padding-left" => "3px",
991     "padding-right" => "3px",
992     "border-top" => "1px solid #dddddd"));
993    
994     $this->add_entry( ".datalist_actionbar", "",
995     array(
996     "border" => "1px solid #999999") );
997    
998     $this->add_entry( ".datalist_actionbar_data_cell", "",
999     array(
1000     "font-family" => "arial",
1001     "font-size" => "10pt",
1002     "background" => "#CCCCCC",
1003     "padding-left" => "3px",
1004     "padding-right" => "3px",
1005     "border-top" => "1px solid #dddddd"));
1006    
1007     $this->add_entry( ".datalist_bottom_seperator", "",
1008     array(
1009     "font-size" => "5px",
1010     "line-height" => "5px",
1011     "background" => "#CCCCCC",
1012     "text-align" => "left",
1013     "white-space" => "nowrap",
1014     "height" => "5px",
1015     "border-left" => "1px solid #FFFFFF",
1016     "border-top" => "1px solid #FFFFFF",
1017     "border-right" => "1px solid #dddddd",
1018     "border-bottom" => "1px solid #dddddd",
1019     "padding-left" => "3px",
1020     "padding-right" => "3px"));
1021 jonen 1.1 }
1022     }
1023     ?>

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