folder.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. $folder = elgg_extract("entity", $vars);
  3. $full_view = elgg_extract("full_view", $vars, false);
  4. $time_preference = "date";
  5. if ($user_time_preference = elgg_get_plugin_user_setting('file_tools_time_display', null, "file_tools")) {
  6. $time_preference = $user_time_preference;
  7. } elseif ($site_time_preference = elgg_get_plugin_setting("file_tools_default_time_display", "file_tools")) {
  8. $time_preference = $site_time_preference;
  9. }
  10. if ($time_preference == 'date') {
  11. $friendlytime = date(elgg_echo("friendlytime:date_format"), $folder->time_created);
  12. } else {
  13. $friendlytime = elgg_view_friendly_time($folder->time_created);
  14. }
  15. $title = $folder->title;
  16. if (empty($title)) {
  17. $title = elgg_echo("untitled");
  18. }
  19. $params = array(
  20. 'text' => elgg_get_excerpt($title, 100),
  21. 'href' => $folder->getURL(),
  22. 'is_trusted' => true,
  23. );
  24. $title = elgg_view('output/url', $params);
  25. $entity_menu = "";
  26. if (!elgg_in_context("widgets")) {
  27. $entity_menu = elgg_view_menu("entity", array(
  28. "entity" => $folder,
  29. "handler" => "file_tools/folder",
  30. "sort_by" => "priority",
  31. "class" => "elgg-menu-hz"
  32. ));
  33. }
  34. if ($full_view) {
  35. // full view
  36. $icon = elgg_view_entity_icon($folder, "small");
  37. $owner_link = elgg_view("output/url", array("text" => $folder->getOwnerEntity()->name, "href" => $folder->getOwnerEntity()->getURL()));
  38. $owner_text = elgg_echo("byline", array($owner_link));
  39. $subtitle = "$owner_text $friendlytime";
  40. $params = array(
  41. "entity" => $folder,
  42. "title" => $title,
  43. "metadata" => $entity_menu,
  44. "tags" => elgg_view("output/tags", array("value" => $folder->tags)),
  45. "subtitle" => $subtitle
  46. );
  47. $params = $params + $vars;
  48. $summary = elgg_view("object/elements/summary", $params);
  49. echo elgg_view("object/elements/full", array(
  50. "entity" => $folder,
  51. "title" => false,
  52. "icon" => $icon,
  53. "summary" => $summary,
  54. "body" => elgg_view("output/longtext", array("value" => $folder->description))
  55. ));
  56. } else {
  57. // summary view
  58. $icon = elgg_view_entity_icon($folder, "tiny");
  59. $icon_alt = "";
  60. if (!elgg_in_context("widgets")) {
  61. $icon_alt = elgg_view("input/checkbox", array("name" => "folder_guids[]", "value" => $folder->getGUID(), "default" => false));
  62. }
  63. $params = array(
  64. "entity" => $folder,
  65. "title" => $title,
  66. "metadata" => $entity_menu
  67. );
  68. $params = $params + $vars;
  69. $list_body = elgg_view("object/elements/summary", $params);
  70. echo elgg_view_image_block($icon, $list_body, array("class" => "file-tools-folder", "image_alt" => $icon_alt));
  71. }