data__sequence_coordinates_formatter.inc

File

tripal_chado/includes/TripalFields/data__sequence_coordinates/data__sequence_coordinates_formatter.inc
View source
  1. <?php
  2. class data__sequence_coordinates_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Sequence Coordinates';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('data__sequence_coordinates');
  7. /**
  8. *
  9. * @see TripalFieldFormatter::view()
  10. */
  11. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  12. $reference_term = 'data:3002';
  13. $fmin_term = chado_get_semweb_term('featureloc', 'fmin');
  14. $fmax_term = chado_get_semweb_term('featureloc', 'fmax');
  15. $strand_term = chado_get_semweb_term('featureloc', 'strand');
  16. $phase_term = chado_get_semweb_term('featureloc', 'phase');
  17. $content = '';
  18. foreach ($items as $item) {
  19. if (!empty($item['value'])) {
  20. $srcfeature = $item['value'][$reference_term];
  21. $fmin = $item['value'][$fmin_term];
  22. $fmax = $item['value'][$fmax_term];
  23. $phase = $item['value'][$phase_term];
  24. $strand = $item['value'][$strand_term];
  25. $content .= $srcfeature . ':' . $fmin . '..' . $fmax . $strand;
  26. }
  27. }
  28. if (!$content) {
  29. $content = 'This feature is not located on any sequence.';
  30. }
  31. $element[0] = array(
  32. '#type' => 'markup',
  33. '#markup' => $content,
  34. );
  35. }
  36. }