libs/sysplugins/smarty_internal_compile_private_print_expression.php Quellcode

smarty_internal_compile_private_print_expression.php
gehe zur Dokumentation dieser Datei
1 <?php
18 {
25  public $optional_attributes = array('assign');
32  public $option_flags = array('nocache', 'nofilter');
33 
44  public function compile($args, $compiler, $parameter)
45  {
46  // check and get attributes
47  $_attr = $this->getAttributes($compiler, $args);
48  // nocache option
49  if ($_attr['nocache'] === true) {
50  $compiler->tag_nocache = true;
51  }
52  if (isset($_attr['assign'])) {
53  // assign output to variable
54  $output = "<?php \$_smarty_tpl->assign({$_attr['assign']},{$parameter['value']});?>";
55  } else {
56  // display value
57  $output = $parameter['value'];
58  // tag modifier
59  if (!empty($parameter['modifierlist'])) {
60  $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'], 'value' => $output));
61  }
62  if (!$_attr['nofilter']) {
63  // default modifier
64  if (!empty($compiler->smarty->default_modifiers)) {
65  if (empty($compiler->default_modifier_list)) {
66  $modifierlist = array();
67  foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
68  preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array);
69  for ($i = 0, $count = count($mod_array[0]); $i < $count; $i ++) {
70  if ($mod_array[0][$i] != ':') {
71  $modifierlist[$key][] = $mod_array[0][$i];
72  }
73  }
74  }
75  $compiler->default_modifier_list = $modifierlist;
76  }
77  $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $compiler->default_modifier_list, 'value' => $output));
78  }
79  // autoescape html
80  if ($compiler->template->smarty->escape_html) {
81  $output = "htmlspecialchars({$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
82  }
83  // loop over registered filters
84  if (!empty($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE])) {
85  foreach ($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE] as $key => $function) {
86  if (!is_array($function)) {
87  $output = "{$function}({$output},\$_smarty_tpl)";
88  } elseif (is_object($function[0])) {
89  $output = "\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)";
90  } else {
91  $output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)";
92  }
93  }
94  }
95  // auto loaded filters
96  if (isset($compiler->smarty->autoload_filters[Smarty::FILTER_VARIABLE])) {
97  foreach ((array) $compiler->template->smarty->autoload_filters[Smarty::FILTER_VARIABLE] as $name) {
98  $result = $this->compile_output_filter($compiler, $name, $output);
99  if ($result !== false) {
100  $output = $result;
101  } else {
102  // not found, throw exception
103  throw new SmartyException("Unable to load filter '{$name}'");
104  }
105  }
106  }
107  if (isset($compiler->template->variable_filters)) {
108  foreach ($compiler->template->variable_filters as $filter) {
109  if (count($filter) == 1 && ($result = $this->compile_output_filter($compiler, $filter[0], $output)) !== false) {
110  $output = $result;
111  } else {
112  $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => array($filter), 'value' => $output));
113  }
114  }
115  }
116  }
117 
118  $compiler->has_output = true;
119  $output = "<?php echo {$output};?>";
120  }
121 
122  return $output;
123  }
124 
132  private function compile_output_filter($compiler, $name, $output)
133  {
134  $plugin_name = "smarty_variablefilter_{$name}";
135  $path = $compiler->smarty->loadPlugin($plugin_name, false);
136  if ($path) {
137  if ($compiler->template->caching) {
138  $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
139  $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
140  } else {
141  $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
142  $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
143  }
144  } else {
145  // not found
146  return false;
147  }
148 
149  return "{$plugin_name}({$output},\$_smarty_tpl)";
150  }
151 }




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.