本文整理汇总了PHP中Smarty_Internal_Debug::start_compile方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Debug::start_compile方法的具体用法?PHP Smarty_Internal_Debug::start_compile怎么用?PHP Smarty_Internal_Debug::start_compile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty_Internal_Debug
的用法示例。
在下文中一共展示了Smarty_Internal_Debug::start_compile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compileTemplateSource
public function compileTemplateSource()
{
if (!$this->source->recompiled) {
$this->properties['file_dependency'] = array();
if ($this->source->components) {
$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);
}
if ($this->smarty->compile_locking && !$this->source->recompiled) {
if ($saved_timestamp = $this->compiled->timestamp) {
touch($this->compiled->filepath);
}
}
try {
$code = $this->compiler->compileTemplate($this);
} catch (Exception $e) {
if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) {
touch($this->compiled->filepath, $saved_timestamp);
}
throw $e;
}
if (!$this->source->recompiled && $this->compiler->write_compiled_code) {
$_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);
}
unset($this->compiler);
}
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:41,代码来源:smarty_internal_template.php
示例2: 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);
}
示例3: compileTemplateSource
/**
* Compiles the template
*
* If the template is not evaluated the compiled template is saved on disk
*/
public function compileTemplateSource()
{
if (!$this->resource_object->isEvaluated) {
$this->properties['file_dependency'] = array();
$this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp(), $this->resource_type);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this);
}
// compile template
if (!is_object($this->compiler_object)) {
// load compiler
$this->smarty->loadPlugin($this->resource_object->compiler_class);
$this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty);
}
// compile locking
if ($this->smarty->compile_locking && !$this->resource_object->isEvaluated) {
if ($saved_timestamp = $this->getCompiledTimestamp()) {
touch($this->getCompiledFilepath());
}
}
// call compiler
try {
$this->compiler_object->compileTemplate($this);
} catch (Exception $e) {
// restore old timestamp in case of error
if ($this->smarty->compile_locking && !$this->resource_object->isEvaluated && $saved_timestamp) {
touch($this->getCompiledFilepath(), $saved_timestamp);
}
throw $e;
}
// compiling succeded
if (!$this->resource_object->isEvaluated && $this->write_compiled_code) {
// write compiled template
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this);
}
// release objects to free memory
Smarty_Internal_TemplateCompilerBase::$_tag_objects = array();
unset($this->compiler_object->parser->root_buffer, $this->compiler_object->parser->current_buffer, $this->compiler_object->parser, $this->compiler_object->lex, $this->compiler_object->template, $this->compiler_object);
}
示例4: fetch
//.........这里部分代码省略.........
} else {
// enable debugging for this page
$this->smarty->debugging = true;
}
} 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) {
$_smarty_tpl = $_template;
if ($_template->source->recompiled) {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($_template);
}
$code = $_template->compiler->compileTemplate($_template);
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($_template);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_render($_template);
}
try {
ob_start();
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();
}
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();
include $_template->compiled->filepath;
}
$_template->compiled->loaded = true;
} else {
示例5: 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);
}
}
示例6: 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);
}
示例7: pushTrace
/**
* push current file and line offset on stack for tracing {block} source lines
* @param string $file new filename
* @param string $uid uid of file
* @param int $line line offset to source
* @param bool $debug false debug end_compile shall not be called
*/
public function pushTrace($file, $uid, $line, $debug = TRUE)
{
if ($this->smarty->debugging && $debug) {
Smarty_Internal_Debug::end_compile($this->template);
}
array_push($this->trace_stack, [$this->smarty->_current_file, $this->trace_filepath, $this->trace_uid, $this->trace_line_offset]);
$this->trace_filepath = $this->smarty->_current_file = $file;
$this->trace_uid = $uid;
$this->trace_line_offset = $line;
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this->template);
}
}
示例8: fetch
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
{
if ($template === null && $this instanceof $this->template_class) {
$template = $this;
}
if (!empty($cache_id) && is_object($cache_id)) {
$parent = $cache_id;
$cache_id = null;
}
if ($parent === null && ($this instanceof Smarty || is_string($template))) {
$parent = $this;
}
$_template = $template instanceof $this->template_class ? $template : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
if ($this instanceof Smarty) {
$_template->caching = $this->caching;
}
if ($merge_tpl_vars) {
$save_tpl_vars = $_template->tpl_vars;
$save_config_vars = $_template->config_vars;
$ptr_array = array($_template);
$ptr = $_template;
while (isset($ptr->parent)) {
$ptr_array[] = $ptr = $ptr->parent;
}
$ptr_array = array_reverse($ptr_array);
$parent_ptr = reset($ptr_array);
$tpl_vars = $parent_ptr->tpl_vars;
$config_vars = $parent_ptr->config_vars;
while ($parent_ptr = next($ptr_array)) {
if (!empty($parent_ptr->tpl_vars)) {
$tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
}
if (!empty($parent_ptr->config_vars)) {
$config_vars = array_merge($config_vars, $parent_ptr->config_vars);
}
}
if (!empty(Smarty::$global_tpl_vars)) {
$tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
}
$_template->tpl_vars = $tpl_vars;
$_template->config_vars = $config_vars;
}
if (!isset($_template->tpl_vars['smarty'])) {
$_template->tpl_vars['smarty'] = new Smarty_Variable();
}
if (isset($this->smarty->error_reporting)) {
$_smarty_old_error_level = error_reporting($this->smarty->error_reporting);
}
if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) {
setcookie('SMARTY_DEBUG', true);
$this->smarty->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) {
setcookie('SMARTY_DEBUG', false);
$this->smarty->debugging = false;
} else {
$this->smarty->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->smarty->debugging = true;
}
}
}
$_template->smarty->merged_templates_func = array();
if ($_template->source->recompiled) {
$_template->caching = false;
}
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}");
}
if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
if (!$_template->source->uncompiled) {
$_smarty_tpl = $_template;
if ($_template->source->recompiled) {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($_template);
}
$code = $_template->compiler->compileTemplate($_template);
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($_template);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_render($_template);
}
try {
ob_start();
eval("?>" . $code);
unset($code);
//.........这里部分代码省略.........
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:101,代码来源:smarty_internal_templatebase.php
示例9: compileTemplateSource
/**
* Compiles the template
*
* If the template is not evaluated the compiled template is saved on disk
*/
public function compileTemplateSource()
{
if (!$this->resource_object->isEvaluated) {
$this->properties['file_dependency'] = array();
$this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this);
}
// compile template
if (!is_object($this->compiler_object)) {
// load compiler
$this->smarty->loadPlugin($this->resource_object->compiler_class);
$this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty);
}
// call compiler
if ($this->compiler_object->compileTemplate($this)) {
// compiling succeded
if (!$this->resource_object->isEvaluated) {
// write compiled template
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty);
}
} else {
// error compiling template
throw new Exception("Error compiling template {$this->getTemplateFilepath()}");
return false;
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this);
}
}
示例10: 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;
// 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(array("\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);
}
$code = 'Smarty_Internal_Extension_Config::loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . ');' . "\n";
return Smarty_Internal_Extension_CodeFrame::create($this->template, array(), $code);
}
示例11: compileTemplateSource
/**
* Compiles the template
*
* If the template is not evaluated the compiled template is saved on disk
*/
public function compileTemplateSource()
{
if (!$this->isEvaluated) {
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this);
}
// compile template
if (!is_object($this->compiler_object)) {
// load compiler
$this->smarty->loadPlugin($this->resource_object->compiler_class);
$this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty);
// load cacher
if ($this->caching) {
$this->smarty->loadPlugin($this->cacher_class);
$this->cacher_object = new $this->cacher_class($this->smarty);
}
}
// call compiler
if ($this->compiler_object->compileTemplate($this)) {
// compiling succeded
if (!$this->isEvaluated()) {
// write compiled template
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty);
// make template and compiled file timestamp match
/**
$this->compiled_timestamp = null;
touch($this->getCompiledFilepath(), $this->getTemplateTimestamp());
// daylight saving time problem on windows
if ($this->template_timestamp != $this->getCompiledTimestamp()) {
touch($this->getCompiledFilepath(), 2 * $this->template_timestamp - $this->compiled_timestamp);
}
**/
}
} else {
// error compiling template
throw new Exception("Error compiling template {$this->getTemplateFilepath()}");
return false;
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this);
}
}