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
This commit is contained in:
parent
bbacac635c
commit
4bd0efd3ea
1 changed files with 17 additions and 8 deletions
|
@ -260,10 +260,17 @@ function get_languages( $rep_language )
|
||||||
return $languages;
|
return $languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - add_style replaces the
|
/**
|
||||||
// $search into <span style="$style">$search</span>
|
* replaces the $search into <span style="$style">$search</span> in the
|
||||||
// in the given $string.
|
* given $string.
|
||||||
// - The function does not replace characters in HTML tags
|
*
|
||||||
|
* 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 )
|
function add_style( $string, $search, $style )
|
||||||
{
|
{
|
||||||
//return $string;
|
//return $string;
|
||||||
|
@ -277,15 +284,17 @@ function add_style( $string, $search, $style )
|
||||||
while ( is_numeric( $start ) and is_numeric( $end ) )
|
while ( is_numeric( $start ) and is_numeric( $end ) )
|
||||||
{
|
{
|
||||||
$treatment = substr ( $remaining, 0, $start );
|
$treatment = substr ( $remaining, 0, $start );
|
||||||
$treatment = str_replace( $search, '<span style="'.$style.'">'.
|
$treatment = preg_replace( '/('.$search.')/i',
|
||||||
$search.'</span>', $treatment );
|
'<span style="'.$style.'">\\0</span>',
|
||||||
|
$treatment );
|
||||||
$return_string.= $treatment.substr( $remaining, $start, $end-$start+1 );
|
$return_string.= $treatment.substr( $remaining, $start, $end-$start+1 );
|
||||||
$remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
|
$remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
|
||||||
$start = strpos ( $remaining, '<' );
|
$start = strpos ( $remaining, '<' );
|
||||||
$end = strpos ( $remaining, '>' );
|
$end = strpos ( $remaining, '>' );
|
||||||
}
|
}
|
||||||
$treatment = str_replace( $search, '<span style="'.$style.'">'.
|
$treatment = preg_replace( '/('.$search.')/i',
|
||||||
$search.'</span>', $remaining );
|
'<span style="'.$style.'">\\0</span>',
|
||||||
|
$remaining );
|
||||||
$return_string.= $treatment;
|
$return_string.= $treatment;
|
||||||
|
|
||||||
return $return_string;
|
return $return_string;
|
||||||
|
|
Loading…
Reference in a new issue