Code

Updated autocompletion
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Feb 2010 11:06:11 +0000 (11:06 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Feb 2010 11:06:11 +0000 (11:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15585 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/html/autocomplete.php
gosa-core/html/themes/default/style.css
gosa-core/include/class_filter.inc
gosa-core/include/functions.inc

index caaa3a0c137d2be62b6ad30767a358f232e6a62a..74b46abd22122fd91fd1dd57901e689583b0a0f3 100644 (file)
@@ -49,15 +49,15 @@ if (isset($_GET['type']) && $_GET['type'] == "base") {
         continue;
       }
       if (mb_stristr($info['name'], $search) !== false) {
-        $res.= "<li>".$pathMapping[$dn].($info['description']==''?"":"<span class='informal'> [".$info['description']."]</span>")."</li>";
+        $res.= "<li>".mark($search, $pathMapping[$dn]).($info['description']==''?"":"<span class='informal'> [".mark($search, $info['description'])."]</span>")."</li>";
         continue;
       }
       if (mb_stristr($info['description'], $search) !== false) {
-        $res.= "<li>".$pathMapping[$dn].($info['description']==''?"":"<span class='informal'> [".$info['description']."]</span>")."</li>";
+        $res.= "<li>".mark($search, $pathMapping[$dn]).($info['description']==''?"":"<span class='informal'> [".mark($search, $info['description'])."]</span>")."</li>";
         continue;
       }
       if (mb_stristr($pathMapping[$dn], $search) !== false) {
-        $res.= "<li>".$pathMapping[$dn].($info['description']==''?"":"<span class='informal'> [".$info['description']."]</span>")."</li>";
+        $res.= "<li>".mark($search, $pathMapping[$dn]).($info['description']==''?"":"<span class='informal'> [".mark($search, $info['description'])."]</span>")."</li>";
         continue;
       }
     }
index 302d4f1fd9eb60061a7d233dc698ae8b8d28d1db..8bf92d7a9a9695e5b444cdf4c0f7abc0c725fc87 100644 (file)
@@ -2007,3 +2007,7 @@ font-style:italic;
 * html div.treeList {
 height: expression( this.scrollHeight > 500 ? "500px" : "auto" );
 }
+
+span.mark {
+color:#B22;
+}
index a8bb6fa3ecdd3dd02b19557087a13d0c6213ec43..51ffec05ec18e0656f35b6d17a3a1a3ac4fa9e07 100644 (file)
@@ -530,7 +530,7 @@ class filter {
 
         echo '<ul>';
         foreach ($result as $entry) {
-          echo '<li>'.$entry.'</li>';
+          echo '<li>'.mark($_POST[$tag], $entry).'</li>';
           if ($max-- == 0) {
             break;
           }
index 34ab7348282a21299de084f5255dab123b874207..8609fab62e3f2236c7a81ea923b6bf1b1e3d5542 100644 (file)
@@ -3504,5 +3504,18 @@ function get_next_id_traditional($attrib, $dn)
 }
 
 
+/* Mark the occurance of a string with a span */
+function mark($needle, $haystack, $ignorecase= true)
+{
+  $result= "";
+
+  while (preg_match('/^(.*)('.preg_quote($needle).')(.*)$/i', $haystack, $matches)) {
+    $result.= $matches[1]."<span class='mark'>".$matches[2]."</span>";
+    $haystack= $matches[3];
+  }
+
+  return $result.$haystack;
+}
+
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>