2011-09-16 14:19:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Smarty Resource Plugin
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage TemplateResources
|
2014-06-06 02:40:04 +00:00
|
|
|
* @author Rodney Rehm
|
2011-09-16 14:19:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Smarty Resource Plugin
|
|
|
|
* Base implementation for resource plugins that don't compile cache
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage TemplateResources
|
|
|
|
*/
|
2013-07-14 22:15:45 +00:00
|
|
|
abstract class Smarty_Resource_Recompiled extends Smarty_Resource
|
|
|
|
{
|
2015-01-01 23:34:29 +01:00
|
|
|
/**
|
|
|
|
* Flag that it's an recompiled resource
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $recompiled = true;
|
|
|
|
|
2015-08-23 01:25:57 +02:00
|
|
|
/**
|
|
|
|
* Resource does implement populateCompiledFilepath() method
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $hasCompiledHandler = true;
|
|
|
|
|
2016-05-15 11:13:31 +02:00
|
|
|
/**
|
|
|
|
* compile template from source
|
|
|
|
*
|
|
|
|
* @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function process(Smarty_Internal_Template $_smarty_tpl)
|
|
|
|
{
|
|
|
|
$compiled = &$_smarty_tpl->compiled;
|
|
|
|
$compiled->file_dependency = array();
|
|
|
|
$compiled->includes = array();
|
|
|
|
$compiled->nocache_hash = null;
|
|
|
|
$compiled->unifunc = null;
|
|
|
|
$level = ob_get_level();
|
|
|
|
ob_start();
|
|
|
|
$_smarty_tpl->loadCompiler();
|
|
|
|
// call compiler
|
|
|
|
try {
|
2017-11-06 01:02:56 +01:00
|
|
|
eval('?>' . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl));
|
2018-08-31 16:45:09 +02:00
|
|
|
} catch (Exception $e) {
|
2016-05-15 11:13:31 +02:00
|
|
|
unset($_smarty_tpl->compiler);
|
|
|
|
while (ob_get_level() > $level) {
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
// release compiler object to free memory
|
|
|
|
unset($_smarty_tpl->compiler);
|
|
|
|
ob_get_clean();
|
|
|
|
$compiled->timestamp = time();
|
|
|
|
$compiled->exists = true;
|
|
|
|
}
|
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* populate Compiled Object with compiled filepath
|
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param Smarty_Template_Compiled $compiled compiled object
|
|
|
|
* @param Smarty_Internal_Template $_template template object
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2011-09-16 14:19:56 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
|
|
|
|
{
|
|
|
|
$compiled->filepath = false;
|
|
|
|
$compiled->timestamp = false;
|
|
|
|
$compiled->exists = false;
|
|
|
|
}
|
2016-05-15 11:13:31 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable timestamp checks for recompiled resource.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-10-26 10:25:41 +02:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-05-15 11:13:31 +02:00
|
|
|
public function checkTimestamps()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|