You are here

function theme_tablefield_view in TableField 7.2

Same name and namespace in other branches
  1. 6 tablefield.module \theme_tablefield_view()
  2. 7.3 tablefield.module \theme_tablefield_view()
  3. 7 tablefield.module \theme_tablefield_view()

Theme function for table view.

1 theme call to theme_tablefield_view()
tablefield_field_formatter_view in ./tablefield.module
Implements hook_field_formatter_view().

File

./tablefield.module, line 1380
Provides a set of fields that can be used to store tabular data with a node.

Code

function theme_tablefield_view($variables) {
  $id = $variables['entity_type'] . '-' . $variables['entity_id'] . '-' . $variables['field_name'] . '-' . $variables['delta'];
  $attributes = $variables['attributes'] + array(
    'id' => drupal_html_id('tablefield-' . $id),
    'class' => array(
      'tablefield',
      'tablefield-' . $id,
    ),
  );

  // Apply scope property to headers for accessibility.
  if (is_array($variables['header'])) {
    foreach ($variables['header'] as &$header) {
      $header['scope'] = 'col';
    }
  }

  // If the user has access to the csv export option, display it now.
  $export = '';
  if ($variables['export'] && user_access('export tablefield')) {
    $url = sprintf('tablefield/export/%s/%s/%s/%s/%s', $variables['entity_type'], $variables['entity_id'], $variables['field_name'], $variables['langcode'], $variables['delta']);
    $export = '<div id="' . drupal_html_id('tablefield-export-link-' . $id) . '" class="tablefield-export-link">' . l(t('Export Table Data'), $url) . '</div>';
  }

  // Prepare variables for theme_table().
  $theme_variables = array(
    'header' => $variables['header'],
    'rows' => $variables['rows'],
    'attributes' => $attributes,
  );
  if (isset($variables['caption'])) {
    $theme_variables['caption'] = $variables['caption'];
  }
  if (isset($variables['sticky'])) {
    $theme_variables['sticky'] = $variables['sticky'];
  }
  return '<div id="' . drupal_html_id('tablefield-wrapper-' . $id) . '" class="tablefield-wrapper">' . theme('table__tablefield', $theme_variables) . $export . '</div>';
}