content.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. $widget = elgg_extract("entity", $vars);
  3. $site_url = elgg_get_site_url();
  4. // how many files to display
  5. $num_display = sanitise_int($widget->num_display, false);
  6. if (empty($num_display)) {
  7. $num_display = 4;
  8. }
  9. $options = array(
  10. "type" => "object",
  11. "subtype" => "file",
  12. "container_guid" => $widget->getOwnerGUID(),
  13. "limit" => $num_display,
  14. "pagination" => false,
  15. "full_view" => false
  16. );
  17. // show only featured files
  18. if ($widget->featured_only == "yes") {
  19. $options["metadata_name_value_pairs"] = array(
  20. "name" => "show_in_widget",
  21. "value" => "0",
  22. "operand" => ">"
  23. );
  24. }
  25. // how to display the files
  26. if ($widget->gallery_list == 2) {
  27. if ($files = elgg_get_entities_from_metadata($options)) {
  28. $list = "<ul class='elgg-gallery'>";
  29. foreach ($files as $file) {
  30. $list .= "<li class='elgg-item'>";
  31. $list .= elgg_view("output/url", array("text" => elgg_view_entity_icon($file, "small"), "href" => $file->getURL(), "title" => $file->title));
  32. $list .= "</li>";
  33. }
  34. $list .= "</ul>";
  35. $owner = $widget->getOwnerEntity();
  36. if (elgg_instanceof($owner, "user")) {
  37. $more_link = $site_url . "file/owner/" . $owner->username;
  38. } else {
  39. $more_link = $site_url . "file/group/" . $owner->getGUID() . "/all";
  40. }
  41. $list .= "<span class='elgg-widget-more'>";
  42. $list .= elgg_view("output/url", array("text" => elgg_echo("file:more"), "href" => $more_link, "is_trusted" => true));
  43. $list .= "</span>";
  44. } else {
  45. $list = elgg_echo("file:none");
  46. }
  47. } elseif ($list = elgg_list_entities_from_metadata($options)) {
  48. $owner = $widget->getOwnerEntity();
  49. if (elgg_instanceof($owner, "user")) {
  50. $more_link = $site_url . "file/owner/" . $owner->username;
  51. } else {
  52. $more_link = $site_url . "file/group/" . $owner->getGUID() . "/all";
  53. }
  54. $list .= "<span class='elgg-widget-more'>";
  55. $list .= elgg_view("output/url", array("text" => elgg_echo("file:more"), "href" => $more_link, "is_trusted" => true));
  56. $list .= "</span>";
  57. } else {
  58. $list = elgg_echo("file:none");
  59. }
  60. echo $list;