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 @ b720ea3e

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
/**
17
 * Implements hook_context_node_condition_alter().
18
 */
19
function date_context_context_node_condition_alter($node, $op) {
20
  if ($plugin = context_get_plugin('condition', 'date_context_date_condition')) {
21
    $plugin->execute($node, $op);
22
  }
23
}
24

    
25
/**
26
 * Implements hook_context_plugins().
27
 */
28
function date_context_context_plugins() {
29
  $plugins = array();
30
  $plugins['date_context_date_condition'] = array(
31
    'handler' => array(
32
      'class' => 'date_context_date_condition',
33
      'parent' => 'context_condition_node',
34
      'path' => drupal_get_path('module', 'date_context') . '/plugins',
35
      'file' => 'date_context_date_condition.inc',
36
    ),
37
  );
38
  return $plugins;
39
}
40

    
41
/**
42
 * Implements hook_context_registry().
43
 */
44
function date_context_context_registry() {
45
  return array(
46
    'conditions' => array(
47
      'date_context_date_condition' => array(
48
        'title' => t('Date'),
49
        'description' => t('Set a condition based on the value of a date field'),
50
        'plugin' => 'date_context_date_condition',
51
      ),
52
    ),
53
  );
54
}