/[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.7 by jonen, Wed Feb 26 21:41:26 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 159  class DefaultGUIDatalist extends DataLis Line 317  class DefaultGUIDatalist extends DataLis
317       */       */
318      function wrap_column_item($obj, $col_name) {      function wrap_column_item($obj, $col_name) {
319    
320            $databrowser = new DataBrowser();
321    
322          //make sure its set to something.          //make sure its set to something.
323          if ($obj == '') {          if ($obj == '') {
324              $obj = "&nbsp;";              $obj = "&nbsp;";
         }          
         // if item is match by expression we will replace it with an link object  
         elseif($this->_decode_column_item_expr($obj)) {  
           $obj = $this->_decode_column_item_expr($obj);  
         }  
         // if item is an Array we will replace it with an selection form object  
         elseif($this->_decode_column_item_array($obj)) {  
           $obj = $this->_decode_column_item_array($obj);  
325          }          }
326                    // if item is match by expression we will replace it with an link object  
327            elseif($databrowser->decode_column_item_expr($obj)) {  
328              $obj = $databrowser->decode_column_item_expr($obj);  
329            }  
330            // if item is an Array we will replace it with an selection form object  
331            elseif($databrowser->decode_column_item_array($obj, array( 'form' => 1)) ) {
332              $obj = $databrowser->decode_column_item_array($obj, array( 'form' => 1));  
333            }  
334    
335          //make sure we don't put a right border on the last          //make sure we don't put a right border on the last
336          //column we are working on.          //column we are working on.
337          $style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";          //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
338            
339    
340                  if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {                  if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
341              $style .= "background-color: #f4f4f4;";              $style = "background-color: #f4f4f4;";
342          } else {          } else {
343                          $style .= "background-color: #ffffff;";                          $style = "background-color: #ffffff;";
344                  }                  }
345    
346          $align = $this->_columns[$col_name]["align"];          $align = $this->_columns[$col_name]["align"];
347          $td = new TDtag(array("align" => $align,          $td = new TDtag(array("align" => $align,
348                                "style" => $style,                                "style" => $style,
349                                                            "class" => "font10"));                                                            "class" => "datalist_data_cell"));
350    
351          if (is_object($obj) && $obj->_tag == "td") {          if (is_object($obj) && $obj->_tag == "td") {
352                          return $obj;                          return $obj;
# Line 211  class DefaultGUIDatalist extends DataLis Line 371  class DefaultGUIDatalist extends DataLis
371                                 "align" => "left",                                 "align" => "left",
372                                 "class" => "font10");                                 "class" => "font10");
373    
374          $table = html_table($this->get_width(),0,0,0,"center");          $table = html_table($this->get_width(),0,0,0,$this->_align);
375    
376          //test to see if they want to render the outer borders          //test to see if they want to render the outer borders
377          $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 396  class DefaultGUIDatalist extends DataLis
396       */       */
397      function _build_search_title() {      function _build_search_title() {
398          //build the title stacked table          //build the title stacked table
399          $title = html_table($this->get_width(), 0, 0, 0, "center");          $title = html_table($this->get_width(), 0, 0, 0, $this->_align);
400    
401          //test to see if they want to render the outer borders          //test to see if they want to render the outer borders
402          $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 432  class DefaultGUIDatalist extends DataLis
432          } else {          } else {
433              //user has many fields to show.              //user has many fields to show.
434              $container->push("Find ",              $container->push("Find ",
435                               form_select($this->_search_fieldVar, $fields, $this->search_field()));                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
436          }          }
437    
438          if ($this->get_simple_search_modifier()) {          if ($this->get_simple_search_modifier()) {
# Line 280  class DefaultGUIDatalist extends DataLis Line 440  class DefaultGUIDatalist extends DataLis
440              $container->push($this->_build_simple_search_modifier());              $container->push($this->_build_simple_search_modifier());
441          }          }
442    
443          $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;")),
444                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
445    
446          if ($this->is_advanced_search_enabled()) {          if ($this->is_advanced_search_enabled()) {
# Line 289  class DefaultGUIDatalist extends DataLis Line 449  class DefaultGUIDatalist extends DataLis
449          }          }
450    
451          if ($cnt == 1) {          if ($cnt == 1) {
452              $container->push(form_hidden($this->_search_fieldVar, $field));              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
453          }          }
454            
455          $hidden_fields = $this->get_hidden_fields();          $hidden_fields = $this->get_hidden_fields();
456          if(is_array($hidden_fields)) {          if(is_array($hidden_fields)) {  
457            foreach($hidden_fields as $key => $value) {            foreach($hidden_fields as $key => $value) {  
458              $container->push(form_hidden($key, $value));              $container->push(form_hidden($key, $value));  
459            }            }
460          }          }
           
461          $container->push(form_close() );          $container->push(form_close() );
   
462          return $container;          return $container;
463      }      }
464    
465    
466      function get_hidden_fields() {      /**
467          user_error("DefaulGUIDataList::get_hidden_fields() - ".       * This function adds an action column.  This
468                                     "child class must override this method ".       * adds a column of either checkboxes or radio
469                                     "this function should return a hash for hidden fields, if not needed just return" );       * buttons.
470         *
471         * @param string - type of column
472         *                 'checkbox' or 'radio'
473         * @param string - which column it lives in
474         *                 'FIRST' or 'LAST'
475         * @param string - which db field is associated
476         *                 with this.
477         * @param string - the title to use for the column.
478         *                 NOTE: if this is set, then there
479         *                       will NOT be a global checkbox
480         *                       that can be used to select/deslect
481         *                       all at once.
482         *
483         */
484        function add_action_column($type, $col, $db_field, $title=NULL) {
485            $action = array("type" => $type,
486                            "dbfield" => $db_field,
487                            "title" => $title);
488            $this->_action_column[$col] = $action;
489      }      }
490    
491            /**
492      function _decode_column_item_array($obj) {       * This function is used to set the default list
493          user_error("DefaulGUIDataList::_decode_column_item_array() - ".       * of selected checkbox items.  This is used so
494                                     "child class must override this method ".       * the user can pre-populate the list of
495                                     "this function should decode the column_item if it is a (sub-) array,".       * checked items in the checkbox action column
496                                      "array should e.g. replaced by a select form." );       *
497         * @param array - the array of checked items
498         */
499        function set_default_checked_items($items) {
500            $this->_default_checked_items = $items;
501        }
502    
503        /**
504         * This function returns the array of default
505         * checked items to be marked as checked in
506         * the checkbox action column
507         *
508         * @return array
509         */
510        function get_default_checked_items() {
511            return $this->_default_checked_items;
512        }
513    
514        /**
515         * set the flag to tell the object to
516         * save the checked items
517         *
518         */
519        function save_checked_items() {
520            $this->_save_checked_items_flag = TRUE;
521        }
522    
523        /**
524         * This tests the object flag to
525         * see if the child class wants to
526         * automatically save the checked
527         * items
528         *
529         * @return boolean
530         */
531        function _save_checked_items_enabled() {
532            return $this->_save_checked_items_flag;
533        }
534    
535        /**
536         * This function tests to see if the child
537         * wants to render an action column
538         *
539         * @param string - the column to test for
540         *                 FIRST or LAST
541         * @return boolean
542         */
543        function _has_action_column($col) {
544            if (isset($this->_action_column[$col])) {
545                return TRUE;
546            }
547            else {
548                return FALSE;
549            }
550        }
551    
552        /**
553         * This allows the caller to
554         * turn on/off the rendering of
555         * the bottom action bar row
556         *
557         * @param boolean - TRUE = on FALSE = off
558         */
559        function set_actionbar($flag = TRUE) {
560            $this->_show_actionbar = $flag;
561        }
562    
563        /**
564         * This function gets the current value
565         * of the show actionbar flag setting.
566         *
567         * @return boolean
568         */
569        function show_actionbar() {
570            return $this->_show_actionbar;
571        }
572    
573        /**
574        * Sets the flag for rendering the select all checkbox
575        *
576        * @param bool flag
577        */
578        function allow_select_all($flag) {
579            $this->_allow_select_all = $flag;
580        }
581    
582    
583        /**
584         * This builds an action column cell
585         *
586         * @param string - the column to test for
587         *                 FIRST or LAST
588         * @param boolean - lets us know this is for
589         *                  the header or a cell.
590         * @param array   - the row's data.
591         * @return HTMLTag object
592         */
593        function _build_action_column($col, $header_flag=FALSE, $row_data=NULL) {
594    
595            $attributes = array("width" => "1%",
596                                "align" => "center");
597    
598            if ($header_flag) $attributes["class"] = "datalist_col_head";
599            else $attributes["class"] = "datalist_actionbar_data_cell";
600    
601            $td = new TDtag($attributes);
602            $form_value = '';
603            if ($header_flag) {
604                //this is for a header item.
605                $form_value = "";
606            } else {
607                $form_value = $row_data[$this->_action_column[$col]["dbfield"]];
608            }
609    
610            switch ($this->_action_column[$col]["type"]) {
611            case "radio":
612                if ($header_flag) {
613                    //we don't put a header button for radio
614                    if ($this->_action_column[$col]["title"])
615                        $obj = $this->_action_column[$col]["title"];
616                    else $obj = _HTML_SPACE;
617                } else {
618                    $name = $this->_vars["radioVar"]."[".$this->_action_count."]";
619                    $obj = form_radio($name, $form_value);
620    
621                    //see if the checkbox should be disabled
622                    if (!$this->is_action_enabled($form_value, $row_data)) {
623                        $obj->set_tag_attribute("DISABLED");
624                        $obj->set_tag_attribute("value","");
625                    }
626                }
627    
628                break;
629            case "checkbox":
630                if ($header_flag) {
631                    //see if the child wants a title instead
632                    //of the global check/uncheck checkbox
633                    if ($this->_action_column[$col]["title"]) {
634                        $obj = $this->_action_column[$col]["title"];
635                        break;
636                    } else {
637                        $name = $this->_vars["checkboxVar"];
638                    }
639                } else {
640                    $name = $this->_vars["checkboxVar"]."[".$this->_action_count."]";
641                }
642    
643                $this->_action_count++;
644                $obj = form_checkbox($name, $form_value);
645                if ($header_flag) {
646                    if ($this->_allow_select_all) {
647                        $obj->set_tag_attribute("onClick", "javascript:mass(this.form)");
648                    } else {
649                        $obj = _HTML_SPACE;
650                    }
651                }
652    
653                //see if the checkbox should be checked
654                if ($this->_is_col_checked($form_value, $row_data)) {
655                    $obj->set_tag_attribute("CHECKED");
656                }
657    
658                //see if the checkbox should be disabled
659                if (!$header_flag && !$this->is_action_enabled($form_value, $row_data)) {
660                    $obj->set_tag_attribute("DISABLED");
661                    $obj->set_tag_attribute("value","");
662                }
663    
664                //save which items we have rendered visibly.
665                //so we can filter those out in the hidden
666                //items
667                $this->_visible_checkbox_items[$form_value] = TRUE;;
668                break;
669            }
670            $td->push($obj);
671            $td->set_collapse();
672            return $td;
673        }
674    
675        /**
676         * This method checks to see if a
677         * particular row has been checked
678         * in the action column
679         *
680         * @param string - the item to look for
681         * @param array   - the row's data.
682         * @return boolean.
683         */
684        function _is_col_checked($value, $row_data) {
685            if (count($this->_hidden_checkbox_items) == 0) {
686                if (isset($_REQUEST[$this->_vars["checkboxVar"]]) && is_array($_REQUEST[$this->_vars["checkboxVar"]])) {
687                    $this->_hidden_checkbox_items = array_flip($_REQUEST[$this->_vars["checkboxVar"]]);
688                }
689            }
690    
691            //call the child function to see if item should
692            //be checked
693            $user_flag = $this->is_action_checked($value, $row_data);
694            $hidden_flag = isset($this->_hidden_checkbox_items[$value]);
695    
696            return($user_flag || $hidden_flag);
697    
698            if (isset($this->_hidden_checkbox_items[$value])) {
699                return TRUE;
700            }
701            else {
702                return FALSE;
703            }
704        }
705    
706        /**
707         * This function is provided to give the child class
708         * the ability to precheck/select a particular
709         * column.
710         *
711         * @param string - the item to look for.
712         * @param array   - the row's data.
713         * @return boolean
714         */
715        function is_action_checked($value, $row_data) {
716            return FALSE;
717        }
718    
719        /**
720         * This function is provided to give the child
721         * class the ability to enable/disable a particular
722         * checkbox.
723         *
724         * @param string - the item to look for.
725         * @param array   - the row's data.
726         * @return boolean
727         */
728        function is_action_enabled($value, $row_data) {
729            return TRUE;
730        }
731    
732        /**
733         * This function renders the action bar at the bottom
734         * of the data list.
735         *
736         * @return TABLEtag object
737         */
738        function _build_actionbar() {
739    
740            if ($this->show_actionbar()) {
741    
742                $table = html_table($this->get_width(),0,0,0,$this->_align);
743                $table->set_class("datalist_actionbar");
744                /*if ($this->show_outer_border()) {
745                    $table->set_tag_attribute("style", _CSS_BORDER_LEFT.
746                                              _CSS_BORDER_RIGHT.
747                                              _CSS_BORDER_BOTTOM);
748                }
749                else {
750                    $table->set_tag_attribute("style", _CSS_BORDER_TOP);
751                }*/
752    
753                            $td = new TDtag(array("class"=>"datalist_bottom_seperator",
754                                                                      "colspan" => 3),
755                                                            _HTML_SPACE);
756                            $table->add_row( $td );
757    
758                $table->add_row($this->_build_actionbar_arrow_cell("FIRST"),
759                                $this->_build_actionbar_data_cell(),
760                                $this->_build_actionbar_arrow_cell("LAST") );
761    
762                return $table;
763            }
764            else return NULL;
765        }
766    
767        /**
768         * This function builds a TD with the
769         * appropriate action arrow.
770         *
771         * @param string - FIRST or LAST
772         * @return TDtag
773         */
774        function _build_actionbar_arrow_cell($col) {
775            $td = new TDtag(array("class" => "datalist_title",
776                                  "style" => "padding-left:14px;padding-right:14px;".
777                                  "padding-top:5px;",
778                                  "width" => "5%")
779                           );
780    
781            if ($col == "FIRST") {
782                $td->set_tag_attribute("align", "left");
783                if ($this->_has_action_column("FIRST") &&
784                    $this->_datasource->get_total_rows()) {
785                    $td->push(html_img("img/widgets/arrow_right.gif"));
786                }
787                else {
788                    $td->push("&nbsp;");
789                }
790            }
791            else {
792                $td->set_tag_attribute("align", "right");
793                if ($this->_has_action_column("LAST") &&
794                    $this->_datasource->get_total_rows()) {
795                    $td->push(html_img("img/widgets/arrow_left.gif"));
796                }
797                else {
798                    $td->push("&nbsp;");
799                }
800            }
801            return $td;
802      }      }
803    
804        /**
805         * This function builds the user's data cell
806         *
807         * @return TDtag;
808         */
809        function _build_actionbar_data_cell() {
810            $td = new TDtag(array("class" => "datalist_title",
811                                  "style" => "padding-left:5px;padding-right:5px;".
812                                  "padding-top:5px;padding-bottom:5px")
813                           );
814    
815            $flag = FALSE;
816            if ($this->_has_action_column("FIRST")) {
817                $flag = TRUE;
818                $td->set_tag_attribute("align", "left");
819            }
820            else if ($this->_has_action_column("LAST")) {
821                $flag = TRUE;
822                $td->set_tag_attribute("align", "right");
823            }
824    
825            if ($flag && $this->_datasource->get_total_rows()) {
826                $td->push($this->actionbar_cell());
827            }
828            else {
829                $td->push("&nbsp;");
830            }
831    
832            return $td;
833        }
834    
835        /**
836         * this is the method that builds
837         * the contents for the middle actionbar
838         * td cell.
839         * NOTE this function is meant to be overriden
840         *      by the child class.
841         *
842         * @return ContainerWidget object
843         */
844        function actionbar_cell() {
845            return _HTML_SPACE;
846        }
847    
848        /**
849         * This function builds an action button that will
850         * modify the form action, to post to a different
851         * script to handle the data
852         *
853         * @param string - the button name
854         * @param string - the script that gets called.
855         * @return INPUTtag object
856         */
857        function action_button($name, $action) {
858    
859            $submit = form_button("_action", $name);
860    
861            // here we make sure that all standard buttons look the same
862            if (strlen($name)<10) $submit->set_tag_attribute("style","width: 80px;");
863    
864            $form_name = $this->get_form_name();
865    
866            $onclick  = "javascript: document.".$form_name.".action='".$action."';";
867            $onclick .= "document.".$form_name.".submit();";
868            $submit->set_tag_attribute("onclick", $onclick);
869            return $submit;
870        }
871    
872        /**
873         * This function returns any Javascript required
874         * for this widget
875         *
876         * @return mixed
877         */
878        function _javascript() {
879            if ($this->_has_action_column("FIRST") || $this->_has_action_column("LAST")) {
880                $last = $this->_action_column["LAST"]["type"];
881                $first = $this->_action_column["FIRST"]["type"];
882                if ($last == "checkbox" || $first == "checkbox") {
883                    return $this->_checkbox_javascript();
884                }
885            }
886            else {
887                return NULL;
888            }
889        }
890    
891        /**
892         * This function builds the JS needed for the checkbox
893         * action column
894         *
895         * @return SCRIPTtag
896         */
897        function _checkbox_javascript() {
898            $script = new SCRIPTtag(array("language" => "Javascript"));
899    
900            $var_name = $this->_vars["checkboxVar"];
901    
902            $js  = "function mass(form) {\n";
903            $js .= "  var i=0;\n";
904            $js .= "  var value=0;\n\n";
905            $js .= "  if (form.$var_name.checked) {\n";
906            $js .= "    value=1;\n";
907            $js .= "  } else {\n";
908            $js .= "    value=0;\n";
909            $js .= "  }\n\n";
910            $js .= "  for (i = 0; i < form.length; i++) {\n";
911            $js .= "    if (form.elements[i].name.substring(0, 8) == '$var_name' && !form.elements[i].disabled) {\n";
912            $js .= "      form.elements[i].checked = value;\n";
913            $js .= "    }\n";
914            $js .= "  }\n";
915            $js .= "}\n";
916    
917            $script->push($js);
918            return $script;
919        }
920    
921        function get_hidden_fields() {
922             user_error("DefaulGUIDataList::get_hidden_fields() - ".
923                               "child class must override this method ".
924                               "this function should return a hash for hidden fields, if not needed just return" );
925        }
926    
927        function _decode_column_item_array($obj) {
928             user_error("DefaulGUIDataList::_decode_column_item_array() - ".
929                               "child class must override this method ".
930                               "this function should decode the column_item if it is a (sub-) array,".
931                               "array should e.g. replaced by a select form." );
932        }
933      
934      function _decode_column_item_expr($obj) {      function _decode_column_item_expr($obj) {
935          user_error("DefaulGUIDataList::_decode_column_item_expr() - ".           user_error("DefaulGUIDataList::_decode_column_item_expr() - ".
936                                     "child class must override this method ".                             "child class must override this method ".
937                                     "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" );
938      }      }
939  }  }
940    
# Line 355  class DefaultGUIDataListCSS extends CSSB Line 967  class DefaultGUIDataListCSS extends CSSB
967    
968                  $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",
969                                                   array("color" => "#000000",                                                   array("color" => "#000000",
970                                   "font-family" => "arial, helvetica, sans-serif",
971                                   "font-size" => "10pt",
972                                   "font-weight" => "bold",
973                                                             "text-decoration" => "none"));                                                             "text-decoration" => "none"));
974    
975                  $this->add_entry(".datalist_col_head_hover", "",                  $this->add_entry(".datalist_col_head_hover", "",
# Line 401  class DefaultGUIDataListCSS extends CSSB Line 1016  class DefaultGUIDataListCSS extends CSSB
1016                                                                  "color" => "#FFFFFF",                                                                  "color" => "#FFFFFF",
1017                                                                  "background-color" => "#999999",                                                                  "background-color" => "#999999",
1018                                                                  "white-space" =>"nowrap"));                                                                  "white-space" =>"nowrap"));
1019    
1020            $this->add_entry( ".datalist_data_cell", "",
1021                              array(
1022                                  "font-family" => "arial",
1023                                  "font-size" => "10pt",
1024                                  "padding-left" => "3px",
1025                                  "padding-right" => "3px",
1026                                  "border-top" => "1px solid #dddddd"));
1027    
1028            $this->add_entry( ".datalist_actionbar", "",
1029                              array(
1030                                  "border" => "1px solid #999999") );
1031    
1032            $this->add_entry( ".datalist_actionbar_data_cell", "",
1033                              array(
1034                                  "font-family" => "arial",
1035                                  "font-size" => "10pt",
1036                                  "background" => "#CCCCCC",
1037                                  "padding-left" => "3px",
1038                                  "padding-right" => "3px",
1039                                  "border-top" => "1px solid #dddddd"));
1040    
1041            $this->add_entry( ".datalist_bottom_seperator", "",
1042                              array(
1043                                  "font-size" => "5px",
1044                                  "line-height" =>  "5px",
1045                                  "background" => "#CCCCCC",
1046                                  "text-align" => "left",
1047                                  "white-space" => "nowrap",
1048                                  "height" => "5px",
1049                                  "border-left" => "1px solid #FFFFFF",
1050                                  "border-top" => "1px solid #FFFFFF",
1051                                  "border-right" => "1px solid #dddddd",
1052                                  "border-bottom" => "1px solid #dddddd",
1053                                  "padding-left" =>  "3px",
1054                                  "padding-right" => "3px"));
1055          }                }      
1056  }  }
1057  ?>  ?>

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

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