content.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. $widget = $vars["entity"];
  3. //get the num of blog entries the user wants to display
  4. $num = (int) $widget->num_display;
  5. //if no number has been set, default to 4
  6. if ($num < 1) {
  7. $num = 4;
  8. }
  9. $options = array(
  10. "type" => "object",
  11. "subtype" => "blog",
  12. "container_guid" => $widget->getOwnerGUID(),
  13. "limit" => $num,
  14. "full_view" => false,
  15. "pagination" => false,
  16. "metadata_name_value_pairs" => array()
  17. );
  18. if (!elgg_is_admin_logged_in() && !($widget->getOwnerGUID() == elgg_get_logged_in_user_guid())) {
  19. $options["metadata_name_value_pairs"][] = array(
  20. "name" => "status",
  21. "value" => "published"
  22. );
  23. }
  24. if ($widget->show_featured == "yes") {
  25. $options["metadata_name_value_pairs"][] = array(
  26. "name" => "featured",
  27. "value" => true
  28. );
  29. }
  30. $content = elgg_list_entities_from_metadata($options);
  31. if (!empty($content)) {
  32. echo $content;
  33. echo "<div class='elgg-widget-more'>";
  34. $owner = $widget->getOwnerEntity();
  35. if (elgg_instanceof($owner, "group")) {
  36. echo elgg_view("output/url", array("href" => "blog/group/" . $owner->getGUID() . "/all", "text" => elgg_echo("blog:moreblogs")));
  37. } else {
  38. echo elgg_view("output/url", array("href" => "blog/owner/" . $owner->username, "text" => elgg_echo("blog:moreblogs")));
  39. }
  40. echo "</div>";
  41. } else {
  42. echo elgg_echo("blog:noblogs");
  43. }