blog.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * View for blog objects
  4. *
  5. * @package Blog
  6. */
  7. $full = elgg_extract('full_view', $vars, FALSE);
  8. $blog = elgg_extract('entity', $vars, FALSE);
  9. if (!$blog) {
  10. return TRUE;
  11. }
  12. $owner = $blog->getOwnerEntity();
  13. $container = $blog->getContainerEntity();
  14. $categories = elgg_view('output/categories', $vars);
  15. $excerpt = $blog->excerpt;
  16. if (empty($excerpt)) {
  17. $excerpt = elgg_get_excerpt($blog->description);
  18. }
  19. $owner_icon = elgg_view_entity_icon($owner, 'tiny');
  20. $owner_link = elgg_view('output/url', array(
  21. 'href' => "blog/owner/$owner->username",
  22. 'text' => $owner->name,
  23. ));
  24. $author_text = elgg_echo('byline', array($owner_link));
  25. // add container text
  26. if (elgg_instanceof($container, "group") && ($container->getGUID() !== elgg_get_page_owner_guid())) {
  27. $params = array(
  28. 'href' => $container->getURL(),
  29. 'text' => $container->name,
  30. 'is_trusted' => true
  31. );
  32. $group_link = elgg_view('output/url', $params);
  33. $author_text .= " " . elgg_echo('river:ingroup', array($group_link));
  34. }
  35. $tags = elgg_view('output/tags', array('tags' => $blog->tags));
  36. $date = elgg_view_friendly_time($blog->time_created);
  37. $info_class = "";
  38. $blog_icon = "";
  39. $title = "";
  40. // show icon
  41. if (!empty($blog->icontime)) {
  42. $params = $vars;
  43. $params["plugin_settings"] = true;
  44. $blog_icon = elgg_view_entity_icon($blog, "dummy", $params);
  45. }
  46. $metadata = elgg_view_menu('entity', array(
  47. 'entity' => $blog,
  48. 'handler' => 'blog',
  49. 'sort_by' => 'priority',
  50. 'class' => 'elgg-menu-hz',
  51. ));
  52. $subtitle = "$author_text $date $categories";
  53. // do not show the metadata and controls in widget view
  54. if (elgg_in_context('widgets')) {
  55. $metadata = '';
  56. }
  57. // Show blog
  58. if ($full) {
  59. // full view
  60. $body = elgg_view('output/longtext', array(
  61. 'value' => $blog->description,
  62. 'class' => 'blog-post',
  63. ));
  64. $header = elgg_view_title($blog->title);
  65. $params = array(
  66. 'entity' => $blog,
  67. 'title' => false,
  68. 'metadata' => $metadata,
  69. 'subtitle' => $subtitle,
  70. 'tags' => $tags,
  71. );
  72. $params = $params + $vars;
  73. $summary = elgg_view('object/elements/summary', $params);
  74. echo elgg_view("object/elements/full", array(
  75. "summary" => $summary,
  76. "icon" => $owner_icon,
  77. "body" => $blog_icon . $body,
  78. ));
  79. } else {
  80. // how to show strapline
  81. if (elgg_in_context("listing")) {
  82. $excerpt = "";
  83. $blog_icon = "";
  84. } elseif (elgg_in_context("simple")) {
  85. $owner_icon = "";
  86. $tags = false;
  87. $subtitle = "";
  88. $title = false;
  89. // prepend title to the excerpt
  90. $title_link = "<h3>" . elgg_view("output/url", array("text" => $blog->title, "href" => $blog->getURL())) . "</h3>";
  91. $excerpt = $title_link . $excerpt;
  92. // add read more link
  93. if (substr($excerpt, -3) == "...") {
  94. $read_more = elgg_view("output/url", array("text" => elgg_echo("blog_tools:readmore"), "href" => $blog->getURL()));
  95. $excerpt .= " " . $read_more;
  96. }
  97. } elseif (elgg_get_plugin_setting("listing_strapline", "blog_tools") == "time") {
  98. $subtitle = "";
  99. $tags = false;
  100. $excerpt = date("F j, Y", $blog->time_created) . " - " . $excerpt;
  101. }
  102. // prepend icon
  103. $excerpt = $blog_icon . $excerpt;
  104. // brief view
  105. $params = array(
  106. 'entity' => $blog,
  107. 'title' => $title,
  108. 'metadata' => $metadata,
  109. 'subtitle' => $subtitle,
  110. 'tags' => $tags,
  111. 'content' => $excerpt,
  112. );
  113. $params = $params + $vars;
  114. $list_body = elgg_view('object/elements/summary', $params);
  115. echo elgg_view_image_block($owner_icon, $list_body);
  116. }