- 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()
{
$smarty = array('get' => $GLOBALS['HTTP_GET_VARS'],
'post' => $GLOBALS['HTTP_POST_VARS'],
'cookies' => $GLOBALS['HTTP_COOKIE_VARS'],
'session' => $GLOBALS['HTTP_SESSION_VARS'],
'server' => $GLOBALS['HTTP_SERVER_VARS'],
'env' => $GLOBALS['HTTP_ENV_VARS']);
$egpcs = array('e' => 'env',
'g' => 'get',
'p' => 'post',
'c' => 'cookie',
's' => 'server');
$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();
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;
$smarty = array('request' => array());
case 'c':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_COOKIE_VARS']);
break;
foreach ($globals_map as $key => $array) {
$smarty[$key] = isset($GLOBALS[$array]) ? $GLOBALS[$array] : array();
}
case 'g':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_GET_VARS']);
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;
foreach (preg_split('!!', strtolower($this->request_vars_order)) as $c) {
if (isset($egpcs[$c])) {
$smarty['request'] = array_merge($smarty['request'], $smarty[$egpcs[$c]]);
}
}
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
$this->assign('smarty', $smarty);
}

View File

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

View File

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

View File

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