aboutsummaryrefslogtreecommitdiff
path: root/mod/search/search_hooks.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-03 16:53:06 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-03 16:53:06 +0000
commit43b104bbe77b6174691513ddbadd4c506c5d74c2 (patch)
tree6d273af3aa2521ae210edcc816587d4b869c4b5b /mod/search/search_hooks.php
parentf8c05bf893f40c59ea48dd532c165c817800f7f9 (diff)
downloadelgg-43b104bbe77b6174691513ddbadd4c506c5d74c2.tar.gz
elgg-43b104bbe77b6174691513ddbadd4c506c5d74c2.tar.bz2
Comments' search hook now correctly trims description and title.
git-svn-id: http://code.elgg.org/elgg/trunk@3720 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/search/search_hooks.php')
-rw-r--r--mod/search/search_hooks.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php
index 8eff06359..371a47633 100644
--- a/mod/search/search_hooks.php
+++ b/mod/search/search_hooks.php
@@ -189,8 +189,25 @@ function search_tags_hook($hook, $type, $value, $params) {
$tags_str = search_get_highlighted_relevant_substrings($tags, $params['query']);
$tags_str = '(' . elgg_echo('tags') . ": $tags_str)";
- $entity->setVolatileData('search_matched_title', $entity->title);
- $entity->setVolatileData('search_matched_description', $entity->description);
+
+ // Nick told me my idea was dirty, so I'm hard coding the numbers.
+ $title_tmp = $entity->title;
+ if (elgg_strlen($title_tmp) > 297) {
+ $title_str = elgg_substr($title_tmp, 0, 297) . '...';
+ } else {
+ $title_str = $title_tmp;
+ }
+
+ $desc_tmp = $entity->description;
+ if (elgg_strlen($desc_tmp) > 297) {
+ $desc_str = elgg_substr($desc_tmp, 0, 297) . '...';
+ } else {
+ $desc_str = $desc_tmp;
+ }
+
+ $desc_str = search_get_highlighted_relevant_substrings($tags, $entity->description);
+ $entity->setVolatileData('search_matched_title', $title_str);
+ $entity->setVolatileData('search_matched_description', $desc_str);
$entity->setVolatileData('search_matched_extra', $tags_str);
}