/[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.10 - (hide annotations)
Tue Apr 8 23:33:48 2003 UTC (21 years, 5 months ago) by jonen
Branch: MAIN
Changes since 1.9: +0 -6 lines
- removed obsolvent custom code

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

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