From 120bd636f587acaa05559cd13e98e0a18ba3acae Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Wed, 31 Jan 2007 14:26:08 +0000 Subject: [PATCH] Faster smarty filters git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1450 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/platalpage.php | 35 ++++++++++++----------------------- include/emails.inc.php | 8 ++++---- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/classes/platalpage.php b/classes/platalpage.php index fad9a66..30b21c6 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -263,20 +263,14 @@ function at_to_globals($tpl_source, &$smarty) function trimwhitespace($source, &$smarty) { - $tags = array('script', 'pre', 'textarea'); - - foreach ($tags as $tag) { - preg_match_all("!<{$tag}[^>]+>.*?!is", $source, ${$tag}); - $source = preg_replace("!<{$tag}[^>]+>.*?!is", "&&&{$tag}&&&", $source); - } + $tags = '(script|pre|textarea)'; + preg_match_all("!<$tags.*?>.*?!is", $source, $tagsmatches); + $source = preg_replace("!<$tags.*?>.*?!is", "&&&tags&&&", $source); // remove all leading spaces, tabs and carriage returns NOT // preceeded by a php close tag. $source = preg_replace('/((?)\n)[\s]+/m', '\1', $source); - - foreach ($tags as $tag) { - $source = preg_replace("!&&&{$tag}&&&!e", 'array_shift(${$tag}[0])', $source); - } + $source = preg_replace("!&&&tags&&&!e", 'array_shift($tagsmatches[0])', $source); return $source; } @@ -307,20 +301,17 @@ function hide_emails($source, &$smarty) fix_encoding($source); //prevent email replacement in