data__sequence_formatter.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class data__sequence_formatter extends TripalFieldFormatter {
  3. // The default lable for this field.
  4. public static $label = 'Sequence';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('data__sequence');
  7. // The list of default settings for this formatter.
  8. public static $settings = array();
  9. /**
  10. *
  11. * @param unknown $element
  12. * @param unknown $entity_type
  13. * @param unknown $entity
  14. * @param unknown $langcode
  15. * @param unknown $items
  16. * @param unknown $display
  17. */
  18. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  19. $element[0] = array(
  20. // We create a render array to produce the desired markup,
  21. '#type' => 'markup',
  22. '#markup' => '',
  23. );
  24. $num_bases = 50;
  25. foreach ($items as $delta => $item) {
  26. $content .= '<pre class="residues-formatter">';
  27. $content .= wordwrap($item['value'], $num_bases, "<br>", TRUE);
  28. $content .= '</pre>';
  29. $element[$delta] = array(
  30. // We create a render array to produce the desired markup,
  31. '#type' => 'markup',
  32. '#markup' => $content,
  33. );
  34. }
  35. }
  36. }