/[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.6 by jonen, Tue Apr 8 17:48:31 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.6  2003/04/08 17:48:31  jonen
8    ##    + bugfix again
9    ##
10    ##    Revision 1.5  2003/04/08 17:33:22  jonen
11    ##    + fixed problems with hidden form fields(current base URL) at the 'simple search form'
12    ##
13    ##    Revision 1.4  2003/04/06 01:41:07  jonen
14    ##    - removed duplicated decode functions
15    ##
16  ##    Revision 1.3  2003/04/04 21:26:06  joko  ##    Revision 1.3  2003/04/04 21:26:06  joko
17  ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure  ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure
18  ##  ##
# Line 212  class GenericGUIDataList extends Default Line 221  class GenericGUIDataList extends Default
221                        
222            */            */
223    
224              $utils = php::mkComponent('WebExplorer::utils');
225              $hidden = $this->_hidden_elements;
226              $options = $this->_options['decode_args'];
227              
228            // 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  
229            if ($this->decode_item_expr($obj)) {              if ($utils->decode_item_expr($obj, $hidden, $options)) {  
230              $obj = $this->decode_item_expr($obj);                $obj = $utils->decode_item_expr($obj, $hidden, $options);  
231            }            }
232    
233            // 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  
234            elseif ( $this->decode_item_array($obj) ) {            elseif ( $utils->decode_item_array($obj, $hidden, $options) ) {
235              $obj = $this->decode_item_array($obj);                $obj = $utils->decode_item_array($obj, $hidden, $options);  
236            }            }
237    
238          }          }
# Line 254  class GenericGUIDataList extends Default Line 266  class GenericGUIDataList extends Default
266      }      }
267    
268    
269    // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      /**
270    function decode_item_array($item) {       * This function builds the simple search TD
271      $options = $this->_options['decode_args'];       *
272      //print "item: " . Dumper($item);       * @return ContainerWidget
273      //print "options: " . Dumper($options);       */
274      if( is_array($item) ) {      function _build_simple_search_form() {
275            //$cur_row_index = $this->_datasource->get_cur_data_index();  
276            //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];          //if there is only 1 item enabled for search
277            // build list for selection form          //then the search looks simple.
278         if($options['form']) {          $fields = $this->_get_searchable_fields();
279            foreach($item as $key => $value) {          $cnt = count($fields);
280                  $tmp = split($options['seperator'], $value);          if ($cnt == 0) {
281                  $ident = $tmp['1'];              return NULL;
282                  $meta = $tmp['2'];          }
283                  $list[$key] = $ident;  
284                  }          $container = new ContainerWidget;
285                  if(is_array($list) ) {  
286                $container = container(          if ($cnt == 1) {
287                    form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),              //user only has 1 field to show.
288                    form_hidden("ecdm", $meta),              list($name, $field) = each($fields);
289                    form_select("ecdid", $list),              $container->push("Find ".$name."  ");
                   form_submit("submit","view" )  
                   );  
                foreach($this->_hidden_elements as $label => $value) {  
                  $container->add(form_hidden($label, $value));  
                }  
               $container->add(form_close() );  
               $item = $container;  
               }  
290          } else {          } else {
291            //print "<b>2</b><br/>";              //user has many fields to show.
292            $container = container();              $container->push("Find ",
293            foreach($item as $key => $value) {                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
294                  $tmp = split($options['seperator'], $value);          }
295                  $ident = $tmp['1'];  
296                  $meta = $tmp['2'];          if ($this->get_simple_search_modifier()) {
297                       foreach($this->_hidden_elements as $label => $value) {              //the user wants the search modifier turned on.
298                         $tmp_array[] = $label . "=" . $value;              $container->push($this->_build_simple_search_modifier());
299                       }          }
300                       $str_hidden = join("&", $tmp_array);  
301                  $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;")),
302            }                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
303            $item = $container;  
304            if ($this->is_advanced_search_enabled()) {
305                $span = html_span(html_a("ass","Advanced Search", "title"));
306                $container->push("&nbsp;", $span);
307          }          }
               return $item;  
     }  
   }  
308    
309    // decodes serialized string representations of object-references          if ($cnt == 1) {
310    // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!              $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
311    function decode_item_expr($item) {          }
312      $options = $this->_options['decode_args'];  
313      //print "item: $item<br/>";          // find variables attached at base URL and add them as hidden fields,
314      if(substr($item, 0, 2) == "o_") {          // so the search method will reach its starting point at deep frameworks
315            $tmp = split($options['seperator'], $item);          $base_url = $this->build_base_url();
316            $ident = $tmp['1'];          $url_vars = split("&amp;", $base_url);
317            $meta = $tmp['2'];          $tmp = split("\?", $url_vars[0]);
318            foreach($this->_hidden_elements as $label => $value) {          $url_vars[0] = $tmp[1];
319               $tmp_array[] = $label . "=" . $value;          if(is_array($url_vars)) {
320              foreach($url_vars as $value) {
321                 $var = split("=", $value);
322                 if($var[0] && $var[1]) {
323                   $container->push(form_hidden($var[0], $var[1]));
324                 }
325            }            }
326            $str_hidden = join("&", $tmp_array);          }
327            $item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");  
328            return $item;          $container->push(form_close() );
329            return $container;
330      }      }
331    }  
332    
333  }  }
334  ?>  ?>

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

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