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

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

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