Serializing form objects into PHP arrays

View: New views
5 Messages — Rating Filter:   Alert me  

Serializing form objects into PHP arrays

by Saeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

CPaint..

    I've readied a function which turns form objects into PHP arrays through
CPaint.  It works to my liking, and I'd be glad to share, since this would
be to everyone's benefit.  As a boon to your library though, I trust that
credit would be given where due?  All I ask is that the
@author function comment remain intact if possible.

Here's an example print_r of what ends up at the PHP function after the
cp.call, this was a form with two fields, email1, email2, a checkbox
(unchecked, when checked it sends the value), and lastly a select list which
was a multiple select, where mama and 123 were selected.

array (
  'email1' => 'some field value',
  'email2' => '',
  'checkbox' => '0',
  'listval' =>
  array (
    0 => 'mama',
    1 => '123',
  ),
  'Submit' => 'Save',
)

Cordially.
Alexandre



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Cpaint-developers mailing list
Cpaint-developers@...
https://lists.sourceforge.net/lists/listinfo/cpaint-developers

Parent Message unknown Re: Serializing form objects into PHP arrays

by John Beneke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd be happy to give credit. Where can I find the function?


>>> saeven@... 2005/09/12 08:54:06 AM >>>
CPaint..

    I've readied a function which turns form objects into PHP arrays
through
CPaint.  It works to my liking, and I'd be glad to share, since this
would
be to everyone's benefit.  As a boon to your library though, I trust
that
credit would be given where due?  All I ask is that the
@author function comment remain intact if possible.

Here's an example print_r of what ends up at the PHP function after
the
cp.call, this was a form with two fields, email1, email2, a checkbox
(unchecked, when checked it sends the value), and lastly a select list
which
was a multiple select, where mama and 123 were selected.

array (
  'email1' => 'some field value',
  'email2' => '',
  'checkbox' => '0',
  'listval' =>
  array (
    0 => 'mama',
    1 => '123',
  ),
  'Submit' => 'Save',
)

Cordially.
Alexandre



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing &
QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf 
_______________________________________________
Cpaint-developers mailing list
Cpaint-developers@...
https://lists.sourceforge.net/lists/listinfo/cpaint-developers


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Cpaint-developers mailing list
Cpaint-developers@...
https://lists.sourceforge.net/lists/listinfo/cpaint-developers

Re: Serializing form objects into PHP arrays

by Dominique Stender :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

don't worry about credit. We give full credit even on
pointing out bugs. You will be mentioned in the doc
comments if we include your code into CPAINT.

If you like, post the code in sf.net as patch, we'll
see how we can integrate it into CPAINT 2.0.2 if
possible.

Thanks in advance,
Dominique

--- "S. Alexandre M. Lemaire" <saeven@...>
wrote:

> CPaint..
>
>     I've readied a function which turns form objects
> into PHP arrays through
> CPaint.  It works to my liking, and I'd be glad to
> share, since this would
> be to everyone's benefit.  As a boon to your library
> though, I trust that
> credit would be given where due?  All I ask is that
> the
> @author function comment remain intact if possible.
>
> Here's an example print_r of what ends up at the PHP
> function after the
> cp.call, this was a form with two fields, email1,
> email2, a checkbox
> (unchecked, when checked it sends the value), and
> lastly a select list which
> was a multiple select, where mama and 123 were
> selected.
>
> array (
>   'email1' => 'some field value',
>   'email2' => '',
>   'checkbox' => '0',
>   'listval' =>
>   array (
>     0 => 'mama',
>     1 => '123',
>   ),
>   'Submit' => 'Save',
> )
>
> Cordially.
> Alexandre
>
>
>
>
-------------------------------------------------------

> SF.Net email is Sponsored by the Better Software
> Conference & EXPO
> September 19-22, 2005 * San Francisco, CA *
> Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects
> & Teams * Testing & QA
> Security * Process Improvement & Measurement *
> http://www.sqe.com/bsce5sf
> _______________________________________________
> Cpaint-developers mailing list
> Cpaint-developers@...
>
https://lists.sourceforge.net/lists/listinfo/cpaint-developers
>



               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Cpaint-developers mailing list
