aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/autocomplete.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-16 21:01:42 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-16 21:01:42 -0300
commit5f6dc365a8445a48156b45912827eac39fd64fc5 (patch)
tree0dc3326151072bb5d97592513e1af4b40be32e07 /views/default/input/autocomplete.php
downloadelgg-5f6dc365a8445a48156b45912827eac39fd64fc5.tar.gz
elgg-5f6dc365a8445a48156b45912827eac39fd64fc5.tar.bz2
Squashed 'mod/subgroups/' content from commit 835015b
git-subtree-dir: mod/subgroups git-subtree-split: 835015b66b9de6dc6de91ab39f95e1f09b2dbf84
Diffstat (limited to 'views/default/input/autocomplete.php')
-rw-r--r--views/default/input/autocomplete.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php
new file mode 100644
index 000000000..4eedac22a
--- /dev/null
+++ b/views/default/input/autocomplete.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Displays an autocomplete text input.
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ * @todo This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page.
+ *
+ * @uses $vars['value'] Current value for the text input
+ * @uses $vars['match_on'] Array | str What to match on. all|array(groups|users|friends)
+ * @uses $vars['match_owner'] Bool. Match only entities that are owned by logged in user.
+ * @uses $vars['livesearsh_url'] Alternative livesearch URL
+ * @uses $vars['class'] Additional CSS class
+ */
+
+if (isset($vars['class'])) {
+ $vars['class'] = "elgg-input-autocomplete {$vars['class']}";
+} else {
+ $vars['class'] = "elgg-input-autocomplete";
+}
+
+if (isset($vars['livesearch_url'])) {
+ $livesearch_url = $vars['livesearch_url'];
+ unset($vars['livesearch_url']);
+} else {
+ $livesearch_url = elgg_get_site_url() . 'livesearch';
+}
+
+$defaults = array(
+ 'value' => '',
+ 'disabled' => false,
+);
+
+$vars = array_merge($defaults, $vars);
+
+$params = array();
+if (isset($vars['match_on'])) {
+ $params['match_on'] = $vars['match_on'];
+ unset($vars['match_on']);
+}
+if (isset($vars['match_owner'])) {
+ $params['match_owner'] = $vars['match_owner'];
+ unset($vars['match_owner']);
+}
+$ac_url_params = http_build_query($params);
+
+elgg_load_js('elgg.autocomplete');
+elgg_load_js('jquery.ui.autocomplete.html');
+
+?>
+
+<script type="text/javascript">
+elgg.provide('elgg.autocomplete');
+elgg.autocomplete.url = "<?php echo $livesearch_url . '?' . $ac_url_params; ?>";
+</script>
+<input type="text" <?php echo elgg_format_attributes($vars); ?> />