/[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.4 by jonen, Sun Apr 6 01:41:07 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  ##    Revision 1.4  2003/04/06 01:41:07  jonen
27  ##    - removed duplicated decode functions  ##    - removed duplicated decode functions
28  ##  ##
# Line 25  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 54  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 76  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 219  class GenericGUIDataList extends Default Line 242  class GenericGUIDataList extends Default
242            $hidden = $this->_hidden_elements;            $hidden = $this->_hidden_elements;
243            $options = $this->_options['decode_args'];            $options = $this->_options['decode_args'];
244                        
245            // 1. if item is match by expression we will replace it with an link object              // a) Iterate through the attributes of the item and replace each
246            if ($utils->decode_item_expr($obj, $hidden, $options)) {              // value with an appropriate link object if it has a certain format.
247              $obj = $utils->decode_item_expr($obj, $hidden, $options);              if ($utils->decode_item_expr($obj, $hidden, $options)) {
248            }  
249              // b) Otherwise: If item is an Array we will replace it with a selection form object.
250            // 2. if item is an Array we will replace it with an selection form object              } else {
251            elseif ( $utils->decode_item_array($obj, $hidden, $options) ) {              $utils->decode_item_array($obj, $hidden, $options);
             $obj = $utils->decode_item_array($obj, $hidden, $options);    
252            }            }
253    
254          }          }
# Line 260  class GenericGUIDataList extends Default Line 282  class GenericGUIDataList extends Default
282      }      }
283    
284    
285        /**
286         * This function builds the simple search TD
287         *
288         * @return ContainerWidget
289         */
290        function _build_simple_search_form() {
291    
292            //if there is only 1 item enabled for search
293            //then the search looks simple.
294            $fields = $this->_get_searchable_fields();
295            $cnt = count($fields);
296            if ($cnt == 0) {
297                return NULL;
298            }
299    
300            $container = new ContainerWidget;
301            
302            // get current request vars and add them ad hidden items
303            $url_vars = $this->_get_current_url_vars();
304            foreach($url_vars as $label => $value) {
305              $container->push(form_hidden($label, $value));
306            }
307    
308            if ($cnt == 1) {
309                //user only has 1 field to show.
310                list($name, $field) = each($fields);
311                $container->push("Find ".$name."&nbsp;&nbsp;");
312            } else {
313                //user has many fields to show.
314                $container->push("Find ",
315                                 form_select($this->_vars["search_fieldVar"], $fields, $this->search_field()));
316            }
317    
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    
341        /**
342         * this is the method that builds
343         * the contents for the middle actionbar
344         * td cell.
345         *
346         * @return ContainerWidget object
347         */
348        function actionbar_cell() {
349            $action_list = $this->_options['actionbar']['list'];
350            $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            }
389            return $cur_url_vars;
390        }
391    
392  }  }
393  ?>  ?>

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

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