/[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.3 by joko, Fri Apr 4 21:26:06 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
12    ##    + bugfix again
13    ##
14    ##    Revision 1.5  2003/04/08 17:33:22  jonen
15    ##    + fixed problems with hidden form fields(current base URL) at the 'simple search form'
16    ##
17    ##    Revision 1.4  2003/04/06 01:41:07  jonen
18    ##    - removed duplicated decode functions
19    ##
20  ##    Revision 1.3  2003/04/04 21:26:06  joko  ##    Revision 1.3  2003/04/04 21:26:06  joko
21  ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure  ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure
22  ##  ##
# Line 51  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 73  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 212  class GenericGUIDataList extends Default Line 229  class GenericGUIDataList extends Default
229                        
230            */            */
231    
232              $utils = php::mkComponent('WebExplorer::utils');
233              $hidden = $this->_hidden_elements;
234              $options = $this->_options['decode_args'];
235              
236            // 1. if item is match by expression we will replace it with an link object              // 1. if item is match by expression we will replace it with an link object  
237            if ($this->decode_item_expr($obj)) {              if ($utils->decode_item_expr($obj, $hidden, $options)) {  
238              $obj = $this->decode_item_expr($obj);                $obj = $utils->decode_item_expr($obj, $hidden, $options);  
239            }            }
240    
241            // 2. if item is an Array we will replace it with an selection form object              // 2. if item is an Array we will replace it with an selection form object  
242            elseif ( $this->decode_item_array($obj) ) {            elseif ( $utils->decode_item_array($obj, $hidden, $options) ) {
243              $obj = $this->decode_item_array($obj);                $obj = $utils->decode_item_array($obj, $hidden, $options);  
244            }            }
245    
246          }          }
# Line 254  class GenericGUIDataList extends Default Line 274  class GenericGUIDataList extends Default
274      }      }
275    
276    
277    // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      /**
278    function decode_item_array($item) {       * This function builds the simple search TD
279      $options = $this->_options['decode_args'];       *
280      //print "item: " . Dumper($item);       * @return ContainerWidget
281      //print "options: " . Dumper($options);       */
282      if( is_array($item) ) {      function _build_simple_search_form() {
283            //$cur_row_index = $this->_datasource->get_cur_data_index();  
284            //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];          //if there is only 1 item enabled for search
285            // build list for selection form          //then the search looks simple.
286         if($options['form']) {          $fields = $this->_get_searchable_fields();
287            foreach($item as $key => $value) {          $cnt = count($fields);
288                  $tmp = split($options['seperator'], $value);          if ($cnt == 0) {
289                  $ident = $tmp['1'];              return NULL;
290                  $meta = $tmp['2'];          }
291                  $list[$key] = $ident;  
292                  }          $container = new ContainerWidget;
293                  if(is_array($list) ) {          
294                $container = container(          // get current request vars and add them ad hidden items
295                    form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),          $url_vars = $this->_get_current_url_vars();
296                    form_hidden("ecdm", $meta),          foreach($url_vars as $label => $value) {
297                    form_select("ecdid", $list),            $container->push(form_hidden($label, $value));
298                    form_submit("submit","view" )          }
299                    );  
300                 foreach($this->_hidden_elements as $label => $value) {          if ($cnt == 1) {
301                   $container->add(form_hidden($label, $value));              //user only has 1 field to show.
302                 }              list($name, $field) = each($fields);
303                $container->add(form_close() );              $container->push("Find ".$name."  ");
               $item = $container;  
               }  
304          } else {          } else {
305            //print "<b>2</b><br/>";              //user has many fields to show.
306            $container = container();              $container->push("Find ",
307            foreach($item as $key => $value) {                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
308                  $tmp = split($options['seperator'], $value);          }
309                  $ident = $tmp['1'];  
310                  $meta = $tmp['2'];          if ($this->get_simple_search_modifier()) {
311                       foreach($this->_hidden_elements as $label => $value) {              //the user wants the search modifier turned on.
312                         $tmp_array[] = $label . "=" . $value;              $container->push($this->_build_simple_search_modifier());
313                       }          }
314                       $str_hidden = join("&", $tmp_array);  
315                  $container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br());                        $container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),
316                             form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
317    
318            if ($this->is_advanced_search_enabled()) {
319                $span = html_span(html_a("ass","Advanced Search", "title"));
320                $container->push("&nbsp;", $span);
321            }
322    
323            if ($cnt == 1) {
324                $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
325            }
326    
327    
328            //$container->push(form_close() );
329            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            $item = $container;            $action_form->add(form_close());
355              return $action_form;
356            } else {
357              return _HTML_SPACE;
358          }          }
               return $item;  
359      }      }
   }  
360    
361    // decodes serialized string representations of object-references  
362    // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      /*
363    function decode_item_expr($item) {       * this method returns the current requested variables
364      $options = $this->_options['decode_args'];       *
365      //print "item: $item<br/>";       * @return array
366      if(substr($item, 0, 2) == "o_") {       */
367            $tmp = split($options['seperator'], $item);      function _get_current_url_vars() {
368            $ident = $tmp['1'];          $cur_url_vars = array();
369            $meta = $tmp['2'];  
370            foreach($this->_hidden_elements as $label => $value) {          // get new LinkBuilder instance
371               $tmp_array[] = $label . "=" . $value;          $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            $str_hidden = join("&", $tmp_array);          }
387            $item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");          return $cur_url_vars;
           return $item;  
388      }      }
   }  
389    
390  }  }
391  ?>  ?>

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

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