2009-04-18 14:46:29 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Smarty Internal Plugin Resource Stream
|
|
|
|
*
|
|
|
|
* Implements the streams as resource for Smarty template
|
|
|
|
*
|
|
|
|
* @package Smarty
|
|
|
|
* @subpackage TemplateResources
|
|
|
|
* @author Uwe Tews
|
|
|
|
*/
|
|
|
|
|
2009-04-18 14:46:29 +00:00
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Smarty Internal Plugin Resource Stream
|
|
|
|
*/
|
2009-08-08 17:28:23 +00:00
|
|
|
class Smarty_Internal_Resource_Stream {
|
|
|
|
public function __construct($smarty)
|
|
|
|
{
|
|
|
|
$this->smarty = $smarty;
|
2011-05-14 10:18:10 +00:00
|
|
|
}
|
2009-04-18 14:46:29 +00:00
|
|
|
// classes used for compiling Smarty templates from file resource
|
|
|
|
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
|
|
|
|
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
|
|
|
|
public $template_parser_class = 'Smarty_Internal_Templateparser';
|
2009-12-27 15:06:49 +00:00
|
|
|
// properties
|
|
|
|
public $usesCompiler = true;
|
|
|
|
public $isEvaluated = true;
|
2009-04-18 14:46:29 +00:00
|
|
|
|
2009-09-30 18:28:50 +00:00
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Return flag if template source is existing
|
|
|
|
*
|
|
|
|
* @return boolean true
|
|
|
|
*/
|
2009-09-30 18:28:50 +00:00
|
|
|
public function isExisting($template)
|
|
|
|
{
|
2009-09-30 22:03:41 +00:00
|
|
|
if ($template->getTemplateSource() == '') {
|
2009-09-30 18:28:50 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
2011-05-14 10:18:10 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-18 14:46:29 +00:00
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Get filepath to template source
|
|
|
|
*
|
|
|
|
* @param object $_template template object
|
|
|
|
* @return string return 'string' as template source is not a file
|
|
|
|
*/
|
2009-04-18 14:46:29 +00:00
|
|
|
public function getTemplateFilepath($_template)
|
2011-05-14 10:18:10 +00:00
|
|
|
{
|
2009-04-18 14:46:29 +00:00
|
|
|
// no filepath for strings
|
|
|
|
// return resource name for compiler error messages
|
2009-10-04 18:12:30 +00:00
|
|
|
return str_replace(':', '://', $_template->template_resource);
|
2011-05-14 10:18:10 +00:00
|
|
|
}
|
2009-04-18 14:46:29 +00:00
|
|
|
|
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Get timestamp to template source
|
|
|
|
*
|
|
|
|
* @param object $_template template object
|
|
|
|
* @return boolean false as string resources have no timestamp
|
|
|
|
*/
|
2009-04-18 14:46:29 +00:00
|
|
|
public function getTemplateTimestamp($_template)
|
2011-05-14 10:18:10 +00:00
|
|
|
{
|
2009-04-18 14:46:29 +00:00
|
|
|
// strings must always be compiled and have no timestamp
|
|
|
|
return false;
|
2011-05-14 10:18:10 +00:00
|
|
|
}
|
2009-04-18 14:46:29 +00:00
|
|
|
|
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Retuen template source from resource name
|
|
|
|
*
|
|
|
|
* @param object $_template template object
|
|
|
|
* @return string content of template source
|
|
|
|
*/
|
2009-04-18 14:46:29 +00:00
|
|
|
public function getTemplateSource($_template)
|
2011-05-14 10:18:10 +00:00
|
|
|
{
|
2009-04-18 14:46:29 +00:00
|
|
|
// return template string
|
|
|
|
$_template->template_source = '';
|
2011-05-14 10:18:10 +00:00
|
|
|
if ($fp = fopen(str_replace(':', '://', $_template->template_resource),'r+')) {
|
2011-05-14 11:11:52 +00:00
|
|
|
while (!feof($fp) && ($current_line = fgets($fp)) !== false ) {
|
|
|
|
$_template->template_source .= $current_line;
|
2011-05-14 10:18:10 +00:00
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 14:46:29 +00:00
|
|
|
|
|
|
|
/**
|
2011-05-14 10:18:10 +00:00
|
|
|
* Get filepath to compiled template
|
|
|
|
*
|
|
|
|
* @param object $_template template object
|
|
|
|
* @return boolean return false as compiled template is not stored
|
|
|
|
*/
|
2009-04-18 14:46:29 +00:00
|
|
|
public function getCompiledFilepath($_template)
|
2011-05-14 10:18:10 +00:00
|
|
|
{
|
2009-04-18 14:46:29 +00:00
|
|
|
// no filepath for strings
|
|
|
|
return false;
|
2011-05-14 10:18:10 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-18 14:46:29 +00:00
|
|
|
|
2010-08-17 15:39:51 +00:00
|
|
|
?>
|