tagcloud_block.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Display content-based tags
  4. *
  5. * @uses $vars['subtypes'] Object subtype string or array of subtypes
  6. * @uses $vars['owner_guid'] The owner of the content being tagged
  7. * @uses $vars['container_guid'] The container of the content being tagged
  8. * @uses $vars['limit'] The maximum number of tags to display
  9. */
  10. $owner_guid = elgg_extract('owner_guid', $vars, ELGG_ENTITIES_ANY_VALUE);
  11. $container_guid = elgg_extract('container_guid', $vars, ELGG_ENTITIES_ANY_VALUE);
  12. $type = elgg_extract('type', $vars, 'object');
  13. $options = array(
  14. 'type' => $type,
  15. 'subtype' => elgg_extract('subtypes', $vars, ELGG_ENTITIES_ANY_VALUE),
  16. 'owner_guid' => $owner_guid,
  17. 'container_guid' => $container_guid,
  18. 'threshold' => 0,
  19. 'limit' => elgg_extract('limit', $vars, 50),
  20. 'tag_name' => 'tags',
  21. );
  22. $title = elgg_echo('tagcloud');
  23. if (is_array($options['subtype']) && count($options['subtype']) > 1) {
  24. // we cannot provide links to tagged objects with multiple types
  25. $tag_data = elgg_get_tags($options);
  26. $cloud = elgg_view("output/tagcloud", array(
  27. 'value' => $tag_data,
  28. 'type' => $type,
  29. ));
  30. } else {
  31. $cloud = elgg_view_tagcloud($options);
  32. }
  33. if (!$cloud) {
  34. return true;
  35. }
  36. // add a link to all site tags
  37. $cloud .= '<p class="small">';
  38. $cloud .= elgg_view_icon('tag');
  39. $cloud .= elgg_view('output/url', array(
  40. 'href' => 'tags',
  41. 'text' => elgg_echo('tagcloud:allsitetags'),
  42. 'is_trusted' => true,
  43. ));
  44. $cloud .= '</p>';
  45. echo elgg_view_module('aside', $title, $cloud);