Commit a7470bb1 by Seldaek

* Fixed an optimization causing foreach/for/loop variables not being accessible…

* Fixed an optimization causing foreach/for/loop variables not being accessible when the foreach/.. name was set dynamically git-svn-id: svn://dwoo.org/dwoo/trunk@271 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent ef0858b2
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
* Fixed parameter parsing issue when a plugin name was all uppercased * Fixed parameter parsing issue when a plugin name was all uppercased
* Fixed assignments failing with autoEscape enabled * Fixed assignments failing with autoEscape enabled
* Fixed parsing of vars with string keys that was too greedy * Fixed parsing of vars with string keys that was too greedy
* Fixed an optimization causing foreach/for/loop variables not being
accessible when the foreach/.. name was set dynamically
* Fixed parsing of comments that were on top of the file when there are * Fixed parsing of comments that were on top of the file when there are
spaces at the end of it spaces at the end of it
* Dwoo_Template::$chmod is now enforced for directories as well (#18) * Dwoo_Template::$chmod is now enforced for directories as well (#18)
......
...@@ -58,6 +58,10 @@ class Dwoo_Plugin_for extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Bloc ...@@ -58,6 +58,10 @@ class Dwoo_Plugin_for extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Bloc
$usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false; $usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
$usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false; $usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
if (strpos($name, '$this->scope[') !== false) {
$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
}
// gets foreach id // gets foreach id
$cnt = self::$cnt++; $cnt = self::$cnt++;
......
...@@ -84,6 +84,10 @@ class Dwoo_Plugin_foreach extends Dwoo_Block_Plugin implements Dwoo_ICompilable_ ...@@ -84,6 +84,10 @@ class Dwoo_Plugin_foreach extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
$usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false; $usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
$usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false; $usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
if (strpos($name, '$this->scope[') !== false) {
$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
}
// override globals vars if implode is used // override globals vars if implode is used
if ($params['implode'] !== 'null') { if ($params['implode'] !== 'null') {
$implode = $params['implode']; $implode = $params['implode'];
......
...@@ -75,6 +75,10 @@ class Dwoo_Plugin_loop extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Blo ...@@ -75,6 +75,10 @@ class Dwoo_Plugin_loop extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Blo
$usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false; $usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
$usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false; $usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
if (strpos($name, '$this->scope[') !== false) {
$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
}
// gets foreach id // gets foreach id
$cnt = self::$cnt++; $cnt = self::$cnt++;
......
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