aboutsummaryrefslogtreecommitdiff
path: root/mod/search/index.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-01-14 15:40:22 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-01-14 15:40:22 +0000
commitde0963eafb5143fdf44dbac17fa115deacc46453 (patch)
tree78eb372f48570c9925aec8dcf145fa9a892d3f2f /mod/search/index.php
parent9c0a913909e0b560ce5e2723098e233601e86903 (diff)
downloadelgg-de0963eafb5143fdf44dbac17fa115deacc46453.tar.gz
elgg-de0963eafb5143fdf44dbac17fa115deacc46453.tar.bz2
Fixed an incorrect var name that caused a bug when hooking against a type but not a subtype.
Added first pass at results sorting. git-svn-id: http://code.elgg.org/elgg/trunk@3808 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/search/index.php')
-rw-r--r--mod/search/index.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/mod/search/index.php b/mod/search/index.php
index e92eee312..bbdad89e6 100644
--- a/mod/search/index.php
+++ b/mod/search/index.php
@@ -22,13 +22,33 @@ $offset = ($search_type == 'all') ? 0 : get_input('offset', 0);
$entity_type = get_input('entity_type', NULL);
$entity_subtype = get_input('entity_subtype', NULL);
$owner_guid = get_input('owner_guid', NULL);
-$friends = (int)get_input('friends', 0);
+$friends = get_input('friends', 0);
+$sort = get_input('sort');
+switch ($sort) {
+ case 'relevance':
+ case 'created':
+ case 'updated':
+ case 'action_on':
+ case 'alpha':
+ break;
+
+ default:
+ $sort = 'relevance';
+ break;
+}
+
+$order = get_input('sort', 'desc');
+if ($order != 'asc' && $order != 'desc') {
+ $order = 'desc';
+}
// set up search params
$params = array(
'query' => $query,
'offset' => $offset,
'limit' => $limit,
+ 'sort' => $sort,
+ 'order' => $order,
'search_type' => $search_type,
'type' => $entity_type,
'subtype' => $entity_subtype,
@@ -147,13 +167,13 @@ if ($search_type == 'all' || $search_type == 'entities') {
$current_params['subtype'] = $subtype;
$current_params['type'] = $type;
- $entities = trigger_plugin_hook('search', "$type:$subtype", $current_params, NULL);
- if ($entities === FALSE) {
+ $results = trigger_plugin_hook('search', "$type:$subtype", $current_params, NULL);
+ if ($results === FALSE) {
// someone is saying not to display these types in searches.
continue;
- } elseif (is_array($entities) && !count($entities)) {
+ } elseif (is_array($results) && !count($results)) {
// no results, but results searched in hook.
- } elseif (!$entities) {
+ } elseif (!$results) {
// no results and not hooked. use default type search.
// don't change the params here, since it's really a different subtype.
// Will be passed to elgg_get_entities().