From 6c4a1e97ef80c650c002d193a08671ec0a6c04a0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 13 Aug 2005 18:25:23 +0000 Subject: [PATCH] Getting closer to it working fully now; just need to figure out the second relativity bit --- template.php | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/template.php b/template.php index 7f962cf..c1c8aeb 100644 --- a/template.php +++ b/template.php @@ -530,27 +530,28 @@ class DB_Template // handle the else if ($tag_full['else']) { - $val = (strlen($fullspread) - strlen($conditional)) - ($tag_full['else'] - $tag_full['posi']) + 2; - $parsed[1] = substr($conditional, 0, $val); + // now relative to the start of the + echo $relpos = $tag_full['else'] - $tag_full['posi']; - print_r($tag_full); + echo '>'; - echo $val . '>>'; - echo $end; + // now relative to the start of iftrue + echo $temp2 = $relpos - 23; + print_around($conditional, $temp2); - 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); + // data2 = 23 + + ### + $parsed[1] = substr($conditional, 0, $temp2); + $parsed[2] = substr($conditional, $temp2 + strlen($tag_else)); } else { $parsed[1] = $conditional; $parsed[2] = ''; } - var_dump($parsed); + #var_dump($parsed); // final parsed output $parsed = '" . ((' . stripslashes($parsed[0]) . ') ? "' . $parsed[1] . '" : "' . $parsed[2] . '") . "'; @@ -569,6 +570,31 @@ class DB_Template } } +/** +* Debugging function used to print characters +* in a string that are around a certain position. +* +* @param string The haystack string +* @param integer Position to print around +*/ +function print_around($str, $pos) +{ + echo '>>> PA >>>>>>>>['; + echo htmlspecialchars($str[ $pos - 5 ]); + echo htmlspecialchars($str[ $pos - 4 ]); + echo htmlspecialchars($str[ $pos - 3 ]); + echo htmlspecialchars($str[ $pos - 2 ]); + echo htmlspecialchars($str[ $pos - 1 ]); + echo '©'; + echo htmlspecialchars($str[ $pos + 0 ]); + echo htmlspecialchars($str[ $pos + 1 ]); + echo htmlspecialchars($str[ $pos + 2 ]); + echo htmlspecialchars($str[ $pos + 3 ]); + echo htmlspecialchars($str[ $pos + 4 ]); + echo htmlspecialchars($str[ $pos + 5 ]); + echo ']<<<<<<<< PA <<<'; +} + /*=====================================================================*\ || ################################################################### || # $HeadURL$ -- 2.22.5