aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/tags.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-06 01:49:35 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-06 01:49:35 +0000
commit45eaa94d22b0237c4a5119645d3a5327545342a3 (patch)
tree70cb48b0131cce3b0d2601f1a5015dcbb35dd328 /engine/lib/tags.php
parent436820f2b1de59269f3ebb640df4292bafe832b3 (diff)
downloadelgg-45eaa94d22b0237c4a5119645d3a5327545342a3.tar.gz
elgg-45eaa94d22b0237c4a5119645d3a5327545342a3.tar.bz2
Added search for group, tags, and users.
git-svn-id: http://code.elgg.org/elgg/trunk@3624 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/tags.php')
-rw-r--r--engine/lib/tags.php60
1 files changed, 59 insertions, 1 deletions
diff --git a/engine/lib/tags.php b/engine/lib/tags.php
index 3c65c2a7a..cdcf213c0 100644
--- a/engine/lib/tags.php
+++ b/engine/lib/tags.php
@@ -174,4 +174,62 @@ function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type
function display_tagcloud($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1) {
return elgg_view("output/tagcloud",array('value' => get_tags($threshold, $limit, $metadata_name, $entity_type, $entity_subtype, $owner_guid, $site_guid),'object' => $entity_type, 'subtype' => $entity_subtype));
-} \ No newline at end of file
+}
+
+
+
+/**
+ * Return default results for searches on groups.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $type
+ * @param unknown_type $value
+ * @param unknown_type $params
+ * @return unknown_type
+ */
+function tags_search_hook($hook, $type, $value, $params) {
+ global $CONFIG;
+
+ $query = $params['query'];
+
+ $params['metadata_name_value_pair'] = array ('name' => 'tags', 'value' => $query, 'case_sensitive' => FALSE);
+
+ $entities = elgg_get_entities_from_metadata($params);
+ $params['count'] = TRUE;
+ $count = elgg_get_entities_from_metadata($params);
+
+ // no need to continue if nothing here.
+ if (!$count) {
+ return array('entities' => array(), 'count' => $count);
+ }
+
+ // add the volatile data for why these entities have been returned.
+ foreach ($entities as $entity) {
+ $tags = implode(',', $entity->tags);
+ $tags_str = search_get_relevant_substring($tags, $query, '<strong class="searchMatch">', '</strong>');
+ $entity->setVolatileData('search_matched_tags', $tags_str);
+ }
+
+ return array(
+ 'entities' => $entities,
+ 'count' => $count,
+ );
+}
+
+/**
+ * Register tags as a custom search type.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $type
+ * @param unknown_type $value
+ * @param unknown_type $params
+ * @return unknown_type
+ */
+function tags_search_custom_types_hook($hook, $type, $value, $params) {
+ $value[] = 'tags';
+ return $value;
+}
+
+
+register_plugin_hook('search', 'tags', 'tags_search_hook');
+register_plugin_hook('search_types', 'get_types', 'tags_search_custom_types_hook'); \ No newline at end of file