PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_data.php
Go to the documentation of this file.
1 <?php
19 
25  public $template_class = 'Smarty_Internal_Template';
31  public $tpl_vars = array();
37  public $parent = null;
43  public $config_vars = array();
44 
54  public function assign($tpl_var, $value = null, $nocache = false)
55  {
56  if (is_array($tpl_var)) {
57  foreach ($tpl_var as $_key => $_val) {
58  if ($_key != '') {
59  $this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache);
60  }
61  }
62  } else {
63  if ($tpl_var != '') {
64  $this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache);
65  }
66  }
67 
68  return $this;
69  }
70 
79  public function assignGlobal($varname, $value = null, $nocache = false)
80  {
81  if ($varname != '') {
82  Smarty::$global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
83  $ptr = $this;
84  while ($ptr instanceof Smarty_Internal_Template) {
85  $ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
86  $ptr = $ptr->parent;
87  }
88  }
89 
90  return $this;
91  }
100  public function assignByRef($tpl_var, &$value, $nocache = false)
101  {
102  if ($tpl_var != '') {
103  $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
104  $this->tpl_vars[$tpl_var]->value = &$value;
105  }
106 
107  return $this;
108  }
109 
119  public function append($tpl_var, $value = null, $merge = false, $nocache = false)
120  {
121  if (is_array($tpl_var)) {
122  // $tpl_var is an array, ignore $value
123  foreach ($tpl_var as $_key => $_val) {
124  if ($_key != '') {
125  if (!isset($this->tpl_vars[$_key])) {
126  $tpl_var_inst = $this->getVariable($_key, null, true, false);
127  if ($tpl_var_inst instanceof Undefined_Smarty_Variable) {
128  $this->tpl_vars[$_key] = new Smarty_variable(null, $nocache);
129  } else {
130  $this->tpl_vars[$_key] = clone $tpl_var_inst;
131  }
132  }
133  if (!(is_array($this->tpl_vars[$_key]->value) || $this->tpl_vars[$_key]->value instanceof ArrayAccess)) {
134  settype($this->tpl_vars[$_key]->value, 'array');
135  }
136  if ($merge && is_array($_val)) {
137  foreach($_val as $_mkey => $_mval) {
138  $this->tpl_vars[$_key]->value[$_mkey] = $_mval;
139  }
140  } else {
141  $this->tpl_vars[$_key]->value[] = $_val;
142  }
143  }
144  }
145  } else {
146  if ($tpl_var != '' && isset($value)) {
147  if (!isset($this->tpl_vars[$tpl_var])) {
148  $tpl_var_inst = $this->getVariable($tpl_var, null, true, false);
149  if ($tpl_var_inst instanceof Undefined_Smarty_Variable) {
150  $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
151  } else {
152  $this->tpl_vars[$tpl_var] = clone $tpl_var_inst;
153  }
154  }
155  if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
156  settype($this->tpl_vars[$tpl_var]->value, 'array');
157  }
158  if ($merge && is_array($value)) {
159  foreach($value as $_mkey => $_mval) {
160  $this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
161  }
162  } else {
163  $this->tpl_vars[$tpl_var]->value[] = $value;
164  }
165  }
166  }
167 
168  return $this;
169  }
170 
179  public function appendByRef($tpl_var, &$value, $merge = false)
180  {
181  if ($tpl_var != '' && isset($value)) {
182  if (!isset($this->tpl_vars[$tpl_var])) {
183  $this->tpl_vars[$tpl_var] = new Smarty_variable();
184  }
185  if (!is_array($this->tpl_vars[$tpl_var]->value)) {
186  settype($this->tpl_vars[$tpl_var]->value, 'array');
187  }
188  if ($merge && is_array($value)) {
189  foreach($value as $_key => $_val) {
190  $this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
191  }
192  } else {
193  $this->tpl_vars[$tpl_var]->value[] = &$value;
194  }
195  }
196 
197  return $this;
198  }
199 
208  public function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
209  {
210  if (isset($varname)) {
211  $_var = $this->getVariable($varname, $_ptr, $search_parents, false);
212  if (is_object($_var)) {
213  return $_var->value;
214  } else {
215  return null;
216  }
217  } else {
218  $_result = array();
219  if ($_ptr === null) {
220  $_ptr = $this;
221  } while ($_ptr !== null) {
222  foreach ($_ptr->tpl_vars AS $key => $var) {
223  if (!array_key_exists($key, $_result)) {
224  $_result[$key] = $var->value;
225  }
226  }
227  // not found, try at parent
228  if ($search_parents) {
229  $_ptr = $_ptr->parent;
230  } else {
231  $_ptr = null;
232  }
233  }
234  if ($search_parents && isset(Smarty::$global_tpl_vars)) {
235  foreach (Smarty::$global_tpl_vars AS $key => $var) {
236  if (!array_key_exists($key, $_result)) {
237  $_result[$key] = $var->value;
238  }
239  }
240  }
241  return $_result;
242  }
243  }
244 
251  public function clearAssign($tpl_var)
252  {
253  if (is_array($tpl_var)) {
254  foreach ($tpl_var as $curr_var) {
255  unset($this->tpl_vars[$curr_var]);
256  }
257  } else {
258  unset($this->tpl_vars[$tpl_var]);
259  }
260 
261  return $this;
262  }
263 
268  public function clearAllAssign()
269  {
270  $this->tpl_vars = array();
271  return $this;
272  }
273 
281  public function configLoad($config_file, $sections = null)
282  {
283  // load Config class
284  $config = new Smarty_Internal_Config($config_file, $this->smarty, $this);
285  $config->loadConfigVars($sections);
286  return $this;
287  }
288 
297  public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true)
298  {
299  if ($_ptr === null) {
300  $_ptr = $this;
301  } while ($_ptr !== null) {
302  if (isset($_ptr->tpl_vars[$variable])) {
303  // found it, return it
304  return $_ptr->tpl_vars[$variable];
305  }
306  // not found, try at parent
307  if ($search_parents) {
308  $_ptr = $_ptr->parent;
309  } else {
310  $_ptr = null;
311  }
312  }
313  if (isset(Smarty::$global_tpl_vars[$variable])) {
314  // found it, return it
315  return Smarty::$global_tpl_vars[$variable];
316  }
317  if ($this->smarty->error_unassigned && $error_enable) {
318  // force a notice
319  $x = $$variable;
320  }
321  return new Undefined_Smarty_Variable;
322  }
323 
330  public function getConfigVariable($variable, $error_enable = true)
331  {
332  $_ptr = $this;
333  while ($_ptr !== null) {
334  if (isset($_ptr->config_vars[$variable])) {
335  // found it, return it
336  return $_ptr->config_vars[$variable];
337  }
338  // not found, try at parent
339  $_ptr = $_ptr->parent;
340  }
341  if ($this->smarty->error_unassigned && $error_enable) {
342  // force a notice
343  $x = $$variable;
344  }
345  return null;
346  }
347 
354  public function getStreamVariable($variable)
355  {
356  $_result = '';
357  $fp = fopen($variable, 'r+');
358  if ($fp) {
359  while (!feof($fp) && ($current_line = fgets($fp)) !== false ) {
360  $_result .= $current_line;
361  }
362  fclose($fp);
363  return $_result;
364  }
365 
366  if ($this->smarty->error_unassigned) {
367  throw new SmartyException('Undefined stream variable "' . $variable . '"');
368  } else {
369  return null;
370  }
371  }
372 
379  public function getConfigVars($varname = null, $search_parents = true)
380  {
381  $_ptr = $this;
382  $var_array = array();
383  while ($_ptr !== null) {
384  if (isset($varname)) {
385  if (isset($_ptr->config_vars[$varname])) {
386  return $_ptr->config_vars[$varname];
387  }
388  } else {
389  $var_array = array_merge($_ptr->config_vars, $var_array);
390  }
391  // not found, try at parent
392  if ($search_parents) {
393  $_ptr = $_ptr->parent;
394  } else {
395  $_ptr = null;
396  }
397  }
398  if (isset($varname)) {
399  return '';
400  } else {
401  return $var_array;
402  }
403  }
404 
411  public function clearConfig($varname = null)
412  {
413  if (isset($varname)) {
414  unset($this->config_vars[$varname]);
415  } else {
416  $this->config_vars = array();
417  }
418  return $this;
419  }
420 
421 }
422 
432 
438  public $smarty = null;
439 
446  public function __construct ($_parent = null, $smarty = null)
447  {
448  $this->smarty = $smarty;
449  if (is_object($_parent)) {
450  // when object set up back pointer
451  $this->parent = $_parent;
452  } elseif (is_array($_parent)) {
453  // set up variable values
454  foreach ($_parent as $_key => $_val) {
455  $this->tpl_vars[$_key] = new Smarty_variable($_val);
456  }
457  } elseif ($_parent != null) {
458  throw new SmartyException("Wrong type for template variables");
459  }
460  }
461 
462 }
463 
473 
479  public $value = null;
485  public $nocache = false;
492 
500  public function __construct($value = null, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
501  {
502  $this->value = $value;
503  $this->nocache = $nocache;
504  $this->scope = $scope;
505  }
506 
512  public function __toString()
513  {
514  return (string) $this->value;
515  }
516 
517 }
518 
528 
535  public function __get($name)
536  {
537  if ($name == 'nocache') {
538  return false;
539  } else {
540  return null;
541  }
542  }
543 
549  public function __toString()
550  {
551  return "";
552  }
553 
554 }
555 
556 ?>
appendByRef($tpl_var, &$value, $merge=false)
appends values to template variables by reference
append($tpl_var, $value=null, $merge=false, $nocache=false)
appends values to template variables
assignByRef($tpl_var, &$value, $nocache=false)
assigns values to template variables by reference
__get($name)
Returns FALSE for 'nocache' and NULL otherwise.
getStreamVariable($variable)
gets a stream variable
assignGlobal($varname, $value=null, $nocache=false)
assigns a global Smarty variable
__construct($value=null, $nocache=false, $scope=Smarty::SCOPE_LOCAL)
create Smarty variable object
clearAssign($tpl_var)
clear the given assigned template variable.
static $global_tpl_vars
#@-
__toString()
Always returns an empty string.
getVariable($variable, $_ptr=null, $search_parents=true, $error_enable=true)
gets the object of a Smarty variable
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
getConfigVariable($variable, $error_enable=true)
gets a config variable
__toString()
<> String conversion
clearConfig($varname=null)
Deassigns a single or all config variables.
const SCOPE_LOCAL
define variable scopes
configLoad($config_file, $sections=null)
load a config file, optionally load just selected sections
__construct($_parent=null, $smarty=null)
create Smarty data object
clearAllAssign()
clear all the assigned template variables.
assign($tpl_var, $value=null, $nocache=false)
assigns a Smarty variable
getTemplateVars($varname=null, $_ptr=null, $search_parents=true)
Returns a single or all template variables.
getConfigVars($varname=null, $search_parents=true)
Returns a single or all config variables.

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.