chado_linker__prop_formatter.inc

File

tripal_chado/includes/TripalFields/chado_linker__prop/chado_linker__prop_formatter.inc
View source
  1. <?php
  2. class chado_linker__prop_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Chado Property';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('chado_linker__prop');
  7. /**
  8. *
  9. * @see TripalFieldFormatter::settingsForm()
  10. */
  11. public function settingsForm($view_mode, $form, &$form_state) {
  12. }
  13. /**
  14. *
  15. * @see TripalFieldFormatter::view()
  16. */
  17. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  18. $field_name = $this->field['field_name'];
  19. $chado_table = $this->instance['settings']['chado_table'];
  20. $list = array();
  21. foreach ($items as $index => $item) {
  22. $list[$index] = $item['value'];
  23. }
  24. // Also need to make sure to not return markup if the field is empty.
  25. if (empty($list)) {
  26. return;
  27. }
  28. // If more than one value has been found display all values in an unordered
  29. // list.
  30. if (count($list) > 1) {
  31. $content = theme_item_list(array(
  32. 'items' => $list,
  33. 'title' => '',
  34. 'attributes' => array('class' => array($entity->bundle . '-properties-list', 'properties-field-list')),
  35. 'type' => 'ul'
  36. ));
  37. }
  38. else {
  39. $content = $list[0];
  40. }
  41. $element[0] = array(
  42. // We create a render array to produce the desired markup,
  43. '#type' => 'markup',
  44. '#markup' => $content,
  45. );
  46. }
  47. }