2009-03-22 16:09:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-08-17 15:39:51 +00:00
|
|
|
* Smarty Internal Plugin Resource String
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2010-08-17 15:39:51 +00:00
|
|
|
* @subpackage TemplateResources
|
2014-06-06 02:40:04 +00:00
|
|
|
* @author Uwe Tews
|
|
|
|
* @author Rodney Rehm
|
2010-08-17 15:39:51 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-08-17 15:39:51 +00:00
|
|
|
* Smarty Internal Plugin Resource String
|
2011-09-16 14:19:56 +00:00
|
|
|
* Implements the strings as resource for Smarty template
|
|
|
|
* {@internal unlike eval-resources the compiled state of string-resources is saved for subsequent access}}
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage TemplateResources
|
2010-08-17 15:39:51 +00:00
|
|
|
*/
|
2013-07-14 22:15:45 +00:00
|
|
|
class Smarty_Internal_Resource_String extends Smarty_Resource
|
|
|
|
{
|
2009-09-30 18:28:50 +00:00
|
|
|
/**
|
2011-09-16 14:19:56 +00:00
|
|
|
* populate Source Object with meta data from Resource
|
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param Smarty_Template_Source $source source 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
|
2010-08-17 15:39:51 +00:00
|
|
|
*/
|
2014-06-06 02:40:04 +00:00
|
|
|
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
2009-09-30 18:28:50 +00:00
|
|
|
{
|
2015-12-24 02:29:21 +01:00
|
|
|
$source->uid = $source->filepath = sha1($source->name . $source->smarty->_joined_template_dir);
|
2016-05-15 11:13:31 +02:00
|
|
|
$source->timestamp = $source->exists = true;
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
|
|
|
|
/**
|
2011-09-16 14:19:56 +00:00
|
|
|
* Load template's source from $resource_name into current template object
|
|
|
|
*
|
2011-10-13 13:10:06 +00:00
|
|
|
* @uses decode() to decode base64 and urlencoded template_resources
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param Smarty_Template_Source $source source object
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string template source
|
2010-08-17 15:39:51 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function getContent(Smarty_Template_Source $source)
|
2011-10-13 13:10:06 +00:00
|
|
|
{
|
|
|
|
return $this->decode($source->name);
|
|
|
|
}
|
2013-07-14 22:15:45 +00:00
|
|
|
|
2011-10-13 13:10:06 +00:00
|
|
|
/**
|
|
|
|
* decode base64 and urlencode
|
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param string $string template_resource to decode
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2011-10-13 13:10:06 +00:00
|
|
|
* @return string decoded template_resource
|
|
|
|
*/
|
|
|
|
protected function decode($string)
|
2011-09-16 14:19:56 +00:00
|
|
|
{
|
|
|
|
// decode if specified
|
2011-10-13 13:10:06 +00:00
|
|
|
if (($pos = strpos($string, ':')) !== false) {
|
|
|
|
if (!strncmp($string, 'base64', 6)) {
|
|
|
|
return base64_decode(substr($string, 7));
|
|
|
|
} elseif (!strncmp($string, 'urlencode', 9)) {
|
|
|
|
return urldecode(substr($string, 10));
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2010-10-01 13:19:53 +00:00
|
|
|
}
|
2011-10-13 13:10:06 +00:00
|
|
|
return $string;
|
|
|
|
}
|
2013-07-14 22:15:45 +00:00
|
|
|
|
2011-10-13 13:10:06 +00:00
|
|
|
/**
|
|
|
|
* modify resource_name according to resource handlers specifications
|
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param Smarty $smarty Smarty instance
|
|
|
|
* @param string $resource_name resource_name to make unique
|
|
|
|
* @param boolean $isConfig flag for config resource
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2011-10-13 13:10:06 +00:00
|
|
|
* @return string unique resource name
|
|
|
|
*/
|
2015-01-01 23:34:29 +01:00
|
|
|
public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false)
|
2011-10-13 13:10:06 +00:00
|
|
|
{
|
2014-06-06 02:40:04 +00:00
|
|
|
return get_class($this) . '#' . $this->decode($resource_name);
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2010-10-01 13:19:53 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2011-09-16 14:19:56 +00:00
|
|
|
* Determine basename for compiled filename
|
|
|
|
* Always returns an empty string.
|
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param Smarty_Template_Source $source source object
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string resource's basename
|
2010-08-17 15:39:51 +00:00
|
|
|
*/
|
2015-01-01 23:34:29 +01:00
|
|
|
public function getBasename(Smarty_Template_Source $source)
|
2010-10-01 13:19:53 +00:00
|
|
|
{
|
2011-09-16 14:19:56 +00:00
|
|
|
return '';
|
|
|
|
}
|
2016-05-15 11:13:31 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable timestamp checks for string 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
|
|
|
}
|