function theme_tablefield_view in TableField 7.3
Same name and namespace in other branches
- 6 tablefield.module \theme_tablefield_view()
- 7 tablefield.module \theme_tablefield_view()
- 7.2 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 2051 - 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'];
$sortable = $variables['sortable'] ? 'tablesorter' : NULL;
$cols_class = isset($variables['header']) ? 'tablefield-columns-' . count($variables['header']) : NULL;
$attributes = array(
'id' => 'tablefield-' . $id,
'class' => array(
'tablefield',
$sortable,
$cols_class,
),
);
// 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_tablefield().
$theme_variables = array(
'header' => $variables['header'],
'rows' => $variables['rows'],
'attributes' => $attributes,
'colgroups' => array(),
'empty' => NULL,
);
if (isset($variables['caption'])) {
$theme_variables['caption'] = $variables['caption'];
}
if (isset($variables['header_orientation'])) {
$theme_variables['header_orientation'] = $variables['header_orientation'];
}
if (isset($variables['sticky'])) {
$theme_variables['sticky'] = $variables['sticky'];
}
if (isset($variables['striping'])) {
$theme_variables['striping'] = $variables['striping'];
}
if (isset($variables['sortable'])) {
$theme_variables['sortable'] = $variables['sortable'];
}
if (!trim($variables['table_custom_class_attributes']) == FALSE) {
$theme_variables['attributes']['class'][] = $variables['table_custom_class_attributes'];
}
return '<div id="' . drupal_html_id('tablefield-wrapper-' . $id) . '" class="tablefield-wrapper">' . theme('tablefield', $theme_variables) . $export . '</div>';
}