Project

General

Profile

« Previous | Next » 

Revision 445

Added by Matthias about 17 years ago

Optimized search and highlighting funktions

View differences:

frontend.functions.php
68 68

  
69 69
//function to highlight search results
70 70
function search_highlight($foo='', $arr_string=array()) {
71
	$last_string="";
71
	require_once(WB_PATH.'/framework/functions.php');
72
	require(WB_PATH.'/search/search_convert.php');
73
	$foo = entities_to_umlauts($foo, 'UTF-8');
72 74
	foreach($arr_string as $string) {
73
		// filter meta-characters
74
		$string=preg_quote($string, '/');
75
		if ($string!=$last_string ) {
76
			$foo=preg_replace('/((>|;)[^&<]*)('.$string.')(?=[^>;]*(&|<))/iUS', '$1<span class="highlight">$3</span>',$foo);
77
			$last_string=$string;
78
		}
75
		$string = strtr($string, $string_htmlspecialchars_decode);
76
		$string = entities_to_umlauts($string, 'UTF-8');
77
		$string = preg_quote($string, '/');
78
		$string = strtr($string, $string_ul_umlauts);
79
		$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
79 80
	}
81
	$foo = umlauts_to_entities($foo, 'UTF-8', 0);
80 82
	return $foo;
81
}  
83
}
82 84

  
83 85
// Old menu call invokes new menu function
84 86
if (!function_exists('page_menu')) {
......
187 189
						if($_GET['searchresult'] == 2) {
188 190
							// exact match
189 191
							$arr_string[0] = strtr($arr_string[0], "_"," ");
190
							$arr_string[1] = strtr($arr_string[1], "_"," ");
191 192
						}
192 193
						ob_start(); //start output buffer
193 194
						require(WB_PATH.'/modules/'.$module.'/view.php');

Also available in: Unified diff