schema__alternate_name_formatter.inc

File

tripal_chado/includes/TripalFields/schema__alternate_name/schema__alternate_name_formatter.inc
View source
  1. <?php
  2. class schema__alternate_name_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Synonyms';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = array('schema__alternate_name');
  7. /**
  8. *
  9. * @see TripalFieldFormatter::view()
  10. */
  11. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  12. $list_items = array();
  13. foreach ($items as $delta => $item) {
  14. $list_items[] = $item['value'];
  15. }
  16. $list = 'There are no synonyms.';
  17. if (count($list_items) > 0) {
  18. $list = array(
  19. 'title' => '',
  20. 'items' => $list_items,
  21. 'type' => 'ul',
  22. 'attributes' => array(),
  23. );
  24. $list = theme_item_list($list);
  25. }
  26. $element[0] = array(
  27. '#type' => 'markup',
  28. '#markup' => $list,
  29. );
  30. }
  31. }