From 4bd0efd3eacaa8e11b6b711e04e0c527ad926a16 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Wed, 31 Mar 2004 22:26:15 +0000 Subject: bug 23 : search case insensitive BUT highlightning case sensitive git-svn-id: http://piwigo.org/svn/branches/release-1_3@410 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/include/functions.inc.php b/include/functions.inc.php index 94050d13b..2a3a795c8 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -260,10 +260,17 @@ function get_languages( $rep_language ) return $languages; } -// - add_style replaces the -// $search into $search -// in the given $string. -// - The function does not replace characters in HTML tags +/** + * replaces the $search into $search in the + * given $string. + * + * case insensitive replacements, does not replace characters in HTML tags + * + * @param string $string + * @param string $search + * @param string $style + * @return string + */ function add_style( $string, $search, $style ) { //return $string; @@ -277,15 +284,17 @@ function add_style( $string, $search, $style ) while ( is_numeric( $start ) and is_numeric( $end ) ) { $treatment = substr ( $remaining, 0, $start ); - $treatment = str_replace( $search, ''. - $search.'', $treatment ); + $treatment = preg_replace( '/('.$search.')/i', + '\\0', + $treatment ); $return_string.= $treatment.substr( $remaining, $start, $end-$start+1 ); $remaining = substr ( $remaining, $end + 1, strlen( $remaining ) ); $start = strpos ( $remaining, '<' ); $end = strpos ( $remaining, '>' ); } - $treatment = str_replace( $search, ''. - $search.'', $remaining ); + $treatment = preg_replace( '/('.$search.')/i', + '\\0', + $remaining ); $return_string.= $treatment; return $return_string; -- cgit v1.2.3