You are here

function theme_uc_file_hook_user_file_downloads in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_file/uc_file.theme.inc \theme_uc_file_hook_user_file_downloads()
  2. 7.3 uc_file/uc_file.theme.inc \theme_uc_file_hook_user_file_downloads()

Themes the download table at the user account page.

File

uc_file/uc_file.module, line 435

Code

function theme_uc_file_hook_user_file_downloads($form) {
  $header = array(
    array(
      'data' => t('Remove'),
    ),
    array(
      'data' => t('Filename'),
    ),
    array(
      'data' => t('Expiration'),
    ),
    array(
      'data' => t('Downloads'),
    ),
    array(
      'data' => t('Addresses'),
    ),
  );
  foreach ($form['file_download'] as $key => $data) {
    if (!isset($data['addresses_in'])) {
      continue;
    }
    $file_download =& $form['file_download'][$key];
    $rows[] = array(
      'data' => array(
        array(
          'data' => drupal_render($file_download['remove']),
        ),
        array(
          'data' => drupal_render($file_download['filename']),
        ),
        array(
          'data' => drupal_render($file_download['expires']) . ' <br />' . '<div class="duration">' . drupal_render($file_download['time_polarity']) . drupal_render($file_download['time_quantity']) . drupal_render($file_download['time_granularity']) . '</div>',
        ),
        array(
          'data' => '<div class="download-table-index">' . drupal_render($file_download['downloads_in']) . '/' . drupal_render($file_download['download_limit']) . '</div>',
        ),
        array(
          'data' => '<div class="download-table-index">' . drupal_render($file_download['addresses_in']) . '/' . drupal_render($file_download['address_limit']) . '</div>',
        ),
      ),
      'class' => 'download-table-row',
    );
  }
  if (!count($rows)) {
    $rows[] = array(
      array(
        'data' => t('No files can be downloaded by this user.'),
        'colspan' => 5,
      ),
    );
  }
  $output = theme('table', $header, $rows, array(
    'id' => 'download-table',
  ));
  $output .= drupal_render($form);
  return $output;
}