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

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

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