date_context.module 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @TODO
  4. *
  5. * Currently only implemented for nodes. Need to add $plugin->execute()
  6. * for any other entities that might be supported.
  7. *
  8. * Cache the date processing, perhaps cache the formatted, timezone-adjusted
  9. * date strings for each entity (would have to be cached differently for each
  10. * timezone, based on the tz_handling method for the date).
  11. *
  12. * Add an option to set/not set the context on forms vs views.
  13. */
  14. /**
  15. * Implements hook_context_node_condition_alter().
  16. */
  17. function date_context_context_node_condition_alter($node, $op) {
  18. if ($plugin = context_get_plugin('condition', 'date_context_date_condition')) {
  19. $plugin->execute($node, $op);
  20. }
  21. }
  22. /**
  23. * Implements hook_context_plugins()
  24. */
  25. function date_context_context_plugins() {
  26. $plugins = array();
  27. $plugins['date_context_date_condition'] = array(
  28. 'handler' => array(
  29. 'class' => 'date_context_date_condition',
  30. 'parent' => 'context_condition_node',
  31. 'path' => drupal_get_path('module', 'date_context') . '/plugins',
  32. 'file' => 'date_context_date_condition.inc',
  33. ),
  34. );
  35. return $plugins;
  36. }
  37. /**
  38. * Implements hook_context_registry()
  39. */
  40. function date_context_context_registry() {
  41. return array(
  42. 'conditions' => array(
  43. 'date_context_date_condition' => array(
  44. 'title' => t('Date'),
  45. 'description' => t('Set a condition based on the value of a date field'),
  46. 'plugin' => 'date_context_date_condition',
  47. ),
  48. ),
  49. );
  50. }