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

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