date_views.views.inc

  1. cis7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  2. cle7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  3. ecd7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  4. elmsmedia7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  5. harmony7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  6. icor7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  7. meedjum_blog7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
  8. mooc7 sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc

Defines date-related Views data and plugins:

Date argument: A generic date argument that has an option to select one or more Views date fields to filter on, automatically adds them to the view, and then filters the view by the value of the selected field(s). The flexible argument will accept and evaluate most ISO date and period formats, like 2009-05-01, 2008-W25, P1W.

Date filter: A generic date filter that has an option to select a Views date field to filter on, with a choice of a widget to use for the filter form and an option to set the default value to a set date or something like 'now +90 days' . If the operator is set to 'between' or 'not between' you can set a default value for both the start and end dates.

Current date argument default Adds a default option to set the argument to the current date when the argument is empty.

Date navigation attachment Navigation that can be attached to any display to create back/next links by date, requires the date argument and uses the current date argument default to set a starting point for the view.

Functions

Namesort descending Description
date_views_querystring
date_views_set_timezone Central function for setting up the right timezone values in the SQL date handler.
date_views_views_data Implements hook_views_data()
date_views_views_data_alter Implements hook_views_data_alter().
date_views_views_plugins Implements hook_views_plugins

File

sites/all/modules/ulmus/date/date_views/includes/date_views.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Defines date-related Views data and plugins:
  5. *
  6. * Date argument:
  7. * A generic date argument that has an option to select one or more
  8. * Views date fields to filter on, automatically adds them to the view,
  9. * and then filters the view by the value of the selected field(s).
  10. * The flexible argument will accept and evaluate most ISO date
  11. * and period formats, like 2009-05-01, 2008-W25, P1W.
  12. *
  13. * Date filter:
  14. * A generic date filter that has an option to select a
  15. * Views date field to filter on, with a choice of a widget to use
  16. * for the filter form and an option to set the default value to
  17. * a set date or something like 'now +90 days' . If the operator is
  18. * set to 'between' or 'not between' you can set a default value for
  19. * both the start and end dates.
  20. *
  21. * Current date argument default
  22. * Adds a default option to set the argument to the current date
  23. * when the argument is empty.
  24. *
  25. * Date navigation attachment
  26. * Navigation that can be attached to any display to create back/next
  27. * links by date, requires the date argument and uses the current
  28. * date argument default to set a starting point for the view.
  29. */
  30. /**
  31. * Implements hook_views_plugins
  32. */
  33. function date_views_views_plugins() {
  34. $path = drupal_get_path('module', 'date_views');
  35. $views_path = drupal_get_path('module', 'views');
  36. module_load_include('inc', 'date_views', 'theme/theme');
  37. return array(
  38. 'module' => 'date_views', // This just tells our themes are elsewhere.
  39. 'display' => array(
  40. // Display plugin for date navigation.
  41. 'date_nav' => array(
  42. 'title' => t('Date browser'),
  43. 'help' => t('Date back/next navigation to attach to other displays. Requires the Date argument.'),
  44. 'handler' => 'date_plugin_display_attachment',
  45. 'parent' => 'attachment',
  46. 'path' => "$path/includes",
  47. 'theme' => 'views_view',
  48. 'use ajax' => TRUE,
  49. 'admin' => t('Date browser'),
  50. 'help topic' => 'date-browser',
  51. ),
  52. ),
  53. 'pager' => array(
  54. 'date_views_pager' => array(
  55. 'title' => t('Page by date'),
  56. 'help' => t('Page using the value of a date field.'),
  57. 'handler' => 'date_views_plugin_pager',
  58. 'path' => "$path/includes",
  59. 'help topic' => 'date-views-pager',
  60. 'uses options' => TRUE,
  61. ),
  62. ),
  63. 'style' => array(
  64. 'date_nav' => array(
  65. 'title' => t('Date browser style'),
  66. 'help' => t('Creates back/next navigation.'),
  67. 'handler' => 'date_navigation_plugin_style',
  68. 'path' => "$path/includes",
  69. 'theme' => 'date_navigation',
  70. 'theme file' => 'theme.inc',
  71. 'theme path' => "$path/theme",
  72. 'uses row plugin' => FALSE,
  73. 'uses fields' => FALSE,
  74. 'uses options' => TRUE,
  75. 'type' => 'date_nav',
  76. 'even empty' => TRUE,
  77. ),
  78. ),
  79. );
  80. }
  81. /**
  82. * Implements hook_views_data()
  83. */
  84. function date_views_views_data() {
  85. $data = array();
  86. $tables = date_views_base_tables();
  87. foreach ($tables as $base_table => $entity) {
  88. // The flexible date argument.
  89. $data[$base_table]['date_argument'] = array(
  90. 'group' => t('Date'),
  91. 'title' => t('Date (!base_table)', array('!base_table' => $base_table)),
  92. 'help' => t('Filter any Views !base_table date field by a date argument, using any common ISO date/period format (i.e. YYYY, YYYY-MM, YYYY-MM-DD, YYYY-W99, YYYY-MM-DD--P3M, P90D, etc). ', array('!base_table' => $base_table)),
  93. 'argument' => array(
  94. 'handler' => 'date_views_argument_handler',
  95. 'empty field name' => t('Undated'),
  96. 'is date' => TRUE,
  97. //'skip base' => $base_table,
  98. ),
  99. );
  100. // The flexible date filter.
  101. $data[$base_table]['date_filter'] = array(
  102. 'group' => t('Date'),
  103. 'title' => t('Date (!base_table)', array('!base_table' => $base_table)),
  104. 'help' => t('Filter any Views !base_table date field.', array('!base_table' => $base_table)),
  105. 'filter' => array(
  106. 'handler' => 'date_views_filter_handler',
  107. 'empty field name' => t('Undated'),
  108. 'is date' => TRUE,
  109. //'skip base' => $base_table,
  110. ),
  111. );
  112. }
  113. return $data;
  114. }
  115. /**
  116. * Implements hook_views_data_alter().
  117. */
  118. function date_views_views_data_alter(&$data) {
  119. // Mark all the core date handlers as date fields.
  120. // This will identify all handlers that directly use the _date handlers,
  121. // will not pick up any that extend those handlers.
  122. foreach ($data as $module => &$table) {
  123. foreach ($table as $id => &$field) {
  124. foreach (array('field', 'sort', 'filter', 'argument') as $type) {
  125. if (isset($field[$type]) && isset($field[$type]['handler']) && ($field[$type]['handler'] == 'views_handler_' . $type . '_date')) {
  126. $field[$type]['is date'] = TRUE;
  127. }
  128. }
  129. }
  130. }
  131. }
  132. /**
  133. * Central function for setting up the right timezone values
  134. * in the SQL date handler.
  135. *
  136. * The date handler will use this information to decide if the
  137. * database value needs a timezone conversion.
  138. *
  139. * In Views, we will always be comparing to a local date value,
  140. * so the goal is to convert the database value to the right
  141. * value to compare to the local value.
  142. */
  143. function date_views_set_timezone(&$date_handler, &$view, $field) {
  144. switch ($field['tz_handling']) {
  145. case 'date' :
  146. $date_handler->db_timezone = 'UTC';
  147. $date_handler->local_timezone_field = $field['timezone_field'];
  148. $date_handler->offset_field = $field['offset_field'];
  149. break;
  150. case 'none':
  151. $date_handler->db_timezone = date_default_timezone();
  152. $date_handler->local_timezone = date_default_timezone();
  153. break;
  154. case 'utc':
  155. $date_handler->db_timezone = 'UTC';
  156. $date_handler->local_timezone = 'UTC';
  157. break;
  158. default :
  159. $date_handler->db_timezone = 'UTC';
  160. $date_handler->local_timezone = date_default_timezone();
  161. break;
  162. }
  163. }
  164. function date_views_querystring($view, $extra_params = array()) {
  165. $query_params = array_merge($_GET, $extra_params);
  166. // Allow NULL params to be removed from the query string.
  167. foreach ($extra_params AS $key => $value) {
  168. if (!isset($value)) {
  169. unset($query_params[$key]);
  170. }
  171. }
  172. // Filter the special "q" and "view" variables out of the query string.
  173. $exclude = array('q');
  174. // If we don't explicitly add a value for "view", filter it out.
  175. if (empty($extra_params['view'])) {
  176. $exclude[] = 'view';
  177. }
  178. // Clear out old date pager settings if not explicitly added.
  179. if (!empty($view->date_info->pager_id) && empty($extra_params[$view->date_info->pager_id])) {
  180. $exclude[] = $view->date_info->pager_id;
  181. }
  182. $query = drupal_get_query_parameters($query_params, $exclude);
  183. // To prevent an empty query string from adding a "?" on to the end of a URL,
  184. // we return NULL.
  185. return !empty($query) ? $query : NULL;
  186. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.