aboutsummaryrefslogtreecommitdiff
path: root/mod/search/index.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-15 04:27:19 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-15 04:27:19 +0000
commita4df77a015527dea272d8b643e89a33f8929361b (patch)
tree903896a5c55e3337d02efea214c16ab2f7ce4b64 /mod/search/index.php
parent9fb9b8565d6a95df0264ef0054106df6b2d3943e (diff)
downloadelgg-a4df77a015527dea272d8b643e89a33f8929361b.tar.gz
elgg-a4df77a015527dea272d8b643e89a33f8929361b.tar.bz2
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
Diffstat (limited to 'mod/search/index.php')
-rw-r--r--mod/search/index.php182
1 files changed, 13 insertions, 169 deletions
diff --git a/mod/search/index.php b/mod/search/index.php
index ee6da32a8..e7081ecb5 100644
--- a/mod/search/index.php
+++ b/mod/search/index.php
@@ -27,11 +27,9 @@ $params = array(
// 'tag_type' => $tag_type,
'owner_guid' => $owner_guid,
// 'friends' => $friends
+ 'pagination' => ($search_type == 'all') ? FALSE : TRUE
);
-$results_html = '';
-//$results_html .= elgg_view_title(elgg_echo('search:results')) . "<input type=\"text\" value=\"$query\" />";
-$results_html .= elgg_view_title(elgg_echo('search:results'));
$types = get_registered_entity_types();
$custom_types = trigger_plugin_hook('search_types', 'get_types', $params, array());
@@ -105,13 +103,18 @@ foreach ($custom_types as $type) {
// check that we have an actual query
if (!$query) {
- $body .= "No query.";
+ $body = elgg_view_title(elgg_echo('search:search_error'));
+ $body .= elgg_view('page_elements/contentwrapper', array('body' => elgg_echo('search:no_query')));
+
$layout = elgg_view_layout('two_column_left_sidebar', '', $body);
page_draw($title, $layout);
return;
}
+// start the actual search
+$results_html = '';
+
if ($search_type == 'all' || $search_type == 'entities') {
// to pass the correct search type to the views
$params['search_type'] = 'entities';
@@ -199,177 +202,18 @@ if ($search_type != 'entities' || $search_type == 'all') {
}
}
-//if ($search_type !== 'all') {
-// var_dump('here');
-// $entities = trigger_plugin_hook('search', $search_type, '', $return);
-//}
-/*
+// highlight search terms
+$searched_words = search_remove_ignored_words($query, 'array');
+$highlighted_query = search_highlight_words($searched_words, $query);
-call search_section_start to display long bar with types and titles
-call search
-
-*/
+$body = elgg_view_title(sprintf(elgg_echo('search:results'), "\"$highlighted_query\""));
if (!$results_html) {
- $body = elgg_echo('search:no_results');
+ $body .= elgg_view('page_elements/contentwrapper', array('body' => elgg_echo('search:no_results')));
} else {
- $body = $results_html;
+ $body .= $results_html;
}
$layout = elgg_view_layout('two_column_left_sidebar', '', $body);
page_draw($title, $layout);
-
-
-
-
-
-
-
-return;
-
-
-/** Main search page */
-
-global $CONFIG;
-
-$tag = get_input('tag');
-$offset = get_input('offset', 0);
-$viewtype = get_input('search_viewtype','list');
-if ($viewtype == 'gallery') {
- $limit = get_input('limit', 12); // 10 items in list view
-} else {
- $limit = get_input('limit', 10); // 12 items in gallery view
-}
-$searchtype = get_input('searchtype', 'all');
-$type = get_input('type', '');
-$subtype = get_input('subtype', '');
-$owner_guid = get_input('owner_guid', '');
-$tagtype = get_input('tagtype', '');
-$friends = (int)get_input('friends', 0);
-$title = sprintf(elgg_echo('searchtitle'), $tag);
-
-if (substr_count($owner_guid, ',')) {
- $owner_guid_array = explode(',', $owner_guid);
-} else {
- $owner_guid_array = $owner_guid;
-}
-if ($friends > 0) {
- if ($friends = get_user_friends($friends, '', 9999)) {
- $owner_guid_array = array();
- foreach($friends as $friend) {
- $owner_guid_array[] = $friend->guid;
- }
- } else {
- $owner_guid = -1;
- }
-}
-
-// Set up submenus
-if ($types = get_registered_entity_types()) {
- foreach($types as $ot => $subtype_array) {
- if (is_array($subtype_array) && count($subtype_array)) {
- foreach($subtype_array as $object_subtype) {
- $label = 'item:' . $ot;
- if (!empty($object_subtype)) {
- $label .= ':' . $object_subtype;
- }
-
- $data = http_build_query(array(
- 'tag' => urlencode($tag),
- 'subtype' => $object_subtype,
- 'type' => urlencode($ot),
- //'tagtype' => urlencode($md_type),
- 'owner_guid' => urlencode($owner_guid)
- ));
-
- $url = "{$CONFIG->wwwroot}pg/search/?$data";
-
- add_submenu_item(elgg_echo($label), $url);
- }
- }
- }
-
- $data = http_build_query(array(
- 'tag' => urlencode($tag),
- 'owner_guid' => urlencode($owner_guid)
- ));
-
- add_submenu_item(elgg_echo('all'), "{$CONFIG->wwwroot}pg/search/?$data");
-}
-
-// pull in search types for external or aggregated searches.
-if ($search_types = trigger_plugin_hook('search', 'types', '', NULL, array())) {
-
-}
-
-$body = '';
-if (!empty($tag)) {
- // start with blank results.
- $results = array(
- 'entities' => array(),
- 'total' => 0
- );
-
- // do the actual searchts
- $params = array(
- 'tag' => $tag,
- 'offset' => $offset,
- 'limit' => $limit,
- 'searchtype' => $searchtype,
- 'type' => $type,
- 'subtype' => $subtype,
- 'tagtype' => $tagtype,
- 'owner_guid' => $owner_guid_array
- );
-
- $results = trigger_plugin_hook('search', 'entities', $params, $results);
-
- if (empty($type) && empty($subtype)) {
- $title = sprintf(elgg_echo('searchtitle'),$tag);
- } else {
- if (empty($type)) {
- $type = 'object';
- }
- $itemtitle = 'item:' . $type;
- if (!empty($subtype)) {
- $itemtitle .= ':' . $subtype;
- }
- $itemtitle = elgg_echo($itemtitle);
- $title = sprintf(elgg_echo('advancedsearchtitle'),$itemtitle,$tag);
- }
-
- $body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));
-
- // call the old (now-deprecated) search hook here
- $body .= trigger_plugin_hook('search','',$tag, '');
-
- $body .= elgg_view('search/startblurb', array('query' => $query));
-
- if ($results->total > 0) {
- $body .= elgg_view('search/entity_list', array(
- 'entities' => $results->entities,
- 'count' => $results->total,
- 'offset' => $offset,
- 'limit' => $limit,
- 'baseurl' => $_SERVER['REQUEST_URI'],
- 'fullview' => false,
- 'context' => 'search',
- 'viewtypetoggle' => true,
- 'viewtype' => $viewtype,
- 'pagination' => true
- ));
- } else {
- $body .= elgg_view('page_elements/contentwrapper', array('body' => elgg_echo('search:noresults')));
- }
-
- elgg_view_entity_list($results->entities, count($results->entities), 0, count($results->entities), false);
-} else {
- // if no tag was given, give the user a box to input a search term
- $body .= elgg_view_title(elgg_echo('search:enterterm'));
- $body .= elgg_view('page_elements/contentwrapper', array('body' => '<div>' . elgg_view('page_elements/searchbox') . '</div>'));
-}
-
-$layout = elgg_view_layout('two_column_left_sidebar','',$body);
-
-page_draw($title, $layout); \ No newline at end of file