bookmarks.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * Elgg bookmark view
  4. *
  5. * @package ElggBookmarks
  6. */
  7. $full = elgg_extract('full_view', $vars, FALSE);
  8. $bookmark = elgg_extract('entity', $vars, FALSE);
  9. if (!$bookmark) {
  10. return;
  11. }
  12. $owner = $bookmark->getOwnerEntity();
  13. $owner_icon = elgg_view_entity_icon($owner, 'tiny');
  14. $categories = elgg_view('output/categories', $vars);
  15. $link = elgg_view('output/url', array('href' => $bookmark->address));
  16. $description = elgg_view('output/longtext', array('value' => $bookmark->description, 'class' => 'pbl'));
  17. $owner_link = elgg_view('output/url', array(
  18. 'href' => "bookmarks/owner/$owner->username",
  19. 'text' => $owner->name,
  20. 'is_trusted' => true,
  21. ));
  22. $author_text = elgg_echo('byline', array($owner_link));
  23. $date = elgg_view_friendly_time($bookmark->time_created);
  24. $comments_count = $bookmark->countComments();
  25. //only display if there are commments
  26. if ($comments_count != 0) {
  27. $text = elgg_echo("comments") . " ($comments_count)";
  28. $comments_link = elgg_view('output/url', array(
  29. 'href' => $bookmark->getURL() . '#comments',
  30. 'text' => $text,
  31. 'is_trusted' => true,
  32. ));
  33. } else {
  34. $comments_link = '';
  35. }
  36. $metadata = elgg_view_menu('entity', array(
  37. 'entity' => $vars['entity'],
  38. 'handler' => 'bookmarks',
  39. 'sort_by' => 'priority',
  40. 'class' => 'elgg-menu-hz',
  41. ));
  42. $subtitle = "$author_text $date $comments_link $categories";
  43. // do not show the metadata and controls in widget view
  44. if (elgg_in_context('widgets')) {
  45. $metadata = '';
  46. }
  47. if ($full && !elgg_in_context('gallery')) {
  48. $params = array(
  49. 'entity' => $bookmark,
  50. 'title' => false,
  51. 'metadata' => $metadata,
  52. 'subtitle' => $subtitle,
  53. );
  54. $params = $params + $vars;
  55. $summary = elgg_view('object/elements/summary', $params);
  56. $bookmark_icon = elgg_view_icon('push-pin-alt');
  57. $body = <<<HTML
  58. <div class="bookmark elgg-content mts">
  59. $bookmark_icon<span class="elgg-heading-basic mbs">$link</span>
  60. $description
  61. </div>
  62. HTML;
  63. echo elgg_view('object/elements/full', array(
  64. 'entity' => $bookmark,
  65. 'icon' => $owner_icon,
  66. 'summary' => $summary,
  67. 'body' => $body,
  68. ));
  69. } elseif (elgg_in_context('gallery')) {
  70. echo <<<HTML
  71. <div class="bookmarks-gallery-item">
  72. <h3>$bookmark->title</h3>
  73. <p class='subtitle'>$owner_link $date</p>
  74. </div>
  75. HTML;
  76. } else {
  77. // brief view
  78. $url = $bookmark->address;
  79. $display_text = $url;
  80. $excerpt = elgg_get_excerpt($bookmark->description);
  81. if ($excerpt) {
  82. $excerpt = " - $excerpt";
  83. }
  84. if (strlen($url) > 25) {
  85. $bits = parse_url($url);
  86. if (isset($bits['host'])) {
  87. $display_text = $bits['host'];
  88. } else {
  89. $display_text = elgg_get_excerpt($url, 100);
  90. }
  91. }
  92. $link = elgg_view('output/url', array(
  93. 'href' => $bookmark->address,
  94. 'text' => $display_text,
  95. ));
  96. $content = elgg_view_icon('push-pin-alt') . "$link{$excerpt}";
  97. $params = array(
  98. 'entity' => $bookmark,
  99. 'metadata' => $metadata,
  100. 'subtitle' => $subtitle,
  101. 'content' => $content,
  102. );
  103. $params = $params + $vars;
  104. $body = elgg_view('object/elements/summary', $params);
  105. echo elgg_view_image_block($owner_icon, $body);
  106. }