mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 11:54:26 +02:00
- reactivated PHP resource for simple PHP templates. Must set allow_php_templates = true to enable
- {PHP} tag can be enabled by allow_php_tag = true
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
10/01/2009
|
||||||
|
- reactivated PHP resource for simple PHP templates. Must set allow_php_templates = true to enable
|
||||||
|
- {PHP} tag can be enabled by allow_php_tag = true
|
||||||
|
|
||||||
09/30/2009
|
09/30/2009
|
||||||
- fixed handling template_exits methode for all resource types
|
- fixed handling template_exits methode for all resource types
|
||||||
|
@@ -6,13 +6,11 @@ $smarty = new Smarty;
|
|||||||
|
|
||||||
|
|
||||||
//$smarty->force_compile = true;
|
//$smarty->force_compile = true;
|
||||||
//$smarty->debugging = true;
|
$smarty->debugging = true;
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
$smarty->caching_lifetime = 120;
|
$smarty->cache_lifetime = 120;
|
||||||
|
|
||||||
|
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
|
||||||
|
|
||||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
|
|
||||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||||
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
|
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package SmartyTestScripts
|
* @package SmartyTestScripts
|
||||||
*/
|
*/
|
||||||
require('../libs/Smarty.class.php');
|
require('../libs/Smarty.class.php');
|
||||||
ini_set('short_open_tag','1');
|
|
||||||
|
|
||||||
class Person
|
class Person
|
||||||
{
|
{
|
||||||
@@ -31,11 +30,13 @@ ini_set('short_open_tag','1');
|
|||||||
}
|
}
|
||||||
|
|
||||||
$smarty = new Smarty();
|
$smarty = new Smarty();
|
||||||
|
$smarty->allow_php_templates= true;
|
||||||
$smarty->force_compile = false;
|
$smarty->force_compile = false;
|
||||||
$smarty->caching = false;
|
$smarty->caching = true;
|
||||||
$smarty->cache_lifetime = 10;
|
$smarty->cache_lifetime = 100;
|
||||||
|
//$smarty->debugging = true;
|
||||||
|
|
||||||
$smarty->assign('foo','<bar>');
|
$smarty->assign('foo',"'bar'");
|
||||||
|
|
||||||
$person = new Person;
|
$person = new Person;
|
||||||
|
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
PHP file test
|
PHP file test
|
||||||
$foo is <?=$foo?>
|
$foo is <?=$foo?>
|
||||||
<br> Test modifier chaining
|
<br> Test functions
|
||||||
<?=$foo->trim()->escape('html')?>
|
<? echo trim($foo,"'");?>
|
||||||
<br>Test objects
|
<br>Test objects
|
||||||
<?=$person->setName('Paul')->setAge(39)->introduce()->trim()->truncate(10)?>
|
<?=$person->setName('Paul')->setAge(39)->introduce()?>
|
||||||
<br>Test Arrays
|
<br>Test Arrays
|
||||||
<?=$array['a']['aa']->truncate(5)?><?=$array['b']?>
|
<?=$array['a']['aa']?> <?=$array['b']?>
|
||||||
<br>Function
|
<br>function time
|
||||||
<?=$_f->trim($array['a']['aa'])->truncate(10)?>
|
<? echo time();?>
|
||||||
DONE
|
<br>nocache function time
|
||||||
|
<? echo '<? echo time();?>';?>
|
||||||
|
<br>DONE
|
||||||
|
@@ -135,6 +135,8 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
public $right_delimiter = "}";
|
public $right_delimiter = "}";
|
||||||
// security
|
// security
|
||||||
public $php_handling = SMARTY_PHP_PASSTHRU;
|
public $php_handling = SMARTY_PHP_PASSTHRU;
|
||||||
|
public $allow_php_tag = false;
|
||||||
|
public $allow_php_templates = false;
|
||||||
public $security = false;
|
public $security = false;
|
||||||
public $security_policy = null;
|
public $security_policy = null;
|
||||||
public $security_handler = null;
|
public $security_handler = null;
|
||||||
|
@@ -25,9 +25,9 @@ function smarty_block_php($params, $content, $smarty, &$repeat, $template)
|
|||||||
$sec_obj = $smarty;
|
$sec_obj = $smarty;
|
||||||
}
|
}
|
||||||
if (is_null($content)) {
|
if (is_null($content)) {
|
||||||
if ($sec_obj->php_handling != SMARTY_PHP_ALLOW) {
|
if (!$smarty->allow_php_tag) {
|
||||||
trigger_error("{php} is deprecated, set php_handling = SMARTY_PHP_ALLOW to enable",E_USER_WARNING);
|
trigger_error("{php} is deprecated, set allow_php_tag = true to enable", E_USER_WARNING);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class Smarty_Internal_Resource_Stream {
|
|||||||
*/
|
*/
|
||||||
public function isExisting($template)
|
public function isExisting($template)
|
||||||
{
|
{
|
||||||
if ($template->getTemplateSource() === false) {
|
if ($template->getTemplateSource() == '') {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -461,10 +461,16 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Resource '$this->resource_type' must use compiler");
|
if (is_callable(array($this->resource_objects[$this->resource_type], 'renderUncompiled'))) {
|
||||||
|
$_start_time = $this->_get_time();
|
||||||
|
ob_start();
|
||||||
|
$this->resource_objects[$this->resource_type]->renderUncompiled($this);
|
||||||
|
} else {
|
||||||
|
throw new Exception("Resource '$this->resource_type' must have 'renderUncompiled' methode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->render_time += $this->_get_time() - $_start_time;
|
|
||||||
$this->rendered_content = ob_get_clean();
|
$this->rendered_content = ob_get_clean();
|
||||||
|
$this->render_time += $this->_get_time() - $_start_time;
|
||||||
if (!$this->isEvaluated) {
|
if (!$this->isEvaluated) {
|
||||||
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
|
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
|
||||||
}
|
}
|
||||||
@@ -476,10 +482,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
|||||||
if (!$this->isEvaluated() && $this->caching) {
|
if (!$this->isEvaluated() && $this->caching) {
|
||||||
// write rendered template
|
// write rendered template
|
||||||
$this->writeCachedContent($this);
|
$this->writeCachedContent($this);
|
||||||
if ($this->usesCompiler()) {
|
|
||||||
// cache file may contain nocache code. read it back for processing
|
// cache file may contain nocache code. read it back for processing
|
||||||
$this->rendered_content = $this->smarty->cache_resource_objects[$this->caching_type]->getCachedContents($this);
|
$this->rendered_content = $this->smarty->cache_resource_objects[$this->caching_type]->getCachedContents($this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user