class sio__references_formatter

Hierarchy

Expanded class hierarchy of sio__references_formatter

2 string references to 'sio__references_formatter'
sio__references.inc in tripal_chado/includes/TripalFields/sio__references/sio__references.inc
tripal_chado_bundle_instances_info_linker in tripal_chado/includes/tripal_chado.fields.inc

File

tripal_chado/includes/TripalFields/sio__references/sio__references_formatter.inc, line 3

View source
class sio__references_formatter extends ChadoFieldFormatter {
  // The default lable for this field.
  public static $default_label = 'References';

  // The list of field types for which this formatter is appropriate.
  public static $field_types = array('sio__references');

  /**
   *
   * @see TripalFieldFormatter::view()
   */
  public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
    $field_name = $this->field['field_name'];
    $chado_table = $this->instance['settings']['chado_table'];

    // First, organize the values by their types.
    $ordered_items = array();
    foreach ($items as $delta => $item) {
      $type = isset($item['value']['rdfs:type']) ? $item['value']['rdfs:type'] : '';
      $entity = isset($item['value']['entity']) ? $item['value']['entity'] : '';
      $name = isset($item['value']['schema:name']) ? $item['value']['schema:name'] : '';
      $identifier = isset($item['value']['data:0842']) ? $item['value']['data:0842'] : '';
      if ($entity) {
        list($entity_type, $entity_id) = explode(':', $entity);
        $name = l(strip_tags($name), 'bio_data/' . $entity_id);
      }
      $ordered_items[ucfirst($type)][] = $name;
    }

    // Reorder the list so it's compatible with theming a list.
    $list_items = array();
    $headers = array();
    $rows = array();
    ksort($ordered_items);
    foreach ($ordered_items as $type => $children) {
      $rows[] = array(
        array(
          'data' => ucfirst($type) . '(s)',
          'header' => TRUE,
          'width' => '20%',
        ),
        theme_item_list(array(
          'items' => $children,
          'title' => '',
          'type' => 'ul',
          'attributes' => array(),
        )),
      );
    }

    $table = array(
      'header' => array(),
      'rows' => $rows,
      'attributes' => array(
        'id' => 'sio__references-table',
        'class' => 'tripal-data-table'
      ),
      'sticky' => FALSE,
      'caption' => "",
      'colgroups' => array(),
      'empty' => 'There are no records in this site to which this publiation refers.',
    );
    $content = theme_table($table);
    $element[0] = array(
      '#type' => 'markup',
      '#markup' => $content,
    );
  }
}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
sio__references_formatter::$default_label public static property The default lable for this field. Overrides TripalFieldFormatter::$default_label
sio__references_formatter::$field_types public static property The list of field types for which this formatter is appropriate. Overrides TripalFieldFormatter::$field_types
sio__references_formatter::view public function Overrides TripalFieldFormatter::view
TripalFieldFormatter::$default_settings public static property The list of default settings for this formatter.
TripalFieldFormatter::ajaxifyPager protected function Updates a pager generated by theme('pager') for use with AJAX.
TripalFieldFormatter::getPagerElementID protected function When constructing a pager for use by a field, all pagers must have a unique ID
TripalFieldFormatter::info public static function Provides information about the formatter for this field.
TripalFieldFormatter::settingsForm public function Provides the field's setting form.
TripalFieldFormatter::settingsSummary public function Provides a summary of the formatter settings.
TripalFieldFormatter::__construct public function Instantiates a new TripalFieldFormatter object.