/[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.2 by jonen, Fri Apr 4 00:45:40 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
17    ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure
18    ##
19  ##    Revision 1.2  2003/04/04 00:45:40  jonen  ##    Revision 1.2  2003/04/04 00:45:40  jonen
20  ##    + reworked decode functions  ##    + reworked decode functions
21  ##  ##
# Line 179  class GenericGUIDataList extends Default Line 191  class GenericGUIDataList extends Default
191    
192          //make sure its set to something.          //make sure its set to something.
193          if ($obj == '') {          if ($obj == '') {
194              $obj = " ";            $obj = " ";
195          }          }
196          // if item is match by expression we will replace it with an link object            
197          elseif($this->_options['decode']) {          // decode item / mungle item data?
198           if($this->decode_item_expr($obj)) {            // TODO: use Data::Lift here!!! (like already done in YAA::JobList and YAA::JobDetails)
199            $obj = $this->decode_item_expr($obj);            elseif ($this->_options['decode']) {
200            }    
201            // if item is an Array we will replace it with an selection form object              // Proposal using Data::Lift: (see YAA::JobList and YAA::JobDetails)
202            elseif($this->decode_item_array($obj) ) {            // This class will get shorter and better to maintain!
203              $obj = $this->decode_item_array($obj);              
204              // Picture Data::Lift as a container component handling
205              // *specific* en-/decoding stuff for your very core components.
206              // This way we will have almost all "specific mungling code" at one place. nice thing!
207              
208              /*
209    
210              // 1. expr: string -> object (phpHtmlLib-object: 'html_a'-tag)
211                // returns a phpHtmlLib object of class 'Xyz' containing a http-/html-link
212                // pointing to a View of a different - linked/referenced - object (reference-interpolation)
213                $this->lift1 = php::mkComponent('Data::Lift', $obj, array( metatype => 'expression' ) );
214                $obj = $this->lift1->to('phpHtmlLib::html_a');
215    
216              // 2. data: hash -> object (phpHtmlLib-object: 'container'-object containing form)
217                // returns a phpHtmlLib object of class 'Container' containing a html-form made up of
218                // phpHtmlLib form-tags wrapping all attribute-value pairs of the data hash (object-edit)
219                $this->lift2 = php::mkComponent('Data::Lift', $obj, array( metatype => 'item' ) );
220                $obj = $this->lift2->to('phpHtmlLib::form');
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  
229              if ($utils->decode_item_expr($obj, $hidden, $options)) {  
230                $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  
234              elseif ( $utils->decode_item_array($obj, $hidden, $options) ) {
235                $obj = $utils->decode_item_array($obj, $hidden, $options);  
236            }            }
237    
238          }          }
239    
240          //make sure we don't put a right border on the last          //make sure we don't put a right border on the last
241          //column we are working on.          //column we are working on.
242          //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";          //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
# Line 221  class GenericGUIDataList extends Default Line 266  class GenericGUIDataList extends Default
266      }      }
267    
268    
269    function decode_item_array($item) {      /**
270      $options = $this->_options['decode_args'];       * This function builds the simple search TD
271      if( is_array($item) ) {       *
272            //$cur_row_index = $this->_datasource->get_cur_data_index();       * @return ContainerWidget
273            //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];       */
274            // build list for selection form      function _build_simple_search_form() {
275         if($options['form']) {  
276            foreach($item as $key => $value) {          //if there is only 1 item enabled for search
277                  $tmp = split($options['seperator'], $value);          //then the search looks simple.
278                  $ident = $tmp['1'];          $fields = $this->_get_searchable_fields();
279                  $meta = $tmp['2'];          $cnt = count($fields);
280                  $list[$key] = $ident;          if ($cnt == 0) {
281                  }              return NULL;
282                  if(is_array($list) ) {          }
283                $container = container(  
284                    form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),          $container = new ContainerWidget;
285                    form_hidden("ecdm", $meta),  
286                    form_select("ecdid", $list),          if ($cnt == 1) {
287                    form_submit("submit","view" )              //user only has 1 field to show.
288                    );              list($name, $field) = each($fields);
289                 foreach($this->_hidden_elements as $label => $value) {              $container->push("Find ".$name."  ");
                  $container->add(form_hidden($label, $value));  
                }  
               $container->add(form_close() );  
               $item = $container;  
               }  
290          } else {          } else {
291            $container = container();              //user has many fields to show.
292            foreach($item as $key => $value) {              $container->push("Find ",
293                  $tmp = split($options['seperator'], $value);                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
                 $ident = $tmp['1'];  
                 $meta = $tmp['2'];  
                      foreach($this->_hidden_elements as $label => $value) {  
                        $tmp_array[] = $label . "=" . $value;  
                      }  
                      $str_hidden = join("&", $tmp_array);  
                 $container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br());                
           }  
           $item = $container;  
294          }          }
               return $item;  
     }  
   }  
295    
296    function decode_item_expr($item) {          if ($this->get_simple_search_modifier()) {
297      $options = $this->_options['decode_args'];              //the user wants the search modifier turned on.
298      if(substr($item, 0, 2) == "o_") {              $container->push($this->_build_simple_search_modifier());
299            $tmp = split($options['seperator'], $item);          }
300            $ident = $tmp['1'];  
301            $meta = $tmp['2'];          $container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),
302            foreach($this->_hidden_elements as $label => $value) {                           form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
303               $tmp_array[] = $label . "=" . $value;  
304            if ($this->is_advanced_search_enabled()) {
305                $span = html_span(html_a("ass","Advanced Search", "title"));
306                $container->push(" ", $span);
307            }
308    
309            if ($cnt == 1) {
310                $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
311            }
312    
313            // find variables attached at base URL and add them as hidden fields,
314            // so the search method will reach its starting point at deep frameworks
315            $base_url = $this->build_base_url();
316            $url_vars = split("&", $base_url);
317            $tmp = split("\?", $url_vars[0]);
318            $url_vars[0] = $tmp[1];
319            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.2  
changed lines
  Added in v.1.6

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