function theme_tripal_bulk_loader_constant_set

2.x tripal_bulk_loader.constants.inc theme_tripal_bulk_loader_constant_set($variables)
3.x tripal_bulk_loader.constants.inc theme_tripal_bulk_loader_constant_set($variables)

Display a constant set.

Parameters

$varaibles: An array of variables that are available: -nid: the NID of the bulk loading job node the constants are for. -constants: An array of constants as loaded by tripal_bulk_loader_load(). -template: An object containing the template record with unserialized template_array. -options: An optional array of options.

Return value

Rendered HTML.

1 string reference to 'theme_tripal_bulk_loader_constant_set'
tripal_bulk_loader_theme in tripal_bulk_loader/tripal_bulk_loader.module
Implements hook_theme().
1 theme call to theme_tripal_bulk_loader_constant_set()
tripal_bulk_loader_set_constants_form in tripal_bulk_loader/includes/tripal_bulk_loader.constants.inc
Set constants (exposed fields in template)

File

tripal_bulk_loader/includes/tripal_bulk_loader.constants.inc, line 617
Manages the constants form added to the tripal bulk loader node form

Code

function theme_tripal_bulk_loader_constant_set($variables) {

  // Check that there are constants to render.
  if (empty($variables['constants'])) {
    return '';
  }

  // Set Defaults.
  $variables['options'] = (isset($variables['options'])) ? $variables['options'] : array();
  $variables['options']['display_operations'] = (isset($variables['options']['display_operations'])) ?
    $variables['options']['display_operations'] : TRUE;

  // Get all the rows.
  $rows = array();
  foreach ($variables['constants'] as $group_id => $set) {
    $row = array();
    $row['group_id'] = $group_id;
    foreach ($set as $record) {
      foreach ($record as $field) {
        $index = $field['record_id'] . '-' . $field['field_id'];
        $row[$index] = $field['value'];
      }
    }
    if ($variables['options']['display_operations']) {
      $row['operations'] = filter_xss(l(t('Edit'), 'node/' . $variables['nid'] . '/constants/' . $group_id . '/edit') . '  |  ' .
        l(t('Delete'), 'node/' . $variables['nid'] . '/constants/' . $group_id . '/delete'));
    }

    $rows[] = $row;
  }

  // Get the header using the last constant set.
  $header = array();
  $header[0]['group_id'] = array(
    'data' => t('Group'),
    'header' => TRUE,
    'rowspan' => 2
  );
  foreach ($set as $record) {
    foreach ($record as $field) {

      $index = $field['record_id'] . '-' . $field['field_id'];

      $header[0][$field['record_id']] = array(
        'data' => $variables['template']->template_array[$field['record_id']]['record_id'],
        'header' => TRUE,
        'colspan' => sizeof($record)
      );

      $header[1][$index] = array(
        'data' => $variables['template']->template_array[$field['record_id']]['fields'][$field['field_id']]['title'],
        'header' => TRUE
      );
    }
  }

  if ($variables['options']['display_operations']) {
    $header[0]['operations'] = array(
      'data' => t('Operations'),
      'header' => TRUE,
      'rowspan' => 2
    );
  }

  return theme(
  'table', 
  array(
    'header' => array(),
    'rows' => array_merge($header, $rows)
  )
  );
}