/** * Hook to fallback to default search functions * * @param string $hook the name of the hook * @param string $type the type of the hook * @param string $returnvalue current return value * @param array $params supplied params * * @return void */ public static function searchFallback($hook, $type, $returnvalue, $params) { if (!empty($returnvalue)) { return; } if (!in_array($type, ['object', 'user', 'group', 'tags'])) { return; } switch ($type) { case 'object': return search_objects_hook($hook, $type, $returnvalue, $params); case 'user': return search_users_hook($hook, $type, $returnvalue, $params); case 'group': return search_groups_hook($hook, $type, $returnvalue, $params); case 'tags': return search_tags_hook($hook, $type, $returnvalue, $params); } }
// search in text $params = array('query' => $query, 'offset' => $offset, 'limit' => $limit, 'sort' => 'relevance', 'order' => 'desc', 'search_type' => 'entities', 'type' => 'object', 'subtype' => 'markdown_wiki', 'pagination' => TRUE); if ($container_guid) { $params['container_guid'] = $container_guid; } $results = elgg_trigger_plugin_hook('search', 'object:markdown_wiki', $params, NULL); if ($results === FALSE) { // someone is saying not to display these types in searches. continue; } elseif (is_array($results) && !count($results)) { // no results, but results searched in hook. } elseif (!$results) { // no results and not hooked. use default type search. // don't change the params here, since it's really a different subtype. // Will be passed to elgg_get_entities(). $results = search_objects_hook('search', 'object:markdown_wiki', '', $params); } if ($container_guid) { // Search for article in group $url = elgg_get_site_url() . 'wiki/search'; $body = '<div class="markdown-wiki-search-form mbm">' . elgg_echo('markdown_wiki:search_in_group', array('')); $body .= elgg_view_form('markdown_wiki/search', array('action' => $url, 'method' => 'get', 'disable_security' => true), array('container_guid' => $container_guid)); $body .= '</div>'; // forward to unique entity or unset entity that title match query foreach ($results['entities'] as $key => $entities) { if ($entities->title == $query) { $results['count'] -= 1; if ($results['count'] == 0) { forward($entities->getURL()); } $page_query = $entities;
/** * Return the data from the default search hook * * @param string $hook name of hook * @param string $type type of hook * @param unknown_type $value current value * @param array $params parameters * * @return array */ function search_advanced_fallback_search_hook($hook, $type, $value, $params) { if (!empty($value)) { return; } if (!in_array($type, ['object', 'user', 'group', 'tags'])) { return; } switch ($type) { case 'object': return search_objects_hook($hook, $type, $value, $params); case 'user': return search_users_hook($hook, $type, $value, $params); case 'group': return search_groups_hook($hook, $type, $value, $params); case 'tags': return search_tags_hook($hook, $type, $value, $params); } }