module.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Elgg module element
  4. *
  5. * @uses $vars['type'] The type of module (main, info, popup, aside, etc.)
  6. * @uses $vars['title'] Optional title text (do not pass header with this option)
  7. * @uses $vars['header'] Optional HTML content of the header
  8. * @uses $vars['body'] HTML content of the body
  9. * @uses $vars['footer'] Optional HTML content of the footer
  10. * @uses $vars['class'] Optional additional class for module
  11. * @uses $vars['id'] Optional id for module
  12. * @uses $vars['show_inner'] Optional flag to leave out inner div (default: false)
  13. */
  14. $type = elgg_extract('type', $vars, false);
  15. $title = elgg_extract('title', $vars, '');
  16. $body = elgg_extract('body', $vars, '');
  17. $footer = elgg_extract('footer', $vars, '');
  18. $show_inner = elgg_extract('show_inner', $vars, false);
  19. $attrs = [
  20. 'id' => elgg_extract('id', $vars),
  21. 'class' => (array) elgg_extract('class', $vars, []),
  22. ];
  23. $attrs['class'][] = 'elgg-module';
  24. if ($type) {
  25. $attrs['class'][] = "elgg-module-$type";
  26. }
  27. $header = elgg_extract('header', $vars);
  28. if ($title) {
  29. $header = elgg_format_element('h3', [], $title);
  30. }
  31. if ($header !== null) {
  32. $header = elgg_format_element('div', ['class' => 'elgg-head'], $header);
  33. }
  34. $body = elgg_format_element('div', ['class' => 'elgg-body'], $body);
  35. if ($footer) {
  36. $footer = elgg_format_element('div', ['class' => 'elgg-foot'], $footer);
  37. }
  38. $contents = $header . $body . $footer;
  39. if ($show_inner) {
  40. $contents = elgg_format_element('div', ['class' => 'elgg-inner'], $contents);
  41. }
  42. echo elgg_format_element('div', $attrs, $contents);