From aeffb854422660317252904bc7432872abd9f42b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 12 Aug 2005 21:23:31 +0000 Subject: [PATCH] Lots of broken nothingness --- template.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/template.php b/template.php index 2a5a371..fa14b6d 100644 --- a/template.php +++ b/template.php @@ -473,20 +473,25 @@ class DB_Template $parsed = array(); $elsestack = array(); + // parse flags + $inelse = false; + for ($i = 0; $i < strlen($template); $i++) { // we've found ourselves a conditional! if (substr($template, $i, strlen($tag_start)) == $tag_start) { // push the position into the tag stack - array_push($stack, $i); + array_push($stack, array('pos' => $i, 'depth' => count($stack))); //echo "OPEN `$i`: " . print_r($stack, true); } // locate else tags else if (substr($template, $i, strlen($tag_else)) == $tag_else) { - array_push($elsestack, end($stack)); + $end = end($stack); + $inelse = true; + array_push($elsestack, array('pos' => $i, $end['depth'])); } // do we have an end tag? else if (substr($template, $i, strlen($tag_end)) == $tag_end) @@ -503,7 +508,7 @@ class DB_Template //echo "CLOSE `$last`: " . print_r($stack, true); // get the full conditional - $fullspread = substr($template, $last, $end - $last); + $fullspread = substr($template, $last['pos'], $end - $last['pos']); // remove the beginning tag $conditional = substr($fullspread, strlen($tag_start)); @@ -521,19 +526,23 @@ class DB_Template $conditional = substr($conditional, 0, strlen($conditional) - strlen($tag_end)); // save all the data for later so we can do a quick replacement - $parsed["$depth"]["$last"] = array( + $parsed["$depth"]["$last[pos]"] = array( 'raw' => $fullspread, 'parsed' => '' ); - if (end($elsestack) == $last) + // get the latest else stack + //$else = end($elsestack); + + /* + if ($else['pos'] == $last['pos'] AND $else['depth'] == $last['depth']) { - $parsed["$depth"]["$last"]['parsed'] = '" . ((' . stripslashes($expression) . ') ? "' . $conditional . '") . "'; + $parsed["$depth"]["$last[pos]"]['parsed'] = '" . ((' . stripslashes($expression) . ') ? "' . $conditional . '") . "'; } else { - $parsed["$depth"]["$last"]['parsed'] = '" . ((' . stripslashes($expression) . ') ? "' . $conditional . '" : "") . "'; - } + $parsed["$depth"]["$last[pos]"]['parsed'] = '" . ((' . stripslashes($expression) . ') ? "' . $conditional . '" : "") . "'; + }*/ } } -- 2.22.5