From a4df77a015527dea272d8b643e89a33f8929361b Mon Sep 17 00:00:00 2001 From: brettp Date: Sun, 15 Nov 2009 04:27:19 +0000 Subject: Search changes. Fixes #1376: Only fetching ft_min_word_length if the query != false. Using IN BOOLEAN MODE for metadata search (comments, tags) to avoid a fulltext index on the metastrings table. Slower for search, faster for site. Simplified and modularized logic for pulling out relevant substrings and highlighting. Corrected the elipse oddities in relevancy substring concatenation. Added pagination on non-homepages. Added missing language strings. Updated and standardized comment results listings. Repeat query in searchbar. Dealing with comments on unavailable entities better (though not well). Increased default word context to 30 characters. Decreased default context max length to 300 characters. Promise to start making atomic commits real soon now. git-svn-id: http://code.elgg.org/elgg/trunk@3684 36083f99-b078-4883-b0ff-0f9b5a30f544 --- .../views/default/page_elements/searchbox.php | 14 ++++- .../views/default/search/comments/listing.php | 70 ++++++++++++++++++---- mod/search/views/default/search/css.php | 3 +- mod/search/views/default/search/listing.php | 55 ++++++++++++----- 4 files changed, 110 insertions(+), 32 deletions(-) (limited to 'mod/search/views/default') diff --git a/mod/search/views/default/page_elements/searchbox.php b/mod/search/views/default/page_elements/searchbox.php index cfc0b953b..f7746b0da 100644 --- a/mod/search/views/default/page_elements/searchbox.php +++ b/mod/search/views/default/page_elements/searchbox.php @@ -1,4 +1,16 @@ + +
- +
diff --git a/mod/search/views/default/search/comments/listing.php b/mod/search/views/default/search/comments/listing.php index 58353a110..13f368f2b 100644 --- a/mod/search/views/default/search/comments/listing.php +++ b/mod/search/views/default/search/comments/listing.php @@ -7,16 +7,12 @@ * @author Curverider Ltd * @link http://elgg.org/ */ -?> -
-+$count more $title_str"; -echo elgg_view('page_elements/contentwrapper', array('body' => $body)); +// get pagination +if (array_key_exists('pagination', $vars) && $vars['pagination']) { + $nav .= elgg_view('navigation/pagination',array( + 'baseurl' => $url, + 'offset' => $vars['params']['offset'], + 'count' => $vars['count'], + 'limit' => $vars['params']['limit'], + )); +} else { + $nav = ''; +} + +// get 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) ? 'comment' : 'comments'; + $more_str = sprintf(elgg_echo('search:more'), $vars['count'], elgg_echo($title_key)); + $more_link = "$more_str"; +} else { + $more_link = ''; +} + +echo $nav; +$body = elgg_view_title($title_str); foreach ($vars['entities'] as $entity) { if ($owner = $entity->getOwnerEntity()) { @@ -41,22 +61,46 @@ foreach ($vars['entities'] as $entity) { } else { $icon = ''; } - $title = "Comment on " . elgg_echo('item:' . $entity->getType() . ':' . $entity->getSubtype()); + + // @todo Sometimes we find comments on entities we can't display... + if ($entity->getVolatileData('search_unavailable_entity')) { + $title = sprintf(elgg_echo('search:comment_on'), elgg_echo('search:unavailable_entity')); + // keep anchor for formatting. + $title = "$title"; + } else { + if ($entity->getType() == 'object') { + $title = $entity->title; + } else { + $title = $entity->name; + } + + if (!$title) { + $title = elgg_echo('item:' . $entity->getType() . ':' . $entity->getSubtype()); + } + + if (!$title) { + $title = elgg_echo('item:' . $entity->getType()); + } + + $title = sprintf(elgg_echo('search:comment_on'), $title); + $url = $entity->getURL() . '#annotation-' . $entity->getVolatileData('search_match_annotation_id'); + $title = "$title"; + } + $description = $entity->getVolatileData('search_matched_comment'); - $url = $entity->getURL(); - $title = "$title"; $tc = $entity->getVolatileData('search_matched_comment_time_created');; $time = friendly_time($tc); - echo <<<___END + $body .= <<<___END

$title

$description
- $icon $time - $more + $icon $time - $more_link
___END; } -?> -
+ +$body .= $nav; +echo elgg_view('page_elements/contentwrapper', array('body' => $body)); diff --git a/mod/search/views/default/search/css.php b/mod/search/views/default/search/css.php index 28dc82a4a..19cca02e8 100644 --- a/mod/search/views/default/search/css.php +++ b/mod/search/views/default/search/css.php @@ -38,7 +38,6 @@ margin: 6px; background-color: #99FF99; } - .searchTitle { text-decoration: underline; } @@ -91,7 +90,7 @@ margin: 6px; } /* override the entity container piece */ -.search_listing .entity_listing { +.search_listing .search_listing { -webkit-border-radius: 0px; -moz-border-radius: 0px; background: transparent; diff --git a/mod/search/views/default/search/listing.php b/mod/search/views/default/search/listing.php index 37850c911..f947bd808 100644 --- a/mod/search/views/default/search/listing.php +++ b/mod/search/views/default/search/listing.php @@ -7,11 +7,8 @@ * @author Curverider Ltd * @link http://elgg.org/ */ -?> -
- $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' => 'entities', ) )); $url = "{$vars['url']}pg/search?$query"; -$more = "+$count more $title_str"; -echo elgg_view('page_elements/contentwrapper', array('body' => $body)); +// get pagination +if (array_key_exists('pagination', $vars['params']) && $vars['params']['pagination']) { + $nav .= elgg_view('navigation/pagination',array( + 'baseurl' => $url, + 'offset' => $vars['params']['offset'], + 'count' => $vars['count'], + 'limit' => $vars['params']['limit'], + )); +} else { + $nav = ''; +} + +// 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) ? 'comment' : 'comments'; + $more_str = sprintf(elgg_echo('search:more'), $count, $type_str); + $more_link = "$more_str"; +} else { + $more_link = ''; +} + +echo $nav; +$body = elgg_view_title($title_str); foreach ($entities as $entity) { if ($owner = $entity->getOwnerEntity()) { @@ -53,16 +78,14 @@ foreach ($entities as $entity) { $tu = $entity->time_updated; $time = friendly_time(($tu > $tc) ? $tu : $tc); - echo <<<___END + $body .= <<<___END

$title

- - $description
- $icon $time - $more -
+ $description
+ $icon $time - $more_link
___END; } -?> -
\ No newline at end of file +echo elgg_view('page_elements/contentwrapper', array('body' => $body)); +echo $nav; \ No newline at end of file -- cgit v1.2.3