/[cvs]/nfo/php/libs/org.netfrag.patches/phphtmllib/widgets/EditDataItem.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.patches/phphtmllib/widgets/EditDataItem.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jonen, Fri Apr 4 23:58:02 2003 UTC revision 1.9 by jonen, Thu May 13 19:19:44 2004 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    -----------------------------------------------------------------------------  ##    -----------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.9  2004/05/13 19:19:44  jonen
8    ##    + bugfix: stripslashes of all posted vars was off
9    ##
10    ##    Revision 1.8  2003/12/15 21:05:19  udo
11    ##    bugfix: $PHP_SELF -> $_SERVER['PHP_SELF']
12    ##
13    ##    Revision 1.7  2003/05/10 18:04:45  jonen
14    ##    + added values needed for 'create/add new' links
15    ##
16    ##    Revision 1.6  2003/04/11 00:48:03  joko
17    ##    minor fix: calling parent constructor explicitely by name now, transparency seems not be automagically compatible with inheritance in php ,-)    (non-orthogonal)
18    ##
19    ##    Revision 1.5  2003/04/09 09:59:30  joko
20    ##    fixes regarding modification of decode-function-behavior
21    ##
22    ##    Revision 1.4  2003/04/06 01:41:33  jonen
23    ##    - removed duplicated decode functions
24    ##
25  ##    Revision 1.3  2003/04/04 23:58:02  jonen  ##    Revision 1.3  2003/04/04 23:58:02  jonen
26  ##    + saving of items sould now work with new 'GenericSource' structure  ##    + saving of items sould now work with new 'GenericSource' structure
27  ##  ##
# Line 59  class EditDataItem extends StandardFormC Line 77  class EditDataItem extends StandardFormC
77      // prefetch data      // prefetch data
78      $this->data_prefetch();      $this->data_prefetch();
79    
80      $parent =  get_parent_class($this);      // doesn't work if EditDataItem gets inherited
81      $this->$parent($title, $PHP_SELF, 600);      //$parent = get_parent_class($this);
82        //$this->$parent($title, $PHP_SELF, 600);
83        
84    //    $this->StandardFormContent($title, $PHP_SELF, 600);
85        $this->StandardFormContent($title, $_SERVER['PHP_SELF'], 600);
86        
87        // enable stripslashes of all inputs
88        $this->set_stripslashes();
89    
90    }    }
91    
92    function set_data_source(&$source) {    function set_data_source(&$source) {
# Line 98  class EditDataItem extends StandardFormC Line 124  class EditDataItem extends StandardFormC
124          //we want an confirmation page for this form.          //we want an confirmation page for this form.
125          $this->set_confirm();          $this->set_confirm();
126    
127             $utils = php::mkComponent('WebExplorer::utils');
128             $hidden = $this->get_hidden_elements();
129             $options = $this->_options['decode_args'];
130    
131          foreach($this->_datasource->_result as $key => $value) {          foreach($this->_datasource->_result as $key => $value) {
132            if($value) {            if($value) {
133              $validation = TRUE;              $validation = TRUE;
134            } else {            } else {
135              $validation = FALSE;              $validation = FALSE;
136            }            }
137            if(!$this->decode_item_expr($value, $this->_options) && !$this->decode_item_array($value, $this->_options)) {            if(!$utils->decode_item_expr($value, $hidden, $options) && !$utils->decode_item_array($value, $hidden, $options)) {
138              $this->add_element( new FEText($key, $validation, "350px") );              $this->add_element( new FEText($key, $validation, "350px") );
139            }            }
140          }          }
# Line 122  class EditDataItem extends StandardFormC Line 152  class EditDataItem extends StandardFormC
152          //and set the initial values of some of the          //and set the initial values of some of the
153          //form fields.          //form fields.
154    
155             $utils = php::mkComponent('WebExplorer::utils');
156             $hidden = $this->get_hidden_elements();
157             $options = $this->_options['decode_args'];
158    
159        foreach($this->_datasource->_result as $key => $value) {        foreach($this->_datasource->_result as $key => $value) {
160          if(!$this->decode_item_expr($value, $this->_options) && !$this->decode_item_array($value, $this->_options)) {          if(!$utils->decode_item_expr($value, $hidden, $options) && !$utils->decode_item_array($value, $hidden, $options)) {
161            $this->set_element_value($key, $value);            $this->set_element_value($key, $value);
162          }          }
163        }        }
# Line 148  class EditDataItem extends StandardFormC Line 182  class EditDataItem extends StandardFormC
182        foreach($this->_datasource->_result as $key => $value) {        foreach($this->_datasource->_result as $key => $value) {
183          // if item is match by expression we will replace it with an link object            // if item is match by expression we will replace it with an link object  
184          if($this->_options['decode']) {          if($this->_options['decode']) {
185           if($this->decode_item_expr($value)) {             $utils = php::mkComponent('WebExplorer::utils');
186            $table->add_row($key, $this->decode_item_expr($value));             $hidden = $this->get_hidden_elements();
187             $options = $this->_options['decode_args'];
188             $options[label] = $key;
189             $options[parent_guid] = $this->_options['parent']['guid'];
190             $options[parent_class] = $this->_options['parent']['class'];
191             if($utils->decode_item_expr($value, $hidden, $options)) {  
192              $table->add_row($key, $value);  
193           }             }  
194           // if item is an Array we will replace it with an selection form object             // if item is an Array we will replace it with an selection form object  
195           elseif($this->decode_item_array($value) ) {           elseif($utils->decode_item_array($value, $hidden, $options) ) {
196              $table->add_row($key, $this->decode_item_array($value));              $table->add_row($key, $value);
197           } else {           } else {
198             $table->add_row($this->element_label($key), $this->element_form($key));             $table->add_row($this->element_label($key), $this->element_form($key));
199           }           }
# Line 237  class EditDataItem extends StandardFormC Line 277  class EditDataItem extends StandardFormC
277       */       */
278      function confirm_action() {      function confirm_action() {
279    
280             $utils = php::mkComponent('WebExplorer::utils');
281             $hidden = $this->get_hidden_elements();
282             $options = $this->_options['decode_args'];
283    
284          foreach($this->_datasource->_result as $label => $value_old) {          foreach($this->_datasource->_result as $label => $value_old) {
285            if(!$this->decode_item_expr($value_old) && !$this->decode_item_array($value_old)) {            if(!$utils->decode_item_expr($value_old, $hidden, $options) && !$utils->decode_item_array($value_old, $hidden, $options)) {
286              $value_new = $this->_elements[$label]->get_value();              $value_new = $this->_elements[$label]->get_value();
287              $data[$label] = $value_new;              $data[$label] = $value_new;
288            }            }
# Line 284  class EditDataItem extends StandardFormC Line 328  class EditDataItem extends StandardFormC
328      }      }
329    
330    
331      function get_hidden_elements() {
332        foreach($this->_hidden_elements as $label => $object) {
333    function decode_item_array($item) {        $value = $this->_hidden_elements[$label]->get_value();
334      $options = $this->_options['decode_args'];        $tmp_array[$label] = $value;
     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 => $object) {  
                   $value = $this->_hidden_elements[$label]->get_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;  
     }  
   }  
   
   
   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 => $object) {  
              $value = $this->_hidden_elements[$label]->get_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;  
335      }      }
336        return $tmp_array;
337    }    }
338    
   
339  }  }
340    
341    
 ?>  
342    ?>

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