uc_roles.theme.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the uc_roles module.
  5. */
  6. /**
  7. * Themes the roles dialog on the account edit 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_roles_user_new($variables) {
  16. $form = $variables['form'];
  17. // Render the expiration tables first.
  18. $output = drupal_render($form['expirations']);
  19. $output .= '<div class="expiration">';
  20. $output .= drupal_render($form['new_role']);
  21. $output .= drupal_render($form['new_role_add']);
  22. $output .= drupal_render($form['new_role_add_for']);
  23. $output .= drupal_render($form['new_role_add_qty']);
  24. $output .= drupal_render($form['new_role_add_granularity']);
  25. $output .= '</div>';
  26. return $output;
  27. }
  28. /**
  29. * Themes the role expiration table on the account edit page.
  30. *
  31. * @param $variables
  32. * An associative array containing:
  33. * - form: A render element representing the form.
  34. *
  35. * @ingroup themeable
  36. */
  37. function theme_uc_roles_user_expiration($variables) {
  38. $form = $variables['form'];
  39. $header = array(
  40. array('data' => t('Make permanent')),
  41. array('data' => t('Role')),
  42. array('data' => t('Expiration')),
  43. array('data' => t('Add/remove time')),
  44. );
  45. $rows = array();
  46. // The expiration table.
  47. foreach ((array)$form['table'] as $rid => $expiration) {
  48. // We only want numeric rid's
  49. if (!is_numeric($rid)) {
  50. continue;
  51. }
  52. // Make sure the renders actually touch the elements.
  53. $data = &$form['table'][$rid];
  54. $rows[] = array(
  55. array('data' => drupal_render($data['remove'])),
  56. array('data' => check_plain($data['name']['#value'])),
  57. array('data' => format_date($data['expiration']['#value'], 'short')),
  58. // Options to adjust the expiration.
  59. array('data' => '<a name="role-expiration-' . $rid . '">' .
  60. '<div class="expiration">' .
  61. drupal_render($data['polarity']) . drupal_render($data['qty']) . drupal_render($data['granularity']) .
  62. '</div></a>'),
  63. );
  64. }
  65. $output = theme('table', array(
  66. 'header' => $header,
  67. 'rows' => $rows,
  68. 'caption' => t('Below you can add or remove time to the expiration dates of the following roles.'),
  69. 'empty' => t('There are no pending expirations for roles this user.'),
  70. ));
  71. $output .= drupal_render_children($form);
  72. return $output;
  73. }