From 6f4362df4a11326d117526207e872eda2aad44a3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 13 Aug 2005 08:24:21 +0000 Subject: [PATCH] Still not working right on --- template.php | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/template.php b/template.php index 5530304..7f962cf 100644 --- a/template.php +++ b/template.php @@ -506,13 +506,11 @@ class DB_Template continue; } - $tag_full['posf'] = $i; - // calculate the position of the end tag - $end = $tag_full['posf'] + strlen($tag_end); + $tag_full['posf'] = $i + strlen($tag_end) - 1; - // get the full conditional - $fullspread = substr($template, $tag_full['posi'], $end - $last['posf']); + // extract the entire conditional from the template + $fullspread = substr($template, $tag_full['posi'], $tag_full['posf'] - $tag_full['posi'] + 1); // remove the beginning tag $conditional = substr($fullspread, strlen($tag_start)); @@ -521,29 +519,38 @@ class DB_Template $temp_end = strpos($conditional, $tag_start_end); // save the expression - $expression = stripslashes(substr($conditional, 0, $temp_end)); + $parsed[0] = stripslashes(substr($conditional, 0, $temp_end)); - // remove the expression from the broken conditional - $conditional = substr($conditional, strlen($expression) + strlen($tag_start_end)); + // remove the expression from the conditional + $conditional = substr($conditional, strlen($parsed[0]) + strlen($tag_start_end)); // remove the tailing end tag $conditional = substr($conditional, 0, strlen($conditional) - strlen($tag_end)); - // parsed expression - $parsed[0] = $expression; - // handle the else if ($tag_full['else']) { - $parsed[1] = substr($conditional, 0, strlen($template) - $tag_full['else'] - strlen($conditional)); - $parsed[2] = substr($conditional, strlen($template) - $tag_full['else'] - strlen($conditional)); + $val = (strlen($fullspread) - strlen($conditional)) - ($tag_full['else'] - $tag_full['posi']) + 2; + $parsed[1] = substr($conditional, 0, $val); + + print_r($tag_full); + + echo $val . '>>'; + echo $end; + + echo $tag_full['else'] . '>'; + + echo strlen($fullspread) - strlen($conditional); + echo '>'; + echo $tag_full['else'] - $tag_full['posi']; + $parsed[2] = substr($conditional, $tag_full['posf'] - $tag_full['else'] - 2); } else { $parsed[1] = $conditional; $parsed[2] = ''; } - print_r($parsed); + var_dump($parsed); // final parsed output $parsed = '" . ((' . stripslashes($parsed[0]) . ') ? "' . $parsed[1] . '" : "' . $parsed[2] . '") . "'; @@ -554,6 +561,7 @@ class DB_Template // reset the parser //$i = $tag_full['posi'] + strlen($tag_start) + strlen($tag_start_end); $tag_full = array(); + break; } } -- 2.43.5