Cpaint-developers@...
https://lists.sourceforge.net/lists/listinfo/cpaint-developers

Re: Serializing form objects into PHP arrays

by Saeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Glad to hear, while I don't claim to have full knowledge of CPaint's functions - here's where I've placed hooks.  The functions finished, are as follows, again, I post these here with your assurance that the author comment will remain.  I'm always weary to contribute to open sourced projects, hopefully this will be a positive experience :)  I leave any testing and furthering to you, I've used this only with the standard response type.  Note that I've made use of SimpleXML (PHP5).  You could use any PHP-side XML parser to recreate the arrays, simpleXML is just a personal preference of ours.
 
Cordially.
Alexandre
 
cpaint.php
 
 
Added to the cpaint_transform object
 
 
/**
 * Unserialize a cpaint-serialized set of values
 * @author A. Lemaire, saeven.net consulting inc
 * @param  string $data A string of 'serialized|' prefixed data which is to be converted into XML.
 * @return mixed An array of values representative of the HTML form options
 */
function unserialize( $data, $encoding ){          
     
    $data = substr( $data, 11, strlen( $data ) - 11 ); 
    $xml  = simplexml_load_string( $data );
    $arr  = array();
  
    foreach( $xml->e as $e ){
        if( isset( $e->v ) )
            $arr[urldecode( (string)$e->k )] = urldecode( (string)$e->v);
        else{
            $narr = array();
            foreach( $e->m->v as $val )     
                array_push( $narr, (string)$val );         
            $arr[urldecode( (string)$e->k )] = $narr;
        }
    }
      
    return $arr;     
}
 
 
And then your array_decode function must be changed to look like this:
 
/**
    * decodes a (nested) array of data from UTF-8 into the configured character set
    *
    * @access   public
    * @param    array     $data         data to convert
    * @param    string    $encoding     character encoding
    * @return   array
    */
    function decode_array($data, $encoding) {
      $return_value = array();
     
      foreach ($data as $key => $value) {
   
      if( @substr( $value, 0, 11 ) == 'serialized|' )
         $return_value[$key] = cpaint_transformer::unserialize( $value, $encoding );       
        else
if( !is_array($value) ) {
          $return_value[$key] = cpaint_transformer::decode( $value, $encoding );
 
        } else {
          $return_value[$key] = cpaint_transformer::decode_array($value, $encoding);
        }
      }
 
      return $return_value;
    }
 
 
 
cpaint2.inc.js
 
  /**
   * Serialize a form object into CPaint-PHP usable data
   *
   * @author A. Lemaire, saeven.net consulting inc.
   * @param  string formData The form that is to be serialized
   * @access public
   * @return string XML-serialized form data
   */
  this.serializeForm = function( formData, depth ){
  oxml = "serialized|<o>";
  for( var i = 0 ; i < formData.length ; i++ ){
    
   var key  = formData[i].name;
   var value  = formData[i].value;
   var mult    = false;
   
   if( !key )
    continue;
   
   switch( formData[i].type ){
    case 'file':
     continue;
    case 'select-multiple':
     mult = true;
 
     oxml += "<e><k>" + encodeURIComponent( key ) + "</k><m>";
     for( var j = 0 ; j < formData[i].options.length ; j++ )
      if( formData[i].options[j].selected )
       oxml += "<v>" + encodeURIComponent( formData[i].options[j].value )  + "</v>";
     oxml += "</m></e>";
     break;
    case 'checkbox':
     if( formData[i].checked == false )
      value = 0;
     break;
    case 'radio':
     if( formData[i].checked == false )
      continue;
     break;
    default:
     break;
   }
   
   if( !mult )
    oxml += "<e><k>" + encodeURIComponent( key ) + "</k><v>" + encodeURIComponent( value ) + "</v></e>";
 
  }
  oxml += "</o>"; 
  return oxml;
  }
 
 
And then you must alter your call functions as follows to call the above code:
 
