Projet

Général

Profil

Paste
Télécharger (1,45 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / date / date_context / date_context.module @ 599a39cd

1
<?php
2

    
3
/**
4
 * @file
5
 * Add an option to set/not set the context on forms vs views.
6
 *
7
 * @todo Currently only implemented for nodes. Need to add $plugin->execute()
8
 * for any other entities that might be supported.
9
 *
10
 * @todo Cache the date processing, perhaps cache the formatted, tz-adjusted
11
 * date strings for each entity (would have to be cached differently for each
12
 * timezone, based on the tz_handling method for the date).
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
}