diff --git a/NEWS b/NEWS index 813c118e..4f5123a2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - added support for passing params to include_php + (Tim Riley, Monte) - added support for math operators in if statements (Monte) - added support for $foo->bar[$x].blah syntax (Monte) diff --git a/Smarty.class.php b/Smarty.class.php index adfb0956..be857692 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -1722,11 +1722,13 @@ class Smarty * @param $_smarty_assign * @param $_smarty_once */ - function _smarty_include_php($_smarty_include_php_file, $_smarty_assign, $_smarty_once) + function _smarty_include_php($_smarty_include_php_file, $_smarty_assign, $_smarty_once, $_smarty_include_vars) { $this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type, $_smarty_php_resource); + extract($_smarty_include_vars, EXTR_PREFIX_SAME, 'include_php_'); + if (!empty($_smarty_assign)) { ob_start(); if ($_smarty_resource_type == 'file') { diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 95d16040..6431f78b 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -857,8 +857,20 @@ class Smarty_Compiler extends Smarty { $assign_var = $this->_dequote($attrs['assign']); $once_var = ( $attrs['once'] === false ) ? 'false' : 'true'; + + foreach($attrs as $arg_name => $arg_value) { + if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { + if(is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + } + + $output = + "_smarty_include_php($attrs[file], '$assign_var', $once_var, " . + "array(".implode(',', (array)$arg_list).")); ?>"; - return "_smarty_include_php($attrs[file], '$assign_var', $once_var); ?>"; + return $output; } @@ -1109,6 +1121,10 @@ class Smarty_Compiler extends Smarty { case '~': case ')': case ',': + case '+': + case '-': + case '*': + case '/': break; case 'eq': diff --git a/docs/getting-started.sgml b/docs/getting-started.sgml index a4e2517b..c650fdf5 100644 --- a/docs/getting-started.sgml +++ b/docs/getting-started.sgml @@ -167,14 +167,14 @@ $smarty = new Smarty; Be sure you know the location of your web server document root. In our - example, the document root is "/web/www.domain.com/docs/". + example, the document root is "/web/www.mydomain.com/docs/". The Smarty directories are defined in the class variables $template_dir, $compile_dir, $config_dir and $cache_dir, which default to the values "templates", "templates_c", "configs" and "cache" respectively. In our example, we'll place all of these directories under - "/web/www.domain.com/smarty/guestbook/". + "/web/www.mydomain.com/smarty/guestbook/". @@ -197,7 +197,7 @@ $smarty = new Smarty; It is convenient to setup the web server so that "index.php" can be identified as the default directory index, so if you access - "http://www.domain.com/guestbook/", the index.php script will be executed + "http://www.mydomain.com/guestbook/", the index.php script will be executed without "index.php" in the URL. In Apache you can set this up by adding "index.php" onto the end of your DirectoryIndex setting (separate each entry with a space.) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index adfb0956..be857692 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1722,11 +1722,13 @@ class Smarty * @param $_smarty_assign * @param $_smarty_once */ - function _smarty_include_php($_smarty_include_php_file, $_smarty_assign, $_smarty_once) + function _smarty_include_php($_smarty_include_php_file, $_smarty_assign, $_smarty_once, $_smarty_include_vars) { $this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type, $_smarty_php_resource); + extract($_smarty_include_vars, EXTR_PREFIX_SAME, 'include_php_'); + if (!empty($_smarty_assign)) { ob_start(); if ($_smarty_resource_type == 'file') { diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 95d16040..6431f78b 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -857,8 +857,20 @@ class Smarty_Compiler extends Smarty { $assign_var = $this->_dequote($attrs['assign']); $once_var = ( $attrs['once'] === false ) ? 'false' : 'true'; + + foreach($attrs as $arg_name => $arg_value) { + if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { + if(is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + } + + $output = + "_smarty_include_php($attrs[file], '$assign_var', $once_var, " . + "array(".implode(',', (array)$arg_list).")); ?>"; - return "_smarty_include_php($attrs[file], '$assign_var', $once_var); ?>"; + return $output; } @@ -1109,6 +1121,10 @@ class Smarty_Compiler extends Smarty { case '~': case ')': case ',': + case '+': + case '-': + case '*': + case '/': break; case 'eq':