/**
  * internal method for remote calls to the local server without use of the proxy script.
  *
  * @access   public
  * @param    array    call_arguments    array of arguments initially passed to cpaint.call()
  * @return   void
  */
  this.call_direct = function( call_arguments ) {
    var url             = call_arguments[0];
    var remote_method   = call_arguments[1];
    var querystring     = '';
    var i               = 0;
   
    // correct link to self
    if (url == 'SELF') {
      url = document.location.href;
    }
 
    if (use_cpaint_api == true) {
      // backend uses cpaint api
      // pass parameters to remote method
      for( i = 3; i < call_arguments.length; i++ ){ 
       if( typeof( call_arguments[i] ) == 'object' && call_arguments[i].tagName == 'FORM' )
        call_arguments[i] = this.serializeForm( call_arguments[i].elements, 0 );
        querystring += '&cpaint_argument[]=' + encodeURIComponent(call_arguments[i]);
      }
   
      // add response type to querystring
      querystring += '&cpaint_response_type=' + response_type;
   
      // build header
      if (transfer_mode == 'GET') {
        url = url + '?cpaint_function=' + remote_method + querystring;
   
      } else {
        querystring = 'cpaint_function=' + remote_method + querystring;
      }
     
    } else {
      // backend does not use cpaint api
      // pass parameters to remote method
      for (i = 3; i < call_arguments.length; i++) {
        if (i == 3) {
          querystring += encodeURIComponent(call_arguments[i]);
       
        } else {
          querystring += '&' + encodeURIComponent(call_arguments[i]);
        }
      }
   
      // build header
      if (transfer_mode == 'GET') {
        url = url + querystring;
      }
    }
 
    // open connection
    get_connection_object();
 
    // open connection to remote target
    debug('opening connection to "' + url + '"', 1);
    httpobj.open(transfer_mode, url, async);
 
    // send "urlencoded" header if necessary (if POST)
    if (transfer_mode == "POST") {
 
      try {
        httpobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
      } catch (cp_err) {
        alert('ERROR! POST cannot be completed due to incompatible browser.  Use GET as your request method.');
      }
    }
 
    // callback handling for asynchronous calls
    httpobj.onreadystatechange = callback;
 
    // send content
    if (transfer_mode == 'GET') {
      httpobj.send(null);
 
    } else {
      debug('sending query: ' + querystring, 1);
      httpobj.send(querystring);
    }
 
    if (async == false) {
      // manual callback handling for synchronized calls
      callback();
    }
  }
 
 
  /**
  * internal method for calls to remote servers through the proxy script.
  *
  * @access   public
  * @param    array    call_arguments    array of arguments passed to cpaint.call()
  * @return   void
  */
  this.call_proxy = function(call_arguments) {
    var proxyscript     = proxy_url;
    var url             = call_arguments[0];
    var remote_method   = call_arguments[1];
    var querystring     = '';
    var i               = 0;
   
 
    var querystring_argument_prefix = 'cpaint_argument[]=';
 
    // pass parameters to remote method
    if (use_cpaint_api == false) {
      // when not talking to a CPAINT backend, don't prefix arguments
      querystring_argument_prefix = '';
    }
 
    for (i = 3; i < call_arguments.length; i++) {
     if( typeof( call_arguments[i] ) == 'object' && call_arguments[i].tagName == 'FORM' )
        call_arguments[i] = this.serializeForm( call_arguments[i].elements, 0 );
      querystring += encodeURIComponent(querystring_argument_prefix + call_arguments[i] + '&');
    }
 
    if (use_cpaint_api == true) {
      // add remote function name to querystring
      querystring += encodeURIComponent('&cpaint_function=' + remote_method);
 
      // add response type to querystring
      querystring += encodeURIComponent('&cpaint_responsetype=' + response_type);
    }
   
    // build header
    if (transfer_mode == 'GET') {
      proxyscript += '?cpaint_remote_url=' + encodeURIComponent(url)
        + '&cpaint_remote_query=' + querystring
        + '&cpaint_remote_method=' + transfer_mode
        + '&cpaint_response_type=' + response_type;
 
    } else {
      querystring = 'cpaint_remote_url=' + encodeURIComponent(url)
        + '&cpaint_remote_query=' + querystring
        + '&cpaint_remote_method=' + transfer_mode
        + '&cpaint_response_type=' + response_type;
    }
 
    // open connection
    get_connection_object();
 
    // open connection to remote target
    debug('opening connection to proxy "' + proxyscript + '"', 1);
    httpobj.open(transfer_mode, proxyscript, async);
 
    // send "urlencoded" header if necessary (if POST)
    if (transfer_mode == "POST") {
 
      try {
        httpobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
      } catch (cp_err) {
        alert('[CPAINT Error] POST cannot be completed due to incompatible browser.  Use GET as your request method.');
      }
    }
 
    // callback handling for asynchronous calls
    httpobj.onreadystatechange = callback;
 
    // send content
    if (transfer_mode == 'GET') {
      httpobj.send(null);
 
    } else {
      debug('sending query: ' + querystring, 1);
      httpobj.send(querystring);
    }
 
    if (async == false) {
      // manual callback handling for synchronized calls
      callback();
    }
  }
 
 
