views_handler_field_markup.inc

  1. 3.x handlers/views_handler_field_markup.inc
  2. 2.x handlers/views_handler_field_markup.inc

Definition of views_handler_field_markup.

File

handlers/views_handler_field_markup.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_markup.
  5. */
  6. /**
  7. * A handler to run a field through check_markup, using a companion
  8. * format field.
  9. *
  10. * - format: (REQUIRED) Either a string format id to use for this field or an
  11. * array('field' => {$field}) where $field is the field in this table
  12. * used to control the format such as the 'format' field in the node,
  13. * which goes with the 'body' field.
  14. *
  15. * @ingroup views_field_handlers
  16. */
  17. class views_handler_field_markup extends views_handler_field {
  18. /**
  19. * Constructor; calls to base object constructor.
  20. */
  21. function construct() {
  22. parent::construct();
  23. $this->format = $this->definition['format'];
  24. $this->additional_fields = array();
  25. if (is_array($this->format)) {
  26. $this->additional_fields['format'] = $this->format;
  27. }
  28. }
  29. function render($values) {
  30. $value = $this->get_value($values);
  31. if (is_array($this->format)) {
  32. $format = $this->get_value($values, 'format');
  33. }
  34. else {
  35. $format = $this->format;
  36. }
  37. if ($value) {
  38. $value = str_replace('<!--break-->', '', $value);
  39. return check_markup($value, $format, '');
  40. }
  41. }
  42. function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
  43. if ($inline) {
  44. return 'span';
  45. }
  46. if (isset($this->definition['element type'])) {
  47. return $this->definition['element type'];
  48. }
  49. return 'div';
  50. }
  51. }