updated date pathauto addressfield honeypot features modules
This commit is contained in:
@@ -8,9 +8,9 @@ dependencies[] = context
|
||||
|
||||
files[] = date_context.module
|
||||
files[] = plugins/date_context_date_condition.inc
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -1,5 +1,8 @@
|
||||
<?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()
|
||||
@@ -8,8 +11,6 @@
|
||||
* Cache the date processing, perhaps cache the formatted, timezone-adjusted
|
||||
* date strings for each entity (would have to be cached differently for each
|
||||
* timezone, based on the tz_handling method for the date).
|
||||
*
|
||||
* Add an option to set/not set the context on forms vs views.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,7 @@ function date_context_context_node_condition_alter($node, $op) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_context_plugins()
|
||||
* Implements hook_context_plugins().
|
||||
*/
|
||||
function date_context_context_plugins() {
|
||||
$plugins = array();
|
||||
@@ -38,7 +39,7 @@ function date_context_context_plugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_context_registry()
|
||||
* Implements hook_context_registry().
|
||||
*/
|
||||
function date_context_context_registry() {
|
||||
return array(
|
||||
@@ -51,4 +52,3 @@ function date_context_context_registry() {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Context date condition plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Expose term views/term forms by vocabulary as a context condition.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_context_date_condition extends context_condition_node {
|
||||
function condition_values() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function condition_values() {
|
||||
$values = array();
|
||||
$fields = field_info_fields();
|
||||
foreach ($fields as $field_name => $field) {
|
||||
@@ -15,10 +25,13 @@ class date_context_date_condition extends context_condition_node {
|
||||
return $values;
|
||||
}
|
||||
|
||||
function options_form($context) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form($context) {
|
||||
$defaults = $this->fetch_from_context($context, 'options');
|
||||
$options = array(
|
||||
'<' => t('Is less than'),
|
||||
'<' => t('Is less than'),
|
||||
'<=' => t('Is less than or equal to'),
|
||||
'>=' => t('Is greater than or equal to'),
|
||||
'>' => t('Is greater than'),
|
||||
@@ -27,6 +40,8 @@ class date_context_date_condition extends context_condition_node {
|
||||
'empty' => t('Is empty'),
|
||||
'not empty' => t('Is not Empty'),
|
||||
);
|
||||
$dependency_options = array('<', '<=', '>', '>=', '=', '!=');
|
||||
|
||||
$form['operation'] = array(
|
||||
'#title' => t('Operation'),
|
||||
'#type' => 'select',
|
||||
@@ -41,12 +56,15 @@ class date_context_date_condition extends context_condition_node {
|
||||
'#description' => t("The value the field should contain to meet the condition. This can either be an absolute date in ISO format (YYYY-MM-DDTHH:MM:SS) or a relative string like '12AM today'. Examples: 2011-12-31T00:00:00, now, now +1 day, 12AM today, Monday next week. <a href=\"@relative_format\">More examples of relative date formats in the PHP documentation</a>.", array('@relative_format' => 'http://www.php.net/manual/en/datetime.formats.relative.php')),
|
||||
'#default_value' => isset($defaults['value']) ? $defaults['value'] : '',
|
||||
'#process' => array('ctools_dependent_process'),
|
||||
'#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => array('<', '<=', '>', '>=', '=', '!=')),
|
||||
'#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => $dependency_options),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function execute($entity, $op) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($entity, $op) {
|
||||
if (in_array($op, array('view', 'form'))) {
|
||||
foreach ($this->get_contexts() as $context) {
|
||||
$options = $this->fetch_from_context($context, 'options');
|
||||
@@ -91,32 +109,37 @@ class date_context_date_condition extends context_condition_node {
|
||||
str_replace('now', 'today', $options['value']);
|
||||
$date = date_create($options['value'], date_default_timezone_object());
|
||||
$compdate = $date->format(DATE_FORMAT_DATETIME);
|
||||
switch($options['operation']) {
|
||||
switch ($options['operation']) {
|
||||
case '=':
|
||||
if ($date2 >= $compdate && $date1 <= $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if ($date1 > $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '>=':
|
||||
if ($date1 >= $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '<':
|
||||
if ($date2 < $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '<=':
|
||||
if ($date2 <= $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '!=':
|
||||
if ($date1 < $compdate || $date2 > $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
@@ -130,3 +153,4 @@ class date_context_date_condition extends context_condition_node {
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
Reference in New Issue
Block a user