Commit 59d28f45 by Seldaek

* User classes extending Dwoo_Template_File are now supporter better with

regard to includes - Thanks to the Kayako.com team for the patch * Objects now act like arrays when you access non-existing properties on them (i.e. it outputs a notice only if it's output straight, and none when passed to a function) git-svn-id: svn://dwoo.org/dwoo/trunk@260 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 2e126167
......@@ -19,6 +19,11 @@
core and he will be its maintainer from now on
* Adapters: Zend: Denis Arh is now appointed maintainer of that part and
fixed a few things since 1.0.1
* User classes extending Dwoo_Template_File are now supporter better with
regard to includes - Thanks to the Kayako.com team for the patch
* Objects now act like arrays when you access non-existing properties on
them (i.e. it outputs a notice only if it's output straight, and none
when passed to a function)
* Fixed a bug with parsing AND/OR keywords in conditionals when they were
followed by round brackets
* Fixed assignments not handling multi-line values correctly
......
......@@ -1177,9 +1177,10 @@ class Dwoo
*
* @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
* @param mixed $data the data array or object to read from
* @param bool $safeRead if true, the function will check whether the index exists to prevent any notices from being output
* @return mixed
*/
public function readVarInto($varstr, $data)
public function readVarInto($varstr, $data, $safeRead = false)
{
if ($data === null) {
return null;
......@@ -1194,13 +1195,13 @@ class Dwoo
while (list($k, $sep) = each($m[1])) {
if ($sep === '.' || $sep === '[' || $sep === '') {
if ((is_array($data) || $data instanceof ArrayAccess) && isset($data[$m[2][$k]])) {
if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) {
$data = $data[$m[2][$k]];
} else {
return null;
}
} else {
if (is_object($data)) {
if (is_object($data) && ($safeRead === false || isset($data->$m[2][$k]))) {
$data = $data->$m[2][$k];
} else {
return null;
......
......@@ -2322,7 +2322,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
if (count($m[2])) {
unset($m[0]);
$output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.')';
$output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false': 'true').')';
}
}
} else {
......@@ -2389,7 +2389,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
}
}
}
$out .= $recursed ? ')."' : '';
$out .= $recursed ? ', true)."' : '';
return $out;
}
......
......@@ -234,7 +234,11 @@ class Dwoo_Template_File extends Dwoo_Template_String
}
}
return new Dwoo_Template_File($resourceId, $cacheTime, $cacheId, $compileId, $includePath);
$class = 'Dwoo_Template_File';
if ($parentTemplate) {
$class = get_class($parentTemplate);
}
return new $class($resourceId, $cacheTime, $cacheId, $compileId, $includePath);
}
/**
......
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