@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $sql = "SELECT MAX(description_type) as MAX |
178 | 178 | FROM $tbl_course_description |
179 | - WHERE c_id = $course_id AND session_id='" . $this->session_id . "'"; |
|
179 | + WHERE c_id = $course_id AND session_id='".$this->session_id."'"; |
|
180 | 180 | $rs = Database::query($sql); |
181 | 181 | $max = Database::fetch_array($rs); |
182 | 182 | $description_type = $max['MAX'] + 1; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | 'session_id' => $this->session_id |
212 | 212 | ]; |
213 | 213 | |
214 | - $last_id = Database::insert($table, $params); |
|
214 | + $last_id = Database::insert($table, $params); |
|
215 | 215 | |
216 | 216 | if ($last_id > 0) { |
217 | 217 | $sql = "UPDATE $table SET id = iid WHERE iid = $last_id"; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | $sql = "DELETE FROM $tbl_course_description |
320 | 320 | WHERE |
321 | 321 | c_id = $course_id AND |
322 | - id = '" . intval($this->id) . "' AND |
|
323 | - session_id = '" . intval($this->session_id) . "'"; |
|
322 | + id = '".intval($this->id)."' AND |
|
323 | + session_id = '" . intval($this->session_id)."'"; |
|
324 | 324 | $result = Database::query($sql); |
325 | 325 | $affected_rows = Database::affected_rows($result); |
326 | 326 | if ($this->id > 0) { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $course_id = api_get_course_int_id(); |
350 | 350 | |
351 | 351 | $sql = "SELECT id FROM $tbl_course_description |
352 | - WHERE c_id = $course_id AND description_type = '" . intval($description_type) . "'"; |
|
352 | + WHERE c_id = $course_id AND description_type = '".intval($description_type)."'"; |
|
353 | 353 | $rs = Database::query($sql); |
354 | 354 | $row = Database::fetch_array($rs); |
355 | 355 | $description_id = $row['id']; |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * This function is for editing profile info from profile_id. |
|
37 | - * @param int $profileId |
|
38 | - * @param string $name |
|
39 | - * @param string $description |
|
40 | - */ |
|
36 | + * This function is for editing profile info from profile_id. |
|
37 | + * @param int $profileId |
|
38 | + * @param string $name |
|
39 | + * @param string $description |
|
40 | + */ |
|
41 | 41 | public function updateProfileInfo($profileId, $name, $description) |
42 | 42 | { |
43 | 43 | $profileId = intval($profileId); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * This function is for getting profile info from profile_id. |
|
132 | - * @param int $profileId |
|
133 | - */ |
|
131 | + * This function is for getting profile info from profile_id. |
|
132 | + * @param int $profileId |
|
133 | + */ |
|
134 | 134 | |
135 | 135 | public function getProfileInfo($profileId) |
136 | 136 | { |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $attributes = array( |
804 | 804 | 'skill_id' => $skill_id, |
805 | 805 | 'parent_id' => $parent_id, |
806 | - 'relation_type' => (isset($params['relation_type'])?$params['relation_type']:0), |
|
806 | + 'relation_type' => (isset($params['relation_type']) ? $params['relation_type'] : 0), |
|
807 | 807 | //'level' => $params['level'], |
808 | 808 | ); |
809 | 809 | $skill_rel_skill->save($attributes); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | $skills[$skill_id] = $skill_info; |
1013 | 1013 | // Uncomment code below to hide the searched skill |
1014 | 1014 | $skills[$skill_id]['data']['parent_id'] = $skill_info['extra']['parent_id']; |
1015 | - $skills[$skill_id]['parent_id'] = 1; |
|
1015 | + $skills[$skill_id]['parent_id'] = 1; |
|
1016 | 1016 | } |
1017 | 1017 | } |
1018 | 1018 | } |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | $skill['data']['skill_has_gradebook'] = true; |
1078 | 1078 | } |
1079 | 1079 | $refs[$skill['id']] = &$skill; |
1080 | - $flat_array[$skill['id']] = &$skill; |
|
1080 | + $flat_array[$skill['id']] = &$skill; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | // Checking family value |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | $refs['root']['children'][0] = $skills[1]; |
1099 | 1099 | $skills[$skill_id]['data']['family_id'] = 1; |
1100 | 1100 | $refs['root']['children'][0]['children'][0] = $skills[$skill_id]; |
1101 | - $flat_array[$skill_id] = $skills[$skill_id]; |
|
1101 | + $flat_array[$skill_id] = $skills[$skill_id]; |
|
1102 | 1102 | } else { |
1103 | 1103 | // Moving node to the children index of their parents |
1104 | 1104 | |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | $skill['data']['family_id'] = $new_family_array[$skill['id']]; |
1108 | 1108 | } |
1109 | 1109 | $refs[$skill['parent_id']]['children'][] = &$skill; |
1110 | - $flat_array[$my_skill_id] = $skill; |
|
1110 | + $flat_array[$my_skill_id] = $skill; |
|
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | INNER JOIN {$this->table_skill_rel_user} su |
1220 | 1220 | ON (s.id = su.skill_id) |
1221 | 1221 | WHERE user_id = $user_id"; |
1222 | - $result = Database::query($sql); |
|
1222 | + $result = Database::query($sql); |
|
1223 | 1223 | if (Database::num_rows($result)) { |
1224 | 1224 | $result = Database::fetch_row($result); |
1225 | 1225 | return $result[0]; |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | */ |
1262 | 1262 | public function get_user_list_skill_ranking_count() |
1263 | 1263 | { |
1264 | - $sql = "SELECT count(*) FROM ( |
|
1264 | + $sql = "SELECT count(*) FROM ( |
|
1265 | 1265 | SELECT count(distinct 1) |
1266 | 1266 | FROM {$this->table} s |
1267 | 1267 | INNER JOIN {$this->table_skill_rel_user} su |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | ON c.code = g.course_code |
1317 | 1317 | WHERE sg.skill_id = $skill_id |
1318 | 1318 | AND (g.session_id IS NULL OR g.session_id = 0)"; |
1319 | - $result = Database::query($sql); |
|
1319 | + $result = Database::query($sql); |
|
1320 | 1320 | |
1321 | 1321 | return Database::store_result($result, 'ASSOC'); |
1322 | 1322 | } |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | WHERE sg.skill_id = $skillId |
1506 | 1506 | AND g.session_id > 0"; |
1507 | 1507 | |
1508 | - $result = Database::query($sql); |
|
1508 | + $result = Database::query($sql); |
|
1509 | 1509 | |
1510 | 1510 | return Database::store_result($result, 'ASSOC'); |
1511 | 1511 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | require_once 'xapian.php'; |
9 | -require_once dirname(__FILE__) . '/../IndexableChunk.class.php'; |
|
9 | +require_once dirname(__FILE__).'/../IndexableChunk.class.php'; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Abstract helper class |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if (!empty($chunk->terms)) { |
131 | 131 | foreach ($chunk->terms as $term) { |
132 | 132 | /* FIXME: think of getting weight */ |
133 | - $doc->add_term($term['flag'] . $term['name'], 1); |
|
133 | + $doc->add_term($term['flag'].$term['name'], 1); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $doc->clear_terms(); |
216 | 216 | foreach ($terms as $term) { |
217 | 217 | //add directly |
218 | - $doc->add_term($prefix . $term, 1); |
|
218 | + $doc->add_term($prefix.$term, 1); |
|
219 | 219 | } |
220 | 220 | $this->db->replace_document($did, $doc); |
221 | 221 | $this->db->flush(); |
@@ -70,13 +70,16 @@ |
||
70 | 70 | */ |
71 | 71 | function connectDb($path = null, $dbMode = null, $lang = 'english') |
72 | 72 | { |
73 | - if ($this->db != null) |
|
74 | - return $this->db; |
|
75 | - if ($dbMode == null) |
|
76 | - $dbMode = Xapian::DB_CREATE_OR_OPEN; |
|
73 | + if ($this->db != null) { |
|
74 | + return $this->db; |
|
75 | + } |
|
76 | + if ($dbMode == null) { |
|
77 | + $dbMode = Xapian::DB_CREATE_OR_OPEN; |
|
78 | + } |
|
77 | 79 | |
78 | - if ($path == null) |
|
79 | - $path = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'; |
|
80 | + if ($path == null) { |
|
81 | + $path = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'; |
|
82 | + } |
|
80 | 83 | |
81 | 84 | try { |
82 | 85 | $this->db = new XapianWritableDatabase($path, $dbMode); |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | * Code |
9 | 9 | */ |
10 | 10 | require_once 'xapian.php'; |
11 | -require_once dirname(__FILE__) . '/../IndexableChunk.class.php'; |
|
11 | +require_once dirname(__FILE__).'/../IndexableChunk.class.php'; |
|
12 | 12 | //TODO: think another way without including specific fields here |
13 | -require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
13 | +require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
14 | 14 | |
15 | -define('XAPIAN_DB', api_get_path(SYS_UPLOAD_PATH) . 'plugins/xapian/searchdb/'); |
|
15 | +define('XAPIAN_DB', api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Queries the database. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | // process each specific field prefix |
97 | 97 | foreach ($specific_fields as $specific_field) { |
98 | - $results[$count]['sf-' . $specific_field['code']] = xapian_get_doc_terms($document, $specific_field['code']); |
|
98 | + $results[$count]['sf-'.$specific_field['code']] = xapian_get_doc_terms($document, $specific_field['code']); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | // rest of data |
@@ -261,6 +261,6 @@ discard block |
||
261 | 261 | } else { |
262 | 262 | $message_error = get_lang('SearchOtherXapianError'); |
263 | 263 | } |
264 | - $display_message = get_lang('Error') . ' : ' . $message_error; |
|
264 | + $display_message = get_lang('Error').' : '.$message_error; |
|
265 | 265 | Display::display_error_message($display_message); |
266 | 266 | } |
@@ -48,7 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | foreach ($sf_term_array as $raw_term) { |
50 | 50 | $term = substr($raw_term, 1); |
51 | - if (empty($term)) continue; |
|
51 | + if (empty($term)) { |
|
52 | + continue; |
|
53 | + } |
|
52 | 54 | $html_term = htmlspecialchars($term, ENT_QUOTES, $charset); |
53 | 55 | $selected = ''; |
54 | 56 | if (!empty($_REQUEST['sf_'.$prefix]) && is_array($_REQUEST['sf_'.$prefix]) && in_array($term,$_REQUEST['sf_'.$prefix])) { |
@@ -69,7 +71,9 @@ discard block |
||
69 | 71 | $max = count($sf_terms); |
70 | 72 | $multiple_selects .=''; |
71 | 73 | foreach ($sf_terms as $prefix => $sf_term_array) { |
72 | - if ($prefix == $prefilter_prefix) continue; |
|
74 | + if ($prefix == $prefilter_prefix) { |
|
75 | + continue; |
|
76 | + } |
|
73 | 77 | $multiple_select = ''; |
74 | 78 | if ($i>0) { |
75 | 79 | //print "+" image |
@@ -342,9 +346,10 @@ discard block |
||
342 | 346 | |
343 | 347 | // Tool introduction |
344 | 348 | // TODO: Settings for the online editor to be checked (insert an image for example). Probably this is a special case here. |
345 | - if (api_get_course_id() !== -1) |
|
346 | - if (!empty($groupId)) { |
|
349 | + if (api_get_course_id() !== -1) { |
|
350 | + if (!empty($groupId)) { |
|
347 | 351 | Display::display_introduction_section(TOOL_SEARCH.$groupId); |
352 | + } |
|
348 | 353 | } else { |
349 | 354 | Display::display_introduction_section(TOOL_SEARCH); |
350 | 355 | } |
@@ -366,7 +371,9 @@ discard block |
||
366 | 371 | break; |
367 | 372 | } |
368 | 373 | } |
369 | - if ($thesaurus_decided) break; |
|
374 | + if ($thesaurus_decided) { |
|
375 | + break; |
|
376 | + } |
|
370 | 377 | } |
371 | 378 | } |
372 | 379 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * Get one term html select |
31 | 31 | */ |
32 | 32 | function format_one_specific_field_select($prefix, $sf_term_array, $op, $extra_select_attr='size="7" class="sf-select-multiple"') { |
33 | - global $charset; |
|
33 | + global $charset; |
|
34 | 34 | $multiple_select = '<select '. $extra_select_attr .' title="'. $prefix .'" id="sf-'. $prefix .'" name="sf_'. $prefix .'[]">'; |
35 | 35 | |
36 | 36 | $all_selected = ''; |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | * could not send a form in pagination |
120 | 120 | */ |
121 | 121 | |
122 | - if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) { |
|
123 | - $action='index.php'; |
|
124 | - } |
|
125 | - $navigator_info = api_get_navigator(); |
|
122 | + if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) { |
|
123 | + $action='index.php'; |
|
124 | + } |
|
125 | + $navigator_info = api_get_navigator(); |
|
126 | 126 | |
127 | - if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
128 | - $submit_button1 = '<input type="submit" id="submit" value="'. get_lang('Search') .'" />'; |
|
129 | - $submit_button2 = '<input class="lower-submit" type="submit" value="'. get_lang('Search') .'" />'; |
|
127 | + if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
128 | + $submit_button1 = '<input type="submit" id="submit" value="'. get_lang('Search') .'" />'; |
|
129 | + $submit_button2 = '<input class="lower-submit" type="submit" value="'. get_lang('Search') .'" />'; |
|
130 | 130 | $reset_button = '<input type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'; |
131 | - } else { |
|
132 | - $submit_button1 = '<button class="search" type="submit" id="submit" value="'. get_lang("Search") .'" /> '. get_lang('Search') .'</button>'; |
|
133 | - $submit_button2 = '<button class="search" type="submit" value="'. get_lang('Search') .'" />'. get_lang('Search') .'</button>'; |
|
131 | + } else { |
|
132 | + $submit_button1 = '<button class="search" type="submit" id="submit" value="'. get_lang("Search") .'" /> '. get_lang('Search') .'</button>'; |
|
133 | + $submit_button2 = '<button class="search" type="submit" value="'. get_lang('Search') .'" />'. get_lang('Search') .'</button>'; |
|
134 | 134 | $reset_button = '<button class="save" type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'. get_lang('SearchResetKeywords') .'</button> '; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | 137 | $form = '<form id="chamilo_search" action="'. $action .'" method="GET"> |
138 | 138 | <input type="text" id="query" name="query" size="40" value="'.stripslashes(Security::remove_XSS($_REQUEST['query'])).'" /> |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | * SortableTableFromArray pagination is done with simple links, so now we |
198 | 198 | * could not send a form in pagination |
199 | 199 | */ |
200 | - if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) { |
|
201 | - $action='index.php'; |
|
202 | - } |
|
200 | + if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) { |
|
201 | + $action='index.php'; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | $form = ' |
205 | 205 | <form id="chamilo_search" action="'. $action .'" method="GET"> |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | </table> |
265 | 265 | </div>'; |
266 | 266 | } |
267 | - $form .= ' |
|
267 | + $form .= ' |
|
268 | 268 | </form> |
269 | 269 | <br style="clear: both;"/>'; |
270 | 270 | |
@@ -322,10 +322,10 @@ discard block |
||
322 | 322 | foreach ($specific_fields as $specific_field) { |
323 | 323 | $temp = array(); |
324 | 324 | if (is_array($dkterms) && count($dkterms)>0) { |
325 | - foreach($dkterms[1] as $obj) { |
|
326 | - $temp = array_merge($obj['sf-'.$specific_field['code']], $temp); |
|
327 | - } |
|
328 | - } |
|
325 | + foreach($dkterms[1] as $obj) { |
|
326 | + $temp = array_merge($obj['sf-'.$specific_field['code']], $temp); |
|
327 | + } |
|
328 | + } |
|
329 | 329 | $sf_terms[$specific_field['code']] = $temp; |
330 | 330 | $url_params[] = 'sf_'.$specific_field['code']; |
331 | 331 | unset($temp); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | } |
341 | 341 | echo '<h2>'.get_lang('Search').'</h2>'; |
342 | 342 | |
343 | - // Tool introduction |
|
343 | + // Tool introduction |
|
344 | 344 | // TODO: Settings for the online editor to be checked (insert an image for example). Probably this is a special case here. |
345 | 345 | if (api_get_course_id() !== -1) |
346 | 346 | if (!empty($groupId)) { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Code |
9 | 9 | */ |
10 | -require_once dirname(__FILE__) . '/IndexableChunk.class.php'; |
|
10 | +require_once dirname(__FILE__).'/IndexableChunk.class.php'; |
|
11 | 11 | require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
12 | 12 | |
13 | 13 | /** |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * Get one term html select |
31 | 31 | */ |
32 | -function format_one_specific_field_select($prefix, $sf_term_array, $op, $extra_select_attr='size="7" class="sf-select-multiple"') { |
|
32 | +function format_one_specific_field_select($prefix, $sf_term_array, $op, $extra_select_attr = 'size="7" class="sf-select-multiple"') { |
|
33 | 33 | global $charset; |
34 | - $multiple_select = '<select '. $extra_select_attr .' title="'. $prefix .'" id="sf-'. $prefix .'" name="sf_'. $prefix .'[]">'; |
|
34 | + $multiple_select = '<select '.$extra_select_attr.' title="'.$prefix.'" id="sf-'.$prefix.'" name="sf_'.$prefix.'[]">'; |
|
35 | 35 | |
36 | 36 | $all_selected = ''; |
37 | - if (!empty($_REQUEST['sf_'. $prefix]) ) { |
|
38 | - if (in_array('__all__', $_REQUEST['sf_'. $prefix])) { |
|
37 | + if (!empty($_REQUEST['sf_'.$prefix])) { |
|
38 | + if (in_array('__all__', $_REQUEST['sf_'.$prefix])) { |
|
39 | 39 | $all_selected = 'selected="selected"'; |
40 | 40 | } |
41 | 41 | } |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | } else if ($op == 'or') { |
45 | 45 | $all_selected_name = get_lang('Any'); |
46 | 46 | } |
47 | - $multiple_select .= '<option value="__all__" '. $all_selected .' >-- '. $all_selected_name .' --</option>'; |
|
47 | + $multiple_select .= '<option value="__all__" '.$all_selected.' >-- '.$all_selected_name.' --</option>'; |
|
48 | 48 | |
49 | 49 | foreach ($sf_term_array as $raw_term) { |
50 | 50 | $term = substr($raw_term, 1); |
51 | 51 | if (empty($term)) continue; |
52 | 52 | $html_term = htmlspecialchars($term, ENT_QUOTES, $charset); |
53 | 53 | $selected = ''; |
54 | - if (!empty($_REQUEST['sf_'.$prefix]) && is_array($_REQUEST['sf_'.$prefix]) && in_array($term,$_REQUEST['sf_'.$prefix])) { |
|
54 | + if (!empty($_REQUEST['sf_'.$prefix]) && is_array($_REQUEST['sf_'.$prefix]) && in_array($term, $_REQUEST['sf_'.$prefix])) { |
|
55 | 55 | $selected = 'selected="selected"'; |
56 | 56 | } |
57 | - $multiple_select .= '<option value="'. $html_term .'" '.$selected.'>'. $html_term .'</option>'; |
|
57 | + $multiple_select .= '<option value="'.$html_term.'" '.$selected.'>'.$html_term.'</option>'; |
|
58 | 58 | } |
59 | 59 | $multiple_select .= '</select>'; |
60 | 60 | return $multiple_select; |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Get terms html selects |
65 | 65 | */ |
66 | -function format_specific_fields_selects($sf_terms, $op, $prefilter_prefix='') { |
|
66 | +function format_specific_fields_selects($sf_terms, $op, $prefilter_prefix = '') { |
|
67 | 67 | // Process each prefix type term |
68 | 68 | $i = 0; |
69 | 69 | $max = count($sf_terms); |
70 | - $multiple_selects =''; |
|
70 | + $multiple_selects = ''; |
|
71 | 71 | foreach ($sf_terms as $prefix => $sf_term_array) { |
72 | 72 | if ($prefix == $prefilter_prefix) continue; |
73 | 73 | $multiple_select = ''; |
74 | - if ($i>0) { |
|
74 | + if ($i > 0) { |
|
75 | 75 | //print "+" image |
76 | 76 | $multiple_select .= '<td><img class="sf-select-splitter" src="../img/search-big-plus.gif" alt="plus-sign-decoration"/></td>'; |
77 | 77 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | |
90 | 90 | $sf_copy = $sf_term_array; |
91 | 91 | // get specific field name |
92 | - $sf_value = get_specific_field_list(array( 'code' => "'$prefix'" )); |
|
92 | + $sf_value = get_specific_field_list(array('code' => "'$prefix'")); |
|
93 | 93 | $sf_value = array_shift($sf_value); |
94 | - $multiple_select .= '<td><label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">' . $sf_value['name'].'</label><br />'; |
|
94 | + $multiple_select .= '<td><label class="sf-select-multiple-title" for="sf_'.$prefix.'[]">'.$sf_value['name'].'</label><br />'; |
|
95 | 95 | $multiple_select .= format_one_specific_field_select($prefix, $sf_term_array, $op, 'multiple="multiple" size="7" class="sf-select-multiple"'); |
96 | 96 | $multiple_select .= '</td>'; |
97 | 97 | $multiple_selects .= $multiple_select; |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) { |
109 | 109 | $thesaurus_icon = Display::return_icon('thesaurus.gif', get_lang('SearchAdvancedOptions'), array('id'=>'thesaurus-icon')); |
110 | - $advanced_options = '<a id="tags-toggle" href="#">'. get_lang('SearchAdvancedOptions') .'</a>'; |
|
111 | - $display_thesaurus = ($show_thesaurus==true? 'block': 'none'); |
|
112 | - $help = '<h3>'. get_lang('SearchKeywordsHelpTitle') .'</h3>'. get_lang('SearchKeywordsHelpComment'); |
|
113 | - $mode = (!empty($_REQUEST['mode'])? htmlentities($_REQUEST['mode']): 'gallery'); |
|
114 | - $type = (!empty($_REQUEST['type'])? htmlentities($_REQUEST['type']): 'normal'); |
|
110 | + $advanced_options = '<a id="tags-toggle" href="#">'.get_lang('SearchAdvancedOptions').'</a>'; |
|
111 | + $display_thesaurus = ($show_thesaurus == true ? 'block' : 'none'); |
|
112 | + $help = '<h3>'.get_lang('SearchKeywordsHelpTitle').'</h3>'.get_lang('SearchKeywordsHelpComment'); |
|
113 | + $mode = (!empty($_REQUEST['mode']) ? htmlentities($_REQUEST['mode']) : 'gallery'); |
|
114 | + $type = (!empty($_REQUEST['type']) ? htmlentities($_REQUEST['type']) : 'normal'); |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * POST avoid long urls, but we are using GET because |
@@ -119,36 +119,36 @@ discard block |
||
119 | 119 | * could not send a form in pagination |
120 | 120 | */ |
121 | 121 | |
122 | - if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) { |
|
123 | - $action='index.php'; |
|
122 | + if (isset($_GET['action']) && strcmp(trim($_GET['action']), 'search') === 0) { |
|
123 | + $action = 'index.php'; |
|
124 | 124 | } |
125 | 125 | $navigator_info = api_get_navigator(); |
126 | 126 | |
127 | - if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { |
|
128 | - $submit_button1 = '<input type="submit" id="submit" value="'. get_lang('Search') .'" />'; |
|
129 | - $submit_button2 = '<input class="lower-submit" type="submit" value="'. get_lang('Search') .'" />'; |
|
130 | - $reset_button = '<input type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'; |
|
127 | + if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') { |
|
128 | + $submit_button1 = '<input type="submit" id="submit" value="'.get_lang('Search').'" />'; |
|
129 | + $submit_button2 = '<input class="lower-submit" type="submit" value="'.get_lang('Search').'" />'; |
|
130 | + $reset_button = '<input type="submit" id="tags-clean" value="'.get_lang('SearchResetKeywords').'" />'; |
|
131 | 131 | } else { |
132 | - $submit_button1 = '<button class="search" type="submit" id="submit" value="'. get_lang("Search") .'" /> '. get_lang('Search') .'</button>'; |
|
133 | - $submit_button2 = '<button class="search" type="submit" value="'. get_lang('Search') .'" />'. get_lang('Search') .'</button>'; |
|
134 | - $reset_button = '<button class="save" type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'. get_lang('SearchResetKeywords') .'</button> '; |
|
132 | + $submit_button1 = '<button class="search" type="submit" id="submit" value="'.get_lang("Search").'" /> '.get_lang('Search').'</button>'; |
|
133 | + $submit_button2 = '<button class="search" type="submit" value="'.get_lang('Search').'" />'.get_lang('Search').'</button>'; |
|
134 | + $reset_button = '<button class="save" type="submit" id="tags-clean" value="'.get_lang('SearchResetKeywords').'" />'.get_lang('SearchResetKeywords').'</button> '; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $query = isset($_REQUEST['query']) ? Security::remove_XSS($_REQUEST['query']) : null; |
138 | 138 | |
139 | - $form = '<form id="chamilo_search" action="'. $action .'" method="GET"> |
|
140 | - <input type="text" id="query" name="query" size="40" value="' . $query . '" /> |
|
141 | - <input type="hidden" name="mode" value="'. $mode .'"/> |
|
142 | - <input type="hidden" name="type" value="'. $type .'"/> |
|
139 | + $form = '<form id="chamilo_search" action="'.$action.'" method="GET"> |
|
140 | + <input type="text" id="query" name="query" size="40" value="' . $query.'" /> |
|
141 | + <input type="hidden" name="mode" value="'. $mode.'"/> |
|
142 | + <input type="hidden" name="type" value="'. $type.'"/> |
|
143 | 143 | <input type="hidden" name="tablename_page_nr" value="1" /> |
144 | 144 | '.$submit_button1.' |
145 | 145 | <br /><br />'; |
146 | 146 | $list = get_specific_field_list(); |
147 | 147 | |
148 | - if(!empty($list)) { |
|
149 | - $form .= '<span class="search-links-box">'. $advanced_options .' </span> |
|
150 | - <div id="tags" class="tags" style="display:'. $display_thesaurus .';"> |
|
151 | - <div class="search-help-box">'. $help .'</div> |
|
148 | + if (!empty($list)) { |
|
149 | + $form .= '<span class="search-links-box">'.$advanced_options.' </span> |
|
150 | + <div id="tags" class="tags" style="display:'. $display_thesaurus.';"> |
|
151 | + <div class="search-help-box">'. $help.'</div> |
|
152 | 152 | <table> |
153 | 153 | <tr>'; |
154 | 154 | $form .= format_specific_fields_selects($sf_terms, $op); |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | $form .= '</tr> |
163 | 163 | <tr> |
164 | 164 | <td id="operator-select"> |
165 | - '. get_lang('SearchCombineSearchWith') .':<br /> |
|
166 | - <input type="radio" class="search-operator" name="operator" value="or" '. $or_checked .'>'. api_strtoupper(get_lang('Or')) .'</input> |
|
167 | - <input type="radio" class="search-operator" name="operator" value="and" '. $and_checked .'>'. api_strtoupper(get_lang('And')) .'</input> |
|
165 | + '. get_lang('SearchCombineSearchWith').':<br /> |
|
166 | + <input type="radio" class="search-operator" name="operator" value="or" '. $or_checked.'>'.api_strtoupper(get_lang('Or')).'</input> |
|
167 | + <input type="radio" class="search-operator" name="operator" value="and" '. $and_checked.'>'.api_strtoupper(get_lang('And')).'</input> |
|
168 | 168 | </td> |
169 | 169 | <td></td> |
170 | 170 | <td> |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | </table> |
177 | 177 | </div>'; |
178 | 178 | } |
179 | - $form .='</form> |
|
179 | + $form .= '</form> |
|
180 | 180 | <br style="clear: both;"/>'; |
181 | 181 | return $form; |
182 | 182 | } |
@@ -186,36 +186,36 @@ discard block |
||
186 | 186 | * |
187 | 187 | * This type allow filter all other multiple select terms by one term in a dinamic way |
188 | 188 | */ |
189 | -function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op, $prefilter_prefix=NULL) { |
|
189 | +function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op, $prefilter_prefix = NULL) { |
|
190 | 190 | $thesaurus_icon = Display::return_icon('thesaurus.gif', get_lang('SearchAdvancedOptions'), array('id'=>'thesaurus-icon')); |
191 | - $advanced_options = '<a id="tags-toggle" href="#">'. get_lang('SearchAdvancedOptions') .'</a>'; |
|
192 | - $display_thesaurus = ($show_thesaurus==true? 'block': 'none'); |
|
193 | - $help = '<h3>'. get_lang('SearchKeywordsHelpTitle') .'</h3>'. get_lang('SearchKeywordsHelpComment'); |
|
194 | - $mode = (!empty($_REQUEST['mode'])? htmlentities($_REQUEST['mode']): 'gallery'); |
|
195 | - $type = (!empty($_REQUEST['type'])? htmlentities($_REQUEST['type']): 'normal'); |
|
191 | + $advanced_options = '<a id="tags-toggle" href="#">'.get_lang('SearchAdvancedOptions').'</a>'; |
|
192 | + $display_thesaurus = ($show_thesaurus == true ? 'block' : 'none'); |
|
193 | + $help = '<h3>'.get_lang('SearchKeywordsHelpTitle').'</h3>'.get_lang('SearchKeywordsHelpComment'); |
|
194 | + $mode = (!empty($_REQUEST['mode']) ? htmlentities($_REQUEST['mode']) : 'gallery'); |
|
195 | + $type = (!empty($_REQUEST['type']) ? htmlentities($_REQUEST['type']) : 'normal'); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * POST avoid long urls, but we are using GET because |
199 | 199 | * SortableTableFromArray pagination is done with simple links, so now we |
200 | 200 | * could not send a form in pagination |
201 | 201 | */ |
202 | - if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) { |
|
203 | - $action='index.php'; |
|
202 | + if (isset($_GET['action']) && strcmp(trim($_GET['action']), 'search') === 0) { |
|
203 | + $action = 'index.php'; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $form = ' |
207 | - <form id="chamilo_search" action="'. $action .'" method="GET"> |
|
207 | + <form id="chamilo_search" action="'. $action.'" method="GET"> |
|
208 | 208 | <input type="text" id="query" name="query" size="40" /> |
209 | - <input type="hidden" name="mode" value="'. $mode .'"/> |
|
210 | - <input type="hidden" name="type" value="'. $type .'"/> |
|
209 | + <input type="hidden" name="mode" value="'. $mode.'"/> |
|
210 | + <input type="hidden" name="type" value="'. $type.'"/> |
|
211 | 211 | <input type="hidden" name="tablename_page_nr" value="1" /> |
212 | - <input type="submit" id="submit" value="'. get_lang("Search") .'" /> |
|
212 | + <input type="submit" id="submit" value="'. get_lang("Search").'" /> |
|
213 | 213 | <br /><br />'; |
214 | 214 | $list = get_specific_field_list(); |
215 | - if(!empty($list)) { |
|
216 | - $form .=' <span class="search-links-box">'. $thesaurus_icon . $advanced_options .' </span> |
|
217 | - <div id="tags" class="tags" style="display:'. $display_thesaurus .';"> |
|
218 | - <div class="search-help-box">'. $help .'</div> |
|
215 | + if (!empty($list)) { |
|
216 | + $form .= ' <span class="search-links-box">'.$thesaurus_icon.$advanced_options.' </span> |
|
217 | + <div id="tags" class="tags" style="display:'. $display_thesaurus.';"> |
|
218 | + <div class="search-help-box">'. $help.'</div> |
|
219 | 219 | <table> |
220 | 220 | <tr>'; |
221 | 221 | if (!is_null($prefilter_prefix)) { |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | $sf_term_array = $temp; |
231 | 231 | |
232 | 232 | // get specific field name |
233 | - $sf_value = get_specific_field_list(array( 'code' => "'$prefilter_prefix'" )); |
|
233 | + $sf_value = get_specific_field_list(array('code' => "'$prefilter_prefix'")); |
|
234 | 234 | $sf_value = array_shift($sf_value); |
235 | - $form .= '<label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">'.$icons_for_search_terms[$prefix].' '.$sf_value['name'].'</label><br />'; |
|
235 | + $form .= '<label class="sf-select-multiple-title" for="sf_'.$prefix.'[]">'.$icons_for_search_terms[$prefix].' '.$sf_value['name'].'</label><br />'; |
|
236 | 236 | |
237 | 237 | $form .= format_one_specific_field_select($prefilter_prefix, $sf_term_array, $op, 'id="prefilter"'); |
238 | 238 | $form .= format_specific_fields_selects($sf_terms, $op, $prefilter_prefix); |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | </tr> |
253 | 253 | <tr> |
254 | 254 | <td id="operator-select"> |
255 | - '. get_lang('SearchCombineSearchWith') .':<br /> |
|
256 | - <input type="radio" class="search-operator" name="operator" value="or" '. $or_checked .'>'. api_strtoupper(get_lang('Or')) .'</input> |
|
257 | - <input type="radio" class="search-operator" name="operator" value="and" '. $and_checked .'>'. api_strtoupper(get_lang('And')) .'</input> |
|
255 | + '. get_lang('SearchCombineSearchWith').':<br /> |
|
256 | + <input type="radio" class="search-operator" name="operator" value="or" '. $or_checked.'>'.api_strtoupper(get_lang('Or')).'</input> |
|
257 | + <input type="radio" class="search-operator" name="operator" value="and" '. $and_checked.'>'.api_strtoupper(get_lang('And')).'</input> |
|
258 | 258 | </td> |
259 | 259 | <td></td> |
260 | 260 | <td> |
261 | 261 | <br /> |
262 | - <input class="lower-submit" type="submit" value="'. get_lang('Search') .'" /> |
|
263 | - <input type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" /> |
|
262 | + <input class="lower-submit" type="submit" value="'. get_lang('Search').'" /> |
|
263 | + <input type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords').'" /> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | 266 | </table> |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * Show search form |
278 | 278 | */ |
279 | 279 | function display_search_form($action, $show_thesaurus, $sf_terms, $op) { |
280 | - $type = (!empty($_REQUEST['type'])? htmlentities($_REQUEST['type']): 'normal'); |
|
280 | + $type = (!empty($_REQUEST['type']) ? htmlentities($_REQUEST['type']) : 'normal'); |
|
281 | 281 | |
282 | 282 | switch ($type) { |
283 | 283 | case 'prefilter': |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param string $action Just in case your action is not |
305 | 305 | * index.php |
306 | 306 | */ |
307 | -function search_widget_show($action='index.php') |
|
307 | +function search_widget_show($action = 'index.php') |
|
308 | 308 | { |
309 | 309 | require_once api_get_path(LIBRARY_PATH).'search/ChamiloQuery.php'; |
310 | 310 | // TODO: load images dinamically when they're avalaible from specific field ui to add |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | if (($cid = api_get_course_id()) != -1) { // with cid |
318 | 318 | |
319 | 319 | // get search engine terms |
320 | - $course_filter = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID . $cid); |
|
320 | + $course_filter = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID.$cid); |
|
321 | 321 | $dkterms = chamilo_query_simple_query('', 0, 1000, array($course_filter)); |
322 | 322 | |
323 | 323 | //prepare specific fields names (and also get possible URL param names) |
324 | 324 | foreach ($specific_fields as $specific_field) { |
325 | 325 | $temp = array(); |
326 | - if (is_array($dkterms) && count($dkterms)>0) { |
|
327 | - foreach($dkterms[1] as $obj) { |
|
326 | + if (is_array($dkterms) && count($dkterms) > 0) { |
|
327 | + foreach ($dkterms[1] as $obj) { |
|
328 | 328 | $temp = array_merge($obj['sf-'.$specific_field['code']], $temp); |
329 | 329 | } |
330 | 330 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | $op = 'or'; |
355 | - if (!empty($_REQUEST['operator']) && in_array($op,array('or','and'))) { |
|
355 | + if (!empty($_REQUEST['operator']) && in_array($op, array('or', 'and'))) { |
|
356 | 356 | $op = $_REQUEST['operator']; |
357 | 357 | } |
358 | 358 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * code |
9 | 9 | */ |
10 | -require_once dirname(__FILE__) . '/../../global.inc.php'; |
|
10 | +require_once dirname(__FILE__).'/../../global.inc.php'; |
|
11 | 11 | include_once 'xapian/XapianIndexer.class.php'; |
12 | 12 | |
13 | 13 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
40 | 40 | return FALSE; |
41 | 41 | |
42 | - require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
|
42 | + require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php'; |
|
43 | 43 | |
44 | 44 | // compare terms |
45 | 45 | $doc = $this->get_document($search_did); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | // save it to search engine |
57 | 57 | foreach ($missing_terms as $term) { |
58 | - $this->add_term_to_doc($prefix . $term, $doc); |
|
58 | + $this->add_term_to_doc($prefix.$term, $doc); |
|
59 | 59 | } |
60 | 60 | foreach ($deprecated_terms as $term) { |
61 | - $this->remove_term_from_doc($prefix . $term, $doc); |
|
61 | + $this->remove_term_from_doc($prefix.$term, $doc); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // don't do anything if no change |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return array Array of terms |
75 | 75 | */ |
76 | 76 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
77 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
77 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
78 | 78 | $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id); |
79 | 79 | $prefix_terms = array(); |
80 | 80 | foreach ($terms as $term) { |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | $stored_terms = $this->get_terms_on_db($prefix, $course_code, $tool_id, $ref_id_high_level); |
37 | 37 | |
38 | 38 | // don't do anything if no change, verify only at DB, not the search engine |
39 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
40 | - return FALSE; |
|
39 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
40 | + return FALSE; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
43 | 44 | |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | $doc = $this->get_document($search_did); |
46 | 47 | $xapian_terms = xapian_get_doc_terms($doc, $prefix); |
47 | 48 | $xterms = array(); |
48 | - foreach ($xapian_terms as $xapian_term) |
|
49 | - $xterms[] = substr($xapian_term['name'], 1); |
|
49 | + foreach ($xapian_terms as $xapian_term) { |
|
50 | + $xterms[] = substr($xapian_term['name'], 1); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $dterms = $terms; |
52 | 54 |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | * @param array extra Extra queries to join with. Optional |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function chamilo_query_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
21 | +function chamilo_query_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
22 | 22 | list($count, $results) = xapian_query($query_string, NULL, $offset, $length, $extra); |
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | -function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
26 | +function chamilo_query_simple_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
27 | 27 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 28 | } |
29 | 29 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | function chamilo_preprocess_results($results) { |
43 | 43 | // group by toolid |
44 | 44 | $results_by_tool = array(); |
45 | - if (count($results)>0) { |
|
45 | + if (count($results) > 0) { |
|
46 | 46 | |
47 | 47 | foreach ($results as $key => $row) { |
48 | 48 | $results_by_tool[$row['toolid']][] = $row; |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $processed_results = array(); |
52 | 52 | foreach ($results_by_tool as $toolid => $rows) { |
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
53 | + $tool_processor_class = $toolid.'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH).'search/tool_processors/'.$tool_processor_class.'.class.php'; |
|
55 | 55 | if (file_exists($tool_processor_path)) { |
56 | 56 | require_once($tool_processor_path); |
57 | 57 | $tool_processor = new $tool_processor_class($rows); |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | * @param string $op |
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | -function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
|
74 | +function chamilo_join_queries($query1, $query2 = NULL, $op = 'or') { |
|
75 | 75 | return xapian_join_queries($query1, $query2, $op); |
76 | 76 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $query_string The term string |
34 | 34 | */ |
35 | 35 | function chamilo_get_boolean_query($term) { |
36 | - return xapian_get_boolean_query($term); |
|
36 | + return xapian_get_boolean_query($term); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | $results_by_tool = array(); |
45 | 45 | if (count($results)>0) { |
46 | 46 | |
47 | - foreach ($results as $key => $row) { |
|
48 | - $results_by_tool[$row['toolid']][] = $row; |
|
49 | - } |
|
47 | + foreach ($results as $key => $row) { |
|
48 | + $results_by_tool[$row['toolid']][] = $row; |
|
49 | + } |
|
50 | 50 | |
51 | - $processed_results = array(); |
|
52 | - foreach ($results_by_tool as $toolid => $rows) { |
|
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | - if (file_exists($tool_processor_path)) { |
|
56 | - require_once($tool_processor_path); |
|
57 | - $tool_processor = new $tool_processor_class($rows); |
|
58 | - $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | - } |
|
60 | - } |
|
51 | + $processed_results = array(); |
|
52 | + foreach ($results_by_tool as $toolid => $rows) { |
|
53 | + $tool_processor_class = $toolid .'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | + if (file_exists($tool_processor_path)) { |
|
56 | + require_once($tool_processor_path); |
|
57 | + $tool_processor = new $tool_processor_class($rows); |
|
58 | + $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return array(count($processed_results), $processed_results); |
|
62 | + return array(count($processed_results), $processed_results); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -72,5 +72,5 @@ discard block |
||
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | 74 | function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
75 | - return xapian_join_queries($query1, $query2, $op); |
|
75 | + return xapian_join_queries($query1, $query2, $op); |
|
76 | 76 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | -require_once dirname(__FILE__) . '../../../global.inc.php'; |
|
21 | -require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloQuery.php'; |
|
20 | +require_once dirname(__FILE__).'../../../global.inc.php'; |
|
21 | +require_once api_get_path(LIBRARY_PATH).'search/ChamiloQuery.php'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * search with filter and build base array avoding repeated terms |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | if (is_array($dkterms) && is_array($dkterms[1])) { |
34 | 34 | foreach ($specific_fields as $specific_field) { |
35 | 35 | foreach ($dkterms[1] as $obj) { |
36 | - foreach ($obj['sf-' . $specific_field['code']] as $raw_term) { |
|
36 | + foreach ($obj['sf-'.$specific_field['code']] as $raw_term) { |
|
37 | 37 | if (count($raw_term['name']) > 1) { |
38 | 38 | $normal_term = substr($raw_term['name'], 1); |
39 | 39 | $sf_terms[$specific_field['code']][$normal_term] = $normal_term; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | |
55 | 55 | if (($cid = api_get_course_id()) != -1) { // with cid |
56 | 56 | // course filter |
57 | - $filter[] = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID . $cid); |
|
57 | + $filter[] = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID.$cid); |
|
58 | 58 | // term filter |
59 | 59 | if ($term != '__all__') { |
60 | - $filter[] = chamilo_get_boolean_query($prefix . $term); |
|
60 | + $filter[] = chamilo_get_boolean_query($prefix.$term); |
|
61 | 61 | // always and between term and courseid |
62 | 62 | $filter = chamilo_join_queries($filter, null, 'and'); |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $sf_terms = get_usual_sf_terms($filter, $specific_fields); |
66 | 66 | } else { // without cid |
67 | 67 | if ($term != '__all__') { |
68 | - $filter[] = chamilo_get_boolean_query($prefix . $term); |
|
68 | + $filter[] = chamilo_get_boolean_query($prefix.$term); |
|
69 | 69 | |
70 | 70 | $sf_terms = get_usual_sf_terms($filter, $specific_fields); |
71 | 71 | } else { // no cid and all/any terms |
@@ -150,7 +150,7 @@ |
||
150 | 150 | $data = substr($png,$ipos,$chunk['size']); |
151 | 151 | $sections = explode("\0", $data); |
152 | 152 | if ($sections[0] == $key) { |
153 | - return $sections; |
|
153 | + return $sections; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | // Extract the data and the CRC |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | foreach (array_keys($this->_chunks[$type]) as $typekey) { |
52 | 52 | list($key, $data) = explode("\0", $this->_chunks[$type][$typekey]); |
53 | 53 | if (strcmp($key, $check) == 0) { |
54 | - echo 'Key "' . $check . '" already exists in "' . $type . '" chunk.'; |
|
54 | + echo 'Key "'.$check.'" already exists in "'.$type.'" chunk.'; |
|
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | } |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function addChunk($chunkType, $key, $value) { |
72 | 72 | |
73 | - $chunkData = $key . "\0" . $value; |
|
74 | - $crc = pack("N", crc32($chunkType . $chunkData)); |
|
73 | + $chunkData = $key."\0".$value; |
|
74 | + $crc = pack("N", crc32($chunkType.$chunkData)); |
|
75 | 75 | $len = pack("N", strlen($chunkData)); |
76 | 76 | |
77 | - $newChunk = $len . $chunkType . $chunkData . $crc; |
|
77 | + $newChunk = $len.$chunkType.$chunkData.$crc; |
|
78 | 78 | $result = substr($this->_contents, 0, $this->_size - 12) |
79 | 79 | . $newChunk |
80 | 80 | . substr($this->_contents, $this->_size - 12, 12); |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function removeChunks($chunkType, $key, $png) { |
94 | 94 | // Read the magic bytes and verify |
95 | - $retval = substr($png,0,8); |
|
95 | + $retval = substr($png, 0, 8); |
|
96 | 96 | $ipos = 8; |
97 | 97 | if ($retval != "\x89PNG\x0d\x0a\x1a\x0a") |
98 | 98 | throw new Exception('Is not a valid PNG image'); |
99 | 99 | // Loop through the chunks. Byte 0-3 is length, Byte 4-7 is type |
100 | - $chunkHeader = substr($png,$ipos,8); |
|
100 | + $chunkHeader = substr($png, $ipos, 8); |
|
101 | 101 | $ipos = $ipos + 8; |
102 | 102 | while ($chunkHeader) { |
103 | 103 | // Extract length and type from binary data |
104 | 104 | $chunk = @unpack('Nsize/a4type', $chunkHeader); |
105 | 105 | $skip = false; |
106 | - if ( $chunk['type'] == $chunkType ) { |
|
107 | - $data = substr($png,$ipos,$chunk['size']); |
|
106 | + if ($chunk['type'] == $chunkType) { |
|
107 | + $data = substr($png, $ipos, $chunk['size']); |
|
108 | 108 | $sections = explode("\0", $data); |
109 | 109 | print_r($sections); |
110 | - if ( $sections[0] == $key ) $skip = true; |
|
110 | + if ($sections[0] == $key) $skip = true; |
|
111 | 111 | } |
112 | 112 | // Extract the data and the CRC |
113 | - $data = substr($png,$ipos,$chunk['size']+4); |
|
113 | + $data = substr($png, $ipos, $chunk['size'] + 4); |
|
114 | 114 | $ipos = $ipos + $chunk['size'] + 4; |
115 | 115 | // Add in the header, data, and CRC |
116 | - if ( ! $skip ) $retval = $retval . $chunkHeader . $data; |
|
116 | + if (!$skip) $retval = $retval.$chunkHeader.$data; |
|
117 | 117 | // Read next chunk header |
118 | - $chunkHeader = substr($png,$ipos,8); |
|
118 | + $chunkHeader = substr($png, $ipos, 8); |
|
119 | 119 | $ipos = $ipos + 8; |
120 | 120 | } |
121 | 121 | return $retval; |
@@ -131,34 +131,34 @@ discard block |
||
131 | 131 | * If there is PNG information that matches the key an array is returned |
132 | 132 | * |
133 | 133 | */ |
134 | - public function extractBadgeInfo($png, $key='openbadges') { |
|
134 | + public function extractBadgeInfo($png, $key = 'openbadges') { |
|
135 | 135 | // Read the magic bytes and verify |
136 | - $retval = substr($png,0,8); |
|
136 | + $retval = substr($png, 0, 8); |
|
137 | 137 | $ipos = 8; |
138 | 138 | if ($retval != "\x89PNG\x0d\x0a\x1a\x0a") { |
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
142 | 142 | // Loop through the chunks. Byte 0-3 is length, Byte 4-7 is type |
143 | - $chunkHeader = substr($png,$ipos,8); |
|
143 | + $chunkHeader = substr($png, $ipos, 8); |
|
144 | 144 | $ipos = $ipos + 8; |
145 | 145 | while ($chunkHeader) { |
146 | 146 | // Extract length and type from binary data |
147 | 147 | $chunk = @unpack('Nsize/a4type', $chunkHeader); |
148 | 148 | $skip = false; |
149 | 149 | if ($chunk['type'] == 'tEXt') { |
150 | - $data = substr($png,$ipos,$chunk['size']); |
|
150 | + $data = substr($png, $ipos, $chunk['size']); |
|
151 | 151 | $sections = explode("\0", $data); |
152 | 152 | if ($sections[0] == $key) { |
153 | 153 | return $sections; |
154 | 154 | } |
155 | 155 | } |
156 | 156 | // Extract the data and the CRC |
157 | - $data = substr($png,$ipos,$chunk['size']+4); |
|
157 | + $data = substr($png, $ipos, $chunk['size'] + 4); |
|
158 | 158 | $ipos = $ipos + $chunk['size'] + 4; |
159 | 159 | |
160 | 160 | // Read next chunk header |
161 | - $chunkHeader = substr($png,$ipos,8); |
|
161 | + $chunkHeader = substr($png, $ipos, 8); |
|
162 | 162 | $ipos = $ipos + 8; |
163 | 163 | } |
164 | 164 | } |
@@ -94,8 +94,9 @@ discard block |
||
94 | 94 | // Read the magic bytes and verify |
95 | 95 | $retval = substr($png,0,8); |
96 | 96 | $ipos = 8; |
97 | - if ($retval != "\x89PNG\x0d\x0a\x1a\x0a") |
|
98 | - throw new Exception('Is not a valid PNG image'); |
|
97 | + if ($retval != "\x89PNG\x0d\x0a\x1a\x0a") { |
|
98 | + throw new Exception('Is not a valid PNG image'); |
|
99 | + } |
|
99 | 100 | // Loop through the chunks. Byte 0-3 is length, Byte 4-7 is type |
100 | 101 | $chunkHeader = substr($png,$ipos,8); |
101 | 102 | $ipos = $ipos + 8; |
@@ -107,13 +108,17 @@ discard block |
||
107 | 108 | $data = substr($png,$ipos,$chunk['size']); |
108 | 109 | $sections = explode("\0", $data); |
109 | 110 | print_r($sections); |
110 | - if ( $sections[0] == $key ) $skip = true; |
|
111 | + if ( $sections[0] == $key ) { |
|
112 | + $skip = true; |
|
113 | + } |
|
111 | 114 | } |
112 | 115 | // Extract the data and the CRC |
113 | 116 | $data = substr($png,$ipos,$chunk['size']+4); |
114 | 117 | $ipos = $ipos + $chunk['size'] + 4; |
115 | 118 | // Add in the header, data, and CRC |
116 | - if ( ! $skip ) $retval = $retval . $chunkHeader . $data; |
|
119 | + if ( ! $skip ) { |
|
120 | + $retval = $retval . $chunkHeader . $data; |
|
121 | + } |
|
117 | 122 | // Read next chunk header |
118 | 123 | $chunkHeader = substr($png,$ipos,8); |
119 | 124 | $ipos = $ipos + 8; |