/[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.6 by jonen, Tue Apr 8 17:48:31 2003 UTC revision 1.7 by jonen, Wed Apr 9 00:37:53 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.7  2003/04/09 00:37:53  jonen
8    ##    + added actionbar
9    ##    + some changes according to request vars
10    ##
11  ##    Revision 1.6  2003/04/08 17:48:31  jonen  ##    Revision 1.6  2003/04/08 17:48:31  jonen
12  ##    + bugfix again  ##    + bugfix again
13  ##  ##
# Line 60  class GenericGUIDataList extends Default Line 64  class GenericGUIDataList extends Default
64    */    */
65    var $_hidden_elements = array();    var $_hidden_elements = array();
66    
67    
68  /**  /**
69    * The constructor is used to pass in some additional    * The constructor is used to pass in some additional
70    * metadata informations as "options".    * metadata informations as "options".
# Line 82  class GenericGUIDataList extends Default Line 87  class GenericGUIDataList extends Default
87    */    */
88    function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {    function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {
89      if ($options) { $this->_options = $options; }      if ($options) { $this->_options = $options; }
90    
91        // call parent constructor
92      $parent =  get_parent_class($this);      $parent =  get_parent_class($this);
93      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);    
94    }    }
95    
96    
97    function get_data_source( ) {    function get_data_source( ) {
98    
99      // finally: create phpHtmlLib source handle (XyzDataListSource)      // finally: create phpHtmlLib source handle (XyzDataListSource)
# Line 282  class GenericGUIDataList extends Default Line 290  class GenericGUIDataList extends Default
290          }          }
291    
292          $container = new ContainerWidget;          $container = new ContainerWidget;
293            
294            // get current request vars and add them ad hidden items
295            $url_vars = $this->_get_current_url_vars();
296            foreach($url_vars as $label => $value) {
297              $container->push(form_hidden($label, $value));
298            }
299    
300          if ($cnt == 1) {          if ($cnt == 1) {
301              //user only has 1 field to show.              //user only has 1 field to show.
# Line 310  class GenericGUIDataList extends Default Line 324  class GenericGUIDataList extends Default
324              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
325          }          }
326    
         // find variables attached at base URL and add them as hidden fields,  
         // so the search method will reach its starting point at deep frameworks  
         $base_url = $this->build_base_url();  
         $url_vars = split("&", $base_url);  
         $tmp = split("\?", $url_vars[0]);  
         $url_vars[0] = $tmp[1];  
         if(is_array($url_vars)) {  
           foreach($url_vars as $value) {  
              $var = split("=", $value);  
              if($var[0] && $var[1]) {  
                $container->push(form_hidden($var[0], $var[1]));  
              }  
           }  
         }  
327    
328          $container->push(form_close() );          //$container->push(form_close() );
329          return $container;          return $container;
330      }      }
331    
332    
333        /**
334         * this is the method that builds
335         * the contents for the middle actionbar
336         * td cell.
337         *
338         * @return ContainerWidget object
339         */
340        function actionbar_cell() {
341            $action_list = $this->_options['actionbar']['list'];
342            $action_name = $this->_options['actionbar']['name'];
343    
344            if($action_name && is_array($action_list)) {
345              $action_form = container("Select action", _HTML_SPACE,
346                                 form_open("data_list_action", $_SERVER['PHP_SELF'], 'POST'),
347                                 form_select($action_name, $action_list),
348                                 form_submit("submit","OK" )                            
349                                 );
350              $url_vars = $this->_get_current_url_vars();
351              foreach($url_vars as $label => $value) {
352                $action_form->add(form_hidden($label, $value));
353              }
354              $action_form->add(form_close());
355              return $action_form;
356            } else {
357              return _HTML_SPACE;
358            }
359        }
360    
361    
362        /*
363         * this method returns the current requested variables
364         *
365         * @return array
366         */
367        function _get_current_url_vars() {
368            $cur_url_vars = array();
369    
370            // get new LinkBuilder instance
371            $linkbuilder = new LinkBuilder();
372    
373            $url_vars = php::array_join_merge($_GET, $_POST);
374            if(is_array($url_vars)) {
375              foreach($url_vars as $key => $value) {
376                   // if there is an LinkBuilder guid instead of variables, encode it
377                   if($key == 'lbid') {
378                     $lb_vars = $linkbuilder->load($value);
379                     foreach($lb_vars as $lbkey => $lbval) {
380                       $cur_url_vars[$lbkey] = $lbval;
381                     }
382                   } else {
383                     $cur_url_vars[$key] = $value;
384                   }
385              }
386            }
387            return $cur_url_vars;
388        }
389    
390  }  }
391  ?>  ?>

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

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