PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_debug.php
Go to the documentation of this file.
1 <?php
19 
25  public static $template_data = array();
26 
32  public static function start_compile($template)
33  {
34  $key = self::get_key($template);
35  self::$template_data[$key]['start_time'] = microtime(true);
36  }
37 
43  public static function end_compile($template)
44  {
45  $key = self::get_key($template);
46  self::$template_data[$key]['compile_time'] += microtime(true) - self::$template_data[$key]['start_time'];
47  }
48 
54  public static function start_render($template)
55  {
56  $key = self::get_key($template);
57  self::$template_data[$key]['start_time'] = microtime(true);
58  }
59 
65  public static function end_render($template)
66  {
67  $key = self::get_key($template);
68  self::$template_data[$key]['render_time'] += microtime(true) - self::$template_data[$key]['start_time'];
69  }
70 
76  public static function start_cache($template)
77  {
78  $key = self::get_key($template);
79  self::$template_data[$key]['start_time'] = microtime(true);
80  }
81 
87  public static function end_cache($template)
88  {
89  $key = self::get_key($template);
90  self::$template_data[$key]['cache_time'] += microtime(true) - self::$template_data[$key]['start_time'];
91  }
92 
98  public static function display_debug($obj)
99  {
100  // prepare information of assigned variables
101  $ptr = self::get_debug_vars($obj);
102  if ($obj instanceof Smarty) {
103  $smarty = clone $obj;
104  } else {
105  $smarty = clone $obj->smarty;
106  }
107  $_assigned_vars = $ptr->tpl_vars;
108  ksort($_assigned_vars);
109  $_config_vars = $ptr->config_vars;
110  ksort($_config_vars);
111  $smarty->registered_filters = array();
112  $smarty->autoload_filters = array();
113  $smarty->default_modifiers = array();
114  $smarty->force_compile = false;
115  $smarty->left_delimiter = '{';
116  $smarty->right_delimiter = '}';
117  $smarty->debugging = false;
118  $smarty->force_compile = false;
119  $_template = new Smarty_Internal_Template($smarty->debug_tpl, $smarty);
120  $_template->caching = false;
121  $_template->disableSecurity();
122  $_template->cache_id = null;
123  $_template->compile_id = null;
124  if ($obj instanceof Smarty_Internal_Template) {
125  $_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
126  }
127  if ($obj instanceof Smarty) {
128  $_template->assign('template_data', self::$template_data);
129  } else {
130  $_template->assign('template_data', null);
131  }
132  $_template->assign('assigned_vars', $_assigned_vars);
133  $_template->assign('config_vars', $_config_vars);
134  $_template->assign('execution_time', microtime(true) - $smarty->start_time);
135  echo $_template->fetch();
136  }
137 
144  public static function get_debug_vars($obj)
145  {
146  $config_vars = $obj->config_vars;
147  $tpl_vars = array();
148  foreach ($obj->tpl_vars as $key => $var) {
149  $tpl_vars[$key] = clone $var;
150  if ($obj instanceof Smarty_Internal_Template) {
151  $tpl_vars[$key]->scope = $obj->source->type . ':' . $obj->source->name;
152  } elseif ($obj instanceof Smarty_Data) {
153  $tpl_vars[$key]->scope = 'Data object';
154  } else {
155  $tpl_vars[$key]->scope = 'Smarty root';
156  }
157  }
158 
159  if (isset($obj->parent)) {
160  $parent = self::get_debug_vars($obj->parent);
161  $tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
162  $config_vars = array_merge($parent->config_vars, $config_vars);
163  } else {
164  foreach (Smarty::$global_tpl_vars as $name => $var) {
165  if (!array_key_exists($name, $tpl_vars)) {
166  $clone = clone $var;
167  $clone->scope = 'Global';
168  $tpl_vars[$name] = $clone;
169  }
170  }
171  }
172  return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
173  }
174 
181  private static function get_key($template)
182  {
183  static $_is_stringy = array('string' => true, 'eval' => true);
184  // calculate Uid if not already done
185  if ($template->source->uid == '') {
186  $template->source->filepath;
187  }
188  $key = $template->source->uid;
189  if (isset(self::$template_data[$key])) {
190  return $key;
191  } else {
192  if (isset($_is_stringy[$template->source->type])) {
193  self::$template_data[$key]['name'] = '\''.substr($template->source->name,0,25).'...\'';
194  } else {
195  self::$template_data[$key]['name'] = $template->source->filepath;
196  }
197  self::$template_data[$key]['compile_time'] = 0;
198  self::$template_data[$key]['render_time'] = 0;
199  self::$template_data[$key]['cache_time'] = 0;
200  return $key;
201  }
202  }
203 
204 }
205 
206 ?>
static end_compile($template)
End logging of compile time.
static start_cache($template)
Start logging of cache time.
static $global_tpl_vars
#@-
static end_cache($template)
End logging of cache time.
Smarty plugin to format text blocks.
static start_compile($template)
Start logging of compile time.
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
static end_render($template)
End logging of compile time.
static display_debug($obj)
Opens a window for the Smarty Debugging Consol and display the data.
static get_debug_vars($obj)
Recursively gets variables from all template/data scopes.
static start_render($template)
Start logging of render time.

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.