aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2003-05-25 08:31:39 +0000
committerz0rglub <z0rglub@piwigo.org>2003-05-25 08:31:39 +0000
commit1de10bd66f761f8b66dcaecd28f5c2547b754ff3 (patch)
tree4588721b837ce115214e1f6a1525408fc3e46aa7 /include/functions.inc.php
parent887c7ee4d443259498795d4760cc8d38d359ed38 (diff)
search improved
git-svn-id: http://piwigo.org/svn/trunk@17 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php31
1 files changed, 21 insertions, 10 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 5ff119f29..eb8571e86 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -169,7 +169,7 @@ function get_dirs( $rep )
{
while ( $file = readdir ( $opendir ) )
{
- if ( $file != "." and $file != ".." and is_dir ( $rep.$file ) )
+ if ( $file != '.' and $file != '..' and is_dir ( $rep.$file ) )
{
array_push( $sub_rep, $file );
}
@@ -274,14 +274,14 @@ function get_themes( $theme_dir )
return $themes;
}
-// - The replace_search function replaces a $search string by the search in
-// another color
+// - add_style replaces the
+// $search into <span style="$style">$search</span>
+// in the given $string.
// - The function does not replace characters in HTML tags
-function replace_search( $string, $search )
+function add_style( $string, $search, $style )
{
//return $string;
- $style_search = "background-color:white;color:red;";
- $return_string = "";
+ $return_string = '';
$remaining = $string;
$start = 0;
@@ -291,21 +291,32 @@ function replace_search( $string, $search )
while ( is_numeric( $start ) and is_numeric( $end ) )
{
$treatment = substr ( $remaining, 0, $start );
- $treatment = str_replace( $search, '<span style="'.$style_search.'">'.
+ $treatment = str_replace( $search, '<span style="'.$style.'">'.
$search.'</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 ) );
$start = strpos ( $remaining, '<' );
$end = strpos ( $remaining, '>' );
}
- $treatment = str_replace( $search, '<span style="'.$style_search.'">'.
+ $treatment = str_replace( $search, '<span style="'.$style.'">'.
$search.'</span>', $remaining );
$return_string.= $treatment;
return $return_string;
}
+// replace_search replaces a searched words array string by the search in
+// another style for the given $string.
+function replace_search( $string, $search )
+{
+ $words = explode( ',', $search );
+ $style = 'background-color:white;color:red;';
+ foreach ( $words as $word ) {
+ $string = add_style( $string, $word, $style );
+ }
+ return $string;
+}
+
function database_connection()
{
// $cfgHote,$cfgUser,$cfgPassword,$cfgBase;