]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Removed tag search listing.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 30 Nov 2009 22:51:07 +0000 (22:51 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 30 Nov 2009 22:51:07 +0000 (22:51 +0000)
Added ability to provide extra info in searches as 'search_matched_extra'.
Allowing overrides for titles.

git-svn-id: http://code.elgg.org/elgg/trunk@3711 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/search/search_hooks.php
mod/search/views/default/search/listing.php
mod/search/views/default/search/tags/listing.php [deleted file]

index 8f0a627038cb5cabdaa74f5d64a1db048e8e736c..8eff06359ec73ce4c82fb9adad81c8f79e282e1b 100644 (file)
@@ -181,9 +181,17 @@ function search_tags_hook($hook, $type, $value, $params) {
 
        // add the volatile data for why these entities have been returned.
        foreach ($entities as $entity) {
-               $tags = implode(',', $entity->tags);
+               $tags = $entity->tags;
+
+               if (is_array($tags)) {
+                       $tags = implode(', ', $entity->tags);
+               }
+
                $tags_str = search_get_highlighted_relevant_substrings($tags, $params['query']);
-               $entity->setVolatileData('search_matched_tags', $tags_str);
+               $tags_str = '(' . elgg_echo('tags') . ": $tags_str)";
+               $entity->setVolatileData('search_matched_title', $entity->title);
+               $entity->setVolatileData('search_matched_description', $entity->description);
+               $entity->setVolatileData('search_matched_extra', $tags_str);
        }
 
        return array(
@@ -264,6 +272,11 @@ function search_comments_hook($hook, $type, $value, $params) {
 
        $result = get_data($q);
        $count = $result[0]->total;
+
+       if (!is_array($comments)) {
+               return FALSE;
+       }
+
        // @todo if plugins are disabled causing subtypes
        // to be invalid and there are comments on entities of those subtypes,
        // the counts will be wrong here and results might not show up correctly,
index 45c45ffee7ef4821bba3cf538040e21f9e85477c..d4bdf3a98325ff25706ee39d7d59777124cd7c5b 100644 (file)
@@ -25,6 +25,14 @@ if (array_key_exists('type', $vars['params']) && array_key_exists('subtype', $va
        $type_str = elgg_echo('search:unknown_entity');
 }
 
+// allow overrides for titles
+$search_type_str = elgg_echo("search_types:{$vars['params']['search_type']}");
+if (array_key_exists('search_type', $vars['params'])
+       && $search_type_str != "search_types:{$vars['params']['search_type']}") {
+
+       $type_str = $search_type_str;
+}
+
 $query = htmlspecialchars(http_build_query(
        array(
                'q' => $vars['params']['query'],
@@ -73,6 +81,7 @@ foreach ($entities as $entity) {
        }
        $title = $entity->getVolatileData('search_matched_title');
        $description = $entity->getVolatileData('search_matched_description');
+       $extra_info = $entity->getVolatileData('search_matched_extra');
        $url = $entity->getURL();
        $title = "<a href=\"$url\">$title</a>";
        $tc = $entity->time_created;
@@ -84,7 +93,7 @@ foreach ($entities as $entity) {
                <div class="search_listing_icon">$icon</div>
                <div class="search_listing_info">
                        <p class="ItemTitle">$title</p>$description
-                       <p class="ItemTimestamp">$time</p>
+                       <p class="ItemTimestamp">$time $extra_info</p>
                </div>
        </div>
 ___END;
diff --git a/mod/search/views/default/search/tags/listing.php b/mod/search/views/default/search/tags/listing.php
deleted file mode 100644 (file)
index 89b96b5..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * Elgg tag search listing
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-?>
-
-
-<?php
-$entities = $vars['entities'];
-
-if (!is_array($vars['entities']) || !count($vars['entities'])) {
-       return FALSE;
-}
-
-$query = htmlspecialchars(http_build_query(
-       array(
-               'q' => $vars['params']['query'],
-               'entity_type' => $vars['params']['type'],
-               'entity_subtype' => $vars['params']['subtype'],
-               'limit' => get_input('limit', 10),
-               'offset' => get_input('offset', 0),
-               'search_type' => 'tags',
-       )
-));
-
-$url = "{$vars['url']}pg/search?$query";
-
-// get any more links.
-$more_check = $vars['count'] - ($vars['params']['offset'] + $vars['params']['limit']);
-$more = ($more_check > 0) ? $more_check : 0;
-
-if ($more) {
-       $title_key = ($more == 1) ? 'tag' : 'tags';
-       $more_str = sprintf(elgg_echo('search:more'), $vars['count'], elgg_echo($title_key));
-       $more_link = "<div class='search_listing'><a href=\"$url\">$more_str</a></div>";
-} else {
-       $more_link = '';
-}
-
-$title_str = elgg_echo("item:{$vars['params']['type']}:{$vars['params']['subtype']}");
-$body = elgg_view_title(elgg_echo('tags'));
-
-foreach ($entities as $entity) {
-       if ($owner = $entity->getOwnerEntity()) {
-               $icon = elgg_view('profile/icon', array('entity' => $owner));
-       } else {
-               $icon = '';
-       }
-       $tags = $entity->getVolatileData('search_matched_tags');
-
-       $entity_html = elgg_view_entity($entity);
-       $url = $entity->getURL();
-       $title = "<a href=\"$url\">$title</a>";
-       $tc = $entity->time_created;
-       $tu = $entity->time_updated;
-       $time = friendly_time(($tu > $tc) ? $tu : $tc);
-
-       $body .= $entity_html;
-}
-echo $body;
-echo $more_link;
-?>