Regards.
Alex
 
----- Original Message -----
From: "Dominique Stender" <saloon12yrd@...>
Sent: Monday, September 12, 2005 3:18 AM
Subject: Re: [Cpaint-developers] Serializing form objects into PHP arrays

Hi,

don't worry about credit. We give full credit even on
pointing out bugs. You will be mentioned in the doc
comments if we include your code into CPAINT.

If you like, post the code in sf.net as patch, we'll
see how we can integrate it into CPAINT 2.0.2 if
possible.

Thanks in advance,
Dominique

--- "S. Alexandre M. Lemaire" <
saeven@...>
wrote:

> CPaint..
>
>     I've readied a function which turns form objects
> into PHP arrays through
> CPaint.  It works to my liking, and I'd be glad to
> share, since this would
> be to everyone's benefit.  As a boon to your library
> though, I trust that
> credit would be given where due?  All I ask is that
> the
> @author function comment remain intact if possible.
>
> Here's an example print_r of what ends up at the PHP
> function after the
> cp.call, this was a form with two fields, email1,
> email2, a checkbox
> (unchecked, when checked it sends the value), and
> lastly a select list which
> was a multiple select, where mama and 123 were
> selected.
>
> array (
>   'email1' => 'some field value',
>   'email2' => '',
>   'checkbox' => '0',
>   'listval' =>
>   array (
>     0 => 'mama',
>     1 => '123',
>   ),
>   'Submit' => 'Save',
> )
>
> Cordially.
> Alexandre
>
>
>
>
-------------------------------------------------------
> SF.Net email is Sponsored by the Better Software
> Conference & EXPO
> September 19-22, 2005 * San Francisco, CA *
> Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects
> & Teams * Testing & QA
> Security * Process Improvement & Measurement *
>
http://www.sqe.com/bsce5sf
> _______________________________________________
> Cpaint-developers mailing list
>
Cpaint-developers@...
>
https://lists.sourceforge.net/lists/listinfo/cpaint-developers
>




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Cpaint-developers mailing list
Cpaint-developers@...
https://lists.sourceforge.net/lists/listinfo/cpaint-developers


Re: Serializing form objects into PHP arrays

by Dominique Stender :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alexandre,

