/[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.3 by jonen, Fri Feb 21 03:23:43 2003 UTC revision 1.10 by jonen, Tue Apr 8 23:33:48 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 163  class DefaultGUIDatalist extends DataLis Line 320  class DefaultGUIDatalist extends DataLis
320          if ($obj == '') {          if ($obj == '') {
321              $obj = "&nbsp;";              $obj = "&nbsp;";
322          }          }
323          // if item is an Array we will replace it with an link or contained form object  
         elseif( is_array($obj) ) {  
           $cur_row_index = $this->_datasource->get_cur_data_index();  
           $parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];  
           foreach($obj as $key => $value) {  
             if(is_numeric($key)) {  
                 $guid = $value['guid'];  
                 $list[$key] = $guid;  
             }  
                 }  
                 if(is_array($list) ) {  
               $container = container(  
                   form_open($obj[guid], $_SERVER["PHP_SELF"] ),  
                   form_select("guid", $list),  
                   form_hidden("ap", "oedit"),  
                   form_hidden("guid", $obj['guid']),  
                   form_hidden("class", $col_name),  
                   form_submit("submit","view" ),  
                   form_close()  
                   );  
               $obj = $container;  
             } else {  
                   $obj = html_a($_SERVER["PHP_SELF"] . "?ap=oedit&guid=" . $obj['guid'] . "&class=" . $col_name, "view");  
                 }  
         }  
           
   
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 228  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 253  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 289  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 297  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 306  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));
         }  
           
         $hidden_fields = $this->get_hidden_fields();  
         if(is_array($hidden_fields)) {  
           foreach($hidden_fields as $key => $value) {  
             $container->push(form_hidden($key, $value));  
           }  
442          }          }
           
         $container->push(form_close() );  
443    
444          return $container;          return $container;
445      }      }
446    
447    
448      function get_hidden_fields() {      /**
449          user_error("DefaulGUIDataList::get_hidden_fields() - ".       * This function adds an action column.  This
450                                     "child class must override this method ".       * adds a column of either checkboxes or radio
451                                     "this function should return a hash for hidden fields, if not needed just return" );       * 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                    $td->push(html_img("img/widgets/arrow_right.gif"));
768                }
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                    $td->push(html_img("img/widgets/arrow_left.gif"));
778                }
779                else {
780                    $td->push("&nbsp;");
781                }
782            }
783            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            }
813    
814            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        }
872    
873        /**
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    
899            $script->push($js);
900            return $script;
901      }      }
902    
903  }  }
# Line 359  class DefaultGUIDataListCSS extends CSSB Line 931  class DefaultGUIDataListCSS extends CSSB
931    
932                  $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",
933                                                   array("color" => "#000000",                                                   array("color" => "#000000",
934                                   "font-family" => "arial, helvetica, sans-serif",
935                                   "font-size" => "10pt",
936                                   "font-weight" => "bold",
937                                                             "text-decoration" => "none"));                                                             "text-decoration" => "none"));
938    
939                  $this->add_entry(".datalist_col_head_hover", "",                  $this->add_entry(".datalist_col_head_hover", "",
# Line 405  class DefaultGUIDataListCSS extends CSSB Line 980  class DefaultGUIDataListCSS extends CSSB
980                                                                  "color" => "#FFFFFF",                                                                  "color" => "#FFFFFF",
981                                                                  "background-color" => "#999999",                                                                  "background-color" => "#999999",
982                                                                  "white-space" =>"nowrap"));                                                                  "white-space" =>"nowrap"));
983    
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          }                }      
1020  }  }
1021  ?>  ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.10

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