/[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.4 by jonen, Sun Apr 6 01:41:07 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.4  2003/04/06 01:41:07  jonen
8    ##    - removed duplicated decode functions
9    ##
10    ##    Revision 1.3  2003/04/04 21:26:06  joko
11    ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure
12    ##
13  ##    Revision 1.2  2003/04/04 00:45:40  jonen  ##    Revision 1.2  2003/04/04 00:45:40  jonen
14  ##    + reworked decode functions  ##    + reworked decode functions
15  ##  ##
# Line 179  class GenericGUIDataList extends Default Line 185  class GenericGUIDataList extends Default
185    
186          //make sure its set to something.          //make sure its set to something.
187          if ($obj == '') {          if ($obj == '') {
188              $obj = " ";            $obj = " ";
189          }          }
190          // if item is match by expression we will replace it with an link object            
191          elseif($this->_options['decode']) {          // decode item / mungle item data?
192           if($this->decode_item_expr($obj)) {            // TODO: use Data::Lift here!!! (like already done in YAA::JobList and YAA::JobDetails)
193            $obj = $this->decode_item_expr($obj);            elseif ($this->_options['decode']) {
194            }    
195            // if item is an Array we will replace it with an selection form object              // Proposal using Data::Lift: (see YAA::JobList and YAA::JobDetails)
196            elseif($this->decode_item_array($obj) ) {            // This class will get shorter and better to maintain!
197              $obj = $this->decode_item_array($obj);              
198              // Picture Data::Lift as a container component handling
199              // *specific* en-/decoding stuff for your very core components.
200              // This way we will have almost all "specific mungling code" at one place. nice thing!
201              
202              /*
203    
204              // 1. expr: string -> object (phpHtmlLib-object: 'html_a'-tag)
205                // returns a phpHtmlLib object of class 'Xyz' containing a http-/html-link
206                // pointing to a View of a different - linked/referenced - object (reference-interpolation)
207                $this->lift1 = php::mkComponent('Data::Lift', $obj, array( metatype => 'expression' ) );
208                $obj = $this->lift1->to('phpHtmlLib::html_a');
209    
210              // 2. data: hash -> object (phpHtmlLib-object: 'container'-object containing form)
211                // returns a phpHtmlLib object of class 'Container' containing a html-form made up of
212                // phpHtmlLib form-tags wrapping all attribute-value pairs of the data hash (object-edit)
213                $this->lift2 = php::mkComponent('Data::Lift', $obj, array( metatype => 'item' ) );
214                $obj = $this->lift2->to('phpHtmlLib::form');
215              
216              */
217    
218              $utils = php::mkComponent('WebExplorer::utils');
219              $hidden = $this->_hidden_elements;
220              $options = $this->_options['decode_args'];
221              
222              // 1. if item is match by expression we will replace it with an link object  
223              if ($utils->decode_item_expr($obj, $hidden, $options)) {  
224                $obj = $utils->decode_item_expr($obj, $hidden, $options);  
225              }
226    
227              // 2. if item is an Array we will replace it with an selection form object  
228              elseif ( $utils->decode_item_array($obj, $hidden, $options) ) {
229                $obj = $utils->decode_item_array($obj, $hidden, $options);  
230            }            }
231    
232          }          }
233    
234          //make sure we don't put a right border on the last          //make sure we don't put a right border on the last
235          //column we are working on.          //column we are working on.
236          //$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 260  class GenericGUIDataList extends Default
260      }      }
261    
262    
   function decode_item_array($item) {  
     $options = $this->_options['decode_args'];  
     if( is_array($item) ) {  
           //$cur_row_index = $this->_datasource->get_cur_data_index();  
           //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];  
           // build list for selection form  
        if($options['form']) {  
           foreach($item as $key => $value) {  
                 $tmp = split($options['seperator'], $value);  
                 $ident = $tmp['1'];  
                 $meta = $tmp['2'];  
                 $list[$key] = $ident;  
                 }  
                 if(is_array($list) ) {  
               $container = container(  
                   form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),  
                   form_hidden("ecdm", $meta),  
                   form_select("ecdid", $list),  
                   form_submit("submit","view" )  
                   );  
                foreach($this->_hidden_elements as $label => $value) {  
                  $container->add(form_hidden($label, $value));  
                }  
               $container->add(form_close() );  
               $item = $container;  
               }  
         } else {  
           $container = container();  
           foreach($item as $key => $value) {  
                 $tmp = split($options['seperator'], $value);  
                 $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;  
         }  
               return $item;  
     }  
   }  
263    
   function decode_item_expr($item) {  
     $options = $this->_options['decode_args'];  
     if(substr($item, 0, 2) == "o_") {  
           $tmp = split($options['seperator'], $item);  
           $ident = $tmp['1'];  
           $meta = $tmp['2'];  
           foreach($this->_hidden_elements as $label => $value) {  
              $tmp_array[] = $label . "=" . $value;  
           }  
           $str_hidden = join("&", $tmp_array);  
           $item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");  
           return $item;  
     }  
   }  
264    
265  }  }
266  ?>  ?>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

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