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
|
/**
|
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
|
/**
|
25
|
* Implements hook_context_plugins()
|
26
|
*/
|
27
|
function date_context_context_plugins() {
|
28
|
$plugins = array();
|
29
|
$plugins['date_context_date_condition'] = array(
|
30
|
'handler' => array(
|
31
|
'class' => 'date_context_date_condition',
|
32
|
'parent' => 'context_condition_node',
|
33
|
'path' => drupal_get_path('module', 'date_context') . '/plugins',
|
34
|
'file' => 'date_context_date_condition.inc',
|
35
|
),
|
36
|
);
|
37
|
return $plugins;
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Implements hook_context_registry()
|
42
|
*/
|
43
|
function date_context_context_registry() {
|
44
|
return array(
|
45
|
'conditions' => array(
|
46
|
'date_context_date_condition' => array(
|
47
|
'title' => t('Date'),
|
48
|
'description' => t('Set a condition based on the value of a date field'),
|
49
|
'plugin' => 'date_context_date_condition',
|
50
|
),
|
51
|
),
|
52
|
);
|
53
|
}
|
54
|
|