diff options
author | Cash Costello <cash.costello@gmail.com> | 2011-10-17 19:37:30 -0700 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2011-10-17 19:37:30 -0700 |
commit | 63ebe7b121105beb7e4c8b9b82e3c649f6a9a489 (patch) | |
tree | 79f51f8b6e94203297cbbc899f3daa400475de34 /engine | |
parent | 9a3ec606cfe2cbbe08949a56198bf9d4bb2e1e64 (diff) | |
parent | 34c968355231216624c2beae59ea9ad17f7ef2c0 (diff) | |
download | elgg-63ebe7b121105beb7e4c8b9b82e3c649f6a9a489.tar.gz elgg-63ebe7b121105beb7e4c8b9b82e3c649f6a9a489.tar.bz2 |
Merge pull request #74 from cash/autocomplete
Fixes #2102, #2712, #3450 Finishes autocomplete and userpicker for 1.8.1
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/elgglib.php | 1 | ||||
-rw-r--r-- | engine/lib/input.php | 72 |
2 files changed, 64 insertions, 9 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 1469067ca..53a15ba7a 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2042,6 +2042,7 @@ function elgg_init() { elgg_register_page_handler('ajax', 'elgg_ajax_page_handler'); elgg_register_js('elgg.autocomplete', 'js/lib/autocomplete.js'); + elgg_register_js('jquery.ui.autocomplete.html', 'vendors/jquery/jquery.ui.autocomplete.html.js'); elgg_register_js('elgg.userpicker', 'js/lib/userpicker.js'); elgg_register_js('elgg.friendspicker', 'js/lib/friends_picker.js'); elgg_register_js('jquery.easing', 'vendors/jquery/jquery.easing.1.3.packed.js'); diff --git a/engine/lib/input.php b/engine/lib/input.php index 5c1a6299c..4900817a5 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -289,13 +289,35 @@ function input_livesearch_page_handler($page) { if ($entities = get_data($query)) { foreach ($entities as $entity) { + $entity = get_entity($entity->guid); + if (!$entity) { + continue; + } + + if (in_array('groups', $match_on)) { + $value = $entity->guid; + } else { + $value = $entity->username; + } + + $output = elgg_view_list_item($entity, array( + 'hover' => false, + 'class' => 'elgg-autocomplete-item', + )); + + $icon = elgg_view_entity_icon($entity, 'tiny', array( + 'hover' => false, + )); + $result = array( 'type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, - 'icon' => '<img class="elgg-livesearch-icon" src="' . - get_entity($entity->guid)->getIconURL('tiny') . '" />', - 'guid' => $entity->guid + 'guid' => $entity->guid, + 'label' => $output, + 'value' => $value, + 'icon' => $icon, + 'url' => $entity->getURL(), ); $results[$entity->name . rand(1, 100)] = $result; } @@ -316,13 +338,29 @@ function input_livesearch_page_handler($page) { "; if ($entities = get_data($query)) { foreach ($entities as $entity) { + $entity = get_entity($entity->guid); + if (!$entity) { + continue; + } + + $output = elgg_view_list_item($entity, array( + 'hover' => false, + 'class' => 'elgg-autocomplete-item', + )); + + $icon = elgg_view_entity_icon($entity, 'tiny', array( + 'hover' => false, + )); + $result = array( 'type' => 'group', 'name' => $entity->name, 'desc' => strip_tags($entity->description), - 'icon' => '<img class="elgg-livesearch-icon" src="' - . get_entity($entity->guid)->getIconURL('tiny') . '" />', - 'guid' => $entity->guid + 'guid' => $entity->guid, + 'label' => $output, + 'value' => $entity->guid, + 'icon' => $icon, + 'url' => $entity->getURL(), ); $results[$entity->name . rand(1, 100)] = $result; @@ -347,13 +385,29 @@ function input_livesearch_page_handler($page) { if ($entities = get_data($query)) { foreach ($entities as $entity) { + $entity = get_entity($entity->guid); + if (!$entity) { + continue; + } + + $output = elgg_view_list_item($entity, array( + 'hover' => false, + 'class' => 'elgg-autocomplete-item', + )); + + $icon = elgg_view_entity_icon($entity, 'tiny', array( + 'hover' => false, + )); + $result = array( 'type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, - 'icon' => '<img class="elgg-livesearch-icon" src="' - . get_entity($entity->guid)->getIconURL('tiny') . '" />', - 'guid' => $entity->guid + 'guid' => $entity->guid, + 'label' => $output, + 'value' => $entity->username, + 'icon' => $icon, + 'url' => $entity->getURL(), ); $results[$entity->name . rand(1, 100)] = $result; } |