views_daterange.module

Tracking 6.x-1.x branch
  1. drupal
    1. 6 contributions/views_daterange/views_daterange.module

Functions & methods

NameDescription
theme_daterange_periods_formTheme the form fragment for the views argument configuration form into a table.
views_daterange_themeImplementation of hook_theme().
views_daterange_views_apiImplementation of hook_views_api().

File

View source
  1. <?php
  2. /**
  3. * Implementation of hook_views_api().
  4. */
  5. function views_daterange_views_api() {
  6. return array(
  7. 'api' => '2.0',
  8. );
  9. }
  10. /**
  11. * Implementation of hook_theme().
  12. */
  13. function views_daterange_theme() {
  14. return array(
  15. 'daterange_periods_form' => array(
  16. 'arguments' => array('form' => array()),
  17. ),
  18. );
  19. }
  20. /**
  21. * Theme the form fragment for the views argument configuration form into a table.
  22. *
  23. * @ingroup themeable
  24. */
  25. function theme_daterange_periods_form($form) {
  26. $output = '';
  27. // Retheme the date range form fragment into a table, which is much nicer
  28. // to read anyway.
  29. $header = array(t('Label'), t('Start day'), t('End day'));
  30. $rows = array();
  31. foreach (element_children($form) as $key) {
  32. $range = &$form[$key];
  33. // We don't want the labels on each element, since they're already the table header.
  34. $range['period']['#title'] = '';
  35. $range['start']['day']['#title'] = '';
  36. $range['start']['month']['#title'] = '';
  37. $range['end']['day']['#title'] = '';
  38. $range['end']['month']['#title'] = '';
  39. $rows[] = array(
  40. drupal_render($range['period']),
  41. drupal_render($range['start']['month']) . drupal_render($range['start']['day']),
  42. drupal_render($range['end']['month']) . drupal_render($range['end']['day']),
  43. );
  44. }
  45. $output .= theme('table', $header, $rows);
  46. $output .= drupal_render($form);
  47. return $output;
  48. }