Private GIT

Skip to content
Snippets Groups Projects
Commit 72f7fd3d authored by Julien Mathis's avatar Julien Mathis
Browse files

replace <? by <?php

git-svn-id: http://svn.centreon.com/trunk/centreon@3477 6bcd3966-0018-0410-8128-fd23d134de7e
parent d1acca95
No related merge requests found
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
* Template compiling class * Template compiling class
* @package Smarty * @package Smarty
*/ */
class Smarty_Compiler extends Smarty { class Smarty_Compiler extends Smarty {
// internal vars // internal vars
...@@ -289,7 +290,7 @@ class Smarty_Compiler extends Smarty { ...@@ -289,7 +290,7 @@ class Smarty_Compiler extends Smarty {
for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
if ($this->php_handling == SMARTY_PHP_PASSTHRU) { if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
/* echo php contents */ /* echo php contents */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?php echo \''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n", $text_blocks[$curr_tb]); $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?phpphp echo \''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n", $text_blocks[$curr_tb]);
} else if ($this->php_handling == SMARTY_PHP_QUOTE) { } else if ($this->php_handling == SMARTY_PHP_QUOTE) {
/* quote php tags */ /* quote php tags */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]); $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);
...@@ -298,7 +299,7 @@ class Smarty_Compiler extends Smarty { ...@@ -298,7 +299,7 @@ class Smarty_Compiler extends Smarty {
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]); $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]);
} else { } else {
/* SMARTY_PHP_ALLOW, but echo non php starting tags */ /* SMARTY_PHP_ALLOW, but echo non php starting tags */
$sp_match[1][$curr_sp] = preg_replace('~(<\?(?!php|=|$))~i', '<?php echo \'\\1\'?>'."\n", $sp_match[1][$curr_sp]); $sp_match[1][$curr_sp] = preg_replace('~(<\?(?!php|=|$))~i', '<?phpphp echo \'\\1\'?>'."\n", $sp_match[1][$curr_sp]);
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]); $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
} }
} }
...@@ -337,7 +338,7 @@ class Smarty_Compiler extends Smarty { ...@@ -337,7 +338,7 @@ class Smarty_Compiler extends Smarty {
/* remove trailing whitespaces from the last text_block */ /* remove trailing whitespaces from the last text_block */
$text_blocks[$j] = rtrim($text_blocks[$j]); $text_blocks[$j] = rtrim($text_blocks[$j]);
} }
$text_blocks[$j] = "<?php echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>"; $text_blocks[$j] = "<?phpphp echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>";
if ($compiled_tags[$j] == '{/strip}') { if ($compiled_tags[$j] == '{/strip}') {
$compiled_tags[$j] = "\n"; /* slurped by php, but necessary $compiled_tags[$j] = "\n"; /* slurped by php, but necessary
if a newline is following the closing strip-tag */ if a newline is following the closing strip-tag */
...@@ -366,7 +367,7 @@ class Smarty_Compiler extends Smarty { ...@@ -366,7 +367,7 @@ class Smarty_Compiler extends Smarty {
} }
if (!empty($this->_cache_serial)) { if (!empty($this->_cache_serial)) {
$compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content; $compiled_content = "<?phpphp \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content;
} }
// remove unnecessary close/open tags // remove unnecessary close/open tags
...@@ -387,7 +388,7 @@ class Smarty_Compiler extends Smarty { ...@@ -387,7 +388,7 @@ class Smarty_Compiler extends Smarty {
} }
// put header at the top of the compiled template // put header at the top of the compiled template
$template_header = "<?php /* Smarty version ".$this->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; $template_header = "<?phpphp /* Smarty version ".$this->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
$template_header .= " compiled from ".strtr(urlencode($resource_name), array('%2F'=>'/', '%3A'=>':'))." */ ?>\n"; $template_header .= " compiled from ".strtr(urlencode($resource_name), array('%2F'=>'/', '%3A'=>':'))." */ ?>\n";
/* Emit code to load needed plugins. */ /* Emit code to load needed plugins. */
...@@ -401,14 +402,14 @@ class Smarty_Compiler extends Smarty { ...@@ -401,14 +402,14 @@ class Smarty_Compiler extends Smarty {
} }
} }
$_plugins_params .= '))'; $_plugins_params .= '))';
$plugins_code = "<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n"; $plugins_code = "<?phpphp require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n";
$template_header .= $plugins_code; $template_header .= $plugins_code;
$this->_plugin_info = array(); $this->_plugin_info = array();
$this->_plugins_code = $plugins_code; $this->_plugins_code = $plugins_code;
} }
if ($this->_init_smarty_vars) { if ($this->_init_smarty_vars) {
$template_header .= "<?php require_once(SMARTY_CORE_DIR . 'core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n"; $template_header .= "<?phpphp require_once(SMARTY_CORE_DIR . 'core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n";
$this->_init_smarty_vars = false; $this->_init_smarty_vars = false;
} }
...@@ -443,7 +444,7 @@ class Smarty_Compiler extends Smarty { ...@@ -443,7 +444,7 @@ class Smarty_Compiler extends Smarty {
if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) { if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) {
/* tag name is a variable or object */ /* tag name is a variable or object */
$_return = $this->_parse_var_props($tag_command . $tag_modifier); $_return = $this->_parse_var_props($tag_command . $tag_modifier);
return "<?php echo $_return; ?>" . $this->_additional_newline; return "<?phpphp echo $_return; ?>" . $this->_additional_newline;
} }
/* If the tag name is a registered object, we process it. */ /* If the tag name is a registered object, we process it. */
...@@ -468,7 +469,7 @@ class Smarty_Compiler extends Smarty { ...@@ -468,7 +469,7 @@ class Smarty_Compiler extends Smarty {
$this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__); $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
else else
$this->_push_tag('else'); $this->_push_tag('else');
return '<?php else: ?>'; return '<?phpphp else: ?>';
case 'elseif': case 'elseif':
list($_open_tag) = end($this->_tag_stack); list($_open_tag) = end($this->_tag_stack);
...@@ -480,7 +481,7 @@ class Smarty_Compiler extends Smarty { ...@@ -480,7 +481,7 @@ class Smarty_Compiler extends Smarty {
case '/if': case '/if':
$this->_pop_tag('if'); $this->_pop_tag('if');
return '<?php endif; ?>'; return '<?phpphp endif; ?>';
case 'capture': case 'capture':
return $this->_compile_capture_tag(true, $tag_args); return $this->_compile_capture_tag(true, $tag_args);
...@@ -500,15 +501,15 @@ class Smarty_Compiler extends Smarty { ...@@ -500,15 +501,15 @@ class Smarty_Compiler extends Smarty {
case 'sectionelse': case 'sectionelse':
$this->_push_tag('sectionelse'); $this->_push_tag('sectionelse');
return "<?php endfor; else: ?>"; return "<?phpphp endfor; else: ?>";
break; break;
case '/section': case '/section':
$_open_tag = $this->_pop_tag('section'); $_open_tag = $this->_pop_tag('section');
if ($_open_tag == 'sectionelse') if ($_open_tag == 'sectionelse')
return "<?php endif; ?>"; return "<?phpphp endif; ?>";
else else
return "<?php endfor; endif; ?>"; return "<?phpphp endfor; endif; ?>";
case 'foreach': case 'foreach':
$this->_push_tag('foreach'); $this->_push_tag('foreach');
...@@ -517,14 +518,14 @@ class Smarty_Compiler extends Smarty { ...@@ -517,14 +518,14 @@ class Smarty_Compiler extends Smarty {
case 'foreachelse': case 'foreachelse':
$this->_push_tag('foreachelse'); $this->_push_tag('foreachelse');
return "<?php endforeach; else: ?>"; return "<?phpphp endforeach; else: ?>";
case '/foreach': case '/foreach':
$_open_tag = $this->_pop_tag('foreach'); $_open_tag = $this->_pop_tag('foreach');
if ($_open_tag == 'foreachelse') if ($_open_tag == 'foreachelse')
return "<?php endif; unset(\$_from); ?>"; return "<?phpphp endif; unset(\$_from); ?>";
else else
return "<?php endforeach; endif; unset(\$_from); ?>"; return "<?phpphp endforeach; endif; unset(\$_from); ?>";
break; break;
case 'strip': case 'strip':
...@@ -555,14 +556,14 @@ class Smarty_Compiler extends Smarty { ...@@ -555,14 +556,14 @@ class Smarty_Compiler extends Smarty {
return ''; return '';
case 3: /* literal */ case 3: /* literal */
return "<?php echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline; return "<?phpphp echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline;
case 4: /* php */ case 4: /* php */
if ($this->security && !$this->security_settings['PHP_TAGS']) { if ($this->security && !$this->security_settings['PHP_TAGS']) {
$this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__); $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__);
return; return;
} }
return '<?php ' . $block[3] .' ?>'; return '<?phpphp ' . $block[3] .' ?>';
} }
break; break;
...@@ -638,7 +639,7 @@ class Smarty_Compiler extends Smarty { ...@@ -638,7 +639,7 @@ class Smarty_Compiler extends Smarty {
if ($have_function) { if ($have_function) {
$output = call_user_func_array($plugin_func, array($tag_args, &$this)); $output = call_user_func_array($plugin_func, array($tag_args, &$this));
if($output != '') { if($output != '') {
$output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command) $output = '<?phpphp ' . $this->_push_cacheable_state('compiler', $tag_command)
. $output . $output
. $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>'; . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
} }
...@@ -724,7 +725,7 @@ class Smarty_Compiler extends Smarty { ...@@ -724,7 +725,7 @@ class Smarty_Compiler extends Smarty {
$this->_pop_tag($tag_command); $this->_pop_tag($tag_command);
if ($start_tag) { if ($start_tag) {
$output = '<?php ' . $this->_push_cacheable_state('block', $tag_command); $output = '<?phpphp ' . $this->_push_cacheable_state('block', $tag_command);
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$_cache_attrs=''; $_cache_attrs='';
$arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs); $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs);
...@@ -732,7 +733,7 @@ class Smarty_Compiler extends Smarty { ...@@ -732,7 +733,7 @@ class Smarty_Compiler extends Smarty {
$output .= '$_block_repeat=true;' . $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);'; $output .= '$_block_repeat=true;' . $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);';
$output .= 'while ($_block_repeat) { ob_start(); ?>'; $output .= 'while ($_block_repeat) { ob_start(); ?>';
} else { } else {
$output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); '; $output = '<?phpphp $_block_content = ob_get_contents(); ob_end_clean(); ';
$_out_tag_text = $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat)'; $_out_tag_text = $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat)';
if ($tag_modifier != '') { if ($tag_modifier != '') {
$this->_parse_modifiers($_out_tag_text, $tag_modifier); $this->_parse_modifiers($_out_tag_text, $tag_modifier);
...@@ -811,7 +812,7 @@ class Smarty_Compiler extends Smarty { ...@@ -811,7 +812,7 @@ class Smarty_Compiler extends Smarty {
} }
if($output != '') { if($output != '') {
$output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';' $output = '<?phpphp ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';'
. $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline; . $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline;
} }
...@@ -909,7 +910,7 @@ class Smarty_Compiler extends Smarty { ...@@ -909,7 +910,7 @@ class Smarty_Compiler extends Smarty {
$output = ''; $output = '';
} }
return '<?php ' . $prefix . $output . $postfix . "?>" . $newline; return '<?phpphp ' . $prefix . $output . $postfix . "?>" . $newline;
} }
/** /**
...@@ -943,7 +944,7 @@ class Smarty_Compiler extends Smarty { ...@@ -943,7 +944,7 @@ class Smarty_Compiler extends Smarty {
$_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline; return "<?phpphp require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline;
} }
/** /**
...@@ -974,7 +975,7 @@ class Smarty_Compiler extends Smarty { ...@@ -974,7 +975,7 @@ class Smarty_Compiler extends Smarty {
$arg_list[] = "'$arg_name' => $arg_value"; $arg_list[] = "'$arg_name' => $arg_value";
} }
$output = '<?php '; $output = '<?phpphp ';
if (isset($assign_var)) { if (isset($assign_var)) {
$output .= "ob_start();\n"; $output .= "ob_start();\n";
...@@ -1027,7 +1028,7 @@ class Smarty_Compiler extends Smarty { ...@@ -1027,7 +1028,7 @@ class Smarty_Compiler extends Smarty {
$_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))"; $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))";
return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline; return "<?phpphp require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline;
} }
...@@ -1042,7 +1043,7 @@ class Smarty_Compiler extends Smarty { ...@@ -1042,7 +1043,7 @@ class Smarty_Compiler extends Smarty {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$arg_list = array(); $arg_list = array();
$output = '<?php '; $output = '<?phpphp ';
$section_name = $attrs['name']; $section_name = $attrs['name'];
if (empty($section_name)) { if (empty($section_name)) {
$this->_syntax_error("missing section name", E_USER_ERROR, __FILE__, __LINE__); $this->_syntax_error("missing section name", E_USER_ERROR, __FILE__, __LINE__);
...@@ -1177,7 +1178,7 @@ class Smarty_Compiler extends Smarty { ...@@ -1177,7 +1178,7 @@ class Smarty_Compiler extends Smarty {
$name = null; $name = null;
} }
$output = '<?php '; $output = '<?phpphp ';
$output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }"; $output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
if (isset($name)) { if (isset($name)) {
$foreach_props = "\$this->_foreach[$name]"; $foreach_props = "\$this->_foreach[$name]";
...@@ -1217,11 +1218,11 @@ class Smarty_Compiler extends Smarty { ...@@ -1217,11 +1218,11 @@ class Smarty_Compiler extends Smarty {
$assign = $attrs['assign']; $assign = $attrs['assign'];
else else
$assign = null; $assign = null;
$output = "<?php ob_start(); ?>"; $output = "<?phpphp ob_start(); ?>";
$this->_capture_stack[] = array($buffer, $assign); $this->_capture_stack[] = array($buffer, $assign);
} else { } else {
list($buffer, $assign) = array_pop($this->_capture_stack); list($buffer, $assign) = array_pop($this->_capture_stack);
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); "; $output = "<?phpphp \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
if (isset($assign)) { if (isset($assign)) {
$output .= " \$this->assign($assign, ob_get_contents());"; $output .= " \$this->assign($assign, ob_get_contents());";
} }
...@@ -1397,9 +1398,9 @@ class Smarty_Compiler extends Smarty { ...@@ -1397,9 +1398,9 @@ class Smarty_Compiler extends Smarty {
} }
if ($elseif) if ($elseif)
return '<?php elseif ('.implode(' ', $tokens).'): ?>'; return '<?phpphp elseif ('.implode(' ', $tokens).'): ?>';
else else
return '<?php if ('.implode(' ', $tokens).'): ?>'; return '<?phpphp if ('.implode(' ', $tokens).'): ?>';
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment