sbo__database_cross_reference_formatter.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class sbo__database_cross_reference_formatter extends TripalFieldFormatter {
  3. // The default lable for this field.
  4. public static $label = 'Database cross reference';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('sbo__database_cross_reference');
  7. // The list of default settings for this formatter.
  8. public static $settings = array();
  9. /**
  10. *
  11. * @see TripalFieldFormatter::settingsForm()
  12. */
  13. public function settingsForm($view_mode, $form, &$form_state) {
  14. }
  15. /**
  16. *
  17. * @see TripalFieldFormatter::view()
  18. */
  19. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  20. $chado_table = $this->field['settings']['chado_table'];
  21. $content = '';
  22. foreach ($items as $delta => $item) {
  23. if (!$item['value']) {
  24. continue;
  25. }
  26. $content = $item['value']['vocabulary'] . ':' . $item['value']['accession'];
  27. if ($item['value']['URL']) {
  28. $content = l($content, $item['value']['URL'], array('attributes' => array('target' => '_blank')));
  29. }
  30. $element[$delta] = array(
  31. '#type' => 'markup',
  32. '#markup' => $content,
  33. );
  34. }
  35. if (count($element) == 0) {
  36. $element[0] = array(
  37. '#type' => 'markup',
  38. '#markup' => '',
  39. );
  40. }
  41. }
  42. }