From 9feea15ab3b714c91ec2ae72b4b00bdc4e7bceeb Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 19 Mar 2005 04:28:36 +0000 Subject: [PATCH] Broken, just checking in code. --- template.php | 58 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/template.php b/template.php index 9a58c5d..3c6ea03 100644 --- a/template.php +++ b/template.php @@ -391,9 +391,11 @@ class DB_Template function _parse_conditionals($template) { global $_isso; - // Tag locations - $location_start = -1; - $location_end = -1; + + if (!$_isso->is_loaded('functions')) + { + $_isso->load('functions'); + } // Tag data $tag_start = '>>>>>> " . $_isso->sanitize($conditional) . " >>>>>>>"; - // place it in iff() - $parsed = '" . iff(' . stripslashes($expression) . ',"' . $conditional . '","") . "'; + // save all the data for later so we can do a quick replacement + $parsed["$depth"]["$last"] = array( + 'parsed' => '" . iff(' . stripslashes($expression) . ',"' . $conditional . '","") . "', + 'start' => $last, + 'end' => $end, + 'unique' => '', + 'length' => array( + 'raw' => strlen($fullspread), + 'new' => 0 + ) + ); + $parsed["$depth"]["$last"]['unique'] = '' . $_isso->funct->rand(strlen($parsed["$depth"]["$last"]['parsed']) - 15) . ''; + $parsed["$depth"]["$last"]['length']['new'] = strlen($parsed["$depth"]["$last"]['parsed']); + + $temp =& $parsed["$depth"]["$last"]; + + //$template = substr_replace($template, $temp['unique'], $temp['start'], $temp['end']); + + // replace the new unique tag into the mix //echo "<<<< " . $_isso->sanitize($parsed) . " >>>> "; // replace it back into the template - //$template = substr_replace($template, $parsed, $i, $i - $end + strlen($tag_end)); + //$template = substr_replace($template, $parsed, $last, $last - $end + strlen($tag_end)); //echo ">>>>>>>>>>> $template <<<<<<<<<<"; //exit; //echo "<<<<<<<<<<<<<<<<< $conditional >>>>>>>>>>>"; } } + //print_r($parsed); + + $offset = 0; + krsort($parsed); + foreach ($parsed AS $depth => $conditionals) + { + krsort($conditionals); + //print_r($conditionals); + foreach ($conditionals AS $parsed) + { + print_r($parsed); + $template = substr_replace($template, $parsed['parsed'], $parsed['start'] - $offset, strlen($parsed['parsed'])); + echo ' ' . $parsed['length']['raw'] - $parsed['length']['new'] . ' '; + //$template = str_replace($conditional['unique'], $conditional['parsed'], $template); + } + } + + return $template; + return ''; //return $template; // ------------------------------ @@ -506,9 +545,6 @@ class DB_Template $iffalse = null; } - // Put the condition and iftrue in the iff() function - $parsed_expression = '" . iff(' . stripslashes($expression_condition) . ',"' . $iftrue . '","' . $iffalse . '") . "'; - // Parse the iff()'d expression back into the template data $template = substr_replace($template, $parsed_expression, $location_start, $location_end + strlen($tag_end) - $location_start); } -- 2.22.5