so__cds_formatter.inc 845 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. class so__cds_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Coding Sequence';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = ['so__cds'];
  7. /**
  8. * @see TripalFieldFormatter::view()
  9. */
  10. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  11. $content = 'There is no coding 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] = [
  19. // We create a render array to produce the desired markup,
  20. '#type' => 'markup',
  21. '#markup' => $content,
  22. ];
  23. }
  24. }