/[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.9 by jonen, Thu Apr 3 23:56:17 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         * This function sets a prefix for all
89         * variables that are used in the item list
90         * table on a page.  This allows you to have
91         * multiple itemlists on a single html page.
92         *
93         * @param string $prefix - the prefix for all vars.
94         */
95        function set_global_prefix($prefix) {
96            $this->_vars["radioVar"] = "radio";
97            $this->_vars["checkboxVar"] = "checkbox";
98            DataList::set_global_prefix($prefix);
99        }
100    
101    
102          function gui_init() {          function gui_init() {
103                  $container = container();                  $container = container();
104                  $container->add( $this->build_tool_link("first"),                  $container->add( $this->build_tool_link("first"),
# Line 33  class DefaultGUIDatalist extends DataLis Line 108  class DefaultGUIDatalist extends DataLis
108                                                   $this->build_tool_link("all"),                                                   $this->build_tool_link("all"),
109                                                   $this->get_page_info() );                                                   $this->get_page_info() );
110    
111                  $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);
112                  $this->_data_table->set_class("datalist_border");                  $this->_data_table->set_class("datalist_border");
113    
114                  $this->_tool_td = html_td("datalist_title", "right", $container);                  $this->_tool_td = html_td("datalist_title", "right", $container);
115          $this->_tool_td->set_style("padding-top: 5px; padding-right: 5px;");          $this->_tool_td->set_style("padding-top: 5px; padding-right: 5px;");
116                  $this->_tool_td->set_tag_attribute("colspan", count($this->_columns)-1);  
117            //calculate the # of columns depending on if they
118            //have added action columns.
119            $cols = count($this->_columns);
120            if ($this->_has_action_column("FIRST")) $cols++;
121            if ($this->_has_action_column("LAST")) $cols++;
122    
123                    //$this->_tool_td->set_tag_attribute("colspan", $cols-1);
124    
125            $title_table = html_table("100%");
126    
127                  $title = new TDtag(array("align" => "left",                  $title = new TDtag(array("align" => "left",
128                                                                   "class" => "datalist_title",                                                                   "class" => "datalist_title",
129                                                                   "style" => "padding-left: 5px;"),                                                                   "style" => "padding-left: 5px;"),
130                                                     $this->get_title() );                                                     $this->get_title() );
131    
132            $title_table->add( new TRtag( array(), $title,
133                                          $this->_tool_td) );
134    
135    
136                  //add the header tr reference                  //add the header tr reference
137                  //it will get populated later                  //it will get populated later
138                  $this->_header_tr = new TRtag;                  $this->_header_tr = new TRtag;
139                  $this->_data_table->add( new TRtag(array(), $title, $this->_tool_td) );                  //$this->_data_table->add( new TRtag(array(), $title, $this->_tool_td) );
140            $this->_data_table->add_row( new TDtag(array("colspan" => $cols),
141                                               $title_table) );
142                  $this->_data_table->add_reference($this->_header_tr);                  $this->_data_table->add_reference($this->_header_tr);
143    
144                  //initialize the first date row                  //initialize the first date row
# Line 60  class DefaultGUIDatalist extends DataLis Line 150  class DefaultGUIDatalist extends DataLis
150    
151          }          }
152    
153        /**
154         * this function is used to set the overall alignment
155         * of the widget
156         *
157         * @param string - the align value
158         */
159        function set_align($align) {
160            $this->_align = $align;
161        }
162    
163          function child_build_column_header($name, $col, $cnt) {          function child_build_column_header($name, $col, $cnt) {
164                  $td = $this->build_column_header($name, $col, $cnt);          if (!$this->_cur_col_cntr) {
165                  $this->_header_tr->add( $td );              $this->_cur_col_cntr = 1;
166                //lets see if we need to add an action column
167                //as the first column.
168                if ($this->_has_action_column("FIRST")) {
169                    //looks like we have a FIRST column actionbar
170                    //lets add it
171                    $td = $this->_build_action_column("FIRST", TRUE);
172                    $this->_header_tr->add( $td );
173                }
174                $td = $this->build_column_header($name, $col, $cnt);
175                $this->_header_tr->add( $td );
176            } else {
177                $td = $this->build_column_header($name, $col, $cnt);
178                $this->_header_tr->add( $td );
179            }
180    
181            if ($this->_cur_col_cntr == $cnt) {
182                //lets see if we need to add an action column
183                //as the first column.
184                if ($this->_has_action_column("LAST")) {
185                    //looks like we have a FIRST column actionbar
186                    //lets add it
187                    $td = $this->_build_action_column("LAST", TRUE);
188                    $this->_header_tr->add( $td );
189                }
190                unset( $this->_cur_col_cntr );
191            } else {
192                $this->_cur_col_cntr++;
193            }        
194          }          }
195    
196          function child_add_row_cell($obj, $col_name, $last_in_row_flag) {          function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) {
197                  $td = $this->wrap_column_item($obj, $col_name);          if (!$this->_cur_col_cntr) {
198                $this->_cur_col_cntr = 1;
199                //lets see if we need to add an action column
200                //as the first column.
201                if ($this->_has_action_column("FIRST")) {
202                    //looks like we have a FIRST column actionbar
203                    //lets add it
204                    $this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data));
205                }
206                $td = $this->wrap_column_item($obj, $col_name);
207                $this->_data_row->add( $td );
208            } else {
209                //show the normal data
210                $td = $this->wrap_column_item($obj, $col_name);
211                $this->_data_row->add( $td );
212            }
213    
214                  $this->_data_row->add( $td );                  
215                  if ($last_in_row_flag) {                  if ($last_in_row_flag) {
216                //lets see if we need to add an action column
217                //as the first column.
218                if ($this->_has_action_column("LAST")) {
219                    //looks like we have a LAST column actionbar
220                    //lets add it
221                    $this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data));
222                }
223    
224    
225    
226                          $this->_data_table->add_row( $this->_data_row );                          $this->_data_table->add_row( $this->_data_row );
227                          $this->_data_row = new TRtag;                          $this->_data_row = new TRtag;
228                  }              unset( $this->_cur_col_cntr );
229                    } else {
230                $this->_cur_col_cntr++;
231            }
232          }          }
233    
234          function child_get_gui() {          function child_get_gui() {
235                  return $this->_data_table;          return container( $this->_data_table,
236                              $this->_build_actionbar() );
237          }          }
238    
239      /**      /**
# Line 162  class DefaultGUIDatalist extends DataLis Line 319  class DefaultGUIDatalist extends DataLis
319          //make sure its set to something.          //make sure its set to something.
320          if ($obj == '') {          if ($obj == '') {
321              $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);  
322          }          }
323            
   
324          //make sure we don't put a right border on the last          //make sure we don't put a right border on the last
325          //column we are working on.          //column we are working on.
326          $style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";          //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
327            
328    
329                  if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {                  if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
330              $style .= "background-color: #f4f4f4;";              $style = "background-color: #f4f4f4;";
331          } else {          } else {
332                          $style .= "background-color: #ffffff;";                          $style = "background-color: #ffffff;";
333                  }                  }
334    
335          $align = $this->_columns[$col_name]["align"];          $align = $this->_columns[$col_name]["align"];
336          $td = new TDtag(array("align" => $align,          $td = new TDtag(array("align" => $align,
337                                "style" => $style,                                "style" => $style,
338                                                            "class" => "font10"));                                                            "class" => "datalist_data_cell"));
339    
340          if (is_object($obj) && $obj->_tag == "td") {          if (is_object($obj) && $obj->_tag == "td") {
341                          return $obj;                          return $obj;
# Line 211  class DefaultGUIDatalist extends DataLis Line 360  class DefaultGUIDatalist extends DataLis
360                                 "align" => "left",                                 "align" => "left",
361                                 "class" => "font10");                                 "class" => "font10");
362    
363          $table = html_table($this->get_width(),0,0,0,"center");          $table = html_table($this->get_width(),0,0,0,$this->_align);
364    
365          //test to see if they want to render the outer borders          //test to see if they want to render the outer borders
366          $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 385  class DefaultGUIDatalist extends DataLis
385       */       */
386      function _build_search_title() {      function _build_search_title() {
387          //build the title stacked table          //build the title stacked table
388          $title = html_table($this->get_width(), 0, 0, 0, "center");          $title = html_table($this->get_width(), 0, 0, 0, $this->_align);
389    
390          //test to see if they want to render the outer borders          //test to see if they want to render the outer borders
391          $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 421  class DefaultGUIDatalist extends DataLis
421          } else {          } else {
422              //user has many fields to show.              //user has many fields to show.
423              $container->push("Find ",              $container->push("Find ",
424                               form_select($this->_search_fieldVar, $fields, $this->search_field()));                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
425          }          }
426    
427          if ($this->get_simple_search_modifier()) {          if ($this->get_simple_search_modifier()) {
# Line 280  class DefaultGUIDatalist extends DataLis Line 429  class DefaultGUIDatalist extends DataLis
429              $container->push($this->_build_simple_search_modifier());              $container->push($this->_build_simple_search_modifier());
430          }          }
431    
432          $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;")),
433                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
434    
435          if ($this->is_advanced_search_enabled()) {          if ($this->is_advanced_search_enabled()) {
# Line 289  class DefaultGUIDatalist extends DataLis Line 438  class DefaultGUIDatalist extends DataLis
438          }          }
439    
440          if ($cnt == 1) {          if ($cnt == 1) {
441              $container->push(form_hidden($this->_search_fieldVar, $field));              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
442          }          }
443            
444          $hidden_fields = $this->get_hidden_fields();          if(is_array($this->hidden_items)) {  
445          if(is_array($hidden_fields)) {            foreach($this->hidden_items as $key => $value) {  
446            foreach($hidden_fields as $key => $value) {              $container->push(form_hidden($key, $value));  
             $container->push(form_hidden($key, $value));  
447            }            }
448          }          }
           
449          $container->push(form_close() );          $container->push(form_close() );
   
450          return $container;          return $container;
451      }      }
452    
453    
454      function get_hidden_fields() {      /**
455          user_error("DefaulGUIDataList::get_hidden_fields() - ".       * This function adds an action column.  This
456                                     "child class must override this method ".       * adds a column of either checkboxes or radio
457                                     "this function should return a hash for hidden fields, if not needed just return" );       * buttons.
458         *
459         * @param string - type of column
460         *                 'checkbox' or 'radio'
461         * @param string - which column it lives in
462         *                 'FIRST' or 'LAST'
463         * @param string - which db field is associated
464         *                 with this.
465         * @param string - the title to use for the column.
466         *                 NOTE: if this is set, then there
467         *                       will NOT be a global checkbox
468         *                       that can be used to select/deslect
469         *                       all at once.
470         *
471         */
472        function add_action_column($type, $col, $db_field, $title=NULL) {
473            $action = array("type" => $type,
474                            "dbfield" => $db_field,
475                            "title" => $title);
476            $this->_action_column[$col] = $action;
477        }
478    
479        /**
480         * This function is used to set the default list
481         * of selected checkbox items.  This is used so
482         * the user can pre-populate the list of
483         * checked items in the checkbox action column
484         *
485         * @param array - the array of checked items
486         */
487        function set_default_checked_items($items) {
488            $this->_default_checked_items = $items;
489        }
490    
491        /**
492         * This function returns the array of default
493         * checked items to be marked as checked in
494         * the checkbox action column
495         *
496         * @return array
497         */
498        function get_default_checked_items() {
499            return $this->_default_checked_items;
500      }      }
501    
502            /**
503      function _decode_column_item_array($obj) {       * set the flag to tell the object to
504          user_error("DefaulGUIDataList::_decode_column_item_array() - ".       * save the checked items
505                                     "child class must override this method ".       *
506                                     "this function should decode the column_item if it is a (sub-) array,".       */
507                                      "array should e.g. replaced by a select form." );      function save_checked_items() {
508            $this->_save_checked_items_flag = TRUE;
509        }
510    
511        /**
512         * This tests the object flag to
513         * see if the child class wants to
514         * automatically save the checked
515         * items
516         *
517         * @return boolean
518         */
519        function _save_checked_items_enabled() {
520            return $this->_save_checked_items_flag;
521        }
522    
523        /**
524         * This function tests to see if the child
525         * wants to render an action column
526         *
527         * @param string - the column to test for
528         *                 FIRST or LAST
529         * @return boolean
530         */
531        function _has_action_column($col) {
532            if (isset($this->_action_column[$col])) {
533                return TRUE;
534            }
535            else {
536                return FALSE;
537            }
538        }
539    
540        /**
541         * This allows the caller to
542         * turn on/off the rendering of
543         * the bottom action bar row
544         *
545         * @param boolean - TRUE = on FALSE = off
546         */
547        function set_actionbar($flag = TRUE) {
548            $this->_show_actionbar = $flag;
549        }
550    
551        /**
552         * This function gets the current value
553         * of the show actionbar flag setting.
554         *
555         * @return boolean
556         */
557        function show_actionbar() {
558            return $this->_show_actionbar;
559        }
560    
561        /**
562        * Sets the flag for rendering the select all checkbox
563        *
564        * @param bool flag
565        */
566        function allow_select_all($flag) {
567            $this->_allow_select_all = $flag;
568        }
569    
570    
571        /**
572         * This builds an action column cell
573         *
574         * @param string - the column to test for
575         *                 FIRST or LAST
576         * @param boolean - lets us know this is for
577         *                  the header or a cell.
578         * @param array   - the row's data.
579         * @return HTMLTag object
580         */
581        function _build_action_column($col, $header_flag=FALSE, $row_data=NULL) {
582    
583            $attributes = array("width" => "1%",
584                                "align" => "center");
585    
586            if ($header_flag) $attributes["class"] = "datalist_col_head";
587            else $attributes["class"] = "datalist_actionbar_data_cell";
588    
589            $td = new TDtag($attributes);
590            $form_value = '';
591            if ($header_flag) {
592                //this is for a header item.
593                $form_value = "";
594            } else {
595                $form_value = $row_data[$this->_action_column[$col]["dbfield"]];
596            }
597    
598            switch ($this->_action_column[$col]["type"]) {
599            case "radio":
600                if ($header_flag) {
601                    //we don't put a header button for radio
602                    if ($this->_action_column[$col]["title"])
603                        $obj = $this->_action_column[$col]["title"];
604                    else $obj = _HTML_SPACE;
605                } else {
606                    $name = $this->_vars["radioVar"]."[".$this->_action_count."]";
607                    $obj = form_radio($name, $form_value);
608    
609                    //see if the checkbox should be disabled
610                    if (!$this->is_action_enabled($form_value, $row_data)) {
611                        $obj->set_tag_attribute("DISABLED");
612                        $obj->set_tag_attribute("value","");
613                    }
614                }
615    
616                break;
617            case "checkbox":
618                if ($header_flag) {
619                    //see if the child wants a title instead
620                    //of the global check/uncheck checkbox
621                    if ($this->_action_column[$col]["title"]) {
622                        $obj = $this->_action_column[$col]["title"];
623                        break;
624                    } else {
625                        $name = $this->_vars["checkboxVar"];
626                    }
627                } else {
628                    $name = $this->_vars["checkboxVar"]."[".$this->_action_count."]";
629                }
630    
631                $this->_action_count++;
632                $obj = form_checkbox($name, $form_value);
633                if ($header_flag) {
634                    if ($this->_allow_select_all) {
635                        $obj->set_tag_attribute("onClick", "javascript:mass(this.form)");
636                    } else {
637                        $obj = _HTML_SPACE;
638                    }
639                }
640    
641                //see if the checkbox should be checked
642                if ($this->_is_col_checked($form_value, $row_data)) {
643                    $obj->set_tag_attribute("CHECKED");
644                }
645    
646                //see if the checkbox should be disabled
647                if (!$header_flag && !$this->is_action_enabled($form_value, $row_data)) {
648                    $obj->set_tag_attribute("DISABLED");
649                    $obj->set_tag_attribute("value","");
650                }
651    
652                //save which items we have rendered visibly.
653                //so we can filter those out in the hidden
654                //items
655                $this->_visible_checkbox_items[$form_value] = TRUE;;
656                break;
657            }
658            $td->push($obj);
659            $td->set_collapse();
660            return $td;
661        }
662    
663        /**
664         * This method checks to see if a
665         * particular row has been checked
666         * in the action column
667         *
668         * @param string - the item to look for
669         * @param array   - the row's data.
670         * @return boolean.
671         */
672        function _is_col_checked($value, $row_data) {
673            if (count($this->_hidden_checkbox_items) == 0) {
674                if (isset($_REQUEST[$this->_vars["checkboxVar"]]) && is_array($_REQUEST[$this->_vars["checkboxVar"]])) {
675                    $this->_hidden_checkbox_items = array_flip($_REQUEST[$this->_vars["checkboxVar"]]);
676                }
677            }
678    
679            //call the child function to see if item should
680            //be checked
681            $user_flag = $this->is_action_checked($value, $row_data);
682            $hidden_flag = isset($this->_hidden_checkbox_items[$value]);
683    
684            return($user_flag || $hidden_flag);
685    
686            if (isset($this->_hidden_checkbox_items[$value])) {
687                return TRUE;
688            }
689            else {
690                return FALSE;
691            }
692        }
693    
694        /**
695         * This function is provided to give the child class
696         * the ability to precheck/select a particular
697         * column.
698         *
699         * @param string - the item to look for.
700         * @param array   - the row's data.
701         * @return boolean
702         */
703        function is_action_checked($value, $row_data) {
704            return FALSE;
705        }
706    
707        /**
708         * This function is provided to give the child
709         * class the ability to enable/disable a particular
710         * checkbox.
711         *
712         * @param string - the item to look for.
713         * @param array   - the row's data.
714         * @return boolean
715         */
716        function is_action_enabled($value, $row_data) {
717            return TRUE;
718        }
719    
720        /**
721         * This function renders the action bar at the bottom
722         * of the data list.
723         *
724         * @return TABLEtag object
725         */
726        function _build_actionbar() {
727    
728            if ($this->show_actionbar()) {
729    
730                $table = html_table($this->get_width(),0,0,0,$this->_align);
731                $table->set_class("datalist_actionbar");
732                /*if ($this->show_outer_border()) {
733                    $table->set_tag_attribute("style", _CSS_BORDER_LEFT.
734                                              _CSS_BORDER_RIGHT.
735                                              _CSS_BORDER_BOTTOM);
736                }
737                else {
738                    $table->set_tag_attribute("style", _CSS_BORDER_TOP);
739                }*/
740    
741                            $td = new TDtag(array("class"=>"datalist_bottom_seperator",
742                                                                      "colspan" => 3),
743                                                            _HTML_SPACE);
744                            $table->add_row( $td );
745    
746                $table->add_row($this->_build_actionbar_arrow_cell("FIRST"),
747                                $this->_build_actionbar_data_cell(),
748                                $this->_build_actionbar_arrow_cell("LAST") );
749    
750                return $table;
751            }
752            else return NULL;
753        }
754    
755        /**
756         * This function builds a TD with the
757         * appropriate action arrow.
758         *
759         * @param string - FIRST or LAST
760         * @return TDtag
761         */
762        function _build_actionbar_arrow_cell($col) {
763            $td = new TDtag(array("class" => "datalist_title",
764                                  "style" => "padding-left:14px;padding-right:14px;".
765                                  "padding-top:5px;",
766                                  "width" => "5%")
767                           );
768    
769            if ($col == "FIRST") {
770                $td->set_tag_attribute("align", "left");
771                if ($this->_has_action_column("FIRST") &&
772                    $this->_datasource->get_total_rows()) {
773                    $td->push(html_img("img/widgets/arrow_right.gif"));
774                }
775                else {
776                    $td->push("&nbsp;");
777                }
778            }
779            else {
780                $td->set_tag_attribute("align", "right");
781                if ($this->_has_action_column("LAST") &&
782                    $this->_datasource->get_total_rows()) {
783                    $td->push(html_img("img/widgets/arrow_left.gif"));
784                }
785                else {
786                    $td->push("&nbsp;");
787                }
788            }
789            return $td;
790      }      }
791    
792      function _decode_column_item_expr($obj) {      /**
793          user_error("DefaulGUIDataList::_decode_column_item_expr() - ".       * This function builds the user's data cell
794                                     "child class must override this method ".       *
795                                     "this function should decode the column_item, if it is encoded for e.g. objects" );       * @return TDtag;
796         */
797        function _build_actionbar_data_cell() {
798            $td = new TDtag(array("class" => "datalist_title",
799                                  "style" => "padding-left:5px;padding-right:5px;".
800                                  "padding-top:5px;padding-bottom:5px")
801                           );
802    
803            $flag = FALSE;
804            if ($this->_has_action_column("FIRST")) {
805                $flag = TRUE;
806                $td->set_tag_attribute("align", "left");
807            }
808            else if ($this->_has_action_column("LAST")) {
809                $flag = TRUE;
810                $td->set_tag_attribute("align", "right");
811            }
812    
813            if ($flag && $this->_datasource->get_total_rows()) {
814                $td->push($this->actionbar_cell());
815            }
816            else {
817                $td->push("&nbsp;");
818            }
819    
820            return $td;
821      }      }
822    
823        /**
824         * this is the method that builds
825         * the contents for the middle actionbar
826         * td cell.
827         * NOTE this function is meant to be overriden
828         *      by the child class.
829         *
830         * @return ContainerWidget object
831         */
832        function actionbar_cell() {
833            return _HTML_SPACE;
834        }
835    
836        /**
837         * This function builds an action button that will
838         * modify the form action, to post to a different
839         * script to handle the data
840         *
841         * @param string - the button name
842         * @param string - the script that gets called.
843         * @return INPUTtag object
844         */
845        function action_button($name, $action) {
846    
847            $submit = form_button("_action", $name);
848    
849            // here we make sure that all standard buttons look the same
850            if (strlen($name)<10) $submit->set_tag_attribute("style","width: 80px;");
851    
852            $form_name = $this->get_form_name();
853    
854            $onclick  = "javascript: document.".$form_name.".action='".$action."';";
855            $onclick .= "document.".$form_name.".submit();";
856            $submit->set_tag_attribute("onclick", $onclick);
857            return $submit;
858        }
859    
860        /**
861         * This function returns any Javascript required
862         * for this widget
863         *
864         * @return mixed
865         */
866        function _javascript() {
867            if ($this->_has_action_column("FIRST") || $this->_has_action_column("LAST")) {
868                $last = $this->_action_column["LAST"]["type"];
869                $first = $this->_action_column["FIRST"]["type"];
870                if ($last == "checkbox" || $first == "checkbox") {
871                    return $this->_checkbox_javascript();
872                }
873            }
874            else {
875                return NULL;
876            }
877        }
878    
879        /**
880         * This function builds the JS needed for the checkbox
881         * action column
882         *
883         * @return SCRIPTtag
884         */
885        function _checkbox_javascript() {
886            $script = new SCRIPTtag(array("language" => "Javascript"));
887    
888            $var_name = $this->_vars["checkboxVar"];
889    
890            $js  = "function mass(form) {\n";
891            $js .= "  var i=0;\n";
892            $js .= "  var value=0;\n\n";
893            $js .= "  if (form.$var_name.checked) {\n";
894            $js .= "    value=1;\n";
895            $js .= "  } else {\n";
896            $js .= "    value=0;\n";
897            $js .= "  }\n\n";
898            $js .= "  for (i = 0; i < form.length; i++) {\n";
899            $js .= "    if (form.elements[i].name.substring(0, 8) == '$var_name' && !form.elements[i].disabled) {\n";
900            $js .= "      form.elements[i].checked = value;\n";
901            $js .= "    }\n";
902            $js .= "  }\n";
903            $js .= "}\n";
904    
905            $script->push($js);
906            return $script;
907        }
908    
909  }  }
910    
911  /**  /**
# Line 355  class DefaultGUIDataListCSS extends CSSB Line 937  class DefaultGUIDataListCSS extends CSSB
937    
938                  $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",
939                                                   array("color" => "#000000",                                                   array("color" => "#000000",
940                                   "font-family" => "arial, helvetica, sans-serif",
941                                   "font-size" => "10pt",
942                                   "font-weight" => "bold",
943                                                             "text-decoration" => "none"));                                                             "text-decoration" => "none"));
944    
945                  $this->add_entry(".datalist_col_head_hover", "",                  $this->add_entry(".datalist_col_head_hover", "",
# Line 401  class DefaultGUIDataListCSS extends CSSB Line 986  class DefaultGUIDataListCSS extends CSSB
986                                                                  "color" => "#FFFFFF",                                                                  "color" => "#FFFFFF",
987                                                                  "background-color" => "#999999",                                                                  "background-color" => "#999999",
988                                                                  "white-space" =>"nowrap"));                                                                  "white-space" =>"nowrap"));
989    
990            $this->add_entry( ".datalist_data_cell", "",
991                              array(
992                                  "font-family" => "arial",
993                                  "font-size" => "10pt",
994                                  "padding-left" => "3px",
995                                  "padding-right" => "3px",
996                                  "border-top" => "1px solid #dddddd"));
997    
998            $this->add_entry( ".datalist_actionbar", "",
999                              array(
1000                                  "border" => "1px solid #999999") );
1001    
1002            $this->add_entry( ".datalist_actionbar_data_cell", "",
1003                              array(
1004                                  "font-family" => "arial",
1005                                  "font-size" => "10pt",
1006                                  "background" => "#CCCCCC",
1007                                  "padding-left" => "3px",
1008                                  "padding-right" => "3px",
1009                                  "border-top" => "1px solid #dddddd"));
1010    
1011            $this->add_entry( ".datalist_bottom_seperator", "",
1012                              array(
1013                                  "font-size" => "5px",
1014                                  "line-height" =>  "5px",
1015                                  "background" => "#CCCCCC",
1016                                  "text-align" => "left",
1017                                  "white-space" => "nowrap",
1018                                  "height" => "5px",
1019                                  "border-left" => "1px solid #FFFFFF",
1020                                  "border-top" => "1px solid #FFFFFF",
1021                                  "border-right" => "1px solid #dddddd",
1022                                  "border-bottom" => "1px solid #dddddd",
1023                                  "padding-left" =>  "3px",
1024                                  "padding-right" => "3px"));
1025          }                }      
1026  }  }
1027  ?>  ?>

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

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