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

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

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