@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package chamilo.search |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -require_once dirname(__FILE__) . '/../inc/global.inc.php'; |
|
| 9 | +require_once dirname(__FILE__).'/../inc/global.inc.php'; |
|
| 10 | 10 | |
| 11 | 11 | function get_suggestions_from_search_engine($q) |
| 12 | 12 | { |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | global $charset; |
| 15 | 15 | |
| 16 | 16 | $json = []; |
| 17 | - $table_sfv = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 17 | + $table_sfv = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 18 | 18 | $q = Database::escape_string($q); |
| 19 | 19 | $cid = api_get_course_id(); |
| 20 | 20 | $sql_add = ''; |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | $i = 0; |
| 29 | 29 | while ($row = Database::fetch_array($sql_result)) { |
| 30 | 30 | $json[] = [ |
| 31 | - 'id' => api_convert_encoding($row['value'],'UTF-8',$charset), |
|
| 32 | - 'value' => api_convert_encoding($row['value'],'UTF-8',$charset), |
|
| 33 | - 'label' => api_convert_encoding($row['value'],'UTF-8',$charset) |
|
| 31 | + 'id' => api_convert_encoding($row['value'], 'UTF-8', $charset), |
|
| 32 | + 'value' => api_convert_encoding($row['value'], 'UTF-8', $charset), |
|
| 33 | + 'label' => api_convert_encoding($row['value'], 'UTF-8', $charset) |
|
| 34 | 34 | ]; |
| 35 | 35 | |
| 36 | - if ($i<20) { |
|
| 37 | - $data[ $row['course_code'] ] [ $row['tool_id'] ] [ $row['ref_id'] ] = 1; |
|
| 36 | + if ($i < 20) { |
|
| 37 | + $data[$row['course_code']] [$row['tool_id']] [$row['ref_id']] = 1; |
|
| 38 | 38 | } |
| 39 | 39 | $i++; |
| 40 | 40 | } |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | // will create a copy as Yannick - Car - Speed |
| 79 | 79 | // in $output[3] |
| 80 | 80 | $c = count($output); |
| 81 | - for ($i=0;$i<$c; $i++) { |
|
| 82 | - $output[($c+$i)] = $current_field_val; |
|
| 81 | + for ($i = 0; $i < $c; $i++) { |
|
| 82 | + $output[($c + $i)] = $current_field_val; |
|
| 83 | 83 | } |
| 84 | 84 | } else { |
| 85 | 85 | //no identical field id, continue as usual |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | foreach ($output as $i=>$out) { |
| 99 | - if (api_stristr($out,$q) === false) {continue;} |
|
| 99 | + if (api_stristr($out, $q) === false) {continue; } |
|
| 100 | 100 | $s = api_convert_encoding(substr($out, 0, -3), 'UTF-8', $charset); |
| 101 | - if (!in_array($s,$more_sugg)) { |
|
| 101 | + if (!in_array($s, $more_sugg)) { |
|
| 102 | 102 | $more_sugg[] = $s; |
| 103 | 103 | $json[] = [ |
| 104 | 104 | 'id' => $s, |