cvs: pear /Structures_DataGrid package2.xml /Structures_DataGrid/DataGrid Renderer.php
| From: | Olivier Guilyardi | Date: | Mon, 19 Jun 2006 17:39:18 +0000 |
| Subject: | cvs: pear /Structures_DataGrid package2.xml /Structures_DataGrid/DataGrid Renderer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-40825@lists.php.net to get a copy of this message | ||
olivierg Mon Jun 19 17:39:18 2006 UTC
Modified files:
/pear/Structures_DataGrid package2.xml
/pear/Structures_DataGrid/DataGrid Renderer.php
Log:
removed PHP_Compat dependency (for http_build_query(), now directly bundled)
http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/package2.xml?r1=1.11&r2=1.12&diff_format=u
Index: pear/Structures_DataGrid/package2.xml
diff -u pear/Structures_DataGrid/package2.xml:1.11 pear/Structures_DataGrid/package2.xml:1.12
--- pear/Structures_DataGrid/package2.xml:1.11 Mon Jun 19 16:04:06 2006
+++ pear/Structures_DataGrid/package2.xml Mon Jun 19 17:39:18 2006
@@ -30,10 +30,10 @@
<active>yes</active>
</lead>
<date>2006-06-19</date>
- <time>18:00:00</time>
+ <time>19:40:00</time>
<version>
- <release>0.7.0</release>
- <api>0.7.0</api>
+ <release>0.7.1</release>
+ <api>0.7.1</api>
</version>
<stability>
<release>beta</release>
@@ -103,8 +103,7 @@
- new DataSource drivers: DBTable, DBQuery and MDB2
- query building:
The query building process has been optimized, and is now more
- flexible due to the use of http_build_query(). This adds a
- new dependency: PHP_Compat >= 1.4.1.
+ flexible due to the use of http_build_query().
- custom rendering containers:
The containers that rendering drivers use to do their job, such as
HTML_Table, Spreadsheet_Excel_Writer, etc. can now be instantiated
@@ -147,11 +146,6 @@
<channel>pear.php.net</channel>
<min>1.2</min>
</package>
- <package>
- <name>PHP_Compat</name>
- <channel>pear.php.net</channel>
- <min>1.4.9</min>
- </package>
</required>
<group name="datasources" hint="(un)installs all optional DataSource
drivers">
<subpackage>
http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.49&r2=1.50&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/Renderer.php
diff -u pear/Structures_DataGrid/DataGrid/Renderer.php:1.49
pear/Structures_DataGrid/DataGrid/Renderer.php:1.50
--- pear/Structures_DataGrid/DataGrid/Renderer.php:1.49 Fri Jun 16 18:10:06 2006
+++ pear/Structures_DataGrid/DataGrid/Renderer.php Mon Jun 19 17:39:18 2006
@@ -17,9 +17,7 @@
// | Olivier Guilyardi <olivier@samalyse.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Renderer.php,v 1.49 2006/06/16 18:10:06 wiesemann Exp $
-
-require_once 'PHP/Compat/Function/http_build_query.php';
+// $Id: Renderer.php,v 1.50 2006/06/19 17:39:18 olivierg Exp $
/**
* Base class of all Renderer drivers
@@ -99,7 +97,7 @@
* - extraVars
* - excludeVars
*
- * @version $Revision: 1.49 $
+ * @version $Revision: 1.50 $
* @author Olivier Guilyardi <olivier@samalyse.com>
* @access public
* @package Structures_DataGrid
@@ -929,4 +927,72 @@
}
+// This function is here because we can't depend on PHP_Compat
+if (!function_exists('http_build_query')) {
+ function http_build_query($formdata, $numeric_prefix = null)
+ {
+ // If $formdata is an object, convert it to an array
+ if (is_object($formdata)) {
+ $formdata = get_object_vars($formdata);
+ }
+
+ // Check we have an array to work with
+ if (!is_array($formdata)) {
+ user_error('http_build_query() Parameter 1 expected to be Array or Object.
Incorrect value given.',
+ E_USER_WARNING);
+ return false;
+ }
+
+ // If the array is empty, return null
+ if (empty($formdata)) {
+ return;
+ }
+
+ // Argument seperator
+ $separator = ini_get('arg_separator.output');
+
+ // Start building the query
+ $tmp = array ();
+ foreach ($formdata as $key => $val) {
+ if (is_integer($key) && $numeric_prefix != null) {
+ $key = $numeric_prefix . $key;
+ }
+
+ if (is_scalar($val)) {
+ array_push($tmp, urlencode($key).'='.urlencode($val));
+ continue;
+ }
+
+ // If the value is an array, recursively parse it
+ if (is_array($val)) {
+ array_push($tmp, __http_build_query($val, urlencode($key)));
+ continue;
+ }
+ }
+
+ return implode($separator, $tmp);
+ }
+
+ // Helper function
+ function __http_build_query ($array, $name)
+ {
+ $tmp = array ();
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ array_push($tmp, __http_build_query($value, sprintf('%s[%s]', $name,
$key)));
+ } elseif (is_scalar($value)) {
+ array_push($tmp, sprintf('%s[%s]=%s', $name, urlencode($key),
urlencode($value)));
+ } elseif (is_object($value)) {
+ array_push($tmp, __http_build_query(get_object_vars($value),
sprintf('%s[%s]', $name, $key)));
+ }
+ }
+
+ // Argument seperator
+ $separator = ini_get('arg_separator.output');
+
+ return implode($separator, $tmp);
+ }
+}
+
+
?>