aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/search/search_hooks.php17
-rw-r--r--mod/search/views/default/search/listing.php11
-rw-r--r--mod/search/views/default/search/tags/listing.php67
3 files changed, 25 insertions, 70 deletions
diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php
index 8f0a62703..8eff06359 100644
--- a/mod/search/search_hooks.php
+++ b/mod/search/search_hooks.php
@@ -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,
diff --git a/mod/search/views/default/search/listing.php b/mod/search/views/default/search/listing.php
index 45c45ffee..d4bdf3a98 100644
--- a/mod/search/views/default/search/listing.php
+++ b/mod/search/views/default/search/listing.php
@@ -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
index 89b96b5a4..000000000
--- a/mod/search/views/default/search/tags/listing.php
+++ /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;
-?>