|
@@ -156,6 +156,35 @@ class SearchController extends Controller
|
156
|
156
|
throw new \Exception('XmlHttpRequest only for this action');
|
157
|
157
|
}
|
158
|
158
|
|
|
159
|
+ protected function sort_search_tags($tags, $search)
|
|
160
|
+ {
|
|
161
|
+ $tag_sorted = $tags;
|
|
162
|
+
|
|
163
|
+ foreach ($tags as $i => $tag)
|
|
164
|
+ {
|
|
165
|
+ // Pas plus de trois caractères en plus de la recherche
|
|
166
|
+ if (strlen(str_replace(strtoupper($search), '', strtoupper($tag))) < 4)
|
|
167
|
+ {
|
|
168
|
+ unset($tag_sorted[$i]);
|
|
169
|
+ $tag_sorted = array_merge(array($tag), $tag_sorted);
|
|
170
|
+ }
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ $tags = $tag_sorted;
|
|
174
|
+
|
|
175
|
+ foreach ($tags as $i => $tag)
|
|
176
|
+ {
|
|
177
|
+ // Pas plus de trois caractères en plus de la recherche
|
|
178
|
+ if (strtoupper($search) == strtoupper($tag))
|
|
179
|
+ {
|
|
180
|
+ unset($tag_sorted[$i]);
|
|
181
|
+ $tag_sorted = array_merge(array($tag), $tag_sorted);
|
|
182
|
+ }
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ return $tag_sorted;
|
|
186
|
+ }
|
|
187
|
+
|
159
|
188
|
/**
|
160
|
189
|
*
|
161
|
190
|
* @param string $string_search
|
|
@@ -197,6 +226,7 @@ class SearchController extends Controller
|
197
|
226
|
$tags_response[] = $tag['name'];
|
198
|
227
|
}
|
199
|
228
|
|
|
229
|
+ $tags_response = $this->sort_search_tags($tags_response, $string_search);
|
200
|
230
|
$status = 'success';
|
201
|
231
|
$error = '';
|
202
|
232
|
}
|