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

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

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