views_handler_field_markup.inc

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

File

handlers/views_handler_field_markup.inc
View source
  1. <?php
  2. /**
  3. * A handler to run a field through check_markup, using a companion
  4. * format field.
  5. *
  6. * - format: (REQUIRED) The field in this table used to control the format
  7. * such as the 'format' field in the node, which goes with the
  8. * 'body' field.
  9. *
  10. * @ingroup views_field_handlers
  11. */
  12. class views_handler_field_markup extends views_handler_field {
  13. /**
  14. * Constructor; calls to base object constructor.
  15. */
  16. function construct() {
  17. parent::construct();
  18. $this->format = $this->definition['format'];
  19. $this->additional_fields = array();
  20. if (!is_numeric($this->format)) {
  21. $this->additional_fields['format'] = array('field' => $this->format);
  22. }
  23. }
  24. function render($values) {
  25. $value = $values->{$this->field_alias};
  26. $format = is_numeric($this->format) ? $this->format : $values->{$this->aliases['format']};
  27. if ($value) {
  28. $value = str_replace('<!--break-->', '', $value);
  29. return check_markup($value, $format, FALSE);
  30. }
  31. }
  32. function element_type() {
  33. if (isset($this->definition['element type'])) {
  34. return $this->definition['element type'];
  35. }
  36. return 'div';
  37. }
  38. }