]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Comments' search hook now correctly trims description and title.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 3 Dec 2009 16:53:06 +0000 (16:53 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 3 Dec 2009 16:53:06 +0000 (16:53 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3720 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/search/search_hooks.php

index 8eff06359ec73ce4c82fb9adad81c8f79e282e1b..371a476338bda112501a644eee808c1a4242aa0d 100644 (file)
@@ -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);
        }