From 7591f8a44a3304a98600065f44ce5e37ed3491b2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 19 Mar 2005 00:48:22 +0000 Subject: [PATCH] We now properly extract the condition :-) --- template.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/template.php b/template.php index 5f7cdd6..fa168d8 100644 --- a/template.php +++ b/template.php @@ -409,25 +409,27 @@ class DB_Template $char = $template[ $i ]; // is the char equal to the first character of the expression? - if ($char == substr($tag_start, 0, 1)) + if ($char == substr($tag_start, 0, 1) OR $char == substr($tag_end, 0, 1)) { // we've found ourselves a condition! if (substr($template, $i, strlen($tag_start)) == $tag_start) { // where do we end the condition $end = strpos($template, $tag_start_end, $i); - // echo " >>>>>> " . $end . " >>>>>> "; + $end += strlen($tag_start_end)/* - 1*/; //echo $template[ $end - 2 ] . $template[ $end - 1 ] . $template[ $end ] . $template[ $end + 1 ] . $template[ $end + 2 ] . " (" . $template[ $end ] . ") "; - $end += strlen($tag_start_end); //echo " { " . $template[ $end - 1 ] . " } "; + //echo " >>>>>> " . $end . " >>>>>> "; // extract the condition - $condition = substr($template, $i, $end); + $condition = substr($template, $i, $end - $i); - // echo $condition . "||||||"; + echo "||||||" . $_isso->sanitize($condition) . "||||||"; // complete the open - array_push($stack, /*array('pos' => $i, 'expr' => $condition)*/ $i); + array_push($stack,/* array('pos' => $i, 'expr' => $condition) /**/$i); + + //print_r($stack); } // do we have an end? // make sure that it's the whole tag @@ -460,14 +462,19 @@ class DB_Template // place it in iff() $parsed = '" . iff(' . stripslashes($expression) . ',"' . $conditional . '","") . "'; + //echo "<<<< $parsed >>>> "; + // replace it back into the template $template = substr_replace($template, $parsed, $i, $end); + //echo ">>>>>>>>>>> $template <<<<<<<<<<"; + //echo "<<<<<<<<<<<<<<<<< $conditional >>>>>>>>>>>"; } } } - return $template; + return ''; + //return $template; // ------------------------------ // ------ END //exit; -- 2.43.5