taxrank__infraspecific_taxon_formatter.inc

File

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