function search_advanced_search_index_combined_search($combine_search_results = 'no', $params) { if (elgg_extract('search_type', $params) !== 'all') { return; } if (empty($params['query'])) { return; } if (!in_array($combine_search_results, ['all', 'objects'])) { return; } $types = search_advanced_search_get_types(); if (isset($types['object']) && in_array('groupforumtopic', $types['object'])) { $types['object'][] = 'discussion_reply'; } if (isset($types['object']) && in_array('page', $types['object'])) { $types['object'][] = 'page_top'; } $current_params = $params; $current_params['search_type'] = 'entities'; if ($combine_search_results == 'objects') { $current_params['type'] = 'object'; $current_params['subtype'] = elgg_extract('object', $types); // show a bit more content but disable pagination $current_params['offset'] = 0; $current_params['limit'] = 20; if (empty($current_params['subtype'])) { return; } $results = elgg_trigger_plugin_hook('search', 'object', $current_params, []); // reset count to 0 to remove the "view more" url $results['count'] = 0; } elseif ($combine_search_results == 'all') { unset($current_params['type']); unset($current_params['subtype']); $current_params['limit'] = (int) get_input('limit', 10); $current_params['offset'] = (int) get_input('offset', 0); $current_params['pagination'] = true; foreach ($types as $type => $subtypes) { if (empty($subtypes)) { $types[$type] = null; } } $current_params['type_subtype_pairs'] = $types; $results = elgg_trigger_plugin_hook('search', 'combined:all', $current_params, []); } $entities = elgg_extract('entities', $results); if (empty($entities)) { return; } elgg_push_context('combined_search'); $view = search_get_search_view($current_params, 'list'); if (empty($view)) { return; } $content = elgg_view($view, ['results' => $results, 'params' => $current_params]); elgg_pop_context(); return ['content' => $content, 'count' => $results['count']]; }
$limit = $search_type == 'all' ? 5 : get_input('limit', 20); } else { $limit = $search_type == 'all' ? 2 : get_input('limit', 10); } // set up search params $params = array('query' => $query, 'offset' => $search_type == 'all' ? 0 : get_input('offset', 0), 'limit' => $limit, 'sort' => get_input('sort', 'relevance'), 'order' => get_input('order', 'desc'), 'search_type' => $search_type, 'type' => $entity_type, 'subtype' => get_input('entity_subtype'), 'owner_guid' => get_input('owner_guid'), 'container_guid' => get_input('container_guid'), 'pagination' => $search_type == 'all' ? false : true, 'search_filter' => (array) get_input('filter', [])); $params = elgg_trigger_plugin_hook('search_params', 'search', $params, $params); // check and show error page $error_vars = $vars; $error_vars['params'] = $params; $error_output = elgg_view('search_advanced/error', $error_vars); if ($error_output) { echo $error_output; return; } $types = search_advanced_search_get_types(); // to pass the correct current search type to the views $current_params = $params; $current_params['search_type'] = 'entities'; // foreach through types. // if a plugin returns FALSE for subtype ignore it. // if a plugin returns NULL or '' for subtype, pass to generic type search function. // if still NULL or '' or empty(array()) no results found. (== don't show??) $combine_search_results = elgg_get_plugin_setting('combine_search_results', 'search_advanced', 'no'); // start the actual search $search_result_counters = []; $results_html = []; foreach ($types as $type => $subtypes) { if ($type !== "object") { if ($type !== "user" && empty($params["query"])) { continue;
function search_advanced_search_index_combined_search($combine_search_results = 'no', $params) { if (elgg_extract('search_type', $params) !== 'all') { return; } if (empty($params['query'])) { return; } if (!in_array($combine_search_results, ['all', 'objects'])) { return; } $types = search_advanced_search_get_types(); $current_params = $params; $current_params['search_type'] = 'entities'; if ($combine_search_results == 'objects') { $current_params['type'] = 'object'; $current_params['subtype'] = elgg_extract('object', $types); // show a bit more content but disable pagination $current_params['offset'] = 0; $current_params['limit'] = 20; if (empty($current_params['subtype'])) { return; } // let others change the search params $hook_params = ['combined' => $combine_search_results, 'search_params' => $current_params]; $current_params = elgg_trigger_plugin_hook('search_params', 'search:combined', $hook_params, $current_params); // execute search $results = elgg_trigger_plugin_hook('search', 'object', $current_params, []); // reset count to 0 to remove the "view more" url $results['count'] = 0; } elseif ($combine_search_results == 'all') { unset($current_params['type']); unset($current_params['subtype']); $current_params['limit'] = (int) get_input('limit', elgg_get_config('default_limit')); $current_params['offset'] = (int) get_input('offset', 0); $current_params['pagination'] = true; foreach ($types as $type => $subtypes) { if (empty($subtypes)) { $types[$type] = ELGG_ENTITIES_ANY_VALUE; } } $current_params['type_subtype_pairs'] = $types; // let others change the search params $hook_params = ['combined' => $combine_search_results, 'search_params' => $current_params]; $current_params = elgg_trigger_plugin_hook('search_params', 'search:combined', $hook_params, $current_params); // execute search $results = elgg_trigger_plugin_hook('search', 'combined:all', $current_params, []); } $entities = elgg_extract('entities', $results); if (empty($entities)) { return; } elgg_push_context('combined_search'); $view = search_get_search_view($current_params, 'list'); if (empty($view)) { return; } $content = elgg_view($view, ['results' => $results, 'params' => $current_params]); elgg_pop_context(); return ['content' => $content, 'count' => $results['count']]; }