date_context.module 1.5 KB

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