summary.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Object summary
  4. *
  5. * Sample output
  6. * <ul class="elgg-menu elgg-menu-entity"><li>Public</li><li>Like this</li></ul>
  7. * <h3><a href="">Title</a></h3>
  8. * <p class="elgg-subtext">Posted 3 hours ago by George</p>
  9. * <p class="elgg-tags"><a href="">one</a>, <a href="">two</a></p>
  10. * <div class="elgg-content">Excerpt text</div>
  11. *
  12. * @uses $vars['entity'] ElggEntity
  13. * @uses $vars['title'] Title link (optional) false = no title, '' = default
  14. * @uses $vars['metadata'] HTML for entity menu and metadata (optional)
  15. * @uses $vars['subtitle'] HTML for the subtitle (optional)
  16. * @uses $vars['tags'] HTML for the tags (default is tags on entity, pass false for no tags)
  17. * @uses $vars['content'] HTML for the entity content (optional)
  18. */
  19. $entity = $vars['entity'];
  20. $title_link = elgg_extract('title', $vars, '');
  21. if ($title_link === '') {
  22. if (isset($entity->title)) {
  23. $text = $entity->title;
  24. } else {
  25. $text = $entity->name;
  26. }
  27. $params = array(
  28. 'text' => elgg_get_excerpt($text, 100),
  29. 'href' => $entity->getURL(),
  30. 'is_trusted' => true,
  31. );
  32. $title_link = elgg_view('output/url', $params);
  33. }
  34. $metadata = elgg_extract('metadata', $vars, '');
  35. $subtitle = elgg_extract('subtitle', $vars, '');
  36. $content = elgg_extract('content', $vars, '');
  37. $tags = elgg_extract('tags', $vars, '');
  38. if ($tags === '') {
  39. $tags = elgg_view('output/tags', array('tags' => $entity->tags));
  40. }
  41. if ($metadata) {
  42. echo $metadata;
  43. }
  44. if ($title_link) {
  45. echo "<h3>$title_link</h3>";
  46. }
  47. echo "<div class=\"elgg-subtext\">$subtitle</div>";
  48. echo $tags;
  49. echo elgg_view('object/summary/extend', $vars);
  50. if ($content) {
  51. echo "<div class=\"elgg-content\">$content</div>";
  52. }