updated ctools, panels, date, diff
This commit is contained in:
@@ -28,6 +28,7 @@ function date_field_formatter_info() {
|
||||
'settings' => array(
|
||||
'interval' => 2,
|
||||
'interval_display' => 'time ago',
|
||||
'use_end_date' => false,
|
||||
),
|
||||
),
|
||||
'date_plain' => array(
|
||||
@@ -207,7 +208,7 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
||||
$variables['item'] = $item;
|
||||
$variables['dates'] = date_formatter_process($formatter, $entity_type, $entity, $field, $instance, $langcode, $item, $display);
|
||||
$variables['attributes'] = !empty($rdf_mapping) ? rdf_rdfa_attributes($rdf_mapping, $item['value']) : array();
|
||||
$variables['show_remaining_days'] = $display['settings']['show_remaining_days'];
|
||||
$variables['show_remaining_days'] = isset($display['settings']['show_remaining_days']) ? $display['settings']['show_remaining_days'] : FALSE;
|
||||
$output = theme('date_display_combination', $variables);
|
||||
if (!empty($output)) {
|
||||
$element[$delta] = array('#markup' => $output);
|
||||
@@ -322,7 +323,7 @@ function date_field_widget_info() {
|
||||
}
|
||||
|
||||
// The date text widget should use an increment of 1.
|
||||
$info['date_text']['increment'] = 1;
|
||||
$info['date_text']['settings']['increment'] = 1;
|
||||
|
||||
return $info;
|
||||
}
|
||||
@@ -462,6 +463,14 @@ function date_field_instance_settings_form($field, $instance) {
|
||||
return _date_field_instance_settings_form($field, $instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation handler for _date_field_instance_settings_form().
|
||||
*/
|
||||
function date_field_instance_settings_form_validate(&$form, &$form_state) {
|
||||
module_load_include('inc', 'date', 'date_admin');
|
||||
return _date_field_instance_settings_form_validate($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_settings_form().
|
||||
*/
|
||||
@@ -470,6 +479,14 @@ function date_field_widget_settings_form($field, $instance) {
|
||||
return _date_field_widget_settings_form($field, $instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation handler for _date_field_widget_settings_form().
|
||||
*/
|
||||
function date_field_widget_settings_form_validate(&$form, &$form_state) {
|
||||
module_load_include('inc', 'date', 'date_admin');
|
||||
return _date_field_widget_settings_form_validate($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_settings_form().
|
||||
*/
|
||||
@@ -478,6 +495,14 @@ function date_field_settings_form($field, $instance, $has_data) {
|
||||
return _date_field_settings_form($field, $instance, $has_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation handler for _date_field_settings_form().
|
||||
*/
|
||||
function date_field_settings_validate(&$form, &$form_state) {
|
||||
module_load_include('inc', 'date', 'date_admin');
|
||||
return _date_field_settings_validate($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_content_migrate_field_alter().
|
||||
*
|
||||
|
@@ -13,10 +13,11 @@ files[] = tests/date_validation.test
|
||||
files[] = tests/date_timezone.test
|
||||
files[] = tests/date_views_pager.test
|
||||
files[] = tests/date_views_popup.test
|
||||
files[] = tests/date_form.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -204,3 +204,11 @@ function date_update_7004() {
|
||||
field_cache_clear();
|
||||
drupal_set_message(t('Date text widgets have been updated to use an increment of 1.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Revisited: Date text widgets should always use an increment of 1.
|
||||
*/
|
||||
function date_update_7005() {
|
||||
// @see https://www.drupal.org/node/1355256
|
||||
date_update_7004();
|
||||
}
|
||||
|
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Support for migration into Date fields.
|
||||
*/
|
||||
|
||||
if (!class_exists('MigrateFieldHandler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
|
@@ -443,7 +443,12 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
|
||||
return 'date_plain';
|
||||
|
||||
default:
|
||||
$format = date_format_type_format($format_type, $langcode);
|
||||
if ($format_type == 'custom') {
|
||||
$format = $settings['custom_date_format'];
|
||||
}
|
||||
else {
|
||||
$format = date_format_type_format($format_type, $langcode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -349,10 +349,10 @@ function theme_date_display_range($variables) {
|
||||
}
|
||||
|
||||
// Wrap the result with the attributes.
|
||||
$output = '<div class="date-display-range">' . t('!start-date to !end-date', array(
|
||||
$output = '<span class="date-display-range">' . t('!start-date to !end-date', array(
|
||||
'!start-date' => $start_date,
|
||||
'!end-date' => $end_date,
|
||||
)) . '</div>';
|
||||
)) . '</span>';
|
||||
|
||||
// Add remaining message and return.
|
||||
return $output . $show_remaining_days;
|
||||
@@ -378,6 +378,8 @@ function theme_date_display_interval($variables) {
|
||||
'end_date' => $dates['value2']['local']['object'],
|
||||
'interval' => $options['interval'],
|
||||
'interval_display' => $options['interval_display'],
|
||||
'use_end_date' => !empty($options['use_end_date']) ?
|
||||
$options['use_end_date'] : FALSE,
|
||||
);
|
||||
|
||||
if ($return = theme('date_time_ago', $time_ago_vars)) {
|
||||
@@ -398,9 +400,9 @@ function theme_date_combo($variables) {
|
||||
|
||||
// Group start/end items together in fieldset.
|
||||
$fieldset = array(
|
||||
'#title' => field_filter_xss(t($element['#title'])) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
|
||||
'#title' => field_filter_xss(t($element['#title'])) . ($element['#delta'] > 0 ? ' ' . intval($element['#delta'] + 1) : ''),
|
||||
'#value' => '',
|
||||
'#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '',
|
||||
'#description' => !empty($element['#description']) ? $element['#description'] : '',
|
||||
'#attributes' => array('class' => array('date-combo')),
|
||||
'#children' => $element['#children'],
|
||||
);
|
||||
|
@@ -14,15 +14,24 @@ function date_default_formatter_settings_form($field, $instance, $view_mode, $fo
|
||||
$formatter = $display['type'];
|
||||
$form = array();
|
||||
|
||||
$date_formats = date_format_type_options();
|
||||
$form['format_type'] = array(
|
||||
'#title' => t('Choose how users view dates and times:'),
|
||||
'#type' => 'select',
|
||||
'#options' => date_format_type_options(),
|
||||
'#options' => $date_formats + array('custom' => t('Custom')),
|
||||
'#default_value' => $settings['format_type'],
|
||||
'#description' => t('To add or edit options, visit <a href="@date-time-page">Date and time settings</a>.', array('@date-time-page' => url('admin/config/regional/date-time'))),
|
||||
'#weight' => 0,
|
||||
);
|
||||
|
||||
$form['custom_date_format'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom date format'),
|
||||
'#description' => t('If "Custom", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
|
||||
'#default_value' => isset($settings['custom_date_format']) ? $settings['custom_date_format'] : '',
|
||||
'#dependency' => array('edit-options-settings-format-type' => array('custom')),
|
||||
);
|
||||
|
||||
$form['fromto'] = array(
|
||||
'#title' => t('Display:'),
|
||||
'#type' => 'select',
|
||||
@@ -116,6 +125,14 @@ function date_interval_formatter_settings_form($field, $instance, $view_mode, $f
|
||||
'#default_value' => $settings['interval_display'],
|
||||
'#weight' => 0,
|
||||
);
|
||||
if (!empty($field['settings']['todate'])) {
|
||||
$form['use_end_date'] = array(
|
||||
'#title' => t('Use End date'),
|
||||
'#description' => 'Use the End date, instead of the start date',
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $settings['use_end_date'],
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -186,7 +203,9 @@ function date_interval_formatter_settings_summary($field, $instance, $view_mode)
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
$formatter = $display['type'];
|
||||
$summary[] = t('Display time ago, showing @interval units.', array('@interval' => $settings['interval']));
|
||||
$field = ($settings['use_end_date'] == 1) ? 'End' : 'Start';
|
||||
$summary[] = t('Display time ago, showing @interval units. Using @field Date',
|
||||
array('@interval' => $settings['interval'], '@field' => $field));
|
||||
|
||||
return $summary;
|
||||
}
|
||||
@@ -273,7 +292,7 @@ function _date_field_instance_settings_form($field, $instance) {
|
||||
/**
|
||||
* Form validation handler for _date_field_instance_settings_form().
|
||||
*/
|
||||
function date_field_instance_settings_form_validate(&$form, &$form_state) {
|
||||
function _date_field_instance_settings_form_validate(&$form, &$form_state) {
|
||||
$settings = $form_state['values']['instance']['settings'];
|
||||
|
||||
if ($settings['default_value'] == 'strtotime') {
|
||||
@@ -459,7 +478,7 @@ function _date_field_widget_settings_form($field, $instance) {
|
||||
/**
|
||||
* Form validation handler for _date_field_widget_settings_form().
|
||||
*/
|
||||
function date_field_widget_settings_form_validate(&$form, &$form_state) {
|
||||
function _date_field_widget_settings_form_validate(&$form, &$form_state) {
|
||||
// The widget settings are in the wrong place in the form because of #tree on
|
||||
// the top level.
|
||||
$settings = $form_state['values']['instance']['widget']['settings'];
|
||||
@@ -561,7 +580,7 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
$form['cache_enabled'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Cache dates'),
|
||||
'#description' => t('Date objects can be created and cached as date fields are loaded rather than when they are displayed to improve performance.'),
|
||||
'#description' => t('Date objects can be created and cached as date fields are loaded, rather than when they are displayed, to improve performance.'),
|
||||
'#default_value' => !empty($settings['cache_enabled']),
|
||||
'#weight' => 10,
|
||||
);
|
||||
@@ -594,7 +613,7 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
/**
|
||||
* Form validation handler for _date_field_settings_form().
|
||||
*/
|
||||
function date_field_settings_validate(&$form, &$form_state) {
|
||||
function _date_field_settings_validate(&$form, &$form_state) {
|
||||
$field = &$form_state['values']['field'];
|
||||
|
||||
if ($field['settings']['tz_handling'] == 'none') {
|
||||
|
@@ -5,9 +5,9 @@ dependencies[] = date
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -9,9 +9,9 @@ stylesheets[all][] = date.css
|
||||
files[] = date_api.module
|
||||
files[] = date_api_sql.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -1833,9 +1833,10 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) {
|
||||
/**
|
||||
* A date object for the current time.
|
||||
*
|
||||
* @param object $timezone
|
||||
* (optional) Optionally force time to a specific timezone, defaults to user
|
||||
* timezone, if set, otherwise site timezone. Defaults to NULL.
|
||||
* @param object|string|null $timezone
|
||||
* (optional) PHP DateTimeZone object, string or NULL allowed. Optionally
|
||||
* force time to a specific timezone, defaults to user timezone, if set,
|
||||
* otherwise site timezone. Defaults to NULL.
|
||||
*
|
||||
* @param bool $reset
|
||||
* (optional) Static cache reset.
|
||||
@@ -1844,11 +1845,16 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) {
|
||||
* The current time as a date object.
|
||||
*/
|
||||
function date_now($timezone = NULL, $reset = FALSE) {
|
||||
if ($reset) {
|
||||
drupal_static_reset(__FUNCTION__ . $timezone);
|
||||
$static_var = __FUNCTION__ . $timezone;
|
||||
if ($timezone instanceof DateTimeZone) {
|
||||
$static_var = __FUNCTION__ . $timezone->getName();
|
||||
}
|
||||
|
||||
$now = &drupal_static(__FUNCTION__ . $timezone);
|
||||
if ($reset) {
|
||||
drupal_static_reset($static_var);
|
||||
}
|
||||
|
||||
$now = &drupal_static($static_var);
|
||||
|
||||
if (!isset($now)) {
|
||||
$now = new DateObject('now', $timezone);
|
||||
@@ -1920,7 +1926,12 @@ function date_days_in_month($year, $month) {
|
||||
// Pick a day in the middle of the month to avoid timezone shifts.
|
||||
$datetime = date_pad($year, 4) . '-' . date_pad($month) . '-15 00:00:00';
|
||||
$date = new DateObject($datetime);
|
||||
return $date->format('t');
|
||||
if ($date->errors) {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
return $date->format('t');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2075,6 +2086,9 @@ function date_iso_week_range($week, $year) {
|
||||
date_timezone_set($min_date, date_default_timezone_object());
|
||||
|
||||
// Find the first day of the first ISO week in the year.
|
||||
// If it's already a Monday, date_modify won't add a Monday,
|
||||
// it will remain the same day. So add a Sunday first, then a Monday.
|
||||
date_modify($min_date, '+1 Sunday');
|
||||
date_modify($min_date, '+1 Monday');
|
||||
|
||||
// Jump ahead to the desired week for the beginning of the week range.
|
||||
|
@@ -111,7 +111,7 @@ function date_default_date($element) {
|
||||
$format = DATE_FORMAT_DATETIME;
|
||||
|
||||
// The text and popup widgets might return less than a full datetime string.
|
||||
if (strlen($element['#default_value']) < 19) {
|
||||
if (is_string($element['#default_value']) && strlen($element['#default_value']) < 19) {
|
||||
switch (strlen($element['#default_value'])) {
|
||||
case 16:
|
||||
$format = 'Y-m-d H:i';
|
||||
@@ -319,7 +319,7 @@ function date_text_element_process($element, &$form_state, $form) {
|
||||
|
||||
$element['#tree'] = TRUE;
|
||||
$element['#theme_wrappers'] = array('date_text');
|
||||
$element['date']['#value'] = $element['#value']['date'];
|
||||
$element['date']['#value'] = isset($element['#value']['date']) ? $element['#value']['date'] : '';
|
||||
$element['date']['#type'] = 'textfield';
|
||||
$element['date']['#weight'] = !empty($element['date']['#weight']) ? $element['date']['#weight'] : $element['#weight'];
|
||||
$element['date']['#attributes'] = array('class' => isset($element['#attributes']['class']) ? $element['#attributes']['class'] += array('date-date') : array('date-date'));
|
||||
|
@@ -194,6 +194,7 @@ function theme_date_calendar_day($variables) {
|
||||
function theme_date_time_ago($variables) {
|
||||
$start_date = $variables['start_date'];
|
||||
$end_date = $variables['end_date'];
|
||||
$use_end_date = isset($variables['use_end_date']) ? $variables['use_end_date'] : false;
|
||||
$interval = !empty($variables['interval']) ? $variables['interval'] : 2;
|
||||
$display = isset($variables['interval_display']) ? $variables['interval_display'] : 'time ago';
|
||||
|
||||
@@ -202,12 +203,20 @@ function theme_date_time_ago($variables) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We use the end date only when the option is checked.
|
||||
if ($use_end_date){
|
||||
$date = date_format($end_date, DATE_FORMAT_UNIX);
|
||||
}
|
||||
else {
|
||||
$date = date_format($start_date, DATE_FORMAT_UNIX);
|
||||
}
|
||||
|
||||
// Time to compare dates to.
|
||||
|
||||
$now = date_format(date_now(), DATE_FORMAT_UNIX);
|
||||
$start = date_format($start_date, DATE_FORMAT_UNIX);
|
||||
|
||||
// Will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence).
|
||||
$time_diff = $now - $start;
|
||||
$time_diff = $now - $date;
|
||||
|
||||
// Uses the same options used by Views format_interval.
|
||||
switch ($display) {
|
||||
|
@@ -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 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -74,7 +74,7 @@ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langco
|
||||
// The repeating values will be re-generated when the repeat widget form is validated.
|
||||
// At this point we can't tell if this form element is going to be hidden by #access, and we're going to
|
||||
// lose all but the first value by doing this, so store the original values in case we need to replace them later.
|
||||
if (!empty($field['settings']['repeat'])) {
|
||||
if (!empty($field['settings']['repeat']) && module_exists('date_repeat_field')) {
|
||||
if ($delta == 0) {
|
||||
$form['#after_build'][] = 'date_repeat_after_build';
|
||||
$form_state['storage']['repeat_fields'][$field_name] = array_merge($form['#parents'], array($field_name));
|
||||
@@ -337,8 +337,11 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
'#date_label_position' => $instance['widget']['settings']['label_position'],
|
||||
);
|
||||
|
||||
$description = !empty($element['#description']) ? t($element['#description']) : '';
|
||||
unset($element['#description']);
|
||||
// Date repeat is a multiple value field. So the description is removed from
|
||||
// the single element earlier. Let's get it back.
|
||||
if (isset($element['show_repeat_settings']) && !empty($element['value']['#instance']['description'])) {
|
||||
$element['#description'] = $element['value']['#instance']['description'];
|
||||
}
|
||||
|
||||
// Give this element the right type, using a Date API
|
||||
// or a Date Popup element type.
|
||||
@@ -383,8 +386,7 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
$element[$to_field]['#prefix'] = '';
|
||||
// Users with JS enabled will never see initially blank values for the end
|
||||
// date (see Drupal.date.EndDateHandler()), so hide the message for them.
|
||||
$description .= '<span class="js-hide"> ' . t("Empty 'End date' values will use the 'Start date' values.") . '</span>';
|
||||
$element['#fieldset_description'] = $description;
|
||||
$element['#description'] .= '<span class="js-hide"> ' . t("Empty 'End date' values will use the 'Start date' values.") . '</span>';
|
||||
if ($field['settings']['todate'] == 'optional') {
|
||||
$element[$to_field]['#states'] = array(
|
||||
'visible' => array(
|
||||
@@ -395,9 +397,6 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$element[$from_field]['#description'] = $description;
|
||||
}
|
||||
|
||||
// Create label for error messages that make sense in multiple values
|
||||
// and when the title field is left blank.
|
||||
@@ -474,6 +473,12 @@ function date_combo_validate($element, &$form_state) {
|
||||
$form_values = drupal_array_get_nested_value($form_state['values'], $element['#field_parents']);
|
||||
$form_input = drupal_array_get_nested_value($form_state['input'], $element['#field_parents']);
|
||||
|
||||
// Programmatically calling drupal_submit_form() does not always add the date
|
||||
// combo to $form_state['input'].
|
||||
if (empty($form_input[$field_name]) && !empty($form_values[$field_name])) {
|
||||
form_set_value($element, $element['#date_items'], $form_state);
|
||||
return;
|
||||
}
|
||||
// If the whole field is empty and that's OK, stop now.
|
||||
if (empty($form_input[$field_name]) && !$element['#required']) {
|
||||
return;
|
||||
@@ -546,11 +551,7 @@ function date_combo_validate($element, &$form_state) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Don't look for further errors if errors are already flagged
|
||||
// because otherwise we'll show errors on the nested elements
|
||||
// more than once.
|
||||
elseif (!form_get_errors()) {
|
||||
|
||||
else {
|
||||
$timezone = !empty($item[$tz_field]) ? $item[$tz_field] : $element['#date_timezone'];
|
||||
$timezone_db = date_get_timezone_db($field['settings']['tz_handling']);
|
||||
$element[$from_field]['#date_timezone'] = $timezone;
|
||||
@@ -625,7 +626,10 @@ function date_combo_validate($element, &$form_state) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
// Don't show further errors if errors are already flagged
|
||||
// because otherwise we'll show errors on the nested elements
|
||||
// more than once.
|
||||
if (!form_get_errors() && !empty($errors)) {
|
||||
if ($field['cardinality']) {
|
||||
form_error($element, t('There are errors in @field_name value #@delta:', array('@field_name' => $instance['label'], '@delta' => $delta + 1)) . theme('item_list', array('items' => $errors)));
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ core = 7.x
|
||||
package = Date/Time
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -20,9 +20,9 @@ package = "Features"
|
||||
project = "date_migrate_example"
|
||||
version = "7.x-2.0"
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -7,9 +7,9 @@ configure = admin/config/date/date_popup
|
||||
|
||||
stylesheets[all][] = themes/datepicker.1.7.css
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -14,6 +14,14 @@
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
if (datePopup.settings.syncEndDate) {
|
||||
$('.start-date-wrapper').each(function(){
|
||||
var start_date_wrapper = this;
|
||||
$(this).find('input:eq(0)').change(function(){
|
||||
$(start_date_wrapper).next('.end-date-wrapper').find('input:eq(0)').val($(this).val());
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'timeEntry':
|
||||
|
@@ -394,6 +394,10 @@ function date_popup_process_date_part(&$element) {
|
||||
'fromTo' => isset($fromto),
|
||||
);
|
||||
|
||||
if (!empty($element['#instance'])) {
|
||||
$settings['syncEndDate'] = $element['#instance']['settings']['default_value2'] == 'sync';
|
||||
}
|
||||
|
||||
// Create a unique id for each set of custom settings.
|
||||
$id = date_popup_js_settings_id($element['#id'], 'datepicker', $settings);
|
||||
|
||||
@@ -474,10 +478,11 @@ function date_popup_process_time_part(&$element) {
|
||||
$grans = array('hour', 'minute', 'second');
|
||||
$time_granularity = array_intersect($granularity, $grans);
|
||||
$format = date_popup_format_to_popup_time(date_limit_format($element['#date_format'], $time_granularity), 'wvega');
|
||||
$default_value = isset($element['#default_value']) ? $element['#default_value'] : '';
|
||||
// The first value in the dropdown list should be the same as the element
|
||||
// default_value, but it needs to be in JS format (i.e. milliseconds since
|
||||
// the epoch).
|
||||
$start_time = new DateObject($element['#default_value'], $element['#date_timezone'], DATE_FORMAT_DATETIME);
|
||||
$start_time = new DateObject($default_value, $element['#date_timezone'], DATE_FORMAT_DATETIME);
|
||||
date_increment_round($start_time, $element['#date_increment']);
|
||||
$start_time = $start_time->format(DATE_FORMAT_UNIX) * 1000;
|
||||
$settings = array(
|
||||
@@ -580,7 +585,7 @@ function date_popup_validate($element, &$form_state) {
|
||||
// If something was input but there is no date, the date is invalid.
|
||||
// If the field is empty and required, set error message and return.
|
||||
$error_field = implode('][', $element['#parents']);
|
||||
if (empty($date) || !empty($date->errors)) {
|
||||
if ((empty($element['#value']['date']) && empty($element['#value']['time'])) || !empty($date->errors)) {
|
||||
if (is_object($date) && !empty($date->errors)) {
|
||||
$message = t('The value input for field %field is invalid:', array('%field' => $label));
|
||||
$message .= '<br />' . implode('<br />', $date->errors);
|
||||
@@ -613,7 +618,9 @@ function date_popup_validate($element, &$form_state) {
|
||||
*/
|
||||
function date_popup_input_date($element, $input, $auto_complete = FALSE) {
|
||||
if (empty($input) || !is_array($input) || !array_key_exists('date', $input) || empty($input['date'])) {
|
||||
return NULL;
|
||||
//check if there is no time associated in the input variable. This is the exception scenario where the user has entered only time and not date.
|
||||
if(empty($input['time']))
|
||||
return NULL;
|
||||
}
|
||||
date_popup_add();
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
@@ -622,9 +629,14 @@ function date_popup_input_date($element, $input, $auto_complete = FALSE) {
|
||||
|
||||
$format = date_popup_date_format($element);
|
||||
$format .= $has_time ? ' ' . date_popup_time_format($element) : '';
|
||||
$datetime = trim($input['date']);
|
||||
//check if date is empty, if yes, then leave it blank.
|
||||
$datetime = !empty($input['date']) ? trim($input['date']) : '';
|
||||
$datetime .= $has_time ? ' ' . trim($input['time']) : '';
|
||||
$date = new DateObject($datetime, $element['#date_timezone'], $format);
|
||||
//if the variable is time only then set TimeOnly to TRUE
|
||||
if(empty($input['date']) && !empty($input['time']) ){
|
||||
$date->timeOnly = 'TRUE';
|
||||
}
|
||||
if (is_object($date)) {
|
||||
$date->limitGranularity($granularity);
|
||||
if ($date->validGranularity($granularity, $flexible)) {
|
||||
@@ -800,6 +812,14 @@ function theme_date_popup($vars) {
|
||||
return '<div ' . drupal_attributes($attributes) . '>' . theme('form_element', $element) . '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_date_field_instance_settings_form_alter().
|
||||
*/
|
||||
function date_popup_date_field_instance_settings_form_alter(&$form, $context) {
|
||||
// Add an extra option to sync the end date with the start date.
|
||||
$form['default_value2']['#options']['sync'] = t('Sync with start date');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
|
@@ -7,9 +7,9 @@ php = 5.2
|
||||
files[] = tests/date_repeat.test
|
||||
files[] = tests/date_repeat_form.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -25,7 +25,7 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Create and log in our privileged user.
|
||||
$this->privileged_user = $this->drupalCreateUser(array(
|
||||
'administer content types', 'administer nodes', 'bypass node access', 'view date repeats'
|
||||
'administer content types', 'administer nodes', 'bypass node access', 'view date repeats', 'administer fields'
|
||||
));
|
||||
$this->drupalLogin($this->privileged_user);
|
||||
|
||||
|
@@ -7,9 +7,9 @@ stylesheets[all][] = date_repeat_field.css
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -6,9 +6,9 @@ core = 7.x
|
||||
configure = admin/config/date/tools
|
||||
files[] = tests/date_tools.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class DateToolsTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Create and log in our privileged user.
|
||||
$this->privileged_user = $this->drupalCreateUser(
|
||||
array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools')
|
||||
array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools', 'administer fields')
|
||||
);
|
||||
$this->drupalLogin($this->privileged_user);
|
||||
|
||||
|
@@ -12,9 +12,9 @@ files[] = includes/date_views_filter_handler_simple.inc
|
||||
files[] = includes/date_views.views.inc
|
||||
files[] = includes/date_views_plugin_pager.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1441727353"
|
||||
datestamp = "1491562090"
|
||||
|
||||
|
@@ -42,6 +42,32 @@ class date_views_filter_handler extends date_views_filter_handler_simple {
|
||||
$this->date_combine_conditions('op_contains');
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
$this->get_query_fields();
|
||||
if (empty($this->query_fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add each condition to the custom filter group.
|
||||
foreach ((array) $this->query_fields as $query_field) {
|
||||
$field = $query_field['field'];
|
||||
$this->date_handler = $query_field['date_handler'];
|
||||
|
||||
// Respect relationships when determining the table alias.
|
||||
if ($field['table_name'] != $this->table || !empty($this->relationship)) {
|
||||
$this->related_table_alias = $this->query->ensure_table($field['table_name'], $this->relationship);
|
||||
}
|
||||
else {
|
||||
$this->related_table_alias = NULL;
|
||||
}
|
||||
|
||||
$table_alias = !empty($this->related_table_alias) ? $this->related_table_alias : $field['table_name'];
|
||||
$field_name = $table_alias . '.' . $field['field_name'];
|
||||
|
||||
parent::op_empty($field_name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines multiple date WHERE expressions into a single WHERE expression.
|
||||
*
|
||||
@@ -67,7 +93,7 @@ class date_views_filter_handler extends date_views_filter_handler_simple {
|
||||
$this->related_table_alias = $this->query->ensure_table($field['table_name'], $this->relationship);
|
||||
}
|
||||
else {
|
||||
$this->related_table_alias = null;
|
||||
$this->related_table_alias = NULL;
|
||||
}
|
||||
$table_alias = !empty($this->related_table_alias) ? $this->related_table_alias : $field['table_name'];
|
||||
$field_name = $table_alias . '.' . $field['field_name'];
|
||||
|
@@ -281,7 +281,7 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
else {
|
||||
$this->view->date_info->prev_date = clone($argument->min_date);
|
||||
date_modify($this->view->date_info->prev_date, '-1 ' . $argument->date_handler->granularity);
|
||||
$this->view->date_info->next_date = clone($argument->max_date);
|
||||
$this->view->date_info->next_date = clone($argument->min_date);
|
||||
date_modify($this->view->date_info->next_date, '+1 ' . $argument->date_handler->granularity);
|
||||
}
|
||||
// Write the date_info properties that depend on the current value.
|
||||
|
@@ -77,7 +77,7 @@ function template_preprocess_date_views_pager(&$vars) {
|
||||
switch ($granularity) {
|
||||
case 'week':
|
||||
$prev_week = date_week(date_format($prev_date, 'Y-m-d'));
|
||||
$prev_arg = date_format($prev_date, 'Y-\W') . date_pad($prev_week);
|
||||
$prev_arg = date_format($prev_date, 'o-\W') . date_pad($prev_week);
|
||||
break;
|
||||
default:
|
||||
$prev_arg = date_format($prev_date, $format[$granularity]);
|
||||
@@ -90,7 +90,7 @@ function template_preprocess_date_views_pager(&$vars) {
|
||||
switch ($granularity) {
|
||||
case 'week':
|
||||
$next_week = date_week(date_format($next_date, 'Y-m-d'));
|
||||
$next_arg = date_format($next_date, 'Y-\W') . date_pad($next_week);
|
||||
$next_arg = date_format($next_date, 'o-\W') . date_pad($next_week);
|
||||
break;
|
||||
default:
|
||||
$next_arg = date_format($next_date, $format[$granularity]);
|
||||
|
@@ -393,7 +393,7 @@ class DateAPITestCase extends DrupalWebTestCase {
|
||||
$input = '23 abc 2012';
|
||||
$timezone = NULL;
|
||||
$format = 'd M Y';
|
||||
$date = new dateObject($input, $timezone, $format);
|
||||
$date = @new dateObject($input, $timezone, $format);
|
||||
$this->assertNotEqual(count($date->errors), 0, '23 abc 2012 should be an invalid date');
|
||||
|
||||
// Test Granularity.
|
||||
|
@@ -16,7 +16,7 @@ abstract class DateFieldBasic extends DrupalWebTestCase {
|
||||
|
||||
// Create and log in our privileged user.
|
||||
$this->privileged_user = $this->drupalCreateUser(
|
||||
array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools')
|
||||
array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools', 'administer fields')
|
||||
);
|
||||
$this->drupalLogin($this->privileged_user);
|
||||
|
||||
|
30
sites/all/modules/contrib/fields/date/tests/date_form.test
Normal file
30
sites/all/modules/contrib/fields/date/tests/date_form.test
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains form specific date element test cases.
|
||||
*/
|
||||
|
||||
class DateFormTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Date Form test'),
|
||||
'description' => t('Test Date form functions.') ,
|
||||
'group' => t('Date'),
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
// Load the date_api module.
|
||||
parent::setUp('date_test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests rendering of a date element in a form.
|
||||
*/
|
||||
public function testDateForm() {
|
||||
$this->drupalGet('date-test/form');
|
||||
}
|
||||
|
||||
}
|
@@ -18,6 +18,7 @@ class DateMigrateExampleUnitTest extends DrupalWebTestCase {
|
||||
'name' => 'Date Migration',
|
||||
'description' => 'Test migration into date fields',
|
||||
'group' => 'Date',
|
||||
'dependencies' => array('migrate', 'features'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,14 @@
|
||||
name = "Date module tests"
|
||||
description = "Support module for date related testing."
|
||||
package = Date/Time
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = date
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-04-07
|
||||
version = "7.x-2.10"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1491562090"
|
||||
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains date test implementations.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function date_test_menu() {
|
||||
$items['date-test/form'] = array(
|
||||
'title' => 'Test form with date element',
|
||||
'description' => "Form with date element to make form related tests",
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('date_test_sample_form'),
|
||||
'access arguments' => array('access content'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form callback. Generates a test form with date elements.
|
||||
*/
|
||||
function date_test_sample_form($form, &$form_state) {
|
||||
$form['date_test_select'] = array(
|
||||
'#type' => 'date_select',
|
||||
'#title' => t('Sample from'),
|
||||
'#date_format' => 'H:i:s a',
|
||||
'#default_value' => array(
|
||||
'hour' => 7,
|
||||
'minute' => 0,
|
||||
'second' => 0,
|
||||
'ampm' => 'am'
|
||||
),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
@@ -16,6 +16,16 @@ class DateTimezoneTestCase extends DateFieldBasic {
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
// Set the timezone explicitly. Otherwise the site's default timezone is
|
||||
// used, which defaults to the server timezone when installing Drupal. This
|
||||
// depends on the environment and is therefore uncertain.
|
||||
// The Australia/Sydney timezone is chosen so all tests are run using an
|
||||
// edge case scenario (UTC+10 and DST).
|
||||
variable_set('date_default_timezone', 'Australia/Sydney');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
@@ -23,7 +33,7 @@ class DateTimezoneTestCase extends DateFieldBasic {
|
||||
// Create a date fields with combinations of various timezone handling and
|
||||
// granularity.
|
||||
foreach (array('date', 'datestamp', 'datetime') as $field_type) {
|
||||
foreach (array('site', 'none', 'date', 'user', 'utc') as $tz_handling) {
|
||||
foreach (array('site', 'none', 'date', 'user', 'utc', 'Europe/Dublin') as $tz_handling) {
|
||||
foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $max_granularity) {
|
||||
// Skip invalid combinations.
|
||||
if (in_array($max_granularity, array('year', 'month', 'day')) && $tz_handling != 'none') {
|
||||
@@ -182,17 +192,32 @@ class DateTimezoneTestCase extends DateFieldBasic {
|
||||
case 'hour':
|
||||
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10';
|
||||
$edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11';
|
||||
$should_be = 'Thu, 10/07/2010 - 10 to Thu, 10/07/2010 - 11';
|
||||
if ($tz_handling == 'utc') {
|
||||
$should_be = 'Thu, 10/07/2010 - 21 to Thu, 10/07/2010 - 22';
|
||||
}
|
||||
else {
|
||||
$should_be = 'Thu, 10/07/2010 - 10 to Thu, 10/07/2010 - 11';
|
||||
}
|
||||
break;
|
||||
case 'minute':
|
||||
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11:30';
|
||||
$should_be = 'Thu, 10/07/2010 - 10:30 to 11:30';
|
||||
if ($tz_handling == 'utc') {
|
||||
$should_be = 'Thu, 10/07/2010 - 21:30 to 22:30';
|
||||
}
|
||||
else {
|
||||
$should_be = 'Thu, 10/07/2010 - 10:30 to 11:30';
|
||||
}
|
||||
break;
|
||||
case 'second':
|
||||
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30:30';
|
||||
$edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11:30:30';
|
||||
$should_be = 'Thu, 10/07/2010 - 10:30:30 to 11:30:30';
|
||||
if ($tz_handling == 'utc') {
|
||||
$should_be = 'Thu, 10/07/2010 - 21:30:30 to 22:30:30';
|
||||
}
|
||||
else {
|
||||
$should_be = 'Thu, 10/07/2010 - 10:30:30 to 11:30:30';
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->drupalPost('node/add/story', $edit, t('Save'));
|
||||
|
Reference in New Issue
Block a user