function au_group_tag_menu_page_handler($page, $identifier) { //show the page of search results // assumes url of group/guid/tag // if the tag is 'all' then will display a tagcloud switch ($page[0]) { case 'group': $entity = get_entity($page[1]); if (!elgg_instanceof($entity, 'group') || $entity->au_group_tag_menu_enable == 'no') { return false; } elgg_push_breadcrumb($entity->name, $entity->getURL()); //should be OK if this is empty $tag = $page[2]; elgg_push_breadcrumb($tag); if ($tag == "all") { //show a tag cloud for all group tags //arbitrarily set to a max of 640 tags - should be enough for anyone :-) $title = elgg_echo("au_group_tag_menu:tagcloud"); $options = array('container_guid' => $entity->getGUID(), 'type' => 'object', 'threshold' => 0, 'limit' => 640, 'tag_names' => array('tags')); $thetags = elgg_get_tags($options); //make it an alphabetical tag cloud, not with most popular first sort($thetags); //find the highest tag count for scaling the font $max = 0; foreach ($thetags as $key) { if ($key->total > $max) { $max = $key->total; } } $content = " "; //loop through and generate tags so they display nicely //in the group, not as a dumb search page foreach ($thetags as $key) { $url = elgg_get_site_url() . "group_tag_menu/group/" . $entity->getGUID() . "/" . urlencode($key->tag); $taglink = elgg_view('output/url', array('text' => ' ' . $key->tag, 'href' => $url, 'title' => "{$key->tag} ({$key->total})", 'rel' => 'tag')); // get the font size for the tag (taken from elgg's own tagcloud code - not sure I love this) $size = round(log($key->total) / log($max + 0.0001) * 100) + 30; if ($size < 100) { $size = 100; } // generate the link $content .= " <a href='{$url}' style='font-size:{$size}%'>" . $key->tag . "</a> "; } } else { //show the results for the selected tag $title = elgg_echo("au_group_tag_menu:title") . "{$tag}"; $options = array('type' => 'object', 'metadata_name' => 'tags', 'metadata_value' => $tag, 'container_guid' => $entity->guid, 'full_view' => false); $content = elgg_list_entities_from_metadata($options); } //display the page if (!$content) { $content = elgg_echo('au_group_tag_menu:noresults'); } $layout = elgg_view_layout('content', array('title' => elgg_view_title($title), 'content' => $content, 'filter' => false)); echo elgg_view_page($title, $layout); break; } return true; }
/** * Add a sidebar menu of plugin types for this developer * * @param int $owner_guid The GUID of the owner of the plugins */ function add_type_menu($owner_guid) { $owner = get_entity($owner_guid); if (!$owner) { return; } $plugin_types = elgg_get_tags(array('threshold' => 0, 'limit' => 10, 'tag_names' => array('plugin_type'), 'type' => 'object', 'subtype' => 'plugin_project', 'container_guid' => $owner_guid)); if ($plugin_types) { foreach ($plugin_types as $type) { $tag = $type->tag; $label = elgg_echo("plugins:type:" . $tag); $url = "/plugins/developer/{$owner->username}/type/{$tag}/"; elgg_register_menu_item('page', array('name' => $label, 'text' => $label, 'href' => $url)); } } }
/** * Get an array of tags with weights for use with the output/tagcloud view. * * @deprecated 1.8 Use elgg_get_tags(). * * @param int $threshold Get the threshold of minimum number of each tags to * bother with (ie only show tags where there are more * than $threshold occurances) * @param int $limit Number of tags to return * @param string $metadata_name Optionally, the name of the field you want to grab for * @param string $entity_type Optionally, the entity type ('object' etc) * @param string $entity_subtype The entity subtype, optionally * @param int $owner_guid The GUID of the tags owner, optionally * @param int $site_guid Optionally, the site to restrict to (default is the current site) * @param int $start_ts Optionally specify a start timestamp for tags used to * generate cloud. * @param int $end_ts Optionally specify an end timestamp for tags used to generate cloud * * @return array|false Array of objects with ->tag and ->total values, or false on failure */ function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") { elgg_deprecated_notice('get_tags() has been replaced by elgg_get_tags()', 1.8); if (is_array($metadata_name)) { return false; } $options = array(); if ($metadata_name === '') { $options['tag_names'] = array(); } else { $options['tag_names'] = array($metadata_name); } $options['threshold'] = $threshold; $options['limit'] = $limit; // rewrite owner_guid to container_guid to emulate old functionality $container_guid = $owner_guid; if ($container_guid) { $options['container_guids'] = $container_guid; } if ($entity_type) { $options['type'] = $entity_type; } if ($entity_subtype) { $options['subtype'] = $entity_subtype; } if ($site_guid != -1) { $options['site_guids'] = $site_guid; } if ($end_ts) { $options['created_time_upper'] = $end_ts; } if ($start_ts) { $options['created_time_lower'] = $start_ts; } $r = elgg_get_tags($options); return $r; }
<?php $owner = $vars["entity"]->getOwnerEntity(); $cloud_options = array(); if ($owner instanceof ElggUser) { $cloud_options["owner_guid"] = $owner->getGUID(); } elseif ($owner instanceof ElggGroup) { $cloud_options["container_guid"] = $owner->getGUID(); } if ($cloud_data = elgg_get_tags($cloud_options)) { shuffle($cloud_data); $cloud = elgg_view("output/tagcloud", array('value' => $cloud_data)); } else { $cloud = elgg_echo("widgets:tagcloud:no_data"); } echo $cloud;
/** * Create a tagcloud for viewing * * @see elgg_get_tags * * @param array $options Any elgg_get_tags() options except: * * type => must be single entity type * * subtype => must be single entity subtype * * @return string * @since 1.7.1 */ function elgg_view_tagcloud(array $options = array()) { $type = $subtype = ''; if (isset($options['type'])) { $type = $options['type']; } if (isset($options['subtype'])) { $subtype = $options['subtype']; } $tag_data = elgg_get_tags($options); return elgg_view("output/tagcloud", array('value' => $tag_data, 'type' => $type, 'subtype' => $subtype)); }
/** * Return all Site Tags for jQuery Tags Inpug plugin * see * https://github.com/aehlke/tag-it * * */ function follow_tags_get_all_tags($limit) { $threshold = elgg_get_plugin_setting("threshold", "follow_tags"); if (!$threshold) { // Set Default threshold $threshold = 0; } $options = array('limit' => $limit, 'threshold' => $threshold, 'tag_name' => 'tags'); $tags = elgg_get_tags($options); $json = array(); foreach ($tags as $tag) { $json[] = $tag->tag; } $defaultTags = elgg_get_plugin_setting("defaultTags", "follow_tags"); if (!empty($defaultTags)) { $defaultTags = explode(',', $defaultTags); $json = array_merge($defaultTags, $json); } if (is_array($json)) { $json = json_encode($json); } else { $json = '[]'; } return $json; }
/** * Returns a list of filetypes * * @param int $container_guid The GUID of the container of the files * @param bool $friends Whether we're looking at the container or the container's friends * @return string The typecloud */ function file_get_type_cloud($container_guid = "", $friends = false) { $container_guids = $container_guid; if ($friends) { // tags interface does not support pulling tags on friends' content so // we need to grab all friends $friend_entities = get_user_friends($container_guid, "", 999999, 0); if ($friend_entities) { $friend_guids = array(); foreach ($friend_entities as $friend) { $friend_guids[] = $friend->getGUID(); } } $container_guids = $friend_guids; } elgg_register_tag_metadata_name('simpletype'); $options = array('type' => 'object', 'subtype' => 'file', 'container_guids' => $container_guids, 'threshold' => 0, 'limit' => 10, 'tag_names' => array('simpletype')); $types = elgg_get_tags($options); $params = array('friends' => $friends, 'types' => $types); return elgg_view('file/typecloud', $params); }
$menu .= "<li class='elgg-state-selected'>"; $menu .= elgg_view("output/url", $url_options) . "</li>"; } } if (($guids == null || count($guids) > 1) && count($filter) < 3) { $tag_options = array("type" => "object", "subtype" => UserSupportFAQ::SUBTYPE, "tag_names" => array("tags"), "wheres" => array()); if (elgg_get_plugin_setting("ignore_site_guid", "user_support") !== "no") { $tag_options["site_guids"] = false; } if (!empty($filter)) { $tag_options["wheres"][] = "(msv.string NOT IN ('" . implode("', '", $filter) . "'))"; } if (!empty($guids)) { $tag_options["wheres"][] = "(e.guid IN (" . implode(",", $guids) . "))"; } $tags = elgg_get_tags($tag_options); if ($tags) { foreach ($tags as $tag) { $tag_text = $tag->tag; $tag_query_params = $query_params; // add the extra tag to the filter $tag_query_params["filter"][] = $tag_text; $url_options = array("href" => "user_support/faq?" . http_build_query($tag_query_params), "text" => elgg_view_icon("checkmark", "float") . $tag_text); $menu .= "<li>" . elgg_view("output/url", $url_options) . "</li>"; } } } if ($menu) { $body = "<ul class='elgg-menu elgg-menu-page elgg-menu-faq'>" . $menu . "</ul>"; echo elgg_view_module("aside", elgg_echo("filter"), $body); }
* <http://www.gnu.org/licenses/>. * * Generally used in a sidebar. Does not work with groups currently. * * @uses $vars['subtypes'] Object subtype string or array of subtypes * @uses $vars['owner_guid'] The owner of the content being tagged * @uses $vars['limit'] The maxinum number of tags to display */ $owner_guid = elgg_extract('owner_guid', $vars, ELGG_ENTITIES_ANY_VALUE); if (!$owner_guid) { $owner_guid = ELGG_ENTITIES_ANY_VALUE; } $owner_entity = get_entity($owner_guid); $options = array('type' => 'object', 'subtype' => elgg_extract('subtypes', $vars, ELGG_ENTITIES_ANY_VALUE), 'container_guid' => $owner_guid, 'threshold' => 0, 'limit' => elgg_extract('limit', $vars, 50), 'tag_name' => 'tags'); $title = elgg_echo('tagcloud'); if (is_array($options['subtype']) && count($options['subtype']) > 1) { // we cannot provide links to tagged objects with multiple types $tag_data = elgg_get_tags($options); $cloud = elgg_view("output/tagcloud", array('value' => $tag_data, 'type' => $type)); } else { $cloud = elgg_view_tagcloud($options); } if (!$cloud) { return true; } // add a link to all site tags $cloud .= '<p class="small">'; $cloud .= elgg_view_icon('tag'); $cloud .= elgg_view('output/url', array('href' => 'tags', 'text' => elgg_echo('tagcloud:allsitetags'), 'is_trusted' => true)); $cloud .= '</p>'; echo elgg_view_module('aside', $title, $cloud);
/** * Registers page menu items for file type filtering and returns a view * * @param int $container_guid The GUID of the container of the files * @param bool $friends Whether we're looking at the container or the container's friends * * @return string The typecloud */ function file_get_type_cloud($container_guid = "", $friends = false) { $container_guids = $container_guid; $container = get_entity($container_guid); if ($friends && $container) { // tags interface does not support pulling tags on friends' content so // we need to grab all friends $friend_entities = $container->getFriends(array('limit' => 0)); if ($friend_entities) { $friend_guids = array(); foreach ($friend_entities as $friend) { $friend_guids[] = $friend->getGUID(); } } $container_guids = $friend_guids; } elgg_register_tag_metadata_name('simpletype'); $options = array('type' => 'object', 'subtype' => 'file', 'container_guids' => $container_guids, 'threshold' => 0, 'limit' => 10, 'tag_names' => array('simpletype')); $types = elgg_get_tags($options); if ($types) { $all = new stdClass(); $all->tag = 'all'; elgg_register_menu_item('page', array('name' => 'file:all', 'text' => elgg_echo('all'), 'href' => file_type_cloud_get_url($all, $friends))); foreach ($types as $type) { elgg_register_menu_item('page', array('name' => "file:{$type->tag}", 'text' => elgg_echo("file:type:{$type->tag}"), 'href' => file_type_cloud_get_url($type, $friends))); } } // returning the view is needed for BC $params = array('friends' => $friends, 'types' => $types); return elgg_view('file/typecloud', $params); }
$page = $vars['page']; if (!elgg_instanceof($entity, 'group') || $entity->au_group_tag_menu_enable == 'no') { return; } elgg_push_breadcrumb($entity->name, $entity->getURL()); //should be OK if this is empty $tag = $page[2]; if ($tag) { elgg_push_breadcrumb($tag); } if ($tag == "all") { //show a tag cloud for all group tags //arbitrarily set to a max of 640 tags - should be enough for anyone :-) $title = elgg_echo("au_group_tag_menu:tagcloud"); $options = array('container_guid' => $entity->getGUID(), 'type' => 'object', 'threshold' => 0, 'limit' => 640, 'tag_names' => array('tags')); $thetags = elgg_get_tags($options); //make it an alphabetical tag cloud, not with most popular first sort($thetags); //find the highest tag count for scaling the font $max = 0; foreach ($thetags as $key) { if ($key->total > $max) { $max = $key->total; } } $content = " "; //loop through and generate tags so they display nicely //in the group, not as a dumb search page foreach ($thetags as $key) { $url = "group_tag_menu/group/" . $entity->guid . "/" . urlencode($key->tag); // get the font size for the tag (taken from elgg's own tagcloud code - not sure I love this)
<?php /** * au_group_tag_menu * get settings for the tag menu * need the tags themselves * to limit results to a specific user's posts */ //get current settings $group = elgg_get_page_owner_entity(); if (!empty($group) && elgg_instanceof($group, "group")) { // build form to enter tags if (!$group->menu_tags) { //populate with top existing group tags $options = array('container_guids' => $group->getGUID(), 'types' => 'object', 'threshold' => 0, 'limit' => 5, 'tag_names' => $group->tags, 'order_by' => 'tag ASC'); $menutags = elgg_get_tags($options); } else { //populate with group menu tags $menutags = $group->menu_tags; } $form_body = "<div>"; $form_body .= "<label for='group_tags'>" . elgg_echo('au_group_tag_menu:tags') . "</label>"; $form_body .= "<p>" . elgg_echo('au_group_tag_menu:tagblurb') . "</p>"; $form_body .= elgg_view('input/tags', array('name' => 'menu_tags', 'id' => 'menu_tags', 'value' => $menutags)); $form_body .= "</div><div>"; //select the number of tags to show if using auto menu $form_body .= "<label for='menu_maxtags'>" . elgg_echo('au_group_tag_menu:maxtags') . "</label> "; $menumax = $group->menu_maxtags; $options = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '15' => '15', '20' => '20', '25' => '25', '30' => '30', '40' => '40', '50' => '50'); $form_body .= elgg_view("input/dropdown", array("name" => "menu_maxtags", "id" => "menu_maxtags", "options_values" => $options, "value" => $menumax)); $form_body .= "</p>";
<?php namespace hypeJunction\Embed; $query = elgg_extract('query', $vars); $simpletype = elgg_extract('simpletype', $vars); $body .= '<div class="elgg-col elgg-col-1of2">'; $body .= '<div class="elgg-inner">'; $body .= '<label>' . elgg_echo('embed:tab:file:search:query') . '</label>'; $body .= elgg_view('input/text', array('value' => $query, 'name' => 'query')); $body .= '</div>'; $body .= '</div>'; elgg_register_tag_metadata_name('simpletype'); $types = elgg_get_tags(array('type' => 'object', 'subtype' => 'file', 'threshold' => 1, 'limit' => 20, 'tag_names' => array('simpletype'))); $type_options = array('' => elgg_echo('file:type:all')); foreach ($types as $type) { $type_options[$type->tag] = elgg_echo("file:type:{$type->tag}"); } $body .= '<div class="elgg-col elgg-col-1of2">'; $body .= '<div class="elgg-inner">'; $body .= '<label>' . elgg_echo('embed:tab:file:search:type') . '</label>'; $body .= elgg_view('input/dropdown', array('value' => $simpletype, 'name' => 'simpletype', 'options_values' => $type_options)); $body .= '</div>'; $body .= '</div>'; $body = '<fieldset>' . $body . '</fieldset>'; $body .= '<fieldset class="elgg-foot">'; $body .= elgg_view('input/submit', array('value' => elgg_echo('search'), 'class' => 'elgg-button-submit')); $body .= '</fieldset>'; echo $body;
/** * Return all Site Tags for jQuery Tags Inpug plugin * see * https://github.com/xoxco/jQuery-Tags-Input * for Examples * https://github.com/xoxco/jQuery-Tags-Input/tree/master/test * */ function follow_tags_get_all_tags() { if (elgg_get_plugin_setting("autocomplete", "follow_tags") == 'yes') { $threshold = elgg_get_plugin_setting("threshold", "follow_tags"); if (!$threshold) { // Set Default threshold $threshold = 0; } $options = array('limit' => false, 'threshold' => $threshold, 'tag_name' => 'tags'); $tags = elgg_get_tags($options); foreach ($tags as $tag) { $json[] = $tag->tag; } $deftags = explode(",", elgg_get_plugin_setting("defaultTags", "follow_tags")); if ($deftags) { if ($json) { $json = array_merge($deftags, $json); } else { $json = $deftags; } } sort($json); $json = json_encode($json); } return $json; }
<?php namespace hypeJunction\Gallery; $search_type = get_input('search_type'); $term = sanitize_string(get_input('term')); $dbprefix = elgg_get_config('dbprefix'); $response = array(); switch ($search_type) { case 'tag': $tags = elgg_get_tags(array('limit' => 20, 'wheres' => array("msv.string LIKE '{$term}%'"))); foreach ($tags as $tag) { $response[] = array('label' => $tag->tag); } break; case 'friend': $logged_in = elgg_get_logged_in_user_entity(); $users = elgg_get_entities(array('types' => 'user', 'limit' => 20, 'joins' => array("JOIN {$dbprefix}entity_relationships er ON e.guid = er.guid_two", "JOIN {$dbprefix}users_entity ue ON e.guid = ue.guid"), 'wheres' => array("((er.relationship = 'friend' AND er.guid_one = {$logged_in->guid}) OR ue.guid = {$logged_in->guid})", "ue.name LIKE '%{$term}%'"))); if ($users) { foreach ($users as $user) { $response[] = array('icon' => $user->getIconURL('tiny'), 'label' => $user->name, 'value' => $user->guid); } } break; } header("Content-type:application/json"); print json_encode($response); exit;