date_context.module in Date 7.2
Same filename and directory in other branches
Add an option to set/not set the context on forms vs views.
@todo Currently only implemented for nodes. Need to add $plugin->execute() for any other entities that might be supported.
@todo Cache the date processing, perhaps cache the formatted, tz-adjusted date strings for each entity (would have to be cached differently for each timezone, based on the tz_handling method for the date).
File
date_context/date_context.moduleView source
<?php
/**
* @file
* Add an option to set/not set the context on forms vs views.
*
* @todo Currently only implemented for nodes. Need to add $plugin->execute()
* for any other entities that might be supported.
*
* @todo Cache the date processing, perhaps cache the formatted, tz-adjusted
* date strings for each entity (would have to be cached differently for each
* timezone, based on the tz_handling method for the date).
*/
/**
* Implements hook_context_node_condition_alter().
*/
function date_context_context_node_condition_alter($node, $op) {
if ($plugin = context_get_plugin('condition', 'date_context_date_condition')) {
$plugin
->execute($node, $op);
}
}
/**
* Implements hook_context_plugins().
*/
function date_context_context_plugins() {
$plugins = array();
$plugins['date_context_date_condition'] = array(
'handler' => array(
'class' => 'date_context_date_condition',
'parent' => 'context_condition_node',
'path' => drupal_get_path('module', 'date_context') . '/plugins',
'file' => 'date_context_date_condition.inc',
),
);
return $plugins;
}
/**
* Implements hook_context_registry().
*/
function date_context_context_registry() {
return array(
'conditions' => array(
'date_context_date_condition' => array(
'title' => t('Date'),
'description' => t('Set a condition based on the value of a date field'),
'plugin' => 'date_context_date_condition',
),
),
);
}
Functions
Name | Description |
---|---|
date_context_context_node_condition_alter | Implements hook_context_node_condition_alter(). |
date_context_context_plugins | Implements hook_context_plugins(). |
date_context_context_registry | Implements hook_context_registry(). |