PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_compile_private_print_expression.php
Go to the documentation of this file.
1 <?php
19 
26  public $optional_attributes = array('assign');
33  public $option_flags = array('nocache', 'nofilter');
34 
43  public function compile($args, $compiler, $parameter)
44  {
45  // check and get attributes
46  $_attr = $this->getAttributes($compiler, $args);
47  // nocache option
48  if ($_attr['nocache'] === true) {
49  $compiler->tag_nocache = true;
50  }
51  // filter handling
52  if ($_attr['nofilter'] === true) {
53  $_filter = 'false';
54  } else {
55  $_filter = 'true';
56  }
57  if (isset($_attr['assign'])) {
58  // assign output to variable
59  $output = "<?php \$_smarty_tpl->assign({$_attr['assign']},{$parameter['value']});?>";
60  } else {
61  // display value
62  $output = $parameter['value'];
63  // tag modifier
64  if (!empty($parameter['modifierlist'])) {
65  $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'], 'value' => $output));
66  }
67  if (!$_attr['nofilter']) {
68  // default modifier
69  if (!empty($compiler->smarty->default_modifiers)) {
70  if (empty($compiler->default_modifier_list)) {
71  $modifierlist = array();
72  foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
73  preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array);
74  for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
75  if ($mod_array[0][$i] != ':') {
76  $modifierlist[$key][] = $mod_array[0][$i];
77  }
78  }
79  }
80  $compiler->default_modifier_list = $modifierlist;
81  }
82  $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $compiler->default_modifier_list, 'value' => $output));
83  }
84  // autoescape html
85  if ($compiler->template->smarty->escape_html) {
86  $output = "htmlspecialchars({$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
87  }
88  // loop over registerd filters
89  if (!empty($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE])) {
90  foreach ($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE] as $key => $function) {
91  if (!is_array($function)) {
92  $output = "{$function}({$output},\$_smarty_tpl)";
93  } else if (is_object($function[0])) {
94  $output = "\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE][{$key}][0]->{$function[1]}({$output},\$_smarty_tpl)";
95  } else {
96  $output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)";
97  }
98  }
99  }
100  // auto loaded filters
101  if (isset($compiler->smarty->autoload_filters[Smarty::FILTER_VARIABLE])) {
102  foreach ((array)$compiler->template->smarty->autoload_filters[Smarty::FILTER_VARIABLE] as $name) {
103  $result = $this->compile_output_filter($compiler, $name, $output);
104  if ($result !== false) {
105  $output = $result;
106  } else {
107  // not found, throw exception
108  throw new SmartyException("Unable to load filter '{$name}'");
109  }
110  }
111  }
112  if (isset($compiler->template->variable_filters)) {
113  foreach ($compiler->template->variable_filters as $filter) {
114  if (count($filter) == 1 && ($result = $this->compile_output_filter($compiler, $filter[0], $output)) !== false) {
115  $output = $result;
116  } else {
117  $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => array($filter), 'value' => $output));
118  }
119  }
120  }
121  }
122 
123  $compiler->has_output = true;
124  $output = "<?php echo {$output};?>";
125  }
126  return $output;
127  }
128 
135  private function compile_output_filter($compiler, $name, $output)
136  {
137  $plugin_name = "smarty_variablefilter_{$name}";
138  $path = $compiler->smarty->loadPlugin($plugin_name, false);
139  if ($path) {
140  if ($compiler->template->caching) {
141  $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
142  $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
143  } else {
144  $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
145  $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
146  }
147  } else {
148  // not found
149  return false;
150  }
151  return "{$plugin_name}({$output},\$_smarty_tpl)";
152  }
153 
154 }
155 
156 ?>
$result
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
const FILTER_VARIABLE
compile($args, $compiler, $parameter)
Compiles code for gererting output from any expression.
static $_CHARSET
The character set to adhere to (e.g.

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.