From: <sy...@us...> - 2005-05-21 11:25:24
|
Update of /cvsroot/tikiwiki/tiki/lib/smarty_tiki In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32016/lib/smarty_tiki Modified Files: Tag: BRANCH-1-9 outputfilter.highlight.php Log Message: don't highlight in head section and popup (and so don't break the code Index: outputfilter.highlight.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/outputfilter.highlight.php,v retrieving revision 1.4.2.6 retrieving revision 1.4.2.7 diff -u -d -r1.4.2.6 -r1.4.2.7 --- outputfilter.highlight.php 12 Feb 2005 19:37:39 -0000 1.4.2.6 +++ outputfilter.highlight.php 21 May 2005 11:25:16 -0000 1.4.2.7 @@ -46,16 +46,27 @@ return $source; } + // Pull out the head block + preg_match_all("!<head>.*?</head>!is", $source, $match); + $_head_blocks = $match[0]; + $source = preg_replace("!<head>.*</head>!is", '@@@==:==@@@', $source); + // Pull out the script blocks preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match); $_script_blocks = $match[0]; $source = preg_replace("!<script[^>]+>.*?</script>!is", '@@@=====@@@', $source); + //pull out the onmouseover (for the user popup) + preg_match_all('!onmouseover="[^"]*"!is', $source, $match); + $_mouse_blocks = $match[0]; + $source = preg_replace('!onmouseover="[^"]*"!is', '@@@ONMOUSEOVER@@@', $source); + // pull out all html tags preg_match_all("'<[\/\!]*?[^<>]*?>'si", $source, $match); $_tag_blocks = $match[0]; $source = preg_replace("'<[\/\!]*?[^<>]*?>'si", '@@@:=====:@@@', $source); + // This array is used to choose colors for supplied highlight terms $colorArr = array('#ffff66','#ff9999','#A0FFFF','#ff66ff','#99ff99'); @@ -65,18 +76,25 @@ $wordArr = split('(%20)|[\+ ]',(htmlentities($highlight))); // htmlentities is safe but it would be better to do strip_tags() only the performance hit is too great foreach($wordArr as $word) { $word = preg_quote($word); - $source = preg_replace('~('.$word.')~si', '<span style="color:black;background-color:'.$colorArr[$i].';">$1</span>', $source); + $source = preg_replace('~('.$word.')~si', '<span style=\\"color:black;background-color:'.$colorArr[$i].';">$1</span>', $source); $i++; } - // replace script blocks + foreach($_tag_blocks as $curr_block) { + $source = preg_replace("!@@@:=====:@@@!",$curr_block,$source,1); + } + + foreach($_mouse_blocks as $curr_block) { + $source = preg_replace("!@@@ONMOUSEOVER@@@!",$curr_block,$source,1); + } + foreach($_script_blocks as $curr_block) { $source = preg_replace("!@@@=====@@@!",$curr_block,$source,1); } - foreach($_tag_blocks as $curr_block) { - $source = preg_replace("!@@@:=====:@@@!",$curr_block,$source,1); - } + foreach($_head_blocks as $curr_block) { + $source = preg_replace("!@@@==:==@@@!",$curr_block,$source,1); + } return $source; } |