Re: trouble with 1.3.2
| From: | Cynic | Date: | Mon, 23 Apr 2001 17:23:51 +0000 |
| Subject: | Re: trouble with 1.3.2 | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-566@lists.php.net to get a copy of this message | ||
Hi there,
I realized I've sent a wrong diff - apologies for that. This
is the right diff. What it does: Smarty::global_assign now
can take the following form:
array( 'foo' , 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' ) ) ;
First, Smarty::Smarty() will now look up $GLOBALS['foo'] and
$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME'], and these will be
available as {$foo} and {$SCRIPT_NAME}. The order is significant,
latter variables overwrite former ones.
Second, if a variable listed in Smarty::global_assign isn't set,
it's set with the value of Smarty::undefined. Effect of this is
that you won't get 'Warning: undefined variable...'.
I have another diff form Smarty_compiler.class.php which I'm
sending in another message.
E:\__server__\www\cynic.cz\tmpl\Smarty-1.3.2>diff -u smarty.class.php.orig smarty.class.php
--- smarty.class.php.orig Wed Apr 18 13:34:08 2001
+++ smarty.class.php Mon Apr 23 19:01:49 2001
@@ -52,9 +52,13 @@
var $compile_dir = './templates_c'; // name of directory for compiled
templates
var $config_dir = './configs'; // directory where config files are
located
- var $global_assign = array('SCRIPT_NAME'); // variables from the GLOBALS array
- // that are implicitly assigned
- // to all templates
+ var $global_assign = array( 'HTTP_SERVER_VARS' =>
+ array( 'SCRIPT_NAME' )
+ ); // variables from the GLOBALS array
+ // that are implicitly assigned
+ // to all templates
+ var $undefined = 'null'; // undefined variables in $global_assign will be
+ // created with this value
var $compile_check = true; // whether to check for compiling step or not:
// This is generally set to false once the
// application is entered into production and
@@ -122,9 +126,21 @@
\*======================================================================*/
function Smarty()
{
- foreach ($this->global_assign as $var_name) {
- if(isset($GLOBALS[$var_name])) {
- $this->assign($var_name, $GLOBALS[$var_name]);
+ foreach ($this->global_assign as $key => $var_name) {
+ if (is_array($var_name)) {
+ foreach ($var_name as $var) {
+ if (isset($GLOBALS[$key][$var])) {
+ $this->assign($var, $GLOBALS[$key][$var]);
+ } else {
+ $this->assign($var, $this->undefined);
+ }
+ }
+ } else {
+ if (isset($GLOBALS[$var_name])) {
+ $this->assign($var_name, $GLOBALS[$var_name]);
+ } else {
+ $this->assign($var_name, $this->undefined);
+ }
}
}
}
At 14:49 18.4. 2001, smarty@lists.ispi.net wrote the following:
--------------------------------------------------------------
>Is there any interest in getting Smarty work properly under
>error_reporting( E_ALL ) ? I've run Smarty-1.3.2/index.php
>with this setting, and got 50 something warnings. (Actually,
>this was _after_ I commented out that damn flock() call (FWIW,
>I'm running NT 5.0 Pro SP1, apache/1.3.20-dev from a two weeks
>old snapshot, and PHP 4.0.5 RC6).
>
>This diff (both inline and attached) makes Smarty::Smarty()
>"register_globals off"-aware. $global_assign can now take the
>following form:
(...)
------end of quote------
cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
- Book of Installation chapt 3 sec 7