2012-07-04 05:23:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Smarty Internal Plugin Resource Registered
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @package Smarty
|
2012-07-04 05:23:08 +00:00
|
|
|
* @subpackage TemplateResources
|
2014-09-07 11:38:28 +00:00
|
|
|
* @author Uwe Tews
|
|
|
|
* @author Rodney Rehm
|
2012-07-04 05:23:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Smarty Internal Plugin Resource Registered
|
|
|
|
* Implements the registered resource for Smarty template
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @package Smarty
|
2012-07-04 05:23:08 +00:00
|
|
|
* @subpackage TemplateResources
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2014-09-07 11:38:28 +00:00
|
|
|
class Smarty_Internal_Resource_Registered extends Smarty_Resource
|
|
|
|
{
|
2012-07-04 05:23:08 +00:00
|
|
|
/**
|
|
|
|
* populate Source Object with meta data from Resource
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @param Smarty_Template_Source $source source object
|
|
|
|
* @param Smarty_Internal_Template $_template template object
|
|
|
|
*
|
2012-07-04 05:23:08 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2014-09-07 11:38:28 +00:00
|
|
|
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
2012-07-04 05:23:08 +00:00
|
|
|
{
|
|
|
|
$source->filepath = $source->type . ':' . $source->name;
|
|
|
|
$source->uid = sha1($source->filepath);
|
|
|
|
if ($source->smarty->compile_check) {
|
|
|
|
$source->timestamp = $this->getTemplateTimestamp($source);
|
|
|
|
$source->exists = !!$source->timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* populate Source Object with timestamp and exists from Resource
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @param Smarty_Template_Source $source source object
|
|
|
|
*
|
2012-07-04 05:23:08 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function populateTimestamp(Smarty_Template_Source $source)
|
|
|
|
{
|
|
|
|
$source->timestamp = $this->getTemplateTimestamp($source);
|
|
|
|
$source->exists = !!$source->timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get timestamp (epoch) the template source was modified
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @param Smarty_Template_Source $source source object
|
|
|
|
*
|
|
|
|
* @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp
|
2012-07-04 05:23:08 +00:00
|
|
|
*/
|
|
|
|
public function getTemplateTimestamp(Smarty_Template_Source $source)
|
|
|
|
{
|
|
|
|
// return timestamp
|
|
|
|
$time_stamp = false;
|
|
|
|
call_user_func_array($source->smarty->registered_resources[$source->type][0][1], array($source->name, &$time_stamp, $source->smarty));
|
2014-09-07 11:38:28 +00:00
|
|
|
|
2012-07-04 05:23:08 +00:00
|
|
|
return is_numeric($time_stamp) ? (int) $time_stamp : $time_stamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load template's source by invoking the registered callback into current template object
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @param Smarty_Template_Source $source source object
|
|
|
|
*
|
|
|
|
* @return string template source
|
|
|
|
* @throws SmartyException if source cannot be loaded
|
2012-07-04 05:23:08 +00:00
|
|
|
*/
|
|
|
|
public function getContent(Smarty_Template_Source $source)
|
|
|
|
{
|
|
|
|
// return template string
|
|
|
|
$t = call_user_func_array($source->smarty->registered_resources[$source->type][0][0], array($source->name, &$source->content, $source->smarty));
|
|
|
|
if (is_bool($t) && !$t) {
|
|
|
|
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
|
|
|
}
|
2014-09-07 11:38:28 +00:00
|
|
|
|
2012-07-04 05:23:08 +00:00
|
|
|
return $source->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine basename for compiled filename
|
|
|
|
*
|
2014-09-07 11:38:28 +00:00
|
|
|
* @param Smarty_Template_Source $source source object
|
|
|
|
*
|
|
|
|
* @return string resource's basename
|
2012-07-04 05:23:08 +00:00
|
|
|
*/
|
|
|
|
protected function getBasename(Smarty_Template_Source $source)
|
|
|
|
{
|
|
|
|
return basename($source->name);
|
|
|
|
}
|
|
|
|
}
|