You are here

function theme_file_formatter_responsive_table in Responsive Tables Filter 7

Returns HTML for a file attachments table.

Parameters

array $variables: An associative array containing:

  • items: An array of file attachments.

File

./responsive_tables_filter.module, line 247
Make tables responsive, when filter is enabled for the field.

Code

function theme_file_formatter_responsive_table(array $variables) {

  // If we aren't loading assets on every page, do so here.
  if (!variable_get(RESPONSIVE_TABLES_FILTER_EVERY_PAGE, FALSE)) {
    _responsive_tables_filter_add_js_css();
  }
  $header = array(
    t('Attachment'),
    t('Size'),
  );
  $rows = array();
  foreach ($variables['items'] as $delta => $item) {
    $rows[] = array(
      theme('file_link', array(
        'file' => (object) $item,
      )),
      format_size($item['filesize']),
    );
  }

  // The following attributes is what is unique about this render.
  $attributes = array(
    'class' => array(
      'tablesaw',
      'tablesaw-stack',
    ),
    'data-tablesaw-mode' => 'stack',
  );
  return empty($rows) ? '' : theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => $attributes,
  ));
}