cvs: pear /Pager Common.php

From: Date: Tue, 29 Nov 2005 16:09:29 +0000
Subject: cvs: pear /Pager Common.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36593@lists.php.net to get a copy of this message
quipo Tue Nov 29 11:09:29 2005 EDT Modified files: /pear/Pager Common.php Log: added "formID" option to reuse an existing form in POST requests (thanks to Marc Veldman) http://cvs.php.net/diff.php/pear/Pager/Common.php?r1=1.41&r2=1.42&ty=u Index: pear/Pager/Common.php diff -u pear/Pager/Common.php:1.41 pear/Pager/Common.php:1.42 --- pear/Pager/Common.php:1.41 Tue Nov 29 11:05:52 2005 +++ pear/Pager/Common.php Tue Nov 29 11:09:27 2005 @@ -33,7 +33,7 @@ * @author Richard Heyes <richard@phpguru.org> * @copyright 2003-2005 Lorenzo Alberton, Richard Heyes * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) - * @version CVS: $Id: Common.php,v 1.41 2005/11/29 16:05:52 quipo Exp $ + * @version CVS: $Id: Common.php,v 1.42 2005/11/29 16:09:27 quipo Exp $ * @link http://pear.php.net/package/Pager */ @@ -139,6 +139,12 @@ * @access private */ var $_httpMethod = 'GET'; + + /** + * @var string specifies which HTML form to use + * @access private + */ + var $_formID = ''; /** * @var boolean whether or not to import submitted data @@ -711,14 +717,25 @@ ); return false; } - $str = 'var form = document.createElement("form"); var input = ""; '; + + if (!empty($this->_formID)) { + $str = 'var form = document.getElementById("'.$this->_formID.'"); var input = "" '; + } else { + $str = 'var form = document.createElement("form"); var input = ""; '; + } + + // We /shouldn't/ need to escape the URL ... $str .= sprintf('form.action = "%s"; ', htmlentities($formAction)); $str .= sprintf('form.method = "%s"; ', $this->_httpMethod); foreach ($data as $key => $val) { $str .= $this->_generateFormOnClickHelper($val, $key); } - $str .= 'document.getElementsByTagName("body")[0].appendChild(form);'; + + if (empty($this->_formID)) { + $str .= 'document.getElementsByTagName("body")[0].appendChild(form);'; + } + $str .= 'form.submit();'; return $str; } @@ -1215,10 +1232,13 @@ $tmp = array (); foreach ($array as $key => $value) { if (is_array($value)) { + //array_push($tmp, $this->__http_build_query($value, sprintf('%s[%s]', $name, $key))); array_push($tmp, $this->__http_build_query($value, $name.'%5B'.$key.'%5D')); } elseif (is_scalar($value)) { + //array_push($tmp, sprintf('%s[%s]=%s', $name, htmlentities($key), htmlentities($value))); array_push($tmp, $name.'%5B'.htmlentities($key).'%5D='.htmlentities($value)); } elseif (is_object($value)) { + //array_push($tmp, $this->__http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key))); array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D')); } } @@ -1266,6 +1286,7 @@ 'fileName', 'append', 'httpMethod', + 'formID', 'importQuery', 'urlVar', 'altFirst',

« previous php.pear.cvs (#36593) next »