obi__organism_formatter.inc

File

tripal_chado/includes/TripalFields/obi__organism/obi__organism_formatter.inc
View source
  1. <?php
  2. class obi__organism_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Organism';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('obi__organism');
  7. /**
  8. * @see TripalFieldFormatter::view()
  9. */
  10. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  11. if (count($items) > 0) {
  12. $content = $items[0]['value']['rdfs:label'];
  13. if (array_key_exists('entity', $items[0]['value'])) {
  14. list($entity_type, $entity_id) = explode(':', $items[0]['value']['entity']);
  15. $content = l(strip_tags($items[0]['value']['rdfs:label']), 'bio_data/' . $entity_id);
  16. }
  17. // The cardinality of this field is 1 so we don't have to
  18. // iterate through the items array, as there will never be more than 1.
  19. $element[0] = array(
  20. '#type' => 'markup',
  21. '#markup' => $content,
  22. );
  23. }
  24. }
  25. }