/[cvs]/nfo/php/libs/org.netfrag.patches/phphtmllib/widgets/GenericGUIDataList.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.patches/phphtmllib/widgets/GenericGUIDataList.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by jonen, Fri Apr 18 18:40:02 2003 UTC revision 1.13 by jonen, Thu Oct 7 14:17:50 2004 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.13  2004/10/07 14:17:50  jonen
8    ##    + pass filter-values to backend now! (page-control!)
9    ##
10    ##    Revision 1.12  2004/05/06 17:14:35  jonen
11    ##     updated
12    ##
13    ##    Revision 1.11  2003/05/10 17:58:45  jonen
14    ##    + reworked to implement 'create/add new' item
15    ##
16  ##    Revision 1.10  2003/04/18 18:40:02  jonen  ##    Revision 1.10  2003/04/18 18:40:02  jonen
17  ##    + fixed bugs at 'actionbar_cell' relating to html-form and js  ##    + fixed bugs at 'actionbar_cell' relating to html-form and js
18  ##  ##
# Line 99  class GenericGUIDataList extends Default Line 108  class GenericGUIDataList extends Default
108    
109      // call parent constructor      // call parent constructor
110      $parent =  get_parent_class($this);      $parent =  get_parent_class($this);
111      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);          $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);
112    }    }
113    
114    
# Line 135  class GenericGUIDataList extends Default Line 144  class GenericGUIDataList extends Default
144        // V5:        // V5:
145        //print "options: " . Dumper($this->_options);        //print "options: " . Dumper($this->_options);
146                
147    
148              //HACK 2004-10-07: page-filter done by backend now,
149              //                 filter-values are passed to backend
150          $this->_options['data_locator_meta']['filter']['offset'] = $this->offset();
151          $this->_options['data_locator_meta']['filter']['numrows'] = $this->numrows();
152          $this->_options['data_locator_meta']['filter']['search_field'] = $this->search_field();
153          $this->_options['data_locator_meta']['filter']['search_value'] = $this->search_value();
154          $this->_options['data_locator_meta']['filter']['search_modifier'] = $this->simple_search_modifier_value();
155          
156          //$this->_set("offsetVar", 0);
157          
158        $initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) );        $initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) );
159        //print "1st locator: " . Dumper($initial_locator);        //print "1st locator: " . Dumper($initial_locator);
160                
# Line 158  class GenericGUIDataList extends Default Line 178  class GenericGUIDataList extends Default
178        $source = $proxy->get_adapter();        $source = $proxy->get_adapter();
179    
180        // V4:        // V4:
181            //$source = $this->_datasource;              //$source = $this->_datasource;
182          
183        //print "objectlist-source: " . Dumper($source);        //print "objectlist-source: " . Dumper($source);
184        //exit;        //exit;
185    
# Line 176  class GenericGUIDataList extends Default Line 196  class GenericGUIDataList extends Default
196                        
197          //print Dumper($source);          //print Dumper($source);
198            $headers = $source->get_header();            $headers = $source->get_header();
199            //print Dumper($headers);            //print "headers: " . Dumper($headers);
200                        
201            $this->set_title( $this->get_title() . ' - ' . $source->get_total_rows() . ' Einträge' );            $this->set_title( $this->get_title() . ' - ' . $source->get_total_rows() . ' Einträge' );
202                        
203            foreach($headers as $val) {            foreach($headers as $val) {
204                  $this->add_header_item($val, "150", $val, SORTABLE, SEARCHABLE);                  $this->add_header_item($val, "150", $val, SORTABLE, SEARCHABLE);
205      }      }
206        
207    
208  /*  /*
209          $this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE);          $this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE);
210          $this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center");          $this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center");
211  */  */
212    
213          }          }
214    
215    
# Line 204  class GenericGUIDataList extends Default Line 226  class GenericGUIDataList extends Default
226       * @param int - the column # we are working on.       * @param int - the column # we are working on.
227       * @return TDtag object       * @return TDtag object
228       */       */
229     function wrap_column_item($obj, $col_name) {     function wrap_column_item($obj, $col_name, $row_data) {
230        
231            //print "item: " . Dumper($obj) . "<br>";
232    
233          //make sure its set to something.          //make sure its set to something.
234          if ($obj == '') {          if ($obj == '') {
# Line 241  class GenericGUIDataList extends Default Line 265  class GenericGUIDataList extends Default
265            $utils = php::mkComponent('WebExplorer::utils');            $utils = php::mkComponent('WebExplorer::utils');
266            $hidden = $this->_hidden_elements;            $hidden = $this->_hidden_elements;
267            $options = $this->_options['decode_args'];            $options = $this->_options['decode_args'];
268              $options[label] = $col_name;
269              $options[parent_guid] = $row_data[guid];
270              $options[parent_class] = $this->_options['parent']['class'];
271                        
272            // a) Iterate through the attributes of the item and replace each            // a) Iterate through the attributes of the item and replace each
273            // value with an appropriate link object if it has a certain format.            // value with an appropriate link object if it has a certain format.
# Line 282  class GenericGUIDataList extends Default Line 309  class GenericGUIDataList extends Default
309      }      }
310    
311    
312    
313      /**      /**
314       * This function builds the simple search TD       * This function builds the simple search TD
315       *       *
# Line 299  class GenericGUIDataList extends Default Line 327  class GenericGUIDataList extends Default
327    
328          $container = new ContainerWidget;          $container = new ContainerWidget;
329                    
330            // OLD - needed hidden elements are now recognized at 'render()'
331            /*
332          // get current request vars and add them ad hidden items          // get current request vars and add them ad hidden items
333          $url_vars = $this->_get_current_url_vars();          $url_vars = $this->_get_current_url_vars();
334          foreach($url_vars as $label => $value) {          foreach($url_vars as $label => $value) {
335            $container->push(form_hidden($label, $value));            $container->push(form_hidden($label, $value));
336          }          }
337            */
338    
339          if ($cnt == 1) {          if ($cnt == 1) {
340              //user only has 1 field to show.              //user only has 1 field to show.
# Line 332  class GenericGUIDataList extends Default Line 363  class GenericGUIDataList extends Default
363              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
364          }          }
365    
   
         //$container->push(form_close() );  
366          return $container;          return $container;
367      }      }
368    
369    
370      /**      /**
371         * This function builds the data cell action buttons or main actionbar
372         *
373         * @return TDtag;
374         */
375        function _build_actionbar_data_cell() {
376            $td = new TDtag(array("class" => "datalist_title",
377                                  "style" => "padding-left:5px;padding-right:5px;".
378                                  "padding-top:5px;padding-bottom:5px")
379                           );
380    
381            $flag = FALSE;
382            if ($this->_has_action_column("FIRST")) {
383                $flag = TRUE;
384                $td->set_tag_attribute("align", "left");
385            }
386            elseif ($this->_has_action_column("LAST")) {
387                $flag = TRUE;
388                $td->set_tag_attribute("align", "right");
389            }
390    
391            if ($flag && $this->_datasource->get_total_rows()) {
392                $td->push($this->actionbar_cell());
393                $td->push($this->actionbar_cell_new());
394            }
395            else {
396                $td->push("&nbsp;");
397                $td->push($this->actionbar_cell_new());
398            }
399    
400            return $td;
401        }
402    
403    
404        /**
405       * this is the method that builds       * this is the method that builds
406       * the contents for the middle actionbar       * the contents for the middle actionbar
407       * td cell.       * td cell.
# Line 351  class GenericGUIDataList extends Default Line 414  class GenericGUIDataList extends Default
414    
415          if($action_name && is_array($action_list)) {          if($action_name && is_array($action_list)) {
416            $action_form = container("Select action", _HTML_SPACE,            $action_form = container("Select action", _HTML_SPACE,
417                               form_select($action_name, $action_list),                               form_select($action_name, $action_list, $this->_options['actionbar']['selected']),
418                               form_submit("ok","OK" )                                                           form_submit("ok","OK" )
419                                 );
420              return $action_form;
421            } else {
422              return _HTML_SPACE;
423            }
424        }
425    
426    
427        /**
428         * this is the method that builds
429         * the contents for the buttons of actionbar
430         * td cell.
431         *
432         * @return ContainerWidget object
433         */
434        function actionbar_cell_new() {
435            $action_buttons = $this->_options['actionbar']['buttons'];
436    
437            if(is_array($action_buttons)) {
438              $action_form = container();
439              foreach($action_buttons as $type) {
440                $action_form->add(
441                                 _HTML_SPACE,
442                                 form_submit($type['name'], $type['value'])
443                               );                               );
444              }
445            return $action_form;            return $action_form;
446          } else {          } else {
447            return _HTML_SPACE;            return _HTML_SPACE;
# Line 362  class GenericGUIDataList extends Default Line 450  class GenericGUIDataList extends Default
450    
451    
452      /*      /*
453       * this method returns the current requested variables       * OLD (depreciated) - this method returns the current requested variables
454       *       *
455       * @return array       * @return array
456       */       */
# Line 389  class GenericGUIDataList extends Default Line 477  class GenericGUIDataList extends Default
477          return $cur_url_vars;          return $cur_url_vars;
478      }      }
479    
480    
481        /**
482         * This function renders the final
483         * widget
484         *
485         */
486        function render($indent_level, $output_debug) {
487    
488            //setup the columns in their sorts
489            $this->setup_columns();
490    
491            //do any data prefetch work
492            //which may be child specific
493            if ( $this->_show_results() ) {
494                $this->data_prefetch();
495            }
496            
497            //This function gives the child class
498            //a chance to build the tables/divs/containers
499            //that will be responsible for the look/feel
500            //of the DataList
501            $this->gui_init();
502    
503            //see if we need to build the search area.
504            if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) {
505                $this->_search_table = $this->child_build_search_table();
506                if ( $this->_search_table ) {
507                    $this->set_form_render(TRUE);
508                }
509            }
510    
511            //see if form is needed by the actionbar
512            if($this->_show_actionbar) {
513              $this->set_form_render(TRUE);
514            }
515    
516            if ( $this->get_form_render() ) {
517                $form =  new FORMtag( array("method" => $this->get_form_method(),
518                                            "action" => $this->build_base_url(),
519                                            "name" => $this->get_form_name(),
520                                            "style" => "margin-top: 0px;margin-bottom:0px;") );
521    
522                $target = $this->get_form_target();
523                if ( $target != NULL )
524                    $form->set_tag_attribute("target",$target);
525    
526                $action = $this->get_form_action();
527                if ( $action != NULL )
528                    $form->set_tag_attribute("action",$action);
529    
530                //now build the UI and return it
531                $form->add( $this->build_gui() );
532                
533            } else {
534                $form = container();
535    
536                //now build the UI and return it
537                $form->add( $this->build_gui() );
538            }
539            
540            //add the hidden vars if we are a POST
541            if ($this->get_form_method() == "POST") {
542                $form->add( $this->_build_default_vars() );
543    
544                //build hidden elements needed for data flow control
545                $hidden = $this->_hidden_elements;
546                //print "Hidden: " . Dumper($hidden);
547                if($hidden) {
548                  foreach($hidden as $label => $value) {
549                    $form->add(form_hidden($label, $value));
550                  }
551                }
552    
553            }
554    
555            //add the save vars the user wants.
556            $form->add( $this->_build_save_vars() );
557    
558            //add any javascript required
559            $container = container( $this->_javascript(), $form );
560            return $container->render( $indent_level, $output_debug );
561        }
562    
563    
564    
565            function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) {
566            if (!$this->_cur_col_cntr) {
567            //if (!isset($this->_cur_col_cntr)) {
568                $this->_cur_col_cntr = 1;
569                //lets see if we need to add an action column
570                //as the first column.
571                if ($this->_has_action_column("FIRST")) {
572                    //looks like we have a FIRST column actionbar
573                    //lets add it
574                    $this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data));
575                }
576                $td = $this->wrap_column_item($obj, $col_name, $row_data);
577                $this->_data_row->add( $td );
578            } else {
579                //show the normal data
580                $td = $this->wrap_column_item($obj, $col_name, $row_data);
581                $this->_data_row->add( $td );
582            }
583    
584                    
585                    if ($last_in_row_flag) {
586                //lets see if we need to add an action column
587                //as the first column.
588                if ($this->_has_action_column("LAST")) {
589                    //looks like we have a LAST column actionbar
590                    //lets add it
591                    $this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data));
592                }
593    
594    
595    
596                            $this->_data_table->add_row( $this->_data_row );
597                            $this->_data_row = new TRtag;
598                unset( $this->_cur_col_cntr );
599                    } else {
600                $this->_cur_col_cntr++;
601            }
602            }
603    
604  }  }
605  ?>  ?>

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

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