Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * Smarty Internal Plugin Debug
  4:  * Class to collect data for the Smarty Debugging Consol
  5:  *
  6:  * @package    Smarty
  7:  * @subpackage Debug
  8:  * @author     Uwe Tews
  9:  */
 10: 
 11: /**
 12:  * Smarty Internal Plugin Debug Class
 13:  *
 14:  * @package    Smarty
 15:  * @subpackage Debug
 16:  */
 17: class Smarty_Internal_Debug extends Smarty_Internal_Data
 18: {
 19:     /**
 20:      * template data
 21:      *
 22:      * @var array
 23:      */
 24:     public static $template_data = array();
 25: 
 26:     /**
 27:      * List of uid's which shall be ignored
 28:      *
 29:      * @var array
 30:      */
 31:     public static $ignore_uid = array();
 32: 
 33:     /**
 34:      * Ignore template
 35:      *
 36:      * @param object $template
 37:      */
 38:     public static function ignore($template)
 39:     {
 40:         // calculate Uid if not already done
 41:         if ($template->source->uid == '') {
 42:             $template->source->filepath;
 43:         }
 44:         self::$ignore_uid[$template->source->uid] = true;
 45:     }
 46: 
 47:     /**
 48:      * Start logging of compile time
 49:      *
 50:      * @param object $template
 51:      */
 52:     public static function start_compile($template)
 53:     {
 54:         static $_is_stringy = array('string' => true, 'eval' => true);
 55:         if (!empty($template->compiler->trace_uid)) {
 56:             $key = $template->compiler->trace_uid;
 57:             if (!isset(self::$template_data[$key])) {
 58:                 if (isset($_is_stringy[$template->source->type])) {
 59:                     self::$template_data[$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
 60:                 } else {
 61:                     self::$template_data[$key]['name'] = $template->source->filepath;
 62:                 }
 63:                 self::$template_data[$key]['compile_time'] = 0;
 64:                 self::$template_data[$key]['render_time'] = 0;
 65:                 self::$template_data[$key]['cache_time'] = 0;
 66:             }
 67:         } else {
 68:             if (isset(self::$ignore_uid[$template->source->uid])) {
 69:                 return;
 70:             }
 71:             $key = self::get_key($template);
 72:         }
 73:         self::$template_data[$key]['start_time'] = microtime(true);
 74:     }
 75: 
 76:     /**
 77:      * End logging of compile time
 78:      *
 79:      * @param object $template
 80:      */
 81:     public static function end_compile($template)
 82:     {
 83:         if (!empty($template->compiler->trace_uid)) {
 84:             $key = $template->compiler->trace_uid;
 85:         } else {
 86:             if (isset(self::$ignore_uid[$template->source->uid])) {
 87:                 return;
 88:             }
 89: 
 90:             $key = self::get_key($template);
 91:         }
 92:         self::$template_data[$key]['compile_time'] += microtime(true) - self::$template_data[$key]['start_time'];
 93:     }
 94: 
 95:     /**
 96:      * Start logging of render time
 97:      *
 98:      * @param object $template
 99:      */
100:     public static function start_render($template)
101:     {
102:         $key = self::get_key($template);
103:         self::$template_data[$key]['start_time'] = microtime(true);
104:     }
105: 
106:     /**
107:      * End logging of compile time
108:      *
109:      * @param object $template
110:      */
111:     public static function end_render($template)
112:     {
113:         $key = self::get_key($template);
114:         self::$template_data[$key]['render_time'] += microtime(true) - self::$template_data[$key]['start_time'];
115:     }
116: 
117:     /**
118:      * Start logging of cache time
119:      *
120:      * @param object $template cached template
121:      */
122:     public static function start_cache($template)
123:     {
124:         $key = self::get_key($template);
125:         self::$template_data[$key]['start_time'] = microtime(true);
126:     }
127: 
128:     /**
129:      * End logging of cache time
130:      *
131:      * @param object $template cached template
132:      */
133:     public static function end_cache($template)
134:     {
135:         $key = self::get_key($template);
136:         self::$template_data[$key]['cache_time'] += microtime(true) - self::$template_data[$key]['start_time'];
137:     }
138: 
139:     /**
140:      * Opens a window for the Smarty Debugging Consol and display the data
141:      *
142:      * @param Smarty_Internal_Template|Smarty $obj object to debug
143:      */
144:     public static function display_debug($obj)
145:     {
146:         // prepare information of assigned variables
147:         $ptr = self::get_debug_vars($obj);
148:         if ($obj instanceof Smarty) {
149:             $smarty = clone $obj;
150:         } else {
151:             $smarty = clone $obj->smarty;
152:         }
153:         $_assigned_vars = $ptr->tpl_vars;
154:         ksort($_assigned_vars);
155:         $_config_vars = $ptr->config_vars;
156:         ksort($_config_vars);
157:         $smarty->registered_filters = array();
158:         $smarty->autoload_filters = array();
159:         $smarty->default_modifiers = array();
160:         $smarty->force_compile = false;
161:         $smarty->left_delimiter = '{';
162:         $smarty->right_delimiter = '}';
163:         $smarty->debugging = false;
164:         $smarty->debugging_ctrl = 'NONE';
165:         $smarty->force_compile = false;
166:         $_template = new Smarty_Internal_Template($smarty->debug_tpl, $smarty);
167:         $_template->caching = false;
168:         $_template->disableSecurity();
169:         $_template->cache_id = null;
170:         $_template->compile_id = null;
171:         if ($obj instanceof Smarty_Internal_Template) {
172:             $_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
173:         }
174:         if ($obj instanceof Smarty) {
175:             $_template->assign('template_data', self::$template_data);
176:         } else {
177:             $_template->assign('template_data', null);
178:         }
179:         $_template->assign('assigned_vars', $_assigned_vars);
180:         $_template->assign('config_vars', $_config_vars);
181:         $_template->assign('execution_time', microtime(true) - $smarty->start_time);
182:         echo $_template->fetch();
183:     }
184: 
185:     /**
186:      * Recursively gets variables from all template/data scopes
187:      *
188:      * @param  Smarty_Internal_Template|Smarty_Data $obj object to debug
189:      *
190:      * @return StdClass
191:      */
192:     public static function get_debug_vars($obj)
193:     {
194:         $config_vars = $obj->config_vars;
195:         $tpl_vars = array();
196:         foreach ($obj->tpl_vars as $key => $var) {
197:             $tpl_vars[$key] = clone $var;
198:             if ($obj instanceof Smarty_Internal_Template) {
199:                 $tpl_vars[$key]->scope = $obj->source->type . ':' . $obj->source->name;
200:             } elseif ($obj instanceof Smarty_Data) {
201:                 $tpl_vars[$key]->scope = 'Data object';
202:             } else {
203:                 $tpl_vars[$key]->scope = 'Smarty root';
204:             }
205:         }
206: 
207:         if (isset($obj->parent)) {
208:             $parent = self::get_debug_vars($obj->parent);
209:             $tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
210:             $config_vars = array_merge($parent->config_vars, $config_vars);
211:         } else {
212:             foreach (Smarty::$global_tpl_vars as $name => $var) {
213:                 if (!array_key_exists($name, $tpl_vars)) {
214:                     $clone = clone $var;
215:                     $clone->scope = 'Global';
216:                     $tpl_vars[$name] = $clone;
217:                 }
218:             }
219:         }
220: 
221:         return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
222:     }
223: 
224:     /**
225:      * Return key into $template_data for template
226:      *
227:      * @param  object $template template object
228:      *
229:      * @return string key into $template_data
230:      */
231:     private static function get_key($template)
232:     {
233:         static $_is_stringy = array('string' => true, 'eval' => true);
234:         // calculate Uid if not already done
235:         if ($template->source->uid == '') {
236:             $template->source->filepath;
237:         }
238:         $key = $template->source->uid;
239:         if (isset(self::$template_data[$key])) {
240:             return $key;
241:         } else {
242:             if (isset($_is_stringy[$template->source->type])) {
243:                 self::$template_data[$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
244:             } else {
245:                 self::$template_data[$key]['name'] = $template->source->filepath;
246:             }
247:             self::$template_data[$key]['compile_time'] = 0;
248:             self::$template_data[$key]['render_time'] = 0;
249:             self::$template_data[$key]['cache_time'] = 0;
250: 
251:             return $key;
252:         }
253:     }
254: }
255: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen