Browse Source

Tri des tags lors d'une recherche: Prise en compte des espaces

bastien 12 years ago
parent
commit
bf838d2df7
1 changed files with 16 additions and 7 deletions
  1. 16 7
      src/Muzich/CoreBundle/Controller/SearchController.php

+ 16 - 7
src/Muzich/CoreBundle/Controller/SearchController.php View File

@@ -163,23 +163,32 @@ class SearchController extends Controller
163 163
     foreach ($tags as $i => $tag)
164 164
     {
165 165
       // Pas plus de trois caractères en plus de la recherche
166
-      if (strlen(str_replace(strtoupper($search), '', strtoupper($tag['name']))) < 4)
166
+      foreach (explode(' ', $search) as $word)
167 167
       {
168
-        unset($tag_sorted[$i]);
169
-        $tag_sorted = array_merge(array($tag), $tag_sorted);
168
+        if (strlen(str_replace(strtoupper($word), '', strtoupper($tag['name']))) < 4)
169
+        {
170
+          unset($tag_sorted[$i]);
171
+          $tag_sorted = array_merge(array($tag), $tag_sorted);
172
+        }
170 173
       }
174
+      
171 175
     }
172 176
     
173 177
     $tags = $tag_sorted;
174 178
     
175 179
     foreach ($tags as $i => $tag)
176 180
     {
177
-      // Pas plus de trois caractères en plus de la recherche
178
-      if (strtoupper($search) == strtoupper($tag['name']))
181
+      // Chaine de caractère identique
182
+      foreach (explode(' ', $search) as $word)
179 183
       {
180
-        unset($tag_sorted[$i]);
181
-        $tag_sorted = array_merge(array($tag), $tag_sorted);
184
+        if (strtoupper($word) == strtoupper($tag['name']))
185
+        {
186
+          unset($tag_sorted[$i]);
187
+          $tag_sorted = array_merge(array($tag), $tag_sorted);
188
+        }
182 189
       }
190
+      
191
+      
183 192
     }
184 193
     
185 194
     return $tag_sorted;