PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_compile_include_php.php
Go to the documentation of this file.
1 <?php
19 
26  public $required_attributes = array('file');
33  public $shorttag_order = array('file');
40  public $optional_attributes = array('once', 'assign');
41 
49  public function compile($args, $compiler)
50  {
51  if (!($compiler->smarty instanceof SmartyBC)) {
52  throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
53  }
54  // check and get attributes
55  $_attr = $this->getAttributes($compiler, $args);
56 
57  $_output = '<?php ';
58 
59  $_smarty_tpl = $compiler->template;
60  $_filepath = false;
61  eval('$_file = ' . $_attr['file'] . ';');
62  if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
63  $_filepath = $_file;
64  } else {
65  if (isset($compiler->smarty->security_policy)) {
66  $_dir = $compiler->smarty->security_policy->trusted_dir;
67  } else {
68  $_dir = $compiler->smarty->trusted_dir;
69  }
70  if (!empty($_dir)) {
71  foreach((array)$_dir as $_script_dir) {
72  $_script_dir = rtrim($_script_dir, '/\\') . DS;
73  if (file_exists($_script_dir . $_file)) {
74  $_filepath = $_script_dir . $_file;
75  break;
76  }
77  }
78  }
79  }
80  if ($_filepath == false) {
81  $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", $compiler->lex->taglineno);
82  }
83 
84  if (isset($compiler->smarty->security_policy)) {
85  $compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
86  }
87 
88  if (isset($_attr['assign'])) {
89  // output will be stored in a smarty variable instead of being displayed
90  $_assign = $_attr['assign'];
91  }
92  $_once = '_once';
93  if (isset($_attr['once'])) {
94  if ($_attr['once'] == 'false') {
95  $_once = '';
96  }
97  }
98 
99  if (isset($_assign)) {
100  return "<?php ob_start(); include{$_once} ('{$_filepath}'); \$_smarty_tpl->assign({$_assign},ob_get_contents()); ob_end_clean();?>";
101  } else {
102  return "<?php include{$_once} ('{$_filepath}');?>\n";
103  }
104  }
105 
106 }
107 
108 ?>
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler)
Compiles code for the {include_php} tag.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:17 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.