- Fixed some E_NOTICE stuff in compiler.

- Generalized assign_smarty_interface() a bit.
This commit is contained in:
andrey
2001-08-01 16:22:55 +00:00
parent a6717ba3a4
commit 78c7cf29b5
4 changed files with 56 additions and 74 deletions

View File

@@ -616,42 +616,30 @@ class Smarty
\*======================================================================*/ \*======================================================================*/
function _assign_smarty_interface() function _assign_smarty_interface()
{ {
$smarty = array('get' => $GLOBALS['HTTP_GET_VARS'], $egpcs = array('e' => 'env',
'post' => $GLOBALS['HTTP_POST_VARS'], 'g' => 'get',
'cookies' => $GLOBALS['HTTP_COOKIE_VARS'], 'p' => 'post',
'session' => $GLOBALS['HTTP_SESSION_VARS'], 'c' => 'cookie',
'server' => $GLOBALS['HTTP_SERVER_VARS'], 's' => 'server');
'env' => $GLOBALS['HTTP_ENV_VARS']); $globals_map = array('get' => 'HTTP_GET_VARS',
'post' => 'HTTP_POST_VARS',
'cookies' => 'HTTP_COOKIE_VARS',
'session' => 'HTTP_SESSION_VARS',
'server' => 'HTTP_SERVER_VARS',
'env' => 'HTTP_ENV_VARS');
$smarty['request'] = array(); $smarty = array('request' => array());
foreach (preg_split('!!', $this->request_vars_order) as $c) {
switch (strtolower($c)) {
case 'p':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_POST_VARS']);
break;
case 'c': foreach ($globals_map as $key => $array) {
$smarty['request'] = array_merge($smarty['request'], $smarty[$key] = isset($GLOBALS[$array]) ? $GLOBALS[$array] : array();
$GLOBALS['HTTP_COOKIE_VARS']); }
break;
case 'g': foreach (preg_split('!!', strtolower($this->request_vars_order)) as $c) {
$smarty['request'] = array_merge($smarty['request'], if (isset($egpcs[$c])) {
$GLOBALS['HTTP_GET_VARS']); $smarty['request'] = array_merge($smarty['request'], $smarty[$egpcs[$c]]);
break;
case 'e':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_ENV_VARS']);
break;
case 's':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_SERVER_VARS']);
break;
} }
} }
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
$this->assign('smarty', $smarty); $this->assign('smarty', $smarty);
} }

View File

@@ -305,6 +305,7 @@ class Smarty_Compiler extends Smarty {
return; return;
} }
$arg_list = array();
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
foreach ($attrs as $arg_name => $arg_value) { foreach ($attrs as $arg_name => $arg_value) {
if (is_bool($arg_value)) if (is_bool($arg_value))
@@ -355,7 +356,7 @@ class Smarty_Compiler extends Smarty {
$attrs['section'] = 'null'; $attrs['section'] = 'null';
} }
$scope = $this->_dequote($attrs['scope']); @$scope = $this->_dequote($attrs['scope']);
if (!empty($scope)) { if (!empty($scope)) {
if ($scope != 'local' && if ($scope != 'local' &&
$scope != 'parent' && $scope != 'parent' &&
@@ -412,6 +413,7 @@ class Smarty_Compiler extends Smarty {
function _compile_section_start($tag_args) function _compile_section_start($tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$arg_list = array();
$output = "<?php "; $output = "<?php ";
$section_name = $attrs['name']; $section_name = $attrs['name'];
@@ -650,6 +652,7 @@ class Smarty_Compiler extends Smarty {
function _parse_is_expr($is_arg, $tokens) function _parse_is_expr($is_arg, $tokens)
{ {
$expr_end = 0; $expr_end = 0;
$negate_expr = false;
if (($first_token = array_shift($tokens)) == 'not') { if (($first_token = array_shift($tokens)) == 'not') {
$negate_expr = true; $negate_expr = true;
@@ -659,7 +662,7 @@ class Smarty_Compiler extends Smarty {
switch ($expr_type) { switch ($expr_type) {
case 'even': case 'even':
if ($tokens[$expr_end] == 'by') { if (@$tokens[$expr_end] == 'by') {
$expr_end++; $expr_end++;
$expr_arg = $tokens[$expr_end++]; $expr_arg = $tokens[$expr_end++];
$expr = "!(($is_arg / $expr_arg) % $expr_arg)"; $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
@@ -669,7 +672,7 @@ class Smarty_Compiler extends Smarty {
break; break;
case 'odd': case 'odd':
if ($tokens[$expr_end] == 'by') { if (@$tokens[$expr_end] == 'by') {
$expr_end++; $expr_end++;
$expr_arg = $tokens[$expr_end++]; $expr_arg = $tokens[$expr_end++];
$expr = "(($is_arg / $expr_arg) % $expr_arg)"; $expr = "(($is_arg / $expr_arg) % $expr_arg)";
@@ -679,7 +682,7 @@ class Smarty_Compiler extends Smarty {
break; break;
case 'div': case 'div':
if ($tokens[$expr_end] == 'by') { if (@$tokens[$expr_end] == 'by') {
$expr_end++; $expr_end++;
$expr_arg = $tokens[$expr_end++]; $expr_arg = $tokens[$expr_end++];
$expr = "!($is_arg % $expr_arg)"; $expr = "!($is_arg % $expr_arg)";
@@ -917,7 +920,7 @@ class Smarty_Compiler extends Smarty {
* First we lookup the modifier function name in the registered * First we lookup the modifier function name in the registered
* modifiers table. * modifiers table.
*/ */
$mod_func_name = $this->custom_mods[$modifier_name]; @$mod_func_name = $this->custom_mods[$modifier_name];
/* /*
* If we don't find that modifier there, we assume it's just a PHP * If we don't find that modifier there, we assume it's just a PHP

View File

@@ -616,42 +616,30 @@ class Smarty
\*======================================================================*/ \*======================================================================*/
function _assign_smarty_interface() function _assign_smarty_interface()
{ {
$smarty = array('get' => $GLOBALS['HTTP_GET_VARS'], $egpcs = array('e' => 'env',
'post' => $GLOBALS['HTTP_POST_VARS'], 'g' => 'get',
'cookies' => $GLOBALS['HTTP_COOKIE_VARS'], 'p' => 'post',
'session' => $GLOBALS['HTTP_SESSION_VARS'], 'c' => 'cookie',
'server' => $GLOBALS['HTTP_SERVER_VARS'], 's' => 'server');
'env' => $GLOBALS['HTTP_ENV_VARS']); $globals_map = array('get' => 'HTTP_GET_VARS',
'post' => 'HTTP_POST_VARS',
'cookies' => 'HTTP_COOKIE_VARS',
'session' => 'HTTP_SESSION_VARS',
'server' => 'HTTP_SERVER_VARS',
'env' => 'HTTP_ENV_VARS');
$smarty['request'] = array(); $smarty = array('request' => array());
foreach (preg_split('!!', $this->request_vars_order) as $c) {
switch (strtolower($c)) {
case 'p':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_POST_VARS']);
break;
case 'c': foreach ($globals_map as $key => $array) {
$smarty['request'] = array_merge($smarty['request'], $smarty[$key] = isset($GLOBALS[$array]) ? $GLOBALS[$array] : array();
$GLOBALS['HTTP_COOKIE_VARS']); }
break;
case 'g': foreach (preg_split('!!', strtolower($this->request_vars_order)) as $c) {
$smarty['request'] = array_merge($smarty['request'], if (isset($egpcs[$c])) {
$GLOBALS['HTTP_GET_VARS']); $smarty['request'] = array_merge($smarty['request'], $smarty[$egpcs[$c]]);
break;
case 'e':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_ENV_VARS']);
break;
case 's':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_SERVER_VARS']);
break;
} }
} }
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
$this->assign('smarty', $smarty); $this->assign('smarty', $smarty);
} }

View File

@@ -305,6 +305,7 @@ class Smarty_Compiler extends Smarty {
return; return;
} }
$arg_list = array();
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
foreach ($attrs as $arg_name => $arg_value) { foreach ($attrs as $arg_name => $arg_value) {
if (is_bool($arg_value)) if (is_bool($arg_value))
@@ -355,7 +356,7 @@ class Smarty_Compiler extends Smarty {
$attrs['section'] = 'null'; $attrs['section'] = 'null';
} }
$scope = $this->_dequote($attrs['scope']); @$scope = $this->_dequote($attrs['scope']);
if (!empty($scope)) { if (!empty($scope)) {
if ($scope != 'local' && if ($scope != 'local' &&
$scope != 'parent' && $scope != 'parent' &&
@@ -412,6 +413,7 @@ class Smarty_Compiler extends Smarty {
function _compile_section_start($tag_args) function _compile_section_start($tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$arg_list = array();
$output = "<?php "; $output = "<?php ";
$section_name = $attrs['name']; $section_name = $attrs['name'];
@@ -650,6 +652,7 @@ class Smarty_Compiler extends Smarty {
function _parse_is_expr($is_arg, $tokens) function _parse_is_expr($is_arg, $tokens)
{ {
$expr_end = 0; $expr_end = 0;
$negate_expr = false;
if (($first_token = array_shift($tokens)) == 'not') { if (($first_token = array_shift($tokens)) == 'not') {
$negate_expr = true; $negate_expr = true;
@@ -659,7 +662,7 @@ class Smarty_Compiler extends Smarty {
switch ($expr_type) { switch ($expr_type) {
case 'even': case 'even':
if ($tokens[$expr_end] == 'by') { if (@$tokens[$expr_end] == 'by') {
$expr_end++; $expr_end++;
$expr_arg = $tokens[$expr_end++]; $expr_arg = $tokens[$expr_end++];
$expr = "!(($is_arg / $expr_arg) % $expr_arg)"; $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
@@ -669,7 +672,7 @@ class Smarty_Compiler extends Smarty {
break; break;
case 'odd': case 'odd':
if ($tokens[$expr_end] == 'by') { if (@$tokens[$expr_end] == 'by') {
$expr_end++; $expr_end++;
$expr_arg = $tokens[$expr_end++]; $expr_arg = $tokens[$expr_end++];
$expr = "(($is_arg / $expr_arg) % $expr_arg)"; $expr = "(($is_arg / $expr_arg) % $expr_arg)";
@@ -679,7 +682,7 @@ class Smarty_Compiler extends Smarty {
break; break;
case 'div': case 'div':
if ($tokens[$expr_end] == 'by') { if (@$tokens[$expr_end] == 'by') {
$expr_end++; $expr_end++;
$expr_arg = $tokens[$expr_end++]; $expr_arg = $tokens[$expr_end++];
$expr = "!($is_arg % $expr_arg)"; $expr = "!($is_arg % $expr_arg)";
@@ -917,7 +920,7 @@ class Smarty_Compiler extends Smarty {
* First we lookup the modifier function name in the registered * First we lookup the modifier function name in the registered
* modifiers table. * modifiers table.
*/ */
$mod_func_name = $this->custom_mods[$modifier_name]; @$mod_func_name = $this->custom_mods[$modifier_name];
/* /*
* If we don't find that modifier there, we assume it's just a PHP * If we don't find that modifier there, we assume it's just a PHP