image_block.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Elgg image block pattern
  4. *
  5. * Common pattern where there is an image, icon, media object to the left
  6. * and a descriptive block of text to the right.
  7. *
  8. * ---------------------------------------------------------------
  9. * | | | alt |
  10. * | image | body | image |
  11. * | block | block | block |
  12. * | | | (optional)|
  13. * ---------------------------------------------------------------
  14. *
  15. * @uses $vars['body'] HTML content of the body block
  16. * @uses $vars['image'] HTML content of the image block
  17. * @uses $vars['image_alt'] HTML content of the alternate image block
  18. * @uses $vars['class'] Optional additional class for media element
  19. * @uses $vars['id'] Optional id for the media element
  20. */
  21. $body = elgg_extract('body', $vars, '');
  22. $image = elgg_extract('image', $vars, '');
  23. $alt_image = elgg_extract('image_alt', $vars, '');
  24. $class = 'elgg-image-block';
  25. $additional_class = elgg_extract('class', $vars, '');
  26. if ($additional_class) {
  27. $class = "$class $additional_class";
  28. }
  29. $id = '';
  30. if (isset($vars['id'])) {
  31. $id = "id=\"{$vars['id']}\"";
  32. }
  33. $body = "<div class=\"elgg-body\">$body</div>";
  34. if ($image) {
  35. $image = "<div class=\"elgg-image\">$image</div>";
  36. }
  37. if ($alt_image) {
  38. $alt_image = "<div class=\"elgg-image-alt\">$alt_image</div>";
  39. }
  40. echo <<<HTML
  41. <div class="$class clearfix" $id>
  42. $image$alt_image$body
  43. </div>
  44. HTML;