本文整理汇总了PHP中Smarty_Internal_Debug类的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Debug类的具体用法?PHP Smarty_Internal_Debug怎么用?PHP Smarty_Internal_Debug使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Smarty_Internal_Debug类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _display
function _display($output = '')
{
parent::_display($output);
if (class_exists('CI_Controller') && class_exists('Smarty_Internal_Debug') && (config_item('smarty_debug') || $this->enable_profiler)) {
$CI =& get_instance();
$smarty_debug = new Smarty_Internal_Debug();
$smarty_debug->display_debug($CI->ci_smarty);
}
}
示例2: content_5467bc02e6f7f7_87226601
function content_5467bc02e6f7f7_87226601($_smarty_tpl)
{
$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug');
Smarty_Internal_Debug::display_debug($_smarty_tpl);
?>
test<?php
}
开发者ID:pawelbienko,项目名称:ssnlab,代码行数:7,代码来源:e4bb86af7a1e4cb6e90080f9476d9869291aa00a.file.index.tpl.php
示例3: createData
/**
* creates a data object
*
* @param object $parent next higher level of Smarty variables
* @param string $name optional data block name
*
* @returns Smarty_Data data object
*/
public function createData($parent = null, $name = null)
{
$dataObj = new Smarty_Data($parent, $this, $name);
if ($this->debugging) {
Smarty_Internal_Debug::register_data($dataObj);
}
return $dataObj;
}
示例4: _display
public function _display($output = '')
{
parent::_display($output);
// If Smarty is active - NOTE: $this->output->enable_profiler(TRUE) active Smarty debug to simplify
if (class_exists('CI_Controller') && class_exists('Smarty_Internal_Debug') && (config_item('smarty_debug') || $this->enable_profiler)) {
$CI =& get_instance();
Smarty_Internal_Debug::display_debug($CI->smarty);
}
}
示例5: createData
/**
* creates a data object
*
* @api Smarty::createData()
* @link http://www.smarty.net/docs/en/api.create.data.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
* variables
* @param string $name optional data block name
*
* @returns Smarty_Data data object
*/
public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
{
/* @var Smarty $smarty */
$smarty = isset($this->smarty) ? $this->smarty : $obj;
$dataObj = new Smarty_Data($parent, $smarty, $name);
if ($smarty->debugging) {
Smarty_Internal_Debug::register_data($dataObj);
}
return $dataObj;
}
示例6: configLoad
/**
* @param $obj
* @param $config_file
* @param null $sections
* @param string $scope
*/
static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
$confObj = new $smarty->template_class($config_file, $smarty, $obj);
$confObj->caching = Smarty::CACHING_OFF;
$confObj->source = Smarty_Template_Config::load($confObj);
$confObj->source->config_sections = $sections;
$confObj->source->scope = $scope;
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
if ($confObj->smarty->debugging) {
Smarty_Internal_Debug::start_render($confObj);
}
$confObj->compiled->render($confObj);
if ($confObj->smarty->debugging) {
Smarty_Internal_Debug::end_render($confObj);
}
if ($obj instanceof Smarty_Internal_Template) {
$obj->properties['file_dependency'][$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
}
}
示例7: configLoad
/**
* @param $obj
* @param $config_file
* @param null $sections
* @param string $scope
*
* @throws \SmartyException
*/
static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
$confObj = new $smarty->template_class($config_file, $smarty, $obj);
$confObj->context = new Smarty_Internal_Context();
$confObj->caching = Smarty::CACHING_OFF;
$confObj->source = Smarty_Template_Config::load($confObj);
$confObj->source->config_sections = $sections;
$confObj->source->scope = $scope;
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
if ($confObj->smarty->debugging) {
Smarty_Internal_Debug::start_render($confObj);
}
$confObj->compiled->render($confObj);
$confObj->context = null;
if ($confObj->smarty->debugging) {
Smarty_Internal_Debug::end_render($confObj);
}
if ($obj instanceof Smarty_Internal_Template && isset($obj->context)) {
$obj->context->resourceInfo[$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
} else {
// TODO config file dependency if loaded in Smarty, Data or Template object
}
}
示例8: smartyDebug
function smartyDebug()
{
if (!defined('Smarty::SMARTY_VERSION')) {
return;
}
$c = Ethna_Controller::getInstance();
$debug_tpl = $c->getDirectory('template') . "/smarty_debug.tpl";
//if smarty2
//if (!file_exists($debug_tpl)) {
// Ethna::raiseWarning(sprintf("Smarty debug template not found, please set %s.", $debug_tpl), E_USER_WARNING);
// return null;
//}
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_debug.php';
// get template directory
$r = $c->getRenderer();
$smarty = $r->getEngine();
$vars = Smarty_Internal_Debug::get_debug_vars($smarty);
//$smarty_original_debugging = $smarty->debugging;
//$smarty_original_debugtpl = $smarty->debug_tpl;
//$smarty->debugging = true;
//$smarty->debug_tpl = $debug_tpl;
//$smarty->assign('_smarty_debug_output', 'html');
echo '<div class="ethna-debug" id="ethna-debug-smartydebugwindow">';
echo '<div class="ethna-debug-title">SmartyDebug</div>';
echo '<div class="ethna-debug-subtitle">Smarty template vars</div>';
echo "<div class=\"ethna-debug-log\">";
foreach ($vars->tpl_vars as $k => $v) {
$v = array($k => $v->value);
self::dumpArray($v);
}
echo "</div> \n";
echo '<div class="ethna-debug-subtitle">Smarty config vars</div>';
echo "<div class=\"ethna-debug-log\">";
foreach ($vars->config_vars as $k => $v) {
$v = array($k => $v->value);
self::dumpArray($v);
//self::dumpArray($v->value);
}
echo "</div> \n";
echo "</div> \n";
echo '</div>';
//$smarty->debugging = $smarty_original_debugging;
//$smarty->debug_tpl = $smarty_original_debugtpl;
}
示例9: renderTemplate
/**
* Render the output using the compiled template or the PHP template source
*
* The rendering process is accomplished by just including the PHP files.
* The only exceptions are evaluated templates (string template). Their code has
* to be evaluated
*/
public function renderTemplate()
{
if ($this->resource_object->usesCompiler) {
if ($this->mustCompile() && $this->compiled_template === null) {
$this->compileTemplateSource();
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_render($this);
}
$_smarty_tpl = $this;
ob_start();
if ($this->resource_object->isEvaluated) {
eval("?>" . $this->compiled_template);
} else {
include $this->getCompiledFilepath();
// check file dependencies at compiled code
if ($this->smarty->compile_check) {
if (!empty($this->properties['file_dependency'])) {
$this->mustCompile = false;
foreach ($this->properties['file_dependency'] as $_file_to_check) {
$this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name);
if ($resource_type == 'file') {
$mtime = filemtime($_file_to_check[0]);
} else {
$resource_handler = $this->loadTemplateResourceHandler($resource_type);
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
}
// If ($mtime != $_file_to_check[1]) {
if ($mtime > $_file_to_check[1]) {
$this->mustCompile = true;
break;
}
}
if ($this->mustCompile) {
// recompile and render again
ob_get_clean();
$this->compileTemplateSource();
ob_start();
include $this->getCompiledFilepath();
}
}
}
}
} else {
if (is_callable(array($this->resource_object, 'renderUncompiled'))) {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_render($this);
}
ob_start();
$this->resource_object->renderUncompiled($this);
} else {
throw new Exception("Resource '{$this->resource_type}' must have 'renderUncompiled' methode");
}
}
$this->rendered_content = ob_get_clean();
if (!$this->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) {
$this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
}
if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
$this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
$this->parent->required_plugins['compiled'] = array_merge($this->parent->required_plugins['compiled'], $this->required_plugins['compiled']);
$this->parent->required_plugins['cache'] = array_merge($this->parent->required_plugins['cache'], $this->required_plugins['cache']);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_render($this);
}
// write to cache when nessecary
if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_SAVED || $this->caching == SMARTY_CACHING_LIFETIME_CURRENT)) {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_cache($this);
}
$this->properties['has_nocache_code'] = false;
// get text between non-cached items
$cache_split = preg_split("!/\\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!s", $this->rendered_content);
// get non-cached items
preg_match_all("!/\\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!s", $this->rendered_content, $cache_parts);
$output = '';
// loop over items, stitch back together
foreach ($cache_split as $curr_idx => $curr_split) {
// escape PHP tags in template content
$output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', '<?php echo \'$1\'; ?>', $curr_split);
if (isset($cache_parts[0][$curr_idx])) {
$this->properties['has_nocache_code'] = true;
// remove nocache tags from cache output
$output .= preg_replace("!/\\*/?%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
}
}
// rendering (must be done before writing cache file because of {function} nocache handling)
$_smarty_tpl = $this;
ob_start();
eval("?>" . $output);
$this->rendered_content = ob_get_clean();
// write cache file content
//.........这里部分代码省略.........
示例10: fetch
//.........这里部分代码省略.........
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->smarty->debugging = true;
}
}
}
// must reset merge template date
$_template->smarty->merged_templates_func = array();
// get rendered template
// disable caching for evaluated code
if ($_template->source->recompiled) {
$_template->caching = false;
}
// checks if template exists
if (!$_template->source->exists) {
if ($_template->parent instanceof Smarty_Internal_Template) {
$parent_resource = " in '{$_template->parent->template_resource}'";
} else {
$parent_resource = '';
}
throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
}
// read from cache or render
if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
// render template (not loaded and not in cache)
if (!$_template->source->uncompiled) {
/** @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
$_smarty_tpl = $_template;
if ($_template->source->recompiled) {
$code = $_template->compiler->compileTemplate($_template);
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_render($_template);
}
try {
ob_start();
/// dark edit
\Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
/// end edit
eval("?>" . $code);
unset($code);
} catch (Exception $e) {
ob_get_clean();
throw $e;
}
} else {
if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
$_template->compileTemplateSource();
$code = file_get_contents($_template->compiled->filepath);
eval("?>" . $code);
unset($code);
$_template->compiled->loaded = true;
$_template->compiled->isCompiled = true;
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_render($_template);
}
if (!$_template->compiled->loaded) {
include $_template->compiled->filepath;
if ($_template->mustCompile) {
// recompile and load again
$_template->compileTemplateSource();
$code = file_get_contents($_template->compiled->filepath);
eval("?>" . $code);
unset($code);
示例11: popTrace
/**
* restore file and line offset
*/
public function popTrace()
{
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this->template);
}
$r = array_pop($this->trace_stack);
$this->smarty->_current_file = $r[0];
$this->trace_filepath = $r[1];
$this->trace_uid = $r[2];
$this->trace_line_offset = $r[3];
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this->template);
}
}
示例12: getInlineSubTemplate
/**
* Template code runtime function to set up an inline subtemplate
*
* @param string $template the resource handle of the template file
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param integer $caching cache mode
* @param integer $cache_lifetime life time of cache data
* @param array $data passed parameter template variables
* @param int $parent_scope scope in which {include} should execute
* @param string $hash nocache hash code
* @param string $content_func name of content function
*
* @returns object template content
*/
public function getInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash, $content_func)
{
$tpl = $this->setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope);
$tpl->properties['nocache_hash'] = $hash;
if (!isset($this->smarty->template_objects[$tpl->templateId])) {
$this->smarty->template_objects[$tpl->templateId] = $tpl;
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_template($tpl);
Smarty_Internal_Debug::start_render($tpl);
}
$tpl->properties['unifunc'] = $content_func;
$output = $tpl->getRenderedTemplateCode();
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_template($tpl);
Smarty_Internal_Debug::end_render($tpl);
}
if (!empty($tpl->properties['file_dependency'])) {
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $tpl->properties['file_dependency']);
}
$this->properties['tpl_function'] = $tpl->properties['tpl_function'];
return str_replace($tpl->properties['nocache_hash'], $this->properties['nocache_hash'], $output);
}
示例13: compileTemplateSource
/**
* Compiles the template
*
* If the template is not evaluated the compiled template is saved on disk
*/
public function compileTemplateSource()
{
if (!$this->source->recompiled) {
$this->properties['file_dependency'] = array();
if ($this->source->components) {
// uses real resource for file dependency
$source = end($this->source->components);
$this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type);
} else {
$this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type);
}
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this);
}
// compile locking
if ($this->smarty->compile_locking && !$this->source->recompiled) {
if ($saved_timestamp = $this->compiled->timestamp) {
touch($this->compiled->filepath);
}
}
// call compiler
try {
$code = $this->compiler->compileTemplate($this);
} catch (Exception $e) {
// restore old timestamp in case of error
if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) {
touch($this->compiled->filepath, $saved_timestamp);
}
throw $e;
}
// compiling succeded
if (!$this->source->recompiled && $this->compiler->write_compiled_code) {
// write compiled template
$_filepath = $this->compiled->filepath;
if ($_filepath === false) {
throw new SmartyException('getCompiledFilepath() did not return a destination to save the compiled template to');
}
Smarty_Internal_Write_File::writeFile($_filepath, $code, $this->smarty);
$this->compiled->exists = true;
$this->compiled->isCompiled = true;
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this);
}
// release compiler object to free memory
unset($this->compiler);
}
示例14: compileTemplate
/**
* Method to compile Smarty config source.
*
* @param Smarty_Internal_Template $template
*
* @return bool true if compiling succeeded, false if it failed
*/
public function compileTemplate(Smarty_Internal_Template $template)
{
$this->template = $template;
$this->template->properties['file_dependency'][$this->template->source->uid] = [$this->template->source->name, $this->template->source->timestamp, $this->template->source->type];
// on empty config just return
if ($template->source->content == '') {
return true;
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this->template);
}
// init the lexer/parser to compile the config file
$lex = new $this->lexer_class(str_replace(["\r\n", "\r"], "\n", $template->source->content) . "\n", $this);
$parser = new $this->parser_class($lex, $this);
if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
} else {
$mbEncoding = null;
}
if ($this->smarty->_parserdebug) {
$parser->PrintTrace();
}
// get tokens from lexer and parse them
while ($lex->yylex()) {
if ($this->smarty->_parserdebug) {
echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
}
$parser->doParse($lex->token, $lex->value);
}
// finish parsing process
$parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this->template);
}
// template header code
$template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
$template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
$code = '<?php Smarty_Internal_Extension_Config::loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>';
return $template_header . Smarty_Internal_Extension_CodeFrame::create($this->template, $code);
}
示例15: createTemplate
/**
* creates a template object
*
* @param string $template the resource handle of the template file
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
* @param boolean $do_clone flag is Smarty object shall be cloned
*
* @return object template object
*/
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
{
if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) {
$parent = $cache_id;
$cache_id = null;
}
if ($parent !== null && is_array($parent)) {
$data = $parent;
$parent = null;
} else {
$data = null;
}
$_templateId = $this->getTemplateId($template, $cache_id, $compile_id);
if (isset($this->template_objects[$_templateId])) {
if ($do_clone) {
$tpl = clone $this->template_objects[$_templateId];
$tpl->smarty = clone $tpl->smarty;
} else {
$tpl = $this->template_objects[$_templateId];
}
$tpl->parent = $parent;
$tpl->tpl_vars = array();
$tpl->config_vars = array();
} else {
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
if ($do_clone) {
$tpl->smarty = clone $tpl->smarty;
}
$tpl->templateId = $_templateId;
}
// fill data if present
if (!empty($data) && is_array($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
$tpl->tpl_vars[$_key] = new Smarty_Variable($_val);
}
}
if ($this->debugging) {
Smarty_Internal_Debug::register_template($tpl);
}
return $tpl;
}