function theme_chado_add_node_form_relationships_table

2.x tripal_core.chado_nodes.relationships.api.inc theme_chado_add_node_form_relationships_table($variables)

Function to theme the add/remove relationships form into a table

Related topics

1 string reference to 'theme_chado_add_node_form_relationships_table'
tripal_core_theme in tripal_core/tripal_core.module
Implements hook_theme(). Registers template files/functions used by this module.

File

tripal_core/api/tripal_core.chado_nodes.relationships.api.inc, line 863
API to manage the chado _relationship table for various Tripal Node Types

Code

function theme_chado_add_node_form_relationships_table($variables) {
  $element = $variables['element'];

  $details = unserialize($element['details']['#value']);

  $header = array(
    'subject_name' => t('Subject ' . $details['base_name_field']),
    'type_name' => t('Type'),
    'object_name' => t('Object ' . $details['base_name_field']),
    'rel_action' => t('Action')
  );

  $rows = array();
  foreach (element_children($element) as $type_id) {
    if ($type_id == 'new') {
      $row = array();

      $row['data'] = array();
      foreach ($header as $fieldname => $title) {
        if ($fieldname == 'subject_name') {
          $row['data'][] = drupal_render($element[$type_id][$fieldname]) . drupal_render($element[$type_id]['subject_is_current']);
        }
        elseif ($fieldname == 'object_name') {
          $row['data'][] = drupal_render($element[$type_id][$fieldname]) . drupal_render($element[$type_id]['object_is_current']);
        }
        else {
          $row['data'][] = drupal_render($element[$type_id][$fieldname]);
        }
      }
      $rows[] = $row;
    }
    else {
      foreach (element_children($element[$type_id]) as $rank) {
        $row = array();

        $row['data'] = array();
        $row['class'] = $element[$type_id][$rank]['#attributes']['class'];
        foreach ($header as $fieldname => $title) {
          $row['data'][] = drupal_render($element[$type_id][$rank][$fieldname]);
        }
        $rows[] = $row;
      }
    }
  }

  return render($element['save_warning']) . theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'sticky' => FALSE
  ));
}