Commit e9bbec69 by Seldaek

* SmartyCompat: Fixed a few bugs in the adapter and processor - thanks to Stefan…

* SmartyCompat: Fixed a few bugs in the adapter and processor - thanks to Stefan Moonen for the patches git-svn-id: svn://dwoo.org/dwoo/trunk@210 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 28b6be1f
[2008--] 1.0.0
[2008-10-23] 1.0.0
! BC Break: Small one that probably won't affect anyone, but it makes the
PluginProxy feature much stronger. Basically if you used a custom one you
will get a fatal error and need to update it to conform to the new
......@@ -20,7 +20,7 @@
and optionally public methods (if the new show_methods arg is set to true)
- thanks to Stephan Wentz for the patch
* Adapters: Zend: Added parameters to provide a custom engine (extends Dwoo)
or a custom data class (extends Dwoo_Data) - thanks to Maxime Mrian for
or a custom data class (extends Dwoo_Data) - thanks to Maxime Merian for
the patch
* Compiler: added Dwoo_Compiler->setNestedCommentsHandling(true) to enable
parsing of nested comments (i.e. {* {* *} *} becomes a valid comment, useful
......@@ -33,6 +33,8 @@
* Fixed handling of variable variables that contained non standard characters
* Fixed a 1.0.0beta regression that messed with custom plugin directories
on Windows
* SmartyCompat: Fixed a few bugs in the adapter and processor - thanks to
Stefan Moonen for the patches
[2008-09-08] 1.0.0beta
! Important note : Dwoo.php should not be included directly anymore, please
......
......@@ -150,7 +150,7 @@ class Dwoo_Smarty__Adapter extends Dwoo
protected $dataProvider;
protected $_filters = array('pre'=>array(), 'post'=>array(), 'output'=>array());
protected static $tplCache = array();
protected $compiler;
protected $compiler = null;
public function __construct()
{
......@@ -158,7 +158,6 @@ class Dwoo_Smarty__Adapter extends Dwoo
$this->charset = 'iso-8859-1';
$this->dataProvider = new Dwoo_Data();
$this->compiler = new Dwoo_Compiler();
$this->compiler->smartyCompat = true;
}
public function display($filename, $cacheId=null, $compileId=null)
......@@ -233,6 +232,14 @@ class Dwoo_Smarty__Adapter extends Dwoo
return $this->get($tpl, $this->dataProvider, $this->compiler, $display===true);
}
public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
{
if ($_compiler === null) {
$_compiler = $this->compiler;
}
return parent::get($_tpl, $data, $_compiler, $_output);
}
public function register_function($name, $callback, $cacheable=true, $cache_attrs=null)
{
......@@ -361,7 +368,16 @@ class Dwoo_Smarty__Adapter extends Dwoo
public function template_exists($filename)
{
return file_exists($this->template_dir.DIRECTORY_SEPARATOR.$filename);
if (!is_array($this->template_dir)) {
return file_exists($this->template_dir.DIRECTORY_SEPARATOR.$filename);
} else {
foreach ($this->template_dir as $tpl_dir) {
if (file_exists($tpl_dir.DIRECTORY_SEPARATOR.$filename)) {
return true;
}
}
return false;
}
}
public function is_cached($tpl, $cacheId = null, $compileId = null)
......@@ -446,6 +462,14 @@ class Dwoo_Smarty__Adapter extends Dwoo
}
return self::$tplCache[$hash];
}
public function triggerError($message, $level=E_USER_NOTICE)
{
if (is_object($this->template)) {
return parent::triggerError($message, $level);
}
trigger_error('Dwoo error : '.$message, $level);
}
}
class Dwoo_Smarty_Filter_Adapter extends Dwoo_Filter
......
......@@ -36,7 +36,7 @@ class Dwoo_Processor_smarty_compat extends Dwoo_Processor
'/\$smarty\./',
'/'.$rl.'\s*php\s*'.$rr.'/',
'/'.$rl.'\s*\/php\s*'.$rr.'/',
'/\|(@?)strip/',
'/\|(@?)strip(\||'.$rr.')/',
'/'.$rl.'\s*sectionelse\s*'.$rr.'/',
);
......@@ -49,7 +49,7 @@ class Dwoo_Processor_smarty_compat extends Dwoo_Processor
'$dwoo.',
'<?php ',
' ?>',
'|$1whitespace',
'|$1whitespace$2',
$l.'else'.$r,
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment