uc_file.theme.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the uc_file module.
  5. */
  6. /**
  7. * Themes the download table at the user account page.
  8. *
  9. * @param $variables
  10. * An associative array containing:
  11. * - form: A render element representing the form.
  12. *
  13. * @ingroup themeable
  14. */
  15. function theme_uc_file_hook_user_file_downloads($variables) {
  16. $form = $variables['form'];
  17. $header = array(
  18. array('data' => t('Remove' )),
  19. array('data' => t('Filename' )),
  20. array('data' => t('Expiration')),
  21. array('data' => t('Downloads' )),
  22. array('data' => t('Addresses' )),
  23. );
  24. $rows = array();
  25. $output = '';
  26. foreach (element_children($form['file_download']) as $key) {
  27. if (!isset($form['file_download'][$key]['addresses_in'])) {
  28. continue;
  29. }
  30. $file_download = &$form['file_download'][$key];
  31. $rows[] = array(
  32. 'data' => array(
  33. array('data' => drupal_render($file_download['remove'])),
  34. array('data' => drupal_render($file_download['filename'])),
  35. array(
  36. 'data' =>
  37. drupal_render($file_download['expires']) . ' <br />' .
  38. '<div class="duration">' .
  39. drupal_render($file_download['time_polarity']) .
  40. drupal_render($file_download['time_quantity']) .
  41. drupal_render($file_download['time_granularity']) .
  42. '</div>',
  43. ),
  44. array(
  45. 'data' =>
  46. '<div class="download-table-index">' .
  47. drupal_render($file_download['downloads_in']) . '/' . drupal_render($file_download['download_limit']) .
  48. '</div>',
  49. ),
  50. array(
  51. 'data' =>
  52. '<div class="download-table-index">' .
  53. drupal_render($file_download['addresses_in']) . '/' . drupal_render($file_download['address_limit']) .
  54. '</div>',
  55. ),
  56. ),
  57. 'class' => array('download-table-row'),
  58. );
  59. }
  60. $output .= theme('table', array(
  61. 'header' => $header,
  62. 'rows' => $rows,
  63. 'attributes' => array('id' => 'download-table'),
  64. 'empty' => t('No files can be downloaded by this user.'),
  65. ));
  66. $output .= drupal_render_children($form);
  67. return $output;
  68. }