/[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.8 by joko, Wed Apr 9 07:54:42 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.8  2003/04/09 07:54:42  joko
8    ##    cleaned up decoding part
9    ##
10    ##    Revision 1.7  2003/04/09 00:37:53  jonen
11    ##    + added actionbar
12    ##    + some changes according to request vars
13    ##
14  ##    Revision 1.6  2003/04/08 17:48:31  jonen  ##    Revision 1.6  2003/04/08 17:48:31  jonen
15  ##    + bugfix again  ##    + bugfix again
16  ##  ##
# Line 60  class GenericGUIDataList extends Default Line 67  class GenericGUIDataList extends Default
67    */    */
68    var $_hidden_elements = array();    var $_hidden_elements = array();
69    
70    
71  /**  /**
72    * The constructor is used to pass in some additional    * The constructor is used to pass in some additional
73    * metadata informations as "options".    * metadata informations as "options".
# Line 82  class GenericGUIDataList extends Default Line 90  class GenericGUIDataList extends Default
90    */    */
91    function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {    function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {
92      if ($options) { $this->_options = $options; }      if ($options) { $this->_options = $options; }
93    
94        // call parent constructor
95      $parent =  get_parent_class($this);      $parent =  get_parent_class($this);
96      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);    
97    }    }
98    
99    
100    function get_data_source( ) {    function get_data_source( ) {
101    
102      // finally: create phpHtmlLib source handle (XyzDataListSource)      // finally: create phpHtmlLib source handle (XyzDataListSource)
# Line 225  class GenericGUIDataList extends Default Line 236  class GenericGUIDataList extends Default
236            $hidden = $this->_hidden_elements;            $hidden = $this->_hidden_elements;
237            $options = $this->_options['decode_args'];            $options = $this->_options['decode_args'];
238                        
239            // 1. if item is match by expression we will replace it with an link object              // a) Iterate through the attributes of the item and replace each
240            if ($utils->decode_item_expr($obj, $hidden, $options)) {              // value with an appropriate link object if it has a certain format.
241              $obj = $utils->decode_item_expr($obj, $hidden, $options);              if ($utils->decode_item_expr($obj, $hidden, $options)) {
242            }  
243              // b) Otherwise: If item is an Array we will replace it with a selection form object.
244            // 2. if item is an Array we will replace it with an selection form object              } else {
245            elseif ( $utils->decode_item_array($obj, $hidden, $options) ) {              $utils->decode_item_array($obj, $hidden, $options);
             $obj = $utils->decode_item_array($obj, $hidden, $options);    
246            }            }
247    
248          }          }
# Line 282  class GenericGUIDataList extends Default Line 292  class GenericGUIDataList extends Default
292          }          }
293    
294          $container = new ContainerWidget;          $container = new ContainerWidget;
295            
296            // get current request vars and add them ad hidden items
297            $url_vars = $this->_get_current_url_vars();
298            foreach($url_vars as $label => $value) {
299              $container->push(form_hidden($label, $value));
300            }
301    
302          if ($cnt == 1) {          if ($cnt == 1) {
303              //user only has 1 field to show.              //user only has 1 field to show.
# Line 310  class GenericGUIDataList extends Default Line 326  class GenericGUIDataList extends Default
326              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
327          }          }
328    
         // 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]));  
              }  
           }  
         }  
329    
330          $container->push(form_close() );          //$container->push(form_close() );
331          return $container;          return $container;
332      }      }
333    
334    
335        /**
336         * this is the method that builds
337         * the contents for the middle actionbar
338         * td cell.
339         *
340         * @return ContainerWidget object
341         */
342        function actionbar_cell() {
343            $action_list = $this->_options['actionbar']['list'];
344            $action_name = $this->_options['actionbar']['name'];
345    
346            if($action_name && is_array($action_list)) {
347              $action_form = container("Select action", _HTML_SPACE,
348                                 form_open("data_list_action", $_SERVER['PHP_SELF'], 'POST'),
349                                 form_select($action_name, $action_list),
350                                 form_submit("submit","OK" )                            
351                                 );
352              $url_vars = $this->_get_current_url_vars();
353              foreach($url_vars as $label => $value) {
354                $action_form->add(form_hidden($label, $value));
355              }
356              $action_form->add(form_close());
357              return $action_form;
358            } else {
359              return _HTML_SPACE;
360            }
361        }
362    
363    
364        /*
365         * this method returns the current requested variables
366         *
367         * @return array
368         */
369        function _get_current_url_vars() {
370            $cur_url_vars = array();
371    
372            // get new LinkBuilder instance
373            $linkbuilder = new LinkBuilder();
374    
375            $url_vars = php::array_join_merge($_GET, $_POST);
376            if(is_array($url_vars)) {
377              foreach($url_vars as $key => $value) {
378                   // if there is an LinkBuilder guid instead of variables, encode it
379                   if($key == 'lbid') {
380                     $lb_vars = $linkbuilder->load($value);
381                     foreach($lb_vars as $lbkey => $lbval) {
382                       $cur_url_vars[$lbkey] = $lbval;
383                     }
384                   } else {
385                     $cur_url_vars[$key] = $value;
386                   }
387              }
388            }
389            return $cur_url_vars;
390        }
391    
392  }  }
393  ?>  ?>

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

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