/[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.10 by jonen, Fri Apr 18 18:40:02 2003 UTC
# Line 1  Line 1 
1  <?  <?
2  /*  /*
3  ##    -----------------------------------------------------------------------------  ## -------------------------------------------------------------------------
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ## -------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.10  2003/04/18 18:40:02  jonen
8    ##    + fixed bugs at 'actionbar_cell' relating to html-form and js
9    ##
10    ##    Revision 1.9  2003/04/11 00:44:46  joko
11    ##    minor update: shortened seperators
12    ##
13    ##    Revision 1.8  2003/04/09 07:54:42  joko
14    ##    cleaned up decoding part
15    ##
16    ##    Revision 1.7  2003/04/09 00:37:53  jonen
17    ##    + added actionbar
18    ##    + some changes according to request vars
19    ##
20    ##    Revision 1.6  2003/04/08 17:48:31  jonen
21    ##    + bugfix again
22    ##
23    ##    Revision 1.5  2003/04/08 17:33:22  jonen
24    ##    + fixed problems with hidden form fields(current base URL) at the 'simple search form'
25    ##
26    ##    Revision 1.4  2003/04/06 01:41:07  jonen
27    ##    - removed duplicated decode functions
28    ##
29  ##    Revision 1.3  2003/04/04 21:26:06  joko  ##    Revision 1.3  2003/04/04 21:26:06  joko
30  ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure  ##    added comments regarding possible (future) refactoring using the Data::Lift-infrastructure
31  ##  ##
# Line 22  Line 44 
44  ##    Revision 1.1  2003/03/01 22:57:40  cvsmax  ##    Revision 1.1  2003/03/01 22:57:40  cvsmax
45  ##    + inital commit  ##    + inital commit
46  ##  ##
47  ##  ## -------------------------------------------------------------------------
 ##    -----------------------------------------------------------------------------  
48  */  */
49    
50    
51  /**  /**
52   * Need to make sure we have the DefaultGUIDataList object   * Need to make sure we have the DefaultGUIDataList object
53   */   */
# Line 51  class GenericGUIDataList extends Default Line 73  class GenericGUIDataList extends Default
73    */    */
74    var $_hidden_elements = array();    var $_hidden_elements = array();
75    
76    
77  /**  /**
78    * The constructor is used to pass in some additional    * The constructor is used to pass in some additional
79    * metadata informations as "options".    * metadata informations as "options".
# Line 73  class GenericGUIDataList extends Default Line 96  class GenericGUIDataList extends Default
96    */    */
97    function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {    function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {
98      if ($options) { $this->_options = $options; }      if ($options) { $this->_options = $options; }
99    
100        // call parent constructor
101      $parent =  get_parent_class($this);      $parent =  get_parent_class($this);
102      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);      $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);    
103    }    }
104    
105    
106    function get_data_source( ) {    function get_data_source( ) {
107    
108      // finally: create phpHtmlLib source handle (XyzDataListSource)      // finally: create phpHtmlLib source handle (XyzDataListSource)
# Line 212  class GenericGUIDataList extends Default Line 238  class GenericGUIDataList extends Default
238                        
239            */            */
240    
241              $utils = php::mkComponent('WebExplorer::utils');
242            // 1. if item is match by expression we will replace it with an link object              $hidden = $this->_hidden_elements;
243            if ($this->decode_item_expr($obj)) {              $options = $this->_options['decode_args'];
244              $obj = $this->decode_item_expr($obj);              
245            }            // a) Iterate through the attributes of the item and replace each
246              // value with an appropriate link object if it has a certain format.
247            // 2. if item is an Array we will replace it with an selection form object              if ($utils->decode_item_expr($obj, $hidden, $options)) {
248            elseif ( $this->decode_item_array($obj) ) {  
249              $obj = $this->decode_item_array($obj);              // b) Otherwise: If item is an Array we will replace it with a selection form object.
250              } else {
251                $utils->decode_item_array($obj, $hidden, $options);
252            }            }
253    
254          }          }
# Line 254  class GenericGUIDataList extends Default Line 282  class GenericGUIDataList extends Default
282      }      }
283    
284    
285    // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      /**
286    function decode_item_array($item) {       * This function builds the simple search TD
287      $options = $this->_options['decode_args'];       *
288      //print "item: " . Dumper($item);       * @return ContainerWidget
289      //print "options: " . Dumper($options);       */
290      if( is_array($item) ) {      function _build_simple_search_form() {
291            //$cur_row_index = $this->_datasource->get_cur_data_index();  
292            //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];          //if there is only 1 item enabled for search
293            // build list for selection form          //then the search looks simple.
294         if($options['form']) {          $fields = $this->_get_searchable_fields();
295            foreach($item as $key => $value) {          $cnt = count($fields);
296                  $tmp = split($options['seperator'], $value);          if ($cnt == 0) {
297                  $ident = $tmp['1'];              return NULL;
298                  $meta = $tmp['2'];          }
299                  $list[$key] = $ident;  
300                  }          $container = new ContainerWidget;
301                  if(is_array($list) ) {          
302                $container = container(          // get current request vars and add them ad hidden items
303                    form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),          $url_vars = $this->_get_current_url_vars();
304                    form_hidden("ecdm", $meta),          foreach($url_vars as $label => $value) {
305                    form_select("ecdid", $list),            $container->push(form_hidden($label, $value));
306                    form_submit("submit","view" )          }
307                    );  
308                 foreach($this->_hidden_elements as $label => $value) {          if ($cnt == 1) {
309                   $container->add(form_hidden($label, $value));              //user only has 1 field to show.
310                 }              list($name, $field) = each($fields);
311                $container->add(form_close() );              $container->push("Find ".$name."&nbsp;&nbsp;");
               $item = $container;  
               }  
312          } else {          } else {
313            //print "<b>2</b><br/>";              //user has many fields to show.
314            $container = container();              $container->push("Find ",
315            foreach($item as $key => $value) {                               form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
                 $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;  
316          }          }
317                return $item;  
318            if ($this->get_simple_search_modifier()) {
319                //the user wants the search modifier turned on.
320                $container->push($this->_build_simple_search_modifier());
321            }
322    
323            $container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")),
324                             form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;")));
325    
326            if ($this->is_advanced_search_enabled()) {
327                $span = html_span(html_a("ass","Advanced Search", "title"));
328                $container->push("&nbsp;", $span);
329            }
330    
331            if ($cnt == 1) {
332                $container->push(form_hidden($this->_vars["search_fieldVar"], $field));
333            }
334    
335    
336            //$container->push(form_close() );
337            return $container;
338      }      }
   }  
339    
340    // decodes serialized string representations of object-references  
341    // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!      /**
342    function decode_item_expr($item) {       * this is the method that builds
343      $options = $this->_options['decode_args'];       * the contents for the middle actionbar
344      //print "item: $item<br/>";       * td cell.
345      if(substr($item, 0, 2) == "o_") {       *
346            $tmp = split($options['seperator'], $item);       * @return ContainerWidget object
347            $ident = $tmp['1'];       */
348            $meta = $tmp['2'];      function actionbar_cell() {
349            foreach($this->_hidden_elements as $label => $value) {          $action_list = $this->_options['actionbar']['list'];
350               $tmp_array[] = $label . "=" . $value;          $action_name = $this->_options['actionbar']['name'];
351    
352            if($action_name && is_array($action_list)) {
353              $action_form = container("Select action", _HTML_SPACE,
354                                 form_select($action_name, $action_list),
355                                 form_submit("ok","OK" )                            
356                                 );
357              return $action_form;
358            } else {
359              return _HTML_SPACE;
360            }
361        }
362    
363    
364        /*
365         * this method returns the current requested variables
366         *
367         * @return array
368         */
369        function _get_current_url_vars() {
370            $cur_url_vars = array();
371    
372            // get new LinkBuilder instance
373            $linkbuilder = new LinkBuilder();
374    
375            $url_vars = php::array_join_merge($_GET, $_POST);
376            if(is_array($url_vars)) {
377              foreach($url_vars as $key => $value) {
378                   // if there is an LinkBuilder guid instead of variables, encode it
379                   if($key == 'lbid') {
380                     $lb_vars = $linkbuilder->load($value);
381                     foreach($lb_vars as $lbkey => $lbval) {
382                       $cur_url_vars[$lbkey] = $lbval;
383                     }
384                   } else {
385                     $cur_url_vars[$key] = $value;
386                   }
387            }            }
388            $str_hidden = join("&", $tmp_array);          }
389            $item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");          return $cur_url_vars;
           return $item;  
390      }      }
   }  
391    
392  }  }
393  ?>  ?>

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

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