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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by jonen, Sat Feb 22 18:02:18 2003 UTC revision 1.5 by jonen, Sat Feb 22 21:08:37 2003 UTC
# Line 1  Line 1 
1  <?php  <?php
   
2  /**  /**
3   *   *
4   * This file contains the Default DataList child   * This file contains the Default DataList child
# Line 10  Line 9 
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   * This class is the Default phpHtmlLib GUI interface
# Line 24  Line 27 
27   */   */
28  class DefaultGUIDatalist extends DataList {  class DefaultGUIDatalist extends DataList {
29    
30    
31        /**
32         * The overall alignment
33         *
34         * DEFAULT: "center"
35         */
36        var $_align = "center";
37    
38        /**
39         * This holds the action column
40         * settings if any.
41         */
42        var $_action_column = array();
43    
44        /**
45         * holds the cntr for the action
46         * checkbox name
47         */
48        var $_action_count = 0;
49    
50        /**
51         * This array holds the list of
52         * hidden checkbox[] items.
53         *
54         */
55        var $_hidden_checkbox_items = array();
56    
57        /**
58         * this array keeps track of the list
59         * of rendered visible checkbox[]
60         * items.  So we can not render the
61         * hidden version of it.
62         */
63        var $_visible_checkbox_items = array();
64    
65    
66        /**
67         * This variable holds the array of default
68         * selected items.  This is populated
69         * inside the user_setup() function
70         * to pre-populate the list of selected
71         * items for a the checkbox action column.
72         *
73         */
74        var $_default_checked_items = array();
75    
76    
77        /**
78         * Do we show action bar row?
79         */
80        var $_show_actionbar = TRUE;
81    
82        /**
83        * This variable tells us whether to display select all checkbox
84        */
85        var $_allow_select_all = TRUE;
86    
87    
88        /**
89         * This function sets a prefix for all
90         * variables that are used in the item list
91         * table on a page.  This allows you to have
92         * multiple itemlists on a single html page.
93         *
94         * @param string $prefix - the prefix for all vars.
95         */
96        function set_global_prefix($prefix) {
97            $this->_vars["radioVar"] = "radio";
98            $this->_vars["checkboxVar"] = "checkbox";
99            DataList::set_global_prefix($prefix);
100        }
101    
102    
103          function gui_init() {          function gui_init() {
104                  $container = container();                  $container = container();
105                  $container->add( $this->build_tool_link("first"),                  $container->add( $this->build_tool_link("first"),
# Line 33  class DefaultGUIDatalist extends DataLis Line 109  class DefaultGUIDatalist extends DataLis
109                                                   $this->build_tool_link("all"),                                                   $this->build_tool_link("all"),
110                                                   $this->get_page_info() );                                                   $this->get_page_info() );
111    
112                  $this->_data_table = html_table($this->get_width(),0,0,0,"center");                  $this->_data_table = html_table($this->get_width(),0,0,0, $this->_align);
113                  $this->_data_table->set_class("datalist_border");                  $this->_data_table->set_class("datalist_border");
114    
115                  $this->_tool_td = html_td("datalist_title", "right", $container);                  $this->_tool_td = html_td("datalist_title", "right", $container);
116          $this->_tool_td->set_style("padding-top: 5px; padding-right: 5px;");          $this->_tool_td->set_style("padding-top: 5px; padding-right: 5px;");
117                  $this->_tool_td->set_tag_attribute("colspan", count($this->_columns)-1);  
118            //calculate the # of columns depending on if they
119            //have added action columns.
120            $cols = count($this->_columns);
121            if ($this->_has_action_column("FIRST")) $cols++;
122            if ($this->_has_action_column("LAST")) $cols++;
123    
124                    //$this->_tool_td->set_tag_attribute("colspan", $cols-1);
125    
126            $title_table = html_table("100%");
127    
128                  $title = new TDtag(array("align" => "left",                  $title = new TDtag(array("align" => "left",
129                                                                   "class" => "datalist_title",                                                                   "class" => "datalist_title",
130                                                                   "style" => "padding-left: 5px;"),                                                                   "style" => "padding-left: 5px;"),
131                                                     $this->get_title() );                                                     $this->get_title() );
132    
133            $title_table->add( new TRtag( array(), $title,
134                                          $this->_tool_td) );
135    
136    
137                  //add the header tr reference                  //add the header tr reference
138                  //it will get populated later                  //it will get populated later
139                  $this->_header_tr = new TRtag;                  $this->_header_tr = new TRtag;
140                  $this->_data_table->add( new TRtag(array(), $title, $this->_tool_td) );                  //$this->_data_table->add( new TRtag(array(), $title, $this->_tool_td) );
141            $this->_data_table->add_row( new TDtag(array("colspan" => $cols),
142                                               $title_table) );
143                  $this->_data_table->add_reference($this->_header_tr);                  $this->_data_table->add_reference($this->_header_tr);
144    
145                  //initialize the first date row                  //initialize the first date row
# Line 60  class DefaultGUIDatalist extends DataLis Line 151  class DefaultGUIDatalist extends DataLis
151    
152          }          }
153    
154        /**
155         * this function is used to set the overall alignment
156         * of the widget
157         *
158         * @param string - the align value
159         */
160        function set_align($align) {
161            $this->_align = $align;
162        }
163    
164          function child_build_column_header($name, $col, $cnt) {          function child_build_column_header($name, $col, $cnt) {
165                  $td = $this->build_column_header($name, $col, $cnt);          if (!$this->_cur_col_cntr) {
166                  $this->_header_tr->add( $td );              $this->_cur_col_cntr = 1;
167                //lets see if we need to add an action column
168                //as the first column.
169                if ($this->_has_action_column("FIRST")) {
170                    //looks like we have a FIRST column actionbar
171                    //lets add it
172                    $td = $this->_build_action_column("FIRST", TRUE);
173                    $this->_header_tr->add( $td );
174                }
175                $td = $this->build_column_header($name, $col, $cnt);
176                $this->_header_tr->add( $td );
177            } else {
178                $td = $this->build_column_header($name, $col, $cnt);
179                $this->_header_tr->add( $td );
180            }
181    
182            if ($this->_cur_col_cntr == $cnt) {
183                //lets see if we need to add an action column
184                //as the first column.
185                if ($this->_has_action_column("LAST")) {
186                    //looks like we have a FIRST column actionbar
187                    //lets add it
188                    $td = $this->_build_action_column("LAST", TRUE);
189                    $this->_header_tr->add( $td );
190                }
191                unset( $this->_cur_col_cntr );
192            } else {
193                $this->_cur_col_cntr++;
194            }        
195          }          }
196    
197          function child_add_row_cell($obj, $col_name, $last_in_row_flag) {          function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) {
198                  $td = $this->wrap_column_item($obj, $col_name);          if (!$this->_cur_col_cntr) {
199                $this->_cur_col_cntr = 1;
200                //lets see if we need to add an action column
201                //as the first column.
202                if ($this->_has_action_column("FIRST")) {
203                    //looks like we have a FIRST column actionbar
204                    //lets add it
205                    $this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data));
206                }
207                $td = $this->wrap_column_item($obj, $col_name);
208                $this->_data_row->add( $td );
209            } else {
210                //show the normal data
211                $td = $this->wrap_column_item($obj, $col_name);
212                $this->_data_row->add( $td );
213            }
214    
215                  $this->_data_row->add( $td );                  
216                  if ($last_in_row_flag) {                  if ($last_in_row_flag) {
217                //lets see if we need to add an action column
218                //as the first column.
219                if ($this->_has_action_column("LAST")) {
220                    //looks like we have a LAST column actionbar
221                    //lets add it
222                    $this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data));
223                }
224    
225    
226    
227                          $this->_data_table->add_row( $this->_data_row );                          $this->_data_table->add_row( $this->_data_row );
228                          $this->_data_row = new TRtag;                          $this->_data_row = new TRtag;
229                  }              unset( $this->_cur_col_cntr );
230                    } else {
231                $this->_cur_col_cntr++;
232            }
233          }          }
234    
235          function child_get_gui() {          function child_get_gui() {
236                  return $this->_data_table;          return container( $this->_data_table,
237                              $this->_build_actionbar() );
238          }          }
239    
240      /**      /**
# Line 162  class DefaultGUIDatalist extends DataLis Line 320  class DefaultGUIDatalist extends DataLis
320          //make sure its set to something.          //make sure its set to something.
321          if ($obj == '') {          if ($obj == '') {
322              $obj = "&nbsp;";              $obj = "&nbsp;";
         }          
         // if item is match by expression we will replace it with an link object  
         elseif($this->_decode_column_item_expr($obj)) {  
           $obj = $this->_decode_column_item_expr($obj);  
         }  
         // if item is an Array we will replace it with an selection form object  
         elseif($this->_decode_column_item_array($obj)) {  
           $obj = $this->_decode_column_item_array($obj);  
323          }          }
           
324    
325          //make sure we don't put a right border on the last          //make sure we don't put a right border on the last
326          //column we are working on.          //column we are working on.
327          $style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";          //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
328            
329    
330                  if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {                  if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
331              $style .= "background-color: #f4f4f4;";              $style = "background-color: #f4f4f4;";
332          } else {          } else {
333                          $style .= "background-color: #ffffff;";                          $style = "background-color: #ffffff;";
334                  }                  }
335    
336          $align = $this->_columns[$col_name]["align"];          $align = $this->_columns[$col_name]["align"];
337          $td = new TDtag(array("align" => $align,          $td = new TDtag(array("align" => $align,
338                                "style" => $style,                                "style" => $style,
339                                                            "class" => "font10"));                                                            "class" => "datalist_data_cell"));
340    
341          if (is_object($obj) && $obj->_tag == "td") {          if (is_object($obj) && $obj->_tag == "td") {
342                          return $obj;                          return $obj;
# Line 211  class DefaultGUIDatalist extends DataLis Line 361  class DefaultGUIDatalist extends DataLis
361                                 "align" => "left",                                 "align" => "left",
362                                 "class" => "font10");                                 "class" => "font10");
363    
364          $table = html_table($this->get_width(),0,0,0,"center");          $table = html_table($this->get_width(),0,0,0,$this->_align);
365    
366          //test to see if they want to render the outer borders          //test to see if they want to render the outer borders
367          $table->set_tag_attribute("style", "border-left: 1px solid #a1a1a1;".          $table->set_tag_attribute("style", "border-left: 1px solid #a1a1a1;".
# Line 236  class DefaultGUIDatalist extends DataLis Line 386  class DefaultGUIDatalist extends DataLis
386       */       */
387      function _build_search_title() {      function _build_search_title() {
388          //build the title stacked table          //build the title stacked table
389          $title = html_table($this->get_width(), 0, 0, 0, "center");          $title = html_table($this->get_width(), 0, 0, 0, $this->_align);
390    
391          //test to see if they want to render the outer borders          //test to see if they want to render the outer borders
392          $title->set_tag_attribute("style","border: 1px solid #a1a1a1;");          $title->set_tag_attribute("style","border: 1px solid #a1a1a1;");
# Line 272  class DefaultGUIDatalist extends DataLis Line 422  class DefaultGUIDatalist extends DataLis
422          } else {          } else {
423              //user has many fields to show.              //user has many fields to show.
424              $container->push("Find ",              $container->push("Find ",
425                               form_select($this->_search_fieldVar, $fields, $this->search_field()));                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
426          }          }
427    
428          if ($this->get_simple_search_modifier()) {          if ($this->get_simple_search_modifier()) {
# Line 280  class DefaultGUIDatalist extends DataLis Line 430  class DefaultGUIDatalist extends DataLis
430              $container->push($this->_build_simple_search_modifier());              $container->push($this->_build_simple_search_modifier());
431          }          }
432    
433          $container->push(form_text($this->_search_valueVar, $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),          $container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),
434                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
435    
436          if ($this->is_advanced_search_enabled()) {          if ($this->is_advanced_search_enabled()) {
# Line 289  class DefaultGUIDatalist extends DataLis Line 439  class DefaultGUIDatalist extends DataLis
439          }          }
440    
441          if ($cnt == 1) {          if ($cnt == 1) {
442              $container->push(form_hidden($this->_search_fieldVar, $field));              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
         }  
           
         $hidden_fields = $this->get_hidden_fields();  
         if(is_array($hidden_fields)) {  
           foreach($hidden_fields as $key => $value) {  
             $container->push(form_hidden($key, $value));  
           }  
443          }          }
           
         $container->push(form_close() );  
444    
445          return $container;          return $container;
446      }      }
447    
448    
449      function get_hidden_fields() {      /**
450          user_error("DefaulGUIDataList::get_hidden_fields() - ".       * This function adds an action column.  This
451                                     "child class must override this method ".       * adds a column of either checkboxes or radio
452                                     "this function should return a hash for hidden fields, if not needed just return" );       * buttons.
453      }       *
454         * @param string - type of column
455             *                 'checkbox' or 'radio'
456      function _decode_column_item_array($obj) {       * @param string - which column it lives in
457          user_error("DefaulGUIDataList::_decode_column_item_array() - ".       *                 'FIRST' or 'LAST'
458                                     "child class must override this method ".       * @param string - which db field is associated
459                                     "this function should decode the column_item if it is a (sub-) array,".       *                 with this.
460                                      "array should e.g. replaced by a select form." );       * @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      function _decode_column_item_expr($obj) {       *                       that can be used to select/deslect
464          user_error("DefaulGUIDataList::_decode_column_item_expr() - ".       *                       all at once.
465                                     "child class must override this method ".       *
466                                     "this function should decode the column_item, if it is encoded for e.g. objects" );       */
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            }
784            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            }
814    
815            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        }
873    
874        /**
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    
900            $script->push($js);
901            return $script;
902      }      }
903    
904    
905  }  }
906    
907  /**  /**
# Line 355  class DefaultGUIDataListCSS extends CSSB Line 933  class DefaultGUIDataListCSS extends CSSB
933    
934                  $this->add_entry(".datalist_col_head", "a.form_link:active,a.form_link:visited,a.form_link:link",                  $this->add_entry(".datalist_col_head", "a.form_link:active,a.form_link:visited,a.form_link:link",
935                                                   array("color" => "#000000",                                                   array("color" => "#000000",
936                                   "font-family" => "arial, helvetica, sans-serif",
937                                   "font-size" => "10pt",
938                                   "font-weight" => "bold",
939                                                             "text-decoration" => "none"));                                                             "text-decoration" => "none"));
940    
941                  $this->add_entry(".datalist_col_head_hover", "",                  $this->add_entry(".datalist_col_head_hover", "",
# Line 401  class DefaultGUIDataListCSS extends CSSB Line 982  class DefaultGUIDataListCSS extends CSSB
982                                                                  "color" => "#FFFFFF",                                                                  "color" => "#FFFFFF",
983                                                                  "background-color" => "#999999",                                                                  "background-color" => "#999999",
984                                                                  "white-space" =>"nowrap"));                                                                  "white-space" =>"nowrap"));
985    
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          }                }      
1022  }  }
1023  ?>  ?>

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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