smarty.request
| From: | Daniel Jaenecke | Date: | Thu, 12 Jun 2003 11:39:30 +0000 |
| Subject: | smarty.request | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-1547@lists.php.net to get a copy of this message | ||
Hello!
I am not quite sure if this is the right place but I'll give it a try...
I just found out that Smarty2.5.0 still uses the $HTTP_*_VARS instead of the
superglobals $_GET, $_POST etc. This is especially bad when making changes
to those arrays which will not be reflected in $smarty.request afterwards.
So I patched Smarty to make use of the superglobals; for BC this depends on
a boolean flag that is set to false by default.
Since I could not find out where else to put it I just post it here,
including the diff; but I would welcome any recommendations where/whom to
show it; apart from /dev/null :)
Regards
dj
--- Smarty.class.php 2003-04-11 13:40:40.000000000 +0000
+++ Smarty.class.patch.php 2003-06-12 10:45:30.000000000 +0000
@@ -71,6 +71,15 @@
/**#@+
* Smarty Configuration Section
*/
+
+ /**
+ * Wether to use the 'new' superglobals $_GET, $_POST etc
+ * to fill $smarty.request
+ * Defaults to FALSE for BC
+ *
+ * @var boolean
+ */
+ var $use_super_globals = false;
/**
* The name of the directory where templates are located.
@@ -1202,22 +1211,39 @@
return;
}
- $globals_map = array('g' => 'HTTP_GET_VARS',
- 'p' => 'HTTP_POST_VARS',
- 'c' => 'HTTP_COOKIE_VARS',
- 's' => 'HTTP_SERVER_VARS',
- 'e' => 'HTTP_ENV_VARS');
-
- $_smarty_vars_request = array();
-
- foreach (preg_split('!!', strtolower($this->request_vars_order)) as
$c) {
- if (isset($globals_map[$c])) {
- $_smarty_vars_request = array_merge($_smarty_vars_request,
$GLOBALS[$globals_map[$c]]);
- }
- }
- $_smarty_vars_request = @array_merge($_smarty_vars_request,
$GLOBALS['HTTP_SESSION_VARS']);
+ if ( $this->use_super_globals == TRUE ) {
+
+ $globals_map = array('g' => '_GET',
+ 'p' =>
'_POST',
+ 'c' =>
'_COOKIE',
+ 's' =>
'_SERVER',
+ 'e' =>
'_ENV');
+
+ $session_key = '_SESSION';
+
+ } // if
+ else {
+
+ $globals_map = array('g' => 'HTTP_GET_VARS',
+ 'p' =>
'HTTP_POST_VARS',
+ 'c' =>
'HTTP_COOKIE_VARS',
+ 's' =>
'HTTP_SERVER_VARS',
+ 'e' =>
'HTTP_ENV_VARS');
+
+ $session_key = '_HTTP_SESSION_VARS';
+
+ } // else
+
+ $_smarty_vars_request = array();
+
+ foreach (preg_split('!!', strtolower($this->request_vars_order)) as $c)
{
+ if (isset($globals_map[$c])) {
+ $_smarty_vars_request = array_me
rge($_smarty_vars_request, $GLOBALS[$globals_map[$c]]);
+ }
+ }
+ $_smarty_vars_request = @array_merge($_smarty_vars_reques
t, $GLOBALS[ $session_key ]);
- $this->_smarty_vars['request'] = $_smarty_vars_request;
+ $this->_smarty_vars['request'] = $_smarty_vars_request;
}