site_announcement.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Display a single site announcement
  4. *
  5. * @uses $vars['entity'] the entity to show
  6. */
  7. $entity = elgg_extract("entity", $vars);
  8. $full_view = elgg_extract("full_view", $vars, false);
  9. if (empty($entity) || !elgg_instanceof($entity, "object", SITE_ANNOUNCEMENT_SUBTYPE)) {
  10. return;
  11. }
  12. $entity_menu = "";
  13. if (!elgg_in_context("widgets")) {
  14. $entity_menu = elgg_view_menu("entity", array(
  15. "entity" => $entity,
  16. "handler" => "announcements",
  17. "class" => "elgg-menu-hz",
  18. "sort_by" => "priority"
  19. ));
  20. }
  21. $entity_icon = elgg_view_entity_icon($entity, "topbar");
  22. if ($full_view) {
  23. // show full view (in header)
  24. $content = elgg_view("output/longtext", array("value" => $entity->description, "class" => "mtn"));
  25. $params = array(
  26. "entity" => $entity,
  27. "metadata" => $entity_menu,
  28. "content" => $content,
  29. );
  30. $params = $params + $vars;
  31. $full_body = elgg_view("object/elements/summary", $params);
  32. $class = "elgg-state-notice";
  33. $announcement_type = $entity->announcement_type;
  34. if (!empty($announcement_type)) {
  35. $class .= " site-announcement-" . $announcement_type;
  36. }
  37. echo elgg_view_image_block($entity_icon, $full_body, array("class" => $class));
  38. } else {
  39. // listing
  40. $subtitle = "<strong>" . elgg_echo("site_announcements:edit:startdate") . "</strong>: " . date(elgg_echo("friendlytime:date_format"), $entity->startdate);
  41. $subtitle .= " <strong>" . elgg_echo("site_announcements:edit:enddate") . "</strong>: " . date(elgg_echo("friendlytime:date_format"), $entity->enddate);
  42. $params = array(
  43. "entity" => $entity,
  44. "metadata" => $entity_menu,
  45. "subtitle" => $subtitle,
  46. "content" => $entity->description,
  47. );
  48. $params = $params + $vars;
  49. $list_body = elgg_view("object/elements/summary", $params);
  50. echo elgg_view_image_block($entity_icon, $list_body);
  51. }