|
@@ -236,6 +236,7 @@ class SearchController extends Controller
|
236
|
236
|
*/
|
237
|
237
|
private function sort_search_tags($tags, $search)
|
238
|
238
|
{
|
|
239
|
+ $same_found = false;
|
239
|
240
|
$canonicalizer = new StrictCanonicalizer();
|
240
|
241
|
$tag_sorted = array();
|
241
|
242
|
|
|
@@ -273,6 +274,7 @@ class SearchController extends Controller
|
273
|
274
|
{
|
274
|
275
|
if (strtoupper($canonicalizer->canonicalize($word)) == strtoupper($tag['slug']))
|
275
|
276
|
{
|
|
277
|
+ $same_found = true;
|
276
|
278
|
$tag_sorted = $this->sort_addtop_if_isnt_in($tag_sorted, $tag);
|
277
|
279
|
}
|
278
|
280
|
}
|
|
@@ -284,7 +286,10 @@ class SearchController extends Controller
|
284
|
286
|
$tag_sorted = $this->sort_addbottom_if_isnt_in($tag_sorted, $tag);
|
285
|
287
|
}
|
286
|
288
|
|
287
|
|
- return $tag_sorted;
|
|
289
|
+ return array(
|
|
290
|
+ 'tags' => $tag_sorted,
|
|
291
|
+ 'same_found' => $same_found
|
|
292
|
+ );
|
288
|
293
|
}
|
289
|
294
|
|
290
|
295
|
/**
|
|
@@ -353,22 +358,24 @@ class SearchController extends Controller
|
353
|
358
|
);
|
354
|
359
|
}
|
355
|
360
|
|
356
|
|
- $tags_response = $this->sort_search_tags($tags_response, $string_search);
|
|
361
|
+ $sort_response = $this->sort_search_tags($tags_response, $string_search);
|
357
|
362
|
$status = 'success';
|
358
|
363
|
$error = '';
|
359
|
364
|
}
|
360
|
365
|
else
|
361
|
366
|
{
|
362
|
367
|
$status = 'error';
|
363
|
|
- $tags_response = array();
|
|
368
|
+ $sort_response = array('tags' => array(), 'same_found' => false);
|
364
|
369
|
$error = 'Vous devez saisir au moins deux caractères';
|
365
|
370
|
}
|
366
|
371
|
|
367
|
372
|
$return_array = array(
|
368
|
|
- 'status' => $status,
|
369
|
|
- 'timestamp' => $timestamp,
|
370
|
|
- 'error' => $error,
|
371
|
|
- 'data' => $tags_response
|
|
373
|
+ 'status' => $status,
|
|
374
|
+ 'timestamp' => $timestamp,
|
|
375
|
+ 'error' => $error,
|
|
376
|
+ 'same_found' => $sort_response['same_found'],
|
|
377
|
+ 'data' => $sort_response['tags']
|
|
378
|
+
|
372
|
379
|
);
|
373
|
380
|
|
374
|
381
|
$response = new Response(json_encode($return_array));
|