From: <mo...@us...> - 2005-08-29 03:15:09
|
Update of /cvsroot/tikiwiki/tiki/lib/smarty_tiki In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15308/lib/smarty_tiki Modified Files: outputfilter.highlight.php Log Message: Instant-Auto-Merge from BRANCH-1-9 to HEAD Index: outputfilter.highlight.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/lib/smarty_tiki/outputfilter.highlight.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- outputfilter.highlight.php 16 Jun 2005 20:11:02 -0000 1.8 +++ outputfilter.highlight.php 29 Aug 2005 03:14:44 -0000 1.9 @@ -1,5 +1,5 @@ <?php - +// $Id$ //this script may only be included - so its better to die if called directly. if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) { header("location: index.php"); @@ -17,10 +17,10 @@ * Version: 1.0 * Date: Aug 10, 2003 * Purpose: Adds Google-cache-like highlighting for terms in a - * template after its rendered. This can be used + * template after its rendered. This can be used * easily integrated with the wiki search functionality * to provide highlighted search terms. - * Install: Drop into the plugin directory, call + * Install: Drop into the plugin directory, call * $smarty->load_filter('output','highlight'); * from application. * Author: Greg Hinkle <gh...@us...> @@ -30,8 +30,8 @@ */ function smarty_outputfilter_highlight($source, &$smarty) { global $feature_referer_highlight; - - $highlight = $_REQUEST['highlight']; + + $highlight = $_REQUEST['highlight']; if(isset($feature_referer_highlight) && $feature_referer_highlight == 'y') { $refererhi = _refererhi(); if(isset($refererhi) && !empty($refererhi)) { @@ -49,12 +49,12 @@ // Pull out the head block preg_match_all("!<head>.*?</head>!is", $source, $match); $_head_blocks = $match[0]; - $source = preg_replace("!<head>.*</head>!is", '@@@==:==@@@', $source); + $source = preg_replace("!<head>.*?</head>!is", '@@@==:==@@@', $source); // Pull out the div with nohightlight - preg_match_all("!<div[^>]*nohighlight.*</div>\{\*nohighlight!is", $source, $match); + preg_match_all("!<div[^>]*nohighlight.*?</div>\{\*nohighlight!is", $source, $match); $_div_blocks = $match[0]; - $source = preg_replace("!<div[^>]*nohighlight.*</div>\{\*nohighlight!is", '@@@=:=@@@', $source); + $source = preg_replace("!<div[^>]*nohighlight.*?</div>\{\*nohighlight!is", '@@@=:=@@@', $source); // Pull out the script blocks preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match); @@ -62,15 +62,15 @@ $source = preg_replace("!<script[^>]+>.*?</script>!is", '@@@=====@@@', $source); //pull out the onmouseover (for the user popup) - preg_match_all('!onmouseover="[^"]*"!is', $source, $match); + preg_match_all('!onmouseover=("[^"]*"|\'[^\']*\')!is', $source, $match); $_mouse_blocks = $match[0]; - $source = preg_replace('!onmouseover="[^"]*"!is', '@@@ONMOUSEOVER@@@', $source); + $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'); @@ -79,8 +79,8 @@ $i = 0; $wordArr = split('(%20)|[\+ ]',$highlight); // htmlentities is safe but it would be better to do strip_tags() only the performance hit is too great -> htmlentities is not safe with accent foreach($wordArr as $word) { - $word = preg_quote($word); - $source = preg_replace('~('.$word.')~si', '<span style=\\"color:black;background-color:'.$colorArr[$i].';">$1</span>', $source); + $word = preg_quote($word, '~'); + $source = preg_replace('~('.$word.')~si', '<span style=\\"color:black;background-color:'.$colorArr[$i].';">$1</span>', $source); $i++; } |