data__sequence_formatter.inc

File

tripal_chado/includes/TripalFields/data__sequence/data__sequence_formatter.inc
View source
  1. <?php
  2. class data__sequence_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Sequence';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('data__sequence');
  7. /**
  8. * @see TripalFieldFormatter::view()
  9. */
  10. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  11. $content = 'There is no sequence.';
  12. if (count($items) > 0 and $items[0]['value']) {
  13. $num_bases = 50;
  14. $content = '<pre class="residues-formatter">';
  15. $content .= wordwrap($items[0]['value'], $num_bases, "<br>", TRUE);
  16. $content .= '</pre>';
  17. }
  18. $element[0] = array(
  19. // We create a render array to produce the desired markup,
  20. '#type' => 'markup',
  21. '#markup' => $content,
  22. );
  23. }
  24. }