thanks for the code. I'll be looking at it next week
(I'm out of town until sunday), so don't wonder if you
don't hear from us :).

Thanks,
Dominique

--- "S. Alexandre M. Lemaire" <saeven@...>
wrote:

> Glad to hear, while I don't claim to have full
> knowledge of CPaint's functions - here's where I've
> placed hooks.  The functions finished, are as
> follows, again, I post these here with your
> assurance that the author comment will remain.  I'm
> always weary to contribute to open sourced projects,
> hopefully this will be a positive experience :)  I
> leave any testing and furthering to you, I've used
> this only with the standard response type.  Note
> that I've made use of SimpleXML (PHP5).  You could
> use any PHP-side XML parser to recreate the arrays,
> simpleXML is just a personal preference of ours.
>
> Cordially.
> Alexandre
>
> cpaint.php
>
>
> Added to the cpaint_transform object
>
>
> /**
>  * Unserialize a cpaint-serialized set of values
>  * @author A. Lemaire, saeven.net consulting inc
>  * @param  string $data A string of 'serialized|'
> prefixed data which is to be converted into XML.
>  * @return mixed An array of values representative
> of the HTML form options
>  */
> function unserialize( $data, $encoding ){          
>      
>     $data = substr( $data, 11, strlen( $data ) - 11
> );  
>     $xml  = simplexml_load_string( $data );
>     $arr  = array();
>  
>     foreach( $xml->e as $e ){
>         if( isset( $e->v ) )
>             $arr[urldecode( (string)$e->k )] =
> urldecode( (string)$e->v);
>         else{
>             $narr = array();
>             foreach( $e->m->v as $val )    
>                 array_push( $narr, (string)$val );  
>      
>             $arr[urldecode( (string)$e->k )] =
> $narr;
>         }
>     }
>      
>     return $arr;    
> }
>
>
> And then your array_decode function must be changed
> to look like this:
>
> /**
>     * decodes a (nested) array of data from UTF-8
> into the configured character set
>     *
>     * @access   public
>     * @param    array     $data         data to
> convert
>     * @param    string    $encoding     character
> encoding
>     * @return   array
>     */
>     function decode_array($data, $encoding) {
>       $return_value = array();
>      
>       foreach ($data as $key => $value) {
>    
>       if( @substr( $value, 0, 11 ) == 'serialized|'
> )
>          $return_value[$key] =
> cpaint_transformer::unserialize( $value, $encoding
> );      
>         else if( !is_array($value) ) {
>           $return_value[$key] =
> cpaint_transformer::decode( $value, $encoding );
>
>         } else {
>           $return_value[$key] =
> cpaint_transformer::decode_array($value, $encoding);
>         }
>       }
>
>       return $return_value;
>     }
>
>
> cpaint2.inc.js
>
>   /**
>    * Serialize a form object into CPaint-PHP usable
> data
>    *
>    * @author A. Lemaire, saeven.net consulting inc.
>    * @param  string formData The form that is to be
> serialized
>    * @access public
>    * @return string XML-serialized form data
>    */
>   this.serializeForm = function( formData, depth ){
>   oxml = "serialized|<o>";
>   for( var i = 0 ; i < formData.length ; i++ ){
>    
>    var key  = formData[i].name;
>    var value  = formData[i].value;
>    var mult    = false;
>    
>    if( !key )
>     continue;
>    
>    switch( formData[i].type ){
>     case 'file':
>      continue;
>     case 'select-multiple':
>      mult = true;
>
>      oxml += "<e><k>" + encodeURIComponent( key ) +
> "</k><m>";
>      for( var j = 0 ; j < formData[i].options.length
> ; j++ )
>       if( formData[i].options[j].selected )
>        oxml += "<v>" + encodeURIComponent(
> formData[i].options[j].value )  + "</v>";
>      oxml += "</m></e>";
>      break;
>     case 'checkbox':
>      if( formData[i].checked == false )
>       value = 0;
>      break;
>     case 'radio':
>      if( formData[i].checked == false )
>       continue;
>      break;
>     default:
>      break;
>    }
>    
>    if( !mult )
>     oxml += "<e><k>" + encodeURIComponent( key ) +
> "</k><v>" + encodeURIComponent( value ) +
> "</v></e>";
>
>   }
>   oxml += "</o>";
>   return oxml;
>   }
>
>
> And then you must alter your call functions as
> follows to call the above code:
>
> /**
>   * internal method for remote calls to the local
> server without use of the proxy script.
>   *
>   * @access   public
>   * @param    array    call_arguments    array of
> arguments initially passed to cpaint.call()
>   * @return   void
>   */
>   this.call_direct = function( call_arguments ) {
>     var url             = call_arguments[0];
>     var remote_method   = call_arguments[1];
>     var querystring     = '';
>     var i               = 0;
>    
>     // correct link to self
>     if (url == 'SELF') {
>       url = document.location.href;
>     }
>  
>     if (use_cpaint_api == true) {
>       // backend uses cpaint api
>       // pass parameters to remote method
>       for( i = 3; i < call_arguments.length; i++ ){
>        if( typeof( call_arguments[i] ) == 'object'
> && call_arguments[i].tagName == 'FORM' )
>         call_arguments[i] = this.serializeForm(
> call_arguments[i].elements, 0 );
>         querystring += '&cpaint_argument[]=' +
> encodeURIComponent(call_arguments[i]);
>       }
>    
>       // add response type to querystring
>       querystring += '&cpaint_response_type=' +
> response_type;
>    
>       // build header
>       if (transfer_mode == 'GET') {
>         url = url + '?cpaint_function=' +
> remote_method + querystring;
>    
>       } else {
>         querystring = 'cpaint_function=' +
> remote_method + querystring;
>       }
>      
>     } else {
>       // backend does not use cpaint api
>       // pass parameters to remote method
>       for (i = 3; i < call_arguments.length; i++) {
>         if (i == 3) {
>           querystring +=
> encodeURIComponent(call_arguments[i]);
>        
>         } else {
>           querystring += '&' +
> encodeURIComponent(call_arguments[i]);
>         }
>       }
>    
>       // build header
>       if (transfer_mode == 'GET') {
>         url = url + querystring;
>       }
>     }
>  
>     // open connection
>     get_connection_object();
>
>     // open connection to remote target
>     debug('opening connection to "' + url + '"', 1);
>     httpobj.open(transfer_mode, url, async);
>
>     // send "urlencoded" header if necessary (if
> POST)
>     if (transfer_mode == "POST") {
>
>       try {
>         httpobj.setRequestHeader("Content-Type",
> "application/x-www-form-urlencoded");
>
>       } catch (cp_err) {
>         alert('ERROR! POST cannot be completed due
> to incompatible browser.  Use GET as your request
> method.');
>       }
>     }
>
>     // callback handling for asynchronous calls
>     httpobj.onreadystatechange = callback;
>
>     // send content
>     if (transfer_mode == 'GET') {
>       httpobj.send(null);
>
>     } else {
>       debug('sending query: ' + querystring, 1);
>       httpobj.send(querystring);
>     }
>
>     if (async == false) {
>       // manual callback handling for synchronized
> calls
>       callback();
>     }
>   }
>  
>  
>   /**
>   * internal method for calls to remote servers
> through the proxy script.
>   *
>   * @access   public
>   * @param    array    call_arguments    array of
> arguments passed to cpaint.call()
>   * @return   void
>   */
>   this.call_proxy = function(call_arguments) {
>     var proxyscript     = proxy_url;
>     var url             = call_arguments[0];
>     var remote_method   = call_arguments[1];
>     var querystring     = '';
>     var i               = 0;
>    
>  
>     var querystring_argument_prefix =
> 'cpaint_argument[]=';
>
>     // pass parameters to remote method
>     if (use_cpaint_api == false) {
>       // when not talking to a CPAINT backend, don't
> prefix arguments
>       querystring_argument_prefix = '';
>     }
>
>     for (i = 3; i < call_arguments.length; i++) {
>      if( typeof( call_arguments[i] ) == 'object' &&
> call_arguments[i].tagName == 'FORM' )
>         call_arguments[i] = this.serializeForm(
> call_arguments[i].elements, 0 );
>       querystring +=
> encodeURIComponent(querystring_argument_prefix +
> call_arguments[i] + '&');
>     }
>
>     if (use_cpaint_api == true) {
>       // add remote function name to querystring
>       querystring +=
> encodeURIComponent('&cpaint_function=' +
> remote_method);
>  
>       // add response type to querystring
>       querystring +=
> encodeURIComponent('&cpaint_responsetype=' +
> response_type);
>     }
>    
>     // build header
>     if (transfer_mode == 'GET') {
>       proxyscript += '?cpaint_remote_url=' +
> encodeURIComponent(url)
>         + '&cpaint_remote_query=' + querystring
>         + '&cpaint_remote_method=' + transfer_mode
>         + '&cpaint_response_type=' + response_type;
>
>     } else {
>       querystring = 'cpaint_remote_url=' +
> encodeURIComponent(url)
>         + '&cpaint_remote_query=' + querystring
>         + '&cpaint_remote_method=' + transfer_mode
>         + '&cpaint_response_type=' + response_type;
>     }
>
>     // open connection
>     get_connection_object();
>
>     // open connection to remote target
>     debug('opening connection to proxy "' +
> proxyscript + '"', 1);
>     httpobj.open(transfer_mode, proxyscript, async);
>
>     // send "urlencoded" header if necessary (if
> POST)
>     if (transfer_mode == "POST") {
>
>       try {
>         httpobj.setRequestHeader("Content-Type",
> "application/x-www-form-urlencoded");
>
>       } catch (cp_err) {
>         alert('[CPAINT Error] POST cannot be
> completed due to incompatible browser.  Use GET as
> your request method.');
>       }
>     }
>
>     // callback handling for asynchronous calls
>     httpobj.onreadystatechange = callback;
>
>     // send content
>     if (transfer_mode == 'GET') {
>       httpobj.send(null);
>
>     } else {
>       debug('sending query: ' + querystring, 1);
>       httpobj.send(querystring);
>     }
>
>     if (async == false) {
>       // manual callback handling for synchronized
> calls
>       callback();
>     }
>   }
>
>
> Regards.
> Alex
>
> ----- Original Message -----
> From: "Dominique Stender" <saloon12yrd@...>
> To: <cpaint-developers@...>
> Sent: Monday, September 12, 2005 3:18 AM
> Subject: Re: [Cpaint-developers] Serializing form
> objects into PHP arrays
>
>
> Hi,
>
> don't worry about credit. We give full credit even
> on
> pointing out bugs. You will be mentioned in the doc
> comments if we include your code into CPAINT.
>
> If you like, post the code in sf.net as patch, we'll
> see how we can integrate it into CPAINT 2.0.2 if
> possible.
>
> Thanks in advance,
> Dominique
>
> --- "S. Alexandre M. Lemaire" <saeven@...>
> wrote:
>
> > CPaint..
> >
> >     I've readied a function which turns form
> objects
> > into PHP arrays through
> > CPaint.  It works to my liking, and I'd be glad to
> > share, since this would
> > be to everyone's benefit.  As a boon to your
> library
> > though, I trust that
> > credit would be given where due?  All I ask is
> that
> > the
> > @author function comment remain intact if
> possible.
> >
> > Here's an example print_r of what ends up at the
> PHP
> > function after the
> > cp.call, this was a form with two fields, email1,
> > email2, a checkbox
> > (unchecked, when checked it sends the value), and
> > lastly a select list which
> > was a multiple select, where mama and 123 were
> > selected.
> >
> > array (
> >   'email1' => 'some field value',
> >   'email2' => '',
> >   'checkbox' => '0',
> >   'listval' =>
> >   array (
> >     0 => 'mama',
> >     1 => '123',
> >   ),
> >   'Submit' => 'Save',
> > )
> >
> > Cordially.
> > Alexandre
> >
> >
> >
> >
>
-------------------------------------------------------

> > SF.Net email is Sponsored by the Better Software
> > Conference & EXPO
> > September 19-22, 2005 * San Francisco, CA *
> > Development Lifecycle Practices
> > Agile & Plan-Driven Development * Managing
> Projects
> > & Teams * Testing & QA
> > Security * Process Improvement & Measurement *
> > http://www.sqe.com/bsce5sf
> > _______________________________________________
> > Cpaint-developers mailing list
> > Cpaint-developers@...
> >
>
https://lists.sourceforge.net/lists/listinfo/cpaint-developers

> >
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
>
>
-------------------------------------------------------

> SF.Net email is Sponsored by the Better Software
> Conference & EXPO
> September 19-22, 2005 * San Francisco, CA *
> Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects
> & Teams * Testing & QA
> Security * Process Improvement & Measurement *
> http://www.sqe.com/bsce5sf
> _______________________________________________
> Cpaint-developers mailing list
> Cpaint-developers@...
>
https://lists.sourceforge.net/lists/listinfo/cpaint-developers
>
>



       
               
______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/ 



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Cpaint-developers mailing list
Cpaint-developers@...
https://lists.sourceforge.net/lists/listinfo/cpaint-developers