Code

Fixed attribute replacement when attributes share part of names
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Aug 2009 13:49:23 +0000 (13:49 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Aug 2009 13:49:23 +0000 (13:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14095 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_filter.inc

index 1247ad781b62997165444711a8d4efc2d4368145..0bea6c4a69439e0d332efb044255762bf63b26fa 100644 (file)
@@ -123,6 +123,17 @@ class filter {
           $this->alphabetElements[]= $tag;
         }
       }
+
+      // Sort elements for element length to allow proper replacing later on
+      function strlenSort($a, $b) {
+        if (strlen($a['tag']) == strlen($b['tag'])) {
+          return 0;
+        }
+       return (strlen($a['tag']) < strlen($b['tag']) ? -1 : 1);
+      } 
+      uasort($this->elements, 'strlenSort');
+      $this->elements= array_reverse($this->elements);
+
     }
 
     return true;  
@@ -132,7 +143,15 @@ class filter {
   function getTextfield($element)
   {
     $tag= $element['tag'];
-    $result= "<input class='filter_textfield' id='$tag' name='$tag' type='text' size='30' maxlength='30' value='".$this->elementValues[$tag]."'>";
+    $size= 30;
+    if (isset($element['size'])){
+      $size= $element['size'];
+    }
+    $maxlength= 30;
+    if (isset($element['maxlength'])){
+      $maxlength= $element['maxlength'];
+    }
+    $result= "<input class='filter_textfield' id='$tag' name='$tag' type='text' size='$size' maxlength='maxlength' value='".$this->elementValues[$tag]."'>";
     if (isset($element['autocomplete'])) {
       $frequency= "0.5";
       $characters= "1";