]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1523: Updated search to use ELGG_ENTITIES_NO_VALUE/ANY_VALUE and removed some...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Feb 2010 00:07:22 +0000 (00:07 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Feb 2010 00:07:22 +0000 (00:07 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3956 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/search/index.php
mod/search/search_hooks.php
mod/search/start.php

index 2f10d5a21b9ab3a1b35628fc28e7dbddb200e5a7..88c91486b830fb88f061e5af9509333f379b98c7 100644 (file)
@@ -19,10 +19,10 @@ $query = stripslashes(get_input('q', get_input('tag', '', FALSE), FALSE));
 $limit = ($search_type == 'all') ? 2 : get_input('limit', 10);
 $offset = ($search_type == 'all') ? 0 : get_input('offset', 0);
 
-$entity_type = get_input('entity_type', NULL);
-$entity_subtype = get_input('entity_subtype', NULL);
-$owner_guid = get_input('owner_guid', NULL);
-$friends = get_input('friends', 0);
+$entity_type = get_input('entity_type', ELGG_ENTITIES_ANY_VALUE);
+$entity_subtype = get_input('entity_subtype', ELGG_ENTITIES_ANY_VALUE);
+$owner_guid = get_input('owner_guid', ELGG_ENTITIES_ANY_VALUE);
+$friends = get_input('friends', ELGG_ENTITIES_ANY_VALUE);
 $sort = get_input('sort');
 switch ($sort) {
        case 'relevance':
@@ -189,9 +189,8 @@ if ($search_type == 'all' || $search_type == 'entities') {
                }
 
                // pull in default type entities with no subtypes
-               // @todo this might currently means "all entities regardless of subtype"
                $current_params['type'] = $type;
-               $current_params['subtype'] = 0;
+               $current_params['subtype'] = ELGG_ENTITIES_NO_VALUE;
 
                $results = trigger_plugin_hook('search', $type, $current_params, array());
                if ($results === FALSE) {
index 1c109025ae3b17ddd82f5428f43fc91558aa9dcc..b61f12339cccb45c8c5fe3b4b770d368ab70987a 100644 (file)
@@ -28,8 +28,6 @@ function search_objects_hook($hook, $type, $value, $params) {
 
        $params['wheres'] = array($where);
 
-       //$params['order_by'] = search_get_order_by_sql('oe', $params['sort'], $params['order']);
-
        $entities = elgg_get_entities($params);
        $params['count'] = TRUE;
        $count = elgg_get_entities($params);
@@ -41,12 +39,9 @@ function search_objects_hook($hook, $type, $value, $params) {
 
        // add the volatile data for why these entities have been returned.
        foreach ($entities as $entity) {
-               //$title = search_get_highlighted_relevant_substrings($entity->title, $params['query']);
-               //$title = search_get_relevant_substring($entity->title, $params['query'], '<strong class="searchMatch">', '</strong>');
                $title = search_get_highlighted_relevant_substrings($entity->title, $params['query']);
                $entity->setVolatileData('search_matched_title', $title);
 
-               //$desc = search_get_relevant_substring($entity->description, $params['query'], '<strong class="searchMatch">', '</strong>');
                $desc = search_get_highlighted_relevant_substrings($entity->description, $params['query']);
                $entity->setVolatileData('search_matched_description', $desc);
        }
@@ -82,7 +77,7 @@ function search_groups_hook($hook, $type, $value, $params) {
        $params['wheres'] = array($where);
 
        // override subtype -- All groups should be returned regardless of subtype.
-       $params['subtype'] = NULL;
+       $params['subtype'] = ELGG_ENTITIES_ANY_VALUE;
 
        $entities = elgg_get_entities($params);
        $params['count'] = TRUE;
@@ -133,7 +128,7 @@ function search_users_hook($hook, $type, $value, $params) {
        $params['wheres'] = array($where);
 
        // override subtype -- All users should be returned regardless of subtype.
-       $params['subtype'] = NULL;
+       $params['subtype'] = ELGG_ENTITIES_ANY_VALUE;
 
        $entities = elgg_get_entities($params);
        $params['count'] = TRUE;
@@ -332,7 +327,6 @@ function search_comments_hook($hook, $type, $value, $params) {
 
        $comments = get_data($q);
 
-//elgg_get_entities()
        $q = "SELECT count(DISTINCT a.id) as total FROM {$CONFIG->dbprefix}annotations a
                JOIN {$CONFIG->dbprefix}metastrings msn ON a.name_id = msn.id
                JOIN {$CONFIG->dbprefix}metastrings msv ON a.value_id = msv.id
index 5767e65fff74afd8c2148ac6664b7a77ac814b18..a6a0bead25e82150240b74903127b83eb5f4efae 100644 (file)
@@ -249,10 +249,10 @@ function search_consolidate_substrings($offsets, $lengths) {
 function search_highlight_words($words, $string) {
        $i = 1;
        $replace_html = array(
-               'strong' => rand(10000,99999),
-               'class' => rand(10000,99999),
-               'searchMatch' => rand(10000,99999),
-               'searchMatchColor' => rand(10000,99999)
+               'strong' => rand(10000, 99999),
+               'class' => rand(10000, 99999),
+               'searchMatch' => rand(10000, 99999),
+               'searchMatchColor' => rand(10000, 99999)
        );
 
        foreach ($words as $word) {