security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -1,9 +1,67 @@
|
||||
Date Module 7.x
|
||||
=================
|
||||
|
||||
===================
|
||||
Version 7.x-2.x-dev
|
||||
===================
|
||||
======================
|
||||
Version 7.x-2.8
|
||||
======================
|
||||
- Issue #106713 by vijaycs85, heddn: Date Field title XSS(SA)
|
||||
- Issue #2310123 by Temoor: Fixed Fatal error in Migrate UI by Date Migrate Example.
|
||||
- Issue #2142277 by Temoor | lliss: Fixed Infinite Loop When Using Repeating Dates.
|
||||
- Issue #1871136 by Temoor | funkimunky: Fixed Cannot remove migrate example content type.
|
||||
- Issue #2261395 by minorOffense | kristofferwiklund: Fixed date_now is not respecting changes to timezone.
|
||||
- Issue #1832400 by imot3k, balintk: Fixed "The year/month/... is missing" error message is not translatable.
|
||||
- Issue #998076 by coredumperror, joelcollinsdc, brenk28: Fixed Problem with timezone handling (caused by date_get_timezone_db returning only UTC).
|
||||
- Issue #1976014 by Harmageddon: Remove unnecessary in date views pager.
|
||||
- Issue #2198807 by stickywes: Refactor field tests to utilize DateFieldBasic.
|
||||
- Issue #2146461 by vijaycs85 | Razia_b: Fixed Translated field's label is not used in its validation messages.
|
||||
- Issue #1874422 by bluetegu, brockfanning, rv0: Fixed Week pager may cause incorrect "next" link on year change.
|
||||
- Issue #2167015 by schifazl: HTML output breaks validation and accessibility.
|
||||
- Issue #2200513 by scor: Fix encoding issues in CHANGELOG.txt.
|
||||
- Issue #2115377 by coredumperror: Notice: Undefined index: add_microdata in theme_date_display_single().
|
||||
- Issue #2178299 by sandykadam | joachim: Incorrect variable name in hook_views_data_alter().
|
||||
- Issue #1431952 by Cadila | Shawn DeArmond: Date field will only set in Rules if it already has a value.
|
||||
- Issue #355058 by Grimreaper | prunelle: Hardcoded day/month/week output format for theme_date_nav_title().
|
||||
- Issue #1968828 by pjcdawkins: Replace field_info_fields() with field_info_field_map() for Drupal >= 7.22.
|
||||
- Issue #2167033 by podarok, vijaycs85: Fixing tests in 2014 .
|
||||
|
||||
======================
|
||||
Version 7.x-2.7
|
||||
======================
|
||||
- Issue #1691342 by Cyberwolf: Field description is displayed multiple times.
|
||||
- Issue #1668240 by ianthomas_uk: /themes/jquery.timeentry.css is not aggregated with other CSS files.
|
||||
- Issue #1974056 by pjcdawkins: Add a CSS class to the date repeat rule.
|
||||
- Issue #2065749 by vijaycs85, blackdog: $class in theme_date_repeat_rrule is not used.
|
||||
- Issue #1840008 by cr0ss, Alan D.: Unlock "Date attributes" (granularity) field setting.
|
||||
- Issue #1580032 by jmuzz | 30equals: Date values are not being saved when field is used in a nested field collection.
|
||||
- Issue #2071629 by blackdog: #after_build wrongly added, overwrites other modules.
|
||||
- Issue #1869962 by kaidjohnson: Date Context breaks context edit form.
|
||||
- Issue #1571258 by David_Rothstein | ddalvi: Date and time form elements do not have accessible labels when the label position is set to 'Within' or 'None'.
|
||||
- Issue #2130575 by kostajh: Unset() should be used with more caution in views_filter_handler_simple().inc.
|
||||
- Issue #1826598 by eromba, jyee: 'c' and 'r' formatter causes date to be printed twice in views.
|
||||
- Issue #1933472 by minorOffense: Added Optimize date_now() function.
|
||||
- Issue #1248786 by kenneth.venken | dboulet: Fixed appearance of marker for required date fields.
|
||||
- Issue #1810734 by ParisLiakos: Fixed Repeat checkboxes working reversed with updated jQuery.
|
||||
- Issue #1844092 by dboulet, kardave, Spleshka: Fixed Untranslated strings: month, day, ...
|
||||
- Issue #1202248 by james.williams, dawehner, mikehues | DamienMcKenna: Fixed Exported view doesn't include 'default_argument_options()' attribute.
|
||||
- Issue #1409120 by anrikun, akamustang | marsbidon: Added Date format in views exposed filter does not respect configured format.
|
||||
- Issue #1858112 by tomdearden: Fixed DateObject->difference not calculating correctly for future dates > 1 year away.
|
||||
- Issue #1659466 by artkon: Fixed Date filter does not remember value in views if the identifier is something other than date_filter().
|
||||
- Issue #1905096 by gielfeldt: Fixed Wrong usage of database API.
|
||||
- Issue #1791804 by 5n00py: Errors on form validation if date field placed in sub-form.
|
||||
- Issue #636208 Date range: Expose a single filter to select events that start before the chosen date and end after the chosen date by anrikun.
|
||||
- Issue #2024269 Date popup documentation fix by RoySegall.
|
||||
- Issue #1835184 by Steven Jones, das-peter, jwhat: Fixed date_limit_format() can have poor performance.
|
||||
- Issue #991830 by milesw | restyler: Fixed validation errors when date_popup() date is localized.
|
||||
- Issue #2098715 by jhodgdon: Fixed Date field not obeying widget alters for #required.
|
||||
- Issue #1266688 by linclark, rbayliss, fago, colette: Support microdata in date fields.
|
||||
- Issue #1863610 by maximpodorov: Fixed Invalid date formatting.
|
||||
- META #2034231 #1832544 Class registration for Migrate 2.5 or later - mikeryan, [#1835214] Automated tests failing - Exception thrown in Date2 migration - PatchRanger, [#
|
||||
- Issue #1350604 by Alan D., johaziel: Added Diff support for Date fields.
|
||||
- Issue #2086313 by dooug: Fixed Wrong path in date_popup() README.txt
|
||||
- Issue #1455558 by BTMash | mediameriquat: Fixed Missing file in date_views().info causes error 500.
|
||||
- Issue #1697322 by Alan D., ianmthomasuk | pandikamal: Fixed Call to a member function getName() on a non-object in date api.
|
||||
- Code cleanup, remove #prev values that were never used in repeat functionality.
|
||||
- Small fix needed to ensure cardinality gets set correctly if repeat option is changed in the UI.
|
||||
|
||||
======================
|
||||
Version 7.x-2.6
|
||||
@@ -110,7 +168,7 @@ Version 7.x-2.1
|
||||
|
||||
- Issue #1437242 by zerbash, Remove extraneous leading slashes in module_load_include().
|
||||
- Issue #1436722 by hefox: Fixed Undefined variable $form_set_error() used as function.
|
||||
- Issue #1250626 by G<EFBFBD>bor Hojtsy, B-Prod, hefox: Added start date and end date labels.
|
||||
- Issue #1250626 by Gábor Hojtsy, B-Prod, hefox: Added start date and end date labels.
|
||||
- Issue #1253482, Make sure $argument->is_default gets reset by the Date pager when altering results.
|
||||
- Adjust Date Tools to work with changes to use Views templates to create calendars.
|
||||
- Issue #1398584 by dhalbert and , Make sure groupby times is initialized.
|
||||
@@ -194,7 +252,7 @@ The Date Browser has been removed. Please use the Date Pager instead. If you hav
|
||||
Browser the navigation will just disappear from them. If you add a Date Pager to the view you should get it back.
|
||||
Then delete the Date Browser attachment from the view, since it doesn't do anything any more.
|
||||
|
||||
The UNTIL date was not getting included in repeating results and that is now fixed. This is an API change of sorts
|
||||
The UNTIL date was not getting included in repeating results and that is now fixed. This is an API change of sorts
|
||||
for anyone who worked around the issue by setting it ahead.
|
||||
|
||||
The All Day checkbox and All Day themes were moved into a separate module, using new hooks added to the date
|
||||
@@ -219,7 +277,7 @@ New Features/Major Changes
|
||||
Bugfixes
|
||||
|
||||
- Fix to new default date handling, the default date has to set a date in the database timezone, not the display timezone.
|
||||
- Issue #1245106 by G<EFBFBD>bor Hojtsy, Hide the option to add the delta into the view for single value fields.
|
||||
- Issue #1245106 by Gábor Hojtsy, Hide the option to add the delta into the view for single value fields.
|
||||
- Issue #1370876, Make sure new Date All Day code does not try to set the popup values if Date Popup is disabled.
|
||||
- Issue #874322, Add back the date_field_all_day() function to avoid breaking other modules that are using it.
|
||||
- Fix Date text placeholder to display a formatted date instead of a format. Follow up to Date repeat UI changes.
|
||||
@@ -316,7 +374,7 @@ Bugfixes
|
||||
- Issue #1179715, Default value callback for the timezone widget was not returning an array.
|
||||
- Issue #1179716, Remove value_callback for date_repeat and date_combo forms, the default behavior works fine.
|
||||
- Issue #1178716 by das-peter, Use drupal_array_get_nested_value() in Date Repeat instead of trying to find it manually.
|
||||
- Issue #1178716 by das-peter and KarenS, Tweak the date repeat widget to identify empty input when used on nodes with translation.
|
||||
- Issue #1178716 by das-peter and KarenS, Tweak the date repeat widget to identify empty input when used on nodes with translation.
|
||||
- Issue #1178716 by das-peter and KarenS, Fix date repeat form values that are not arrays when hidden on a node that has translation.
|
||||
- Issue #1178176 by das-peter, Fix date_combo_value_callback to return NULL to avoid data lost on untranslatable dates used with Entity Translation.
|
||||
- Date Context module was making incorrect assumptions about the $language of the field.
|
||||
@@ -350,7 +408,7 @@ field settings. Previous versions did not always honor those settings, this one
|
||||
|
||||
New Features/UX Improvements
|
||||
|
||||
- Issue #1249724 by KarenS, G<EFBFBD>bor Hojtsy, David_Rothstein, Improve usability of date and time input configuration.
|
||||
- Issue #1249724 by KarenS, Gábor Hojtsy, David_Rothstein, Improve usability of date and time input configuration.
|
||||
- Issue #1250784 by David_Rothstein, Add user-friendly labels for start and end date values in Views.
|
||||
- Issue #742146, Add option to remove X-WR-CALNAME if VEVENT is not a feed.
|
||||
- Add option to change method from PUBLISH to REQUEST in VCALENDAR.
|
||||
@@ -360,8 +418,8 @@ New Features/UX Improvements
|
||||
- Issue #1249724 by David_Rothstein: Improve usability of date and time input configuration
|
||||
- Issue #1177198 by tim.plunkett: Allow CTools to process #dependency for date elements.
|
||||
- Issue #1245562 by David_Rothstein, Rename the default date display format to something friendlier
|
||||
- Issue #1239934 by David_Rothstein and G<EFBFBD>bor Hojtsy, Reuse the "years back and forward" dropdown widget on the Views filter settings page.
|
||||
- Issue #1239228 by G<EFBFBD>bor Hojtsy, Date Views filter form UI improvements, clarify the way absolute and relative dates work.
|
||||
- Issue #1239934 by David_Rothstein and Gábor Hojtsy, Reuse the "years back and forward" dropdown widget on the Views filter settings page.
|
||||
- Issue #1239228 by Gábor Hojtsy, Date Views filter form UI improvements, clarify the way absolute and relative dates work.
|
||||
- Issue #233047 by ksenzee and David_Rothstein, Add the Vegas jQuery timepicker as a new time selector option.
|
||||
- Issue #1145976 by tim.plunkett and KarenS, Add 'is date' identifier to all date handlers.
|
||||
- Issue #1234140 by arlinsundbulte, Change terminology in user-facing text from 'From/To Date' to 'Start/End Date'.
|
||||
@@ -408,10 +466,10 @@ Bugfixes
|
||||
- Issue #1254582 Repeat additions need to be adjusted to use the same time as the original date.
|
||||
- Move vcalendar and vevent templates from Date Views to Date API modules.
|
||||
- Follow up to Issue #1250344, We don't need extra space when there is a description, only when there is not.
|
||||
- Issue #1239228 by G<EFBFBD>bor Hojtsy, More tweaks to filter css.
|
||||
- Issue #1244924 by G<EFBFBD>bor Hojtsy, Minor text improvements in date filter configuration
|
||||
- Issue #1239228 by Gábor Hojtsy, More tweaks to filter css.
|
||||
- Issue #1244924 by Gábor Hojtsy, Minor text improvements in date filter configuration
|
||||
- Issue #1245556 by David_Rothstein, Date granularity description incorrectly implies that it affects the date attributes that are displayed
|
||||
- Issue #1247444 by G<EFBFBD>bor Hojtsy, Give a little breathing space to the date year range "other" field
|
||||
- Issue #1247444 by Gábor Hojtsy, Give a little breathing space to the date year range "other" field
|
||||
- Issue #1250344 by jessebeach, Fix padding around date fields by adding clearfix class.
|
||||
- Issue #1249116 by yched, Fix various glitches with D6 migration code.
|
||||
- Issue #1243022 by fmosca and KarenS, Make sure all_day #states visibility is only set when there is a value for all_day.
|
||||
@@ -419,7 +477,7 @@ Bugfixes
|
||||
- Issue #1246416, Test whether libraries_get_path() returns a valid path before using it.
|
||||
- Issue #1235994, Don't display 'All Day' when using a format that has no time.
|
||||
- Issue #1245690 by mikeryan, Migration plugin missing seconds from date formats
|
||||
- Issue #1229406 by David Rothstein, G<EFBFBD>bor Hojtsy, and tim.plunkett Fix broken timepicker in Chrome and Safari.
|
||||
- Issue #1229406 by David Rothstein, Gábor Hojtsy, and tim.plunkett Fix broken timepicker in Chrome and Safari.
|
||||
- Issue #1239412 by keithm, Fix validation error when #access is false.
|
||||
- Issue #1232522, Don't alter field_ui_field_edit form except on date fields.
|
||||
- Issue #1243842, Make sure the All Day and Show End Date flags work correctly in unlimited value fields that use ajax.
|
||||
|
@@ -344,9 +344,6 @@ function hook_date_combo_process_alter(&$element, &$form_state, $context) {
|
||||
'#date_increment' => $instance['widget']['settings']['increment'],
|
||||
'#date_year_range' => $instance['widget']['settings']['year_range'],
|
||||
'#date_label_position' => $instance['widget']['settings']['label_position'],
|
||||
'#prev_value' => isset($item['value']) ? $item['value'] : '',
|
||||
'#prev_value2' => isset($item['value2']) ? $item['value2'] : '',
|
||||
'#prev_rrule' => isset($item['rrule']) ? $item['rrule'] : '',
|
||||
'#date_repeat_widget' => str_replace('_repeat', '', $instance['widget']['type']),
|
||||
'#date_repeat_collapsed' => $instance['widget']['settings']['repeat_collapsed'],
|
||||
'#date_flexible' => 0,
|
||||
|
79
sites/all/modules/contrib/fields/date/date.diff.inc
Normal file
79
sites/all/modules/contrib/fields/date/date.diff.inc
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff field functions for the Date module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing date fields comparative values.
|
||||
*/
|
||||
function date_field_diff_view($items, $context) {
|
||||
$diff_items = array();
|
||||
$display = $context['display'];
|
||||
$display['settings']['format_type'] = $context['settings']['format_type'];
|
||||
$display['settings']['fromto'] = $context['settings']['fromto'];
|
||||
foreach ($items as $delta => $item) {
|
||||
$date = date_formatter_process('date_default', $context['entity_type'], $context['entity'], $context['field'], $context['instance'], $context['language'], $item, $display);
|
||||
switch ($display['settings']['fromto']) {
|
||||
case 'both':
|
||||
if ($date['value']['formatted'] != $date['value2']['formatted']) {
|
||||
$diff_items[$delta] = t('@from to @to', array(
|
||||
'@from' => $date['value']['formatted'],
|
||||
'@to' => $date['value2']['formatted'],
|
||||
));
|
||||
}
|
||||
else {
|
||||
$diff_items[$delta] = $date['value']['formatted'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'value':
|
||||
case 'value2':
|
||||
$diff_items[$delta] = $date[$display['settings']['fromto']]['formatted'];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return $diff_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default field comparison options.
|
||||
*/
|
||||
function date_field_diff_default_options($field_type) {
|
||||
return array(
|
||||
'format_type' => 'long',
|
||||
'fromto' => 'both',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting the field comparison options.
|
||||
*/
|
||||
function date_field_diff_options_form($field_type, $settings) {
|
||||
$options_form = array();
|
||||
|
||||
$form['format_type'] = array(
|
||||
'#title' => t('Choose how render dates and times'),
|
||||
'#type' => 'select',
|
||||
'#options' => date_format_type_options(),
|
||||
'#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['fromto'] = array(
|
||||
'#title' => t('Display'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'both' => t('Both Start and End dates'),
|
||||
'value' => t('Start date only'),
|
||||
'value2' => t('End date only'),
|
||||
),
|
||||
'#default_value' => $settings['fromto'],
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
return $options_form;
|
||||
}
|
@@ -125,8 +125,16 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
||||
'attributes' => array(),
|
||||
'rdf_mapping' => array(),
|
||||
'add_rdf' => module_exists('rdf'),
|
||||
'microdata' => array(),
|
||||
'add_microdata' => module_exists('microdata'),
|
||||
);
|
||||
|
||||
// If the microdata module is enabled, the microdata mapping will have been
|
||||
// passed in via the entity.
|
||||
if ($variables['add_microdata'] && isset($entity->microdata[$field['field_name']])) {
|
||||
$variables['microdata'] = $entity->microdata[$field['field_name']];
|
||||
}
|
||||
|
||||
// If there is an RDf mapping for this date field, pass it down to the theme.
|
||||
$rdf_mapping = array();
|
||||
if (!empty($entity->rdf_mapping) && function_exists('rdf_rdfa_attributes')) {
|
||||
|
@@ -4,15 +4,17 @@ dependencies[] = date_api
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
php = 5.2
|
||||
files[] = date.migrate.inc
|
||||
files[] = tests/date_api.test
|
||||
files[] = tests/date.test
|
||||
files[] = tests/date_field.test
|
||||
files[] = tests/date_migrate.test
|
||||
files[] = tests/date_validation.test
|
||||
files[] = tests/date_timezone.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -5,6 +5,17 @@
|
||||
* Support for migration into Date fields.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
function date_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
'field handlers' => array('DateMigrateFieldHandler'),
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
|
||||
class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
|
||||
/**
|
||||
@@ -57,37 +68,47 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
$arguments = array();
|
||||
}
|
||||
|
||||
if (isset($arguments['timezone'])) {
|
||||
$default_timezone = $arguments['timezone'];
|
||||
}
|
||||
else {
|
||||
$default_timezone = 'UTC';
|
||||
}
|
||||
if (isset($arguments['timezone_db'])) {
|
||||
$default_timezone_db = $arguments['timezone_db'];
|
||||
}
|
||||
else {
|
||||
$default_timezone_db = NULL;
|
||||
}
|
||||
if (isset($arguments['rrule'])) {
|
||||
$default_rrule = $arguments['rrule'];
|
||||
}
|
||||
else {
|
||||
$default_rrule = NULL;
|
||||
}
|
||||
$language = $this->getFieldLanguage($entity, $field_info, $arguments);
|
||||
|
||||
// Setup the standard Field API array for saving.
|
||||
$delta = 0;
|
||||
foreach ($values as $from) {
|
||||
// Set defaults.
|
||||
$to = NULL;
|
||||
$timezone = $default_timezone;
|
||||
$timezone_db = $default_timezone_db;
|
||||
$rrule = $default_rrule;
|
||||
foreach ($values as $delta => $from) {
|
||||
if (!empty($arguments['timezone'])) {
|
||||
if (is_array($arguments['timezone'])) {
|
||||
$timezone = $arguments['timezone'][$delta];
|
||||
}
|
||||
else {
|
||||
$timezone = $arguments['timezone'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$timezone = 'UTC';
|
||||
}
|
||||
|
||||
// Is the value a straight datetime value, or JSON containing a set of
|
||||
// properties?
|
||||
if (!empty($arguments['rrule'])) {
|
||||
if (is_array($arguments['rrule'])) {
|
||||
$rrule = $arguments['rrule'][$delta];
|
||||
}
|
||||
else {
|
||||
$rrule = $arguments['rrule'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$rrule = NULL;
|
||||
}
|
||||
|
||||
if (!empty($arguments['to'])) {
|
||||
if (is_array($arguments['to'])) {
|
||||
$to = $arguments['to'][$delta];
|
||||
}
|
||||
else {
|
||||
$to = $arguments['to'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$to = NULL;
|
||||
}
|
||||
|
||||
// Legacy support for JSON containing a set of properties - deprecated
|
||||
// now that we have subfields.
|
||||
if (!empty($from) && $from{0} == '{') {
|
||||
$properties = drupal_json_decode($from);
|
||||
$from = $properties['from'];
|
||||
@@ -98,9 +119,6 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
if (!empty($properties['timezone'])) {
|
||||
$timezone = $properties['timezone'];
|
||||
}
|
||||
if (!empty($properties['timezone_db'])) {
|
||||
$timezone_db = $properties['timezone_db'];
|
||||
}
|
||||
if (!empty($properties['rrule'])) {
|
||||
$rrule = $properties['rrule'];
|
||||
}
|
||||
@@ -165,11 +183,18 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
$return[$language][$delta]['value2'] = $to;
|
||||
}
|
||||
}
|
||||
$delta++;
|
||||
}
|
||||
if (!isset($return)) {
|
||||
$return = NULL;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function fields($migration = NULL) {
|
||||
return array(
|
||||
'timezone' => t('Timezone'),
|
||||
'rrule' => t('Recurring event rule'),
|
||||
'to' => t('End date date'),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines date/time field types.
|
||||
*/
|
||||
|
||||
module_load_include('theme', 'date', 'date');
|
||||
module_load_include('inc', 'date', 'date.field');
|
||||
module_load_include('inc', 'date', 'date_elements');
|
||||
@@ -78,6 +76,8 @@ function date_theme() {
|
||||
'attributes' => array(),
|
||||
'rdf_mapping' => NULL,
|
||||
'add_rdf' => NULL,
|
||||
'microdata' => NULL,
|
||||
'add_microdata' => NULL,
|
||||
),
|
||||
),
|
||||
'date_display_range' => $base + array(
|
||||
@@ -95,6 +95,8 @@ function date_theme() {
|
||||
'attributes_end' => array(),
|
||||
'rdf_mapping' => NULL,
|
||||
'add_rdf' => NULL,
|
||||
'microdata' => NULL,
|
||||
'add_microdata' => NULL,
|
||||
)),
|
||||
'date_display_combination' => $base + array(
|
||||
'variables' => array(
|
||||
@@ -110,6 +112,8 @@ function date_theme() {
|
||||
'attributes' => array(),
|
||||
'rdf_mapping' => NULL,
|
||||
'add_rdf' => NULL,
|
||||
'microdata' => NULL,
|
||||
'add_microdata' => NULL,
|
||||
),
|
||||
),
|
||||
'date_display_interval' => $base + array(
|
||||
@@ -247,7 +251,7 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
|
||||
elseif ($format == 'format_calendar_day') {
|
||||
$dates[$processed]['calendar_day'] = date_format_calendar_day($date);
|
||||
}
|
||||
elseif ($format == 'U') {
|
||||
elseif ($format == 'U' || $format == 'r' || $format == 'c') {
|
||||
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format);
|
||||
$dates[$processed]['formatted_date'] = date_format_date($date, 'custom', $format);
|
||||
$dates[$processed]['formatted_time'] = '';
|
||||
@@ -532,6 +536,7 @@ function date_entity_metadata_property_info_alter(&$info, $entity_type, $field,
|
||||
if (!empty($field['settings']['todate'])) {
|
||||
// Define a simple data structure containing both dates.
|
||||
$property['type'] = ($field['cardinality'] != 1) ? 'list<struct>' : 'struct';
|
||||
$property['auto creation'] = 'date_entity_metadata_struct_create';
|
||||
$property['getter callback'] = 'entity_metadata_field_verbatim_get';
|
||||
$property['setter callback'] = 'entity_metadata_field_verbatim_set';
|
||||
$property['property info'] = array(
|
||||
@@ -543,6 +548,8 @@ function date_entity_metadata_property_info_alter(&$info, $entity_type, $field,
|
||||
// The getter and setter callbacks for 'value' and 'value2'
|
||||
// will not provide the field name as $name, we'll add it to $info.
|
||||
'field_name' => $field['field_name'],
|
||||
// Alert Microdata module that this value can be exposed in microdata.
|
||||
'microdata' => TRUE,
|
||||
),
|
||||
'value2' => array(
|
||||
'type' => 'date',
|
||||
@@ -552,6 +559,8 @@ function date_entity_metadata_property_info_alter(&$info, $entity_type, $field,
|
||||
// The getter and setter callbacks for 'value' and 'value2'
|
||||
// will not provide the field name as $name, we'll add it to $info.
|
||||
'field_name' => $field['field_name'],
|
||||
// Alert Microdata module that this value can be exposed in microdata.
|
||||
'microdata' => TRUE,
|
||||
),
|
||||
'duration' => array(
|
||||
'type' => 'duration',
|
||||
@@ -566,6 +575,11 @@ function date_entity_metadata_property_info_alter(&$info, $entity_type, $field,
|
||||
);
|
||||
unset($property['query callback']);
|
||||
}
|
||||
else {
|
||||
// If this doesn't have a todate, it is handled as a date rather than a
|
||||
// struct. Enable microdata on the field itself rather than the properties.
|
||||
$property['microdata'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,6 +646,16 @@ function date_entity_metadata_field_setter(&$entity, $name, $value, $langcode, $
|
||||
drupal_static_reset('field_language');
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto creation callback for fields which contain two date values in one
|
||||
*/
|
||||
function date_entity_metadata_struct_create($name, $property_info) {
|
||||
return array(
|
||||
'date_type' => $property_info['field']['columns'][$name]['type'],
|
||||
'timezone_db' => $property_info['field']['settings']['timezone_db'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for setting an individual field value if a to-date may be there too.
|
||||
* Based on entity_property_verbatim_set().
|
||||
|
@@ -74,6 +74,8 @@ function theme_date_display_combination($variables) {
|
||||
$attributes = $variables['attributes'];
|
||||
$rdf_mapping = $variables['rdf_mapping'];
|
||||
$add_rdf = $variables['add_rdf'];
|
||||
$microdata = $variables['microdata'];
|
||||
$add_microdata = $variables['add_microdata'];
|
||||
$precision = date_granularity_precision($field['settings']['granularity']);
|
||||
|
||||
$output = '';
|
||||
@@ -162,6 +164,8 @@ function theme_date_display_combination($variables) {
|
||||
'attributes' => $attributes,
|
||||
'rdf_mapping' => $rdf_mapping,
|
||||
'add_rdf' => $add_rdf,
|
||||
'microdata' => $microdata,
|
||||
'add_microdata' => $add_microdata,
|
||||
'dates' => $dates,
|
||||
));
|
||||
}
|
||||
@@ -179,6 +183,8 @@ function theme_date_display_combination($variables) {
|
||||
'attributes' => $attributes,
|
||||
'rdf_mapping' => $rdf_mapping,
|
||||
'add_rdf' => $add_rdf,
|
||||
'microdata' => $microdata,
|
||||
'add_microdata' => $add_microdata,
|
||||
'dates' => $dates,
|
||||
));
|
||||
$replaced = str_replace($time1, $time, $date1);
|
||||
@@ -200,6 +206,8 @@ function theme_date_display_combination($variables) {
|
||||
'attributes' => $attributes,
|
||||
'rdf_mapping' => $rdf_mapping,
|
||||
'add_rdf' => $add_rdf,
|
||||
'microdata' => $microdata,
|
||||
'add_microdata' => $add_microdata,
|
||||
'dates' => $dates,
|
||||
));
|
||||
}
|
||||
@@ -211,7 +219,7 @@ function theme_date_display_combination($variables) {
|
||||
* Template preprocess function for displaying a single date.
|
||||
*/
|
||||
function template_preprocess_date_display_single(&$variables) {
|
||||
if ($variables['add_rdf']) {
|
||||
if ($variables['add_rdf'] || !empty($variables['add_microdata'])) {
|
||||
// Pass along the rdf mapping for this field, if any. Add some default rdf
|
||||
// attributes that will be used if not overridden by attributes passed in.
|
||||
$rdf_mapping = $variables['rdf_mapping'];
|
||||
@@ -222,6 +230,24 @@ function template_preprocess_date_display_single(&$variables) {
|
||||
);
|
||||
$variables['attributes'] = $variables['attributes'] + $base_attributes;
|
||||
}
|
||||
|
||||
// Pass along microdata attributes, or set display to false if none are set.
|
||||
if (!empty($variables['add_microdata'])) {
|
||||
// Because the Entity API integration for Date has a variable data
|
||||
// structure depending on whether there is an end value, the attributes
|
||||
// could be attached to the field or to the value property.
|
||||
if(!empty($variables['microdata']['#attributes']['itemprop'])) {
|
||||
$variables['microdata']['value']['#attributes'] = $variables['microdata']['#attributes'];
|
||||
}
|
||||
|
||||
// Add the machine readable time using the content attribute.
|
||||
if(!empty($variables['microdata']['value']['#attributes'])) {
|
||||
$variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso'];
|
||||
}
|
||||
else {
|
||||
$variables['add_microdata'] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +259,13 @@ function theme_date_display_single($variables) {
|
||||
$attributes = $variables['attributes'];
|
||||
|
||||
// Wrap the result with the attributes.
|
||||
return '<span class="date-display-single"' . drupal_attributes($attributes) . '>' . $date . $timezone . '</span>';
|
||||
$output = '<span class="date-display-single"' . drupal_attributes($attributes) . '>' . $date . $timezone . '</span>';
|
||||
|
||||
if (!empty($variables['add_microdata'])) {
|
||||
$output .= '<meta' . drupal_attributes($variables['microdata']['value']['#attributes']) . '/>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +279,6 @@ function template_preprocess_date_display_range(&$variables) {
|
||||
if ($variables['add_rdf']) {
|
||||
// Pass along the rdf mapping for this field, if any. Add some default rdf
|
||||
// attributes that will be used if not overridden by attributes passed in.
|
||||
$rdf_mapping = $variables['rdf_mapping'];
|
||||
$dates = $variables['dates'];
|
||||
$base_attributes = array(
|
||||
'property' => array('dc:date'),
|
||||
@@ -261,6 +292,17 @@ function template_preprocess_date_display_range(&$variables) {
|
||||
$variables['attributes_end']['property'][$delta] = str_replace('start', 'end', $property);
|
||||
}
|
||||
}
|
||||
|
||||
// Pass along microdata attributes, or set display to false if none are set.
|
||||
if ($variables['add_microdata']) {
|
||||
if (!empty($variables['microdata']['value']['#attributes'])) {
|
||||
$variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso'];
|
||||
$variables['microdata']['value2']['#attributes']['content'] = $variables['dates']['value2']['formatted_iso'];
|
||||
}
|
||||
else {
|
||||
$variables['add_microdata'] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,10 +315,20 @@ function theme_date_display_range($variables) {
|
||||
$attributes_start = $variables['attributes_start'];
|
||||
$attributes_end = $variables['attributes_end'];
|
||||
|
||||
$start_date = '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>';
|
||||
$end_date = '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . $timezone . '</span>';
|
||||
|
||||
// If microdata attributes for the start date property have been passed in,
|
||||
// add the microdata in meta tags.
|
||||
if (!empty($variables['add_microdata'])) {
|
||||
$start_date .= '<meta' . drupal_attributes($variables['microdata']['value']['#attributes']) . '/>';
|
||||
$end_date .= '<meta' . drupal_attributes($variables['microdata']['value2']['#attributes']) . '/>';
|
||||
}
|
||||
|
||||
// Wrap the result with the attributes.
|
||||
return t('!start-date to !end-date', array(
|
||||
'!start-date' => '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>',
|
||||
'!end-date' => '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . $timezone . '</span>',
|
||||
'!start-date' => $start_date,
|
||||
'!end-date' => $end_date,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -320,12 +372,16 @@ function theme_date_combo($variables) {
|
||||
|
||||
// Group start/end items together in fieldset.
|
||||
$fieldset = array(
|
||||
'#title' => 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'] : '',
|
||||
'#attributes' => array(),
|
||||
'#children' => $element['#children'],
|
||||
);
|
||||
// Add marker to required date fields.
|
||||
if ($element['#required']) {
|
||||
$fieldset['#title'] .= " " . theme('form_required_marker');
|
||||
}
|
||||
return theme('fieldset', array('element' => $fieldset));
|
||||
}
|
||||
|
||||
|
@@ -370,11 +370,11 @@ function _date_field_widget_settings_form($field, $instance) {
|
||||
);
|
||||
if (in_array($widget['type'], array('date_select'))) {
|
||||
$options = array('above' => t('Above'), 'within' => t('Within'), 'none' => t('None'));
|
||||
$description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'Within' inserts the label as the first option in the select list and in blank textfields. 'None' doesn't label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text.");
|
||||
$description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'Within' inserts the label as the first option in the select list and in blank textfields. 'None' doesn't visually label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text.");
|
||||
}
|
||||
else {
|
||||
$options = array('above' => t('Above'), 'none' => t('None'));
|
||||
$description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'None' doesn't label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text.");
|
||||
$description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'None' doesn't visually label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text.");
|
||||
}
|
||||
$form['advanced']['label_position'] = array(
|
||||
'#type' => 'radios',
|
||||
@@ -453,6 +453,9 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
$tz_handling = $settings['tz_handling'];
|
||||
|
||||
$description = t('Select the date attributes to collect and store.');
|
||||
if ($has_data) {
|
||||
$description .= ' ' . t('Changes to date attributes only effects new or updated content.');
|
||||
}
|
||||
$options = date_granularity_names();
|
||||
$checkbox_year = array(
|
||||
'#type' => 'checkbox',
|
||||
@@ -469,7 +472,6 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
'#options' => $options,
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#description' => $description,
|
||||
'#disabled' => $has_data,
|
||||
'year' => $checkbox_year,
|
||||
);
|
||||
|
||||
@@ -499,7 +501,6 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
'#default_value' => $tz_handling,
|
||||
'#options' => date_timezone_handling_options(),
|
||||
'#description' => $description,
|
||||
'#disabled' => $has_data,
|
||||
'#attached' => array(
|
||||
'js' => array(drupal_get_path('module', 'date') . '/date_admin.js'),
|
||||
),
|
||||
|
@@ -5,9 +5,9 @@ dependencies[] = date
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -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 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -276,18 +276,17 @@ class DateObject extends DateTime {
|
||||
$this->setGranularityFromTime($time, $tz);
|
||||
}
|
||||
}
|
||||
// If this tz was given as just an offset or the timezone
|
||||
// was invalid, we need to do some tweaking.
|
||||
|
||||
// If we haven't got a valid timezone name yet, we need to set one or
|
||||
// we will get undefined index errors.
|
||||
// This can happen if $time had an offset or no timezone.
|
||||
if (!$this->getTimezone() || !preg_match('/[a-zA-Z]/', $this->getTimezone()->getName())) {
|
||||
|
||||
// If the timezone name is an offset and the original
|
||||
// $tz has a name, use it. This happens if you pass in
|
||||
// a date string with an offset along with a specific timezone name.
|
||||
if (!preg_match('/[a-zA-Z]/', $this->getTimezone()->getName()) && preg_match('/[a-zA-Z]/', $tz->getName())) {
|
||||
// If the original $tz has a name, use it.
|
||||
if (preg_match('/[a-zA-Z]/', $tz->getName())) {
|
||||
$this->setTimezone($tz);
|
||||
}
|
||||
// If we get this far, we have no information about the timezone name,
|
||||
// but we will get undefined index errors without any name.
|
||||
// We have no information about the timezone so must fallback to a default.
|
||||
else {
|
||||
$this->setTimezone(new DateTimeZone("UTC"));
|
||||
$this->errors['timezone'] = t('No valid timezone name was provided.');
|
||||
@@ -459,8 +458,27 @@ class DateObject extends DateTime {
|
||||
$true = $this->hasGranularity() && (!$granularity || $flexible || $this->hasGranularity($granularity));
|
||||
if (!$true && $granularity) {
|
||||
foreach ((array) $granularity as $part) {
|
||||
if (!$this->hasGranularity($part)) {
|
||||
$this->errors[$part] = t("The @part is missing.", array('@part' => $part));
|
||||
if (!$this->hasGranularity($part) && in_array($part, array('second', 'minute', 'hour', 'day', 'month', 'year'))) {
|
||||
switch ($part) {
|
||||
case 'second':
|
||||
$this->errors[$part] = t('The second is missing.');
|
||||
break;
|
||||
case 'minute':
|
||||
$this->errors[$part] = t('The minute is missing.');
|
||||
break;
|
||||
case 'hour':
|
||||
$this->errors[$part] = t('The hour is missing.');
|
||||
break;
|
||||
case 'day':
|
||||
$this->errors[$part] = t('The day is missing.');
|
||||
break;
|
||||
case 'month':
|
||||
$this->errors[$part] = t('The month is missing.');
|
||||
break;
|
||||
case 'year':
|
||||
$this->errors[$part] = t('The year is missing.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -574,7 +592,7 @@ class DateObject extends DateTime {
|
||||
$regex2 = preg_replace($patterns, $repl2, $format_regexp, 1);
|
||||
$regex2 = str_replace('A', '(AM|PM)', $regex2);
|
||||
$regex2 = str_replace('a', '(am|pm)', $regex2);
|
||||
preg_match('`^' . $regex2 . '$`', $date, $values);
|
||||
preg_match('`^' . $regex2 . '$`u', $date, $values);
|
||||
array_shift($values);
|
||||
// If we did not find all the values for the patterns in the format, abort.
|
||||
if (count($letters) != count($values)) {
|
||||
@@ -951,6 +969,11 @@ class DateObject extends DateTime {
|
||||
if ($year_diff == 0) {
|
||||
return intval($item2 - $item1);
|
||||
}
|
||||
elseif ($year_diff < 0) {
|
||||
$item_diff = 0 - $item1;
|
||||
$item_diff -= intval((abs($year_diff) - 1) * 12);
|
||||
return $item_diff - (12 - $item2);
|
||||
}
|
||||
else {
|
||||
$item_diff = 12 - $item1;
|
||||
$item_diff += intval(($year_diff - 1) * 12);
|
||||
@@ -965,6 +988,14 @@ class DateObject extends DateTime {
|
||||
if ($year_diff == 0) {
|
||||
return intval($item2 - $item1);
|
||||
}
|
||||
elseif ($year_diff < 0) {
|
||||
$item_diff = 0 - $item1;
|
||||
for ($i = 1; $i < abs($year_diff); $i++) {
|
||||
date_modify($date1, '-1 year');
|
||||
$item_diff -= date_days_in_year($date1);
|
||||
}
|
||||
return $item_diff - (date_days_in_year($date2) - $item2);
|
||||
}
|
||||
else {
|
||||
$item_diff = date_days_in_year($date1) - $item1;
|
||||
for ($i = 1; $i < $year_diff; $i++) {
|
||||
@@ -978,9 +1009,12 @@ class DateObject extends DateTime {
|
||||
case 'weeks':
|
||||
$week_diff = date_format($date2, 'W') - date_format($date1, 'W');
|
||||
$year_diff = date_format($date2, 'o') - date_format($date1, 'o');
|
||||
for ($i = 1; $i <= $year_diff; $i++) {
|
||||
date_modify($date1, '+1 year');
|
||||
$week_diff += date_iso_weeks_in_year($date1);
|
||||
|
||||
$sign = ($year_diff < 0) ? -1 : 1;
|
||||
|
||||
for ($i = 1; $i <= abs($year_diff); $i++) {
|
||||
date_modify($date1, (($sign > 0) ? '+': '-').'1 year');
|
||||
$week_diff += (date_iso_weeks_in_year($date1) * $sign);
|
||||
}
|
||||
return $week_diff;
|
||||
}
|
||||
@@ -1705,11 +1739,28 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) {
|
||||
* (optional) Optionally force time to a specific timezone, defaults to user
|
||||
* timezone, if set, otherwise site timezone. Defaults to NULL.
|
||||
*
|
||||
* @param boolean $reset [optional]
|
||||
* Static cache reset
|
||||
*
|
||||
* @return object
|
||||
* The current time as a date object.
|
||||
*/
|
||||
function date_now($timezone = NULL) {
|
||||
return new DateObject('now', $timezone);
|
||||
function date_now($timezone = NULL, $reset = FALSE) {
|
||||
if ($reset) {
|
||||
drupal_static_reset(__FUNCTION__ . $timezone);
|
||||
}
|
||||
|
||||
$now = &drupal_static(__FUNCTION__ . $timezone);
|
||||
|
||||
if (!isset($now)) {
|
||||
$now = new DateObject('now', $timezone);
|
||||
}
|
||||
|
||||
// Avoid unexpected manipulation of cached $now object
|
||||
// by subsequent code execution
|
||||
// @see https://drupal.org/node/2261395
|
||||
$clone = clone $now;
|
||||
return $clone;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2100,6 +2151,17 @@ function date_part_format($part, $format) {
|
||||
* The format string with all other elements removed.
|
||||
*/
|
||||
function date_limit_format($format, $granularity) {
|
||||
// Use the advanced drupal_static() pattern to improve performance.
|
||||
static $drupal_static_fast;
|
||||
if (!isset($drupal_static_fast)) {
|
||||
$drupal_static_fast['formats'] = &drupal_static(__FUNCTION__);
|
||||
}
|
||||
$formats = &$drupal_static_fast['formats'];
|
||||
$format_granularity_cid = $format .'|'. implode(',', $granularity);
|
||||
if (isset($formats[$format_granularity_cid])) {
|
||||
return $formats[$format_granularity_cid];
|
||||
}
|
||||
|
||||
// If punctuation has been escaped, remove the escaping. Done using strtr()
|
||||
// because it is easier than getting the escape character extracted using
|
||||
// preg_replace().
|
||||
@@ -2169,11 +2231,14 @@ function date_limit_format($format, $granularity) {
|
||||
// After removing the non-desired parts of the format, test if the only things
|
||||
// left are escaped, non-date, characters. If so, return nothing.
|
||||
// Using S instead of w to pick up non-ASCII characters.
|
||||
$test = trim(preg_replace('(\\\\\S{1,3})', '', $format));
|
||||
$test = trim(preg_replace('(\\\\\S{1,3})u', '', $format));
|
||||
if (empty($test)) {
|
||||
$format = '';
|
||||
}
|
||||
|
||||
// Store the return value in the static array for performance.
|
||||
$formats[$format_granularity_cid] = $format;
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
@@ -2320,26 +2385,38 @@ function date_get_timezone($handling, $timezone = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to figure out which db timezone applies to a date and select it.
|
||||
* Function to figure out which db timezone applies to a date.
|
||||
*
|
||||
* @param string $handling
|
||||
* The timezone handling.
|
||||
* @param string $timezone
|
||||
* (optional) A timezone string. Defaults to an empty string.
|
||||
* (optional) When $handling is 'date', date_get_timezone_db() returns this
|
||||
* value.
|
||||
*
|
||||
* @return string
|
||||
* The timezone string.
|
||||
*/
|
||||
function date_get_timezone_db($handling, $timezone = '') {
|
||||
function date_get_timezone_db($handling, $timezone = NULL) {
|
||||
switch ($handling) {
|
||||
case 'none':
|
||||
$timezone = date_default_timezone();
|
||||
break;
|
||||
default:
|
||||
case ('utc'):
|
||||
case ('site'):
|
||||
case ('user'):
|
||||
// These handling modes all convert to UTC before storing in the DB.
|
||||
$timezone = 'UTC';
|
||||
break;
|
||||
case ('date'):
|
||||
if ($timezone == NULL) {
|
||||
// This shouldn't happen, since it's meaning is undefined. But we need
|
||||
// to fall back to *something* that's a legal timezone.
|
||||
$timezone = date_default_timezone();
|
||||
}
|
||||
break;
|
||||
case ('none'):
|
||||
default:
|
||||
$timezone = date_default_timezone();
|
||||
break;
|
||||
}
|
||||
return $timezone > '' ? $timezone : 'UTC';
|
||||
return $timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -239,7 +239,8 @@ function date_timezone_element_process($element, &$form_state, $form) {
|
||||
$label = theme('date_part_label_timezone', array('part_type' => 'select', 'element' => $element));
|
||||
$element['timezone'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $element['#date_label_position'] == 'above' ? $label : '',
|
||||
'#title' => $label,
|
||||
'#title_display' => $element['#date_label_position'] == 'above' ? 'before' : 'invisible',
|
||||
'#options' => date_timezone_names($element['#required']),
|
||||
'#value' => $element['#value'],
|
||||
'#weight' => $element['#weight'],
|
||||
@@ -320,6 +321,8 @@ function date_text_element_process($element, &$form_state, $form) {
|
||||
$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'));
|
||||
$now = date_example_date();
|
||||
$element['date']['#title'] = t('Date');
|
||||
$element['date']['#title_display'] = 'invisible';
|
||||
$element['date']['#description'] = ' ' . t('Format: @date', array('@date' => date_format_date(date_example_date(), 'custom', $element['#date_format'])));
|
||||
$element['date']['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE;
|
||||
|
||||
@@ -585,6 +588,8 @@ function date_parts_element($element, $date, $format) {
|
||||
$sub_element[$field]['#type'] = 'textfield';
|
||||
$sub_element[$field]['#theme'] = 'date_textfield_element';
|
||||
$sub_element[$field]['#size'] = 7;
|
||||
$sub_element[$field]['#title'] = $label;
|
||||
$sub_element[$field]['#title_display'] = in_array($element['#date_label_position'], array('within', 'none')) ? 'invisible' : 'before';
|
||||
if ($element['#date_label_position'] == 'within') {
|
||||
if (!empty($sub_element[$field]['#options']) && is_array($sub_element[$field]['#options'])) {
|
||||
$sub_element[$field]['#options'] = array(
|
||||
@@ -594,20 +599,16 @@ function date_parts_element($element, $date, $format) {
|
||||
$sub_element[$field]['#default_value'] = '-' . $label;
|
||||
}
|
||||
}
|
||||
elseif ($element['#date_label_position'] != 'none') {
|
||||
$sub_element[$field]['#title'] = $label;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sub_element[$field]['#type'] = 'select';
|
||||
$sub_element[$field]['#theme'] = 'date_select_element';
|
||||
$sub_element[$field]['#title'] = $label;
|
||||
$sub_element[$field]['#title_display'] = in_array($element['#date_label_position'], array('within', 'none')) ? 'invisible' : 'before';
|
||||
if ($element['#date_label_position'] == 'within') {
|
||||
$sub_element[$field]['#options'] = array(
|
||||
'' => '-' . $label) + $sub_element[$field]['#options'];
|
||||
}
|
||||
elseif ($element['#date_label_position'] != 'none') {
|
||||
$sub_element[$field]['#title'] = $label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,9 +622,12 @@ function date_parts_element($element, $date, $format) {
|
||||
}
|
||||
|
||||
if (($hours_format == 'g' || $hours_format == 'h') && date_has_time($granularity)) {
|
||||
$label = theme('date_part_label_ampm', array('part_type' => 'ampm', 'element' => $element));
|
||||
$sub_element['ampm'] = array(
|
||||
'#type' => 'select',
|
||||
'#theme' => 'date_select_element',
|
||||
'#title' => $label,
|
||||
'#title_display' => in_array($element['#date_label_position'], array('within', 'none')) ? 'invisible' : 'before',
|
||||
'#default_value' => is_object($date) ? (date_format($date, 'G') >= 12 ? 'pm' : 'am') : '',
|
||||
'#options' => drupal_map_assoc(date_ampm($part_required)),
|
||||
'#required' => $part_required,
|
||||
@@ -631,10 +635,7 @@ function date_parts_element($element, $date, $format) {
|
||||
'#attributes' => array('class' => array('date-ampm')),
|
||||
);
|
||||
if ($element['#date_label_position'] == 'within') {
|
||||
$sub_element['ampm']['#options'] = array('' => '-' . theme('date_part_label_ampm', array('part_type' => 'ampm', 'eleement' => $element))) + $sub_element['ampm']['#options'];
|
||||
}
|
||||
elseif ($element['#date_label_position'] != 'none') {
|
||||
$sub_element['ampm']['#title'] = theme('date_part_label_ampm', array('part_type' => 'ampm', 'element' => $element));
|
||||
$sub_element['ampm']['#options'] = array('' => '-' . $label) + $sub_element['ampm']['#options'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,9 +20,8 @@
|
||||
* Correct sql string for database type.
|
||||
*/
|
||||
function date_sql_concat($array) {
|
||||
switch (db_driver()) {
|
||||
switch (Database::getConnection()->databaseType()) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
return "CONCAT(" . implode(",", $array) . ")";
|
||||
case 'pgsql':
|
||||
return implode(" || ", $array);
|
||||
@@ -39,9 +38,8 @@ function date_sql_concat($array) {
|
||||
* SQL statement to return the first non-NULL value in the list.
|
||||
*/
|
||||
function date_sql_coalesce($array) {
|
||||
switch (db_driver()) {
|
||||
switch (Database::getConnection()->databaseType()) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
case 'pgsql':
|
||||
return "COALESCE(" . implode(',', $array) . ")";
|
||||
}
|
||||
@@ -89,7 +87,7 @@ class date_sql_handler {
|
||||
* The object constuctor.
|
||||
*/
|
||||
function __construct($date_type = DATE_DATETIME, $local_timezone = NULL, $offset = '+00:00') {
|
||||
$this->db_type = db_driver();
|
||||
$this->db_type = Database::getConnection()->databaseType();
|
||||
$this->date_type = $date_type;
|
||||
$this->db_timezone = 'UTC';
|
||||
$this->local_timezone = isset($local_timezone) ? $local_timezone : date_default_timezone();
|
||||
@@ -105,7 +103,6 @@ class date_sql_handler {
|
||||
$has_support = FALSE;
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
$test = db_query("SELECT CONVERT_TZ('2008-02-15 12:00:00', 'UTC', 'US/Central')")->fetchField();
|
||||
if ($test == '2008-02-15 06:00:00') {
|
||||
$has_support = TRUE;
|
||||
@@ -141,11 +138,10 @@ class date_sql_handler {
|
||||
*/
|
||||
function set_db_timezone($offset = '+00:00') {
|
||||
static $already_set = FALSE;
|
||||
$type = db_driver();
|
||||
$type = Database::getConnection()->databaseType();
|
||||
if (!$already_set) {
|
||||
switch ($type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
db_query("SET @@session.time_zone = '$offset'");
|
||||
break;
|
||||
case 'pgsql':
|
||||
@@ -199,7 +195,6 @@ class date_sql_handler {
|
||||
}
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
switch ($this->date_type) {
|
||||
case DATE_UNIX:
|
||||
$field = "FROM_UNIXTIME($field)";
|
||||
@@ -258,7 +253,6 @@ class date_sql_handler {
|
||||
if (!empty($offset)) {
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
return "ADDTIME($field, SEC_TO_TIME($offset))";
|
||||
case 'pgsql':
|
||||
return "($field + INTERVAL '$offset SECONDS')";;
|
||||
@@ -288,7 +282,6 @@ class date_sql_handler {
|
||||
$granularity = strtoupper($granularity);
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
switch ($direction) {
|
||||
case 'ADD':
|
||||
return "DATE_ADD($field, INTERVAL $count $granularity)";
|
||||
@@ -358,7 +351,6 @@ class date_sql_handler {
|
||||
else {
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
return "CONVERT_TZ($field, $db_zone, $localzone)";
|
||||
case 'pgsql':
|
||||
// WITH TIME ZONE assumes the date is using the system
|
||||
@@ -382,7 +374,6 @@ class date_sql_handler {
|
||||
function sql_format($format, $field) {
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
$replace = array(
|
||||
'Y' => '%Y',
|
||||
'y' => '%y',
|
||||
@@ -553,7 +544,6 @@ class date_sql_handler {
|
||||
case 'WEEK':
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
// WEEK using arg 3 in MySQl should return the same value as
|
||||
// Postgres EXTRACT.
|
||||
return "WEEK($field, 3)";
|
||||
@@ -563,7 +553,6 @@ class date_sql_handler {
|
||||
case 'DOW':
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
// MySQL returns 1 for Sunday through 7 for Saturday, PHP date
|
||||
// functions and Postgres use 0 for Sunday and 6 for Saturday.
|
||||
return "INTEGER(DAYOFWEEK($field) - 1)";
|
||||
@@ -573,7 +562,6 @@ class date_sql_handler {
|
||||
case 'DOY':
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
return "DAYOFYEAR($field)";
|
||||
case 'pgsql':
|
||||
return "EXTRACT(DOY FROM($field))";
|
||||
@@ -896,30 +884,30 @@ class date_sql_handler {
|
||||
}
|
||||
$formats = array('display', 'sql');
|
||||
// Start with the site long date format and add seconds to it.
|
||||
$long = str_replace(':i', ':i:s', variable_get('date_format_long', 'l, F j, Y - H:i'));
|
||||
$short = str_replace(':i', ':i:s', variable_get('date_format_short', 'l, F j, Y - H:i'));
|
||||
switch ($granularity) {
|
||||
case 'year':
|
||||
$formats['display'] = 'Y';
|
||||
$formats['sql'] = 'Y';
|
||||
break;
|
||||
case 'month':
|
||||
$formats['display'] = date_limit_format($long, array('year', 'month'));
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month'));
|
||||
$formats['sql'] = 'Y-m';
|
||||
break;
|
||||
case 'day':
|
||||
$formats['display'] = date_limit_format($long, array('year', 'month', 'day'));
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day'));
|
||||
$formats['sql'] = 'Y-m-d';
|
||||
break;
|
||||
case 'hour':
|
||||
$formats['display'] = date_limit_format($long, array('year', 'month', 'day', 'hour'));
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour'));
|
||||
$formats['sql'] = 'Y-m-d\TH';
|
||||
break;
|
||||
case 'minute':
|
||||
$formats['display'] = date_limit_format($long, array('year', 'month', 'day', 'hour', 'minute'));
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour', 'minute'));
|
||||
$formats['sql'] = 'Y-m-d\TH:i';
|
||||
break;
|
||||
case 'second':
|
||||
$formats['display'] = date_limit_format($long, array('year', 'month', 'day', 'hour', 'minute', 'second'));
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour', 'minute', 'second'));
|
||||
$formats['sql'] = 'Y-m-d\TH:i:s';
|
||||
break;
|
||||
case 'week':
|
||||
|
@@ -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 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -41,7 +41,7 @@ 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(':input[name="conditions[plugins][date_context_date_condition][options][operation]"]' => array('<', '<=', '>', '>=', '=', '!=')),
|
||||
'#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => array('<', '<=', '>', '>=', '=', '!=')),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langco
|
||||
// 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 ($delta == 0) {
|
||||
$form['#after_build'] = array('date_repeat_after_build');
|
||||
$form['#after_build'][] = 'date_repeat_after_build';
|
||||
$form_state['storage']['repeat_fields'][$field_name] = array_merge($form['#parents'], array($field_name));
|
||||
$form_state['storage']['date_items'][$field_name][$langcode] = $items;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
'#field' => $field,
|
||||
'#instance' => $instance,
|
||||
'#weight' => $instance['widget']['weight'],
|
||||
'#required' => ($instance['required'] && $delta == 0) ? 1 : 0,
|
||||
'#required' => ($element['#required'] && $delta == 0) ? 1 : 0,
|
||||
'#default_value' => isset($element['#default_value'][$from_field]) ? $element['#default_value'][$from_field] : '',
|
||||
'#delta' => $delta,
|
||||
'#date_timezone' => $element['#date_timezone'],
|
||||
@@ -331,7 +331,8 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
'#date_label_position' => $instance['widget']['settings']['label_position'],
|
||||
);
|
||||
|
||||
$description = !empty($instance['description']) ? t($instance['description']) : '';
|
||||
$description = !empty($element['#description']) ? t($element['#description']) : '';
|
||||
unset($element['#description']);
|
||||
|
||||
// Give this element the right type, using a Date API
|
||||
// or a Date Popup element type.
|
||||
@@ -363,8 +364,8 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
// is the 'Start' and which is the 'End' .
|
||||
|
||||
if (!empty($field['settings']['todate'])) {
|
||||
$element[$from_field]['#title'] = '';
|
||||
$element[$to_field] = $element[$from_field];
|
||||
$element[$from_field]['#title_display'] = 'none';
|
||||
$element[$to_field]['#title'] = t('to:');
|
||||
$element[$from_field]['#wrapper_attributes']['class'][] = 'start-date-wrapper';
|
||||
$element[$to_field]['#wrapper_attributes']['class'][] = 'end-date-wrapper';
|
||||
@@ -400,7 +401,7 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
$element[$to_field]['#date_title'] = t('@field_name End date', array('@field_name' => $instance['label']));
|
||||
}
|
||||
else {
|
||||
$element[$from_field]['#date_title'] = $instance['label'];
|
||||
$element[$from_field]['#date_title'] = t('@field_name', array('@field_name' => $instance['label']));
|
||||
}
|
||||
|
||||
$context = array(
|
||||
@@ -451,8 +452,8 @@ function date_combo_validate($element, &$form_state) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item = $form_values[$field_name][$langcode][$delta];
|
||||
$posted = $form_input[$field_name][$langcode][$delta];
|
||||
$item = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
|
||||
$posted = drupal_array_get_nested_value($form_state['input'], $element['#parents']);
|
||||
|
||||
$field = field_widget_field($element, $form_state);
|
||||
$instance = field_widget_instance($element, $form_state);
|
||||
|
@@ -1,16 +1,12 @@
|
||||
name = Date Migration
|
||||
description = Provides support for importing into date fields with the Migrate module.
|
||||
description = Obsolete data migration module. Disable if no other modules depend on it.
|
||||
core = 7.x
|
||||
package = Date/Time
|
||||
hidden = TRUE
|
||||
|
||||
dependencies[] = migrate
|
||||
dependencies[] = date
|
||||
files[] = date.migrate.inc
|
||||
files[] = date_migrate.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -2,15 +2,5 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Migration integration for Date Migrate.
|
||||
* Obsolete migration integration for Date - now in Date itself.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
function date_migrate_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ core = "7.x"
|
||||
dependencies[] = "date"
|
||||
dependencies[] = "date_repeat"
|
||||
dependencies[] = "date_repeat_field"
|
||||
dependencies[] = "date_migrate"
|
||||
dependencies[] = "features"
|
||||
dependencies[] = "migrate"
|
||||
description = "Examples of migrating with the Date module"
|
||||
@@ -21,9 +20,9 @@ package = "Features"
|
||||
project = "date_migrate_example"
|
||||
version = "7.x-2.0"
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -12,3 +12,12 @@ function date_migrate_example_disable() {
|
||||
Migration::deregisterMigration('DateExample');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function date_migrate_example_uninstall() {
|
||||
node_type_delete('date_migrate_example');
|
||||
variable_del('node_preview_date_migrate_example');
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
}
|
||||
|
@@ -66,28 +66,34 @@ class DateExampleMigration extends XMLMigration {
|
||||
|
||||
// For date ranges, we add the "end" value in prepareRow() below.
|
||||
$this->addFieldMapping('field_date_range', 'date_range_from');
|
||||
$this->addFieldMapping('field_date_range:to', 'date_range_to');
|
||||
|
||||
// RRULEs on repeat fields are also done in prepareRow().
|
||||
$this->addFieldMapping('field_date_repeat', 'date_repeat');
|
||||
$this->addFieldMapping('field_date_repeat:rrule', 'date_repeat_rrule');
|
||||
|
||||
$this->addFieldMapping('field_datestamp', 'datestamp')
|
||||
->xpath('datestamp');
|
||||
$this->addFieldMapping('field_datestamp_range', 'datestamp_range_from');
|
||||
$this->addFieldMapping('field_datestamp_range:to', 'datestamp_range_to');
|
||||
|
||||
// You can specify a timezone to be applied to all values going into the
|
||||
// field (Tokyo is UTC+9, no DST)
|
||||
$arguments = DateMigrateFieldHandler::arguments('Asia/Tokyo');
|
||||
$this->addFieldMapping('field_datetime', 'datetime')
|
||||
->xpath('datetime')
|
||||
->arguments($arguments);
|
||||
->xpath('datetime');
|
||||
$this->addFieldMapping('field_datetime:timezone')
|
||||
->defaultValue('Asia/Tokyo');
|
||||
|
||||
// You can also get the timezone from the source data - it can be different
|
||||
// for each instance of the field. Like To and RRULE values, it is added
|
||||
// in prepareRow().
|
||||
$this->addFieldMapping('field_datetime_range', 'datetime_range_from');
|
||||
$this->addFieldMapping('field_datetime_range:to', 'datetime_range_to');
|
||||
$this->addFieldMapping('field_datetime_range:timezone', 'datetime_range_timezone');
|
||||
|
||||
// Unmapped destination fields.
|
||||
$this->addUnmigratedDestinations(array('is_new', 'status', 'promote', 'revision', 'language', 'sticky', 'created', 'changed', 'revision_uid'));
|
||||
$this->addUnmigratedDestinations(array('is_new', 'status', 'promote',
|
||||
'revision', 'language', 'sticky', 'created', 'changed', 'revision_uid'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,30 +107,25 @@ class DateExampleMigration extends XMLMigration {
|
||||
// The date range field can have multiple values.
|
||||
$current_row->date_range_from = array();
|
||||
foreach ($current_row->xml->date_range as $range) {
|
||||
$date_data = array(
|
||||
'from' => (string) $range->from[0],
|
||||
'to' => (string) $range->to[0],
|
||||
);
|
||||
$current_row->date_range_from[] = drupal_json_encode($date_data);
|
||||
$current_row->date_range_from[] = (string)$range->from[0];
|
||||
$current_row->date_range_to[] = (string)$range->to[0];
|
||||
}
|
||||
|
||||
$date_data = array(
|
||||
'from' => (string) $current_row->xml->datestamp_range->from[0],
|
||||
'to' => (string) $current_row->xml->datestamp_range->to[0],
|
||||
);
|
||||
$current_row->datestamp_range_from = drupal_json_encode($date_data);
|
||||
$current_row->datestamp_range_from =
|
||||
(string) $current_row->xml->datestamp_range->from[0];
|
||||
$current_row->datestamp_range_to =
|
||||
(string) $current_row->xml->datestamp_range->to[0];
|
||||
|
||||
$date_data = array(
|
||||
'from' => (string) $current_row->xml->datetime_range->from[0],
|
||||
'to' => (string) $current_row->xml->datetime_range->to[0],
|
||||
'timezone' => (string) $current_row->xml->datetime_range->timezone[0],
|
||||
);
|
||||
$current_row->datetime_range_from = drupal_json_encode($date_data);
|
||||
$current_row->datetime_range_from =
|
||||
(string) $current_row->xml->datetime_range->from[0];
|
||||
$current_row->datetime_range_to =
|
||||
(string) $current_row->xml->datetime_range->to[0];
|
||||
$current_row->datetime_range_timezone =
|
||||
(string) $current_row->xml->datetime_range->timezone[0];
|
||||
|
||||
$date_data = array(
|
||||
'from' => (string) $current_row->xml->date_repeat->date[0],
|
||||
'rrule' => (string) $current_row->xml->date_repeat->rule[0],
|
||||
);
|
||||
$current_row->date_repeat = drupal_json_encode($date_data);
|
||||
$current_row->date_repeat =
|
||||
(string) $current_row->xml->date_repeat->date[0];
|
||||
$current_row->date_repeat_rrule =
|
||||
(string) $current_row->xml->date_repeat->rule[0];
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,9 @@ include_once 'date_migrate_example.features.inc';
|
||||
function date_migrate_example_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
'migrations' => array(
|
||||
'DateExample' => array('class_name' => 'DateExampleMigration')
|
||||
),
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ Timepicker
|
||||
================================================================================
|
||||
|
||||
There are three ways to let users select time in the Date Popup widgets.
|
||||
You can choose between them by going to admin/config/content/date_popup.
|
||||
You can choose between them by going to admin/config/date/date_popup.
|
||||
|
||||
The options are:
|
||||
|
||||
@@ -99,10 +99,10 @@ Example:
|
||||
|
||||
$form['date'] = array(
|
||||
'#type' => 'date_popup',
|
||||
'#default_value' => '2007-01-01 10:30:00,
|
||||
'#default_value' => '2007-01-01 10:30:00',
|
||||
'#date_type' => DATE_DATETIME,
|
||||
'#date_timezone' => date_default_timezone(),
|
||||
'#date_format' => 'm/d/Y - H:i',
|
||||
'#date_format' => 'm-d-Y H:i',
|
||||
'#date_increment' => 1,
|
||||
'#date_year_range' => '-3:+3',
|
||||
);
|
||||
|
@@ -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 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -87,7 +87,7 @@ function date_popup_library() {
|
||||
$path . '/jquery.timeentry.pack.js' => array(),
|
||||
),
|
||||
'css' => array(
|
||||
$path . '/themes/jquery.timeentry.css' => array('preprocess' => FALSE),
|
||||
$path . '/themes/jquery.timeentry.css' => array(),
|
||||
),
|
||||
);
|
||||
return $libraries;
|
||||
@@ -352,7 +352,8 @@ function date_popup_process_date_part(&$element) {
|
||||
$parents = array_merge($element['#parents'], array('date'));
|
||||
$sub_element = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $element['#date_label_position'] == 'above' ? theme('date_part_label_date', array('part_type' => 'date', 'element' => $element)) : '',
|
||||
'#title' => theme('date_part_label_date', array('part_type' => 'date', 'element' => $element)),
|
||||
'#title_display' => $element['#date_label_position'] == 'above' ? 'before' : 'invisible',
|
||||
'#default_value' => $element['#value']['date'],
|
||||
'#id' => $id,
|
||||
'#input' => FALSE,
|
||||
@@ -427,7 +428,8 @@ function date_popup_process_time_part(&$element) {
|
||||
$parents = array_merge($element['#parents'], array('time'));
|
||||
$sub_element = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $element['#date_label_position'] == 'above' ? theme('date_part_label_time', array('part_type' => 'time', 'element' => $element)) : '',
|
||||
'#title' => theme('date_part_label_time', array('part_type' => 'time', 'element' => $element)),
|
||||
'#title_display' => $element['#date_label_position'] == 'above' ? 'before' : 'invisible',
|
||||
'#default_value' => $element['#value']['time'],
|
||||
'#id' => $id,
|
||||
'#size' => 15,
|
||||
|
@@ -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 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -173,7 +173,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
}
|
||||
if ($rrule['FREQ'] == 'YEARLY') {
|
||||
// Back up to first of year and jump.
|
||||
$current_day = date_repeat_set_year_day($current_day, NULL, 1, '+', $timezone, $modify_time);
|
||||
$current_day = date_repeat_set_year_day($current_day, NULL, NULL, 1, '+', $timezone, $modify_time);
|
||||
date_modify($current_day, '+' . $jump . $modify_time);
|
||||
}
|
||||
$finished = date_repeat_is_finished($current_day, $days, $count, $end_date);
|
||||
@@ -223,18 +223,42 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
$ordered = date_repeat_days_ordered($week_start_rule);
|
||||
$ordered_keys = array_flip($ordered);
|
||||
|
||||
foreach ($rrule['BYDAY'] as $day) {
|
||||
preg_match("@(-)?([0-9]+)?([SU|MO|TU|WE|TH|FR|SA]{2})@", trim($day), $regs);
|
||||
if (!empty($regs[2])) {
|
||||
// Convert parameters into full day name, count, and direction.
|
||||
$direction_days[] = array(
|
||||
'day' => $day_names[$regs[3]],
|
||||
'direction' => !empty($regs[1]) ? $regs[1] : '+',
|
||||
'direction_count' => $regs[2],
|
||||
);
|
||||
if ($rrule['FREQ'] == 'YEARLY' && !empty($rrule['BYMONTH'])) {
|
||||
// Additional cycle to apply month preferences.
|
||||
foreach ($rrule['BYMONTH'] as $month) {
|
||||
foreach ($rrule['BYDAY'] as $day) {
|
||||
preg_match("@(-)?([0-9]+)?([SU|MO|TU|WE|TH|FR|SA]{2})@", trim($day), $regs);
|
||||
// Convert parameters into full day name, count, and direction.
|
||||
// Add leading zero to first 9 months.
|
||||
if (!empty($regs[2])) {
|
||||
$direction_days[] = array(
|
||||
'day' => $day_names[$regs[3]],
|
||||
'direction' => !empty($regs[1]) ? $regs[1] : '+',
|
||||
'direction_count' => $regs[2],
|
||||
'month' => strlen($month) > 1 ? $month : '0' . $month,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$week_days[$ordered_keys[$regs[3]]] = $day_names[$regs[3]];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$week_days[$ordered_keys[$regs[3]]] = $day_names[$regs[3]];
|
||||
}
|
||||
else {
|
||||
foreach ($rrule['BYDAY'] as $day) {
|
||||
preg_match("@(-)?([0-9]+)?([SU|MO|TU|WE|TH|FR|SA]{2})@", trim($day), $regs);
|
||||
if (!empty($regs[2])) {
|
||||
// Convert parameters into full day name, count, and direction.
|
||||
$direction_days[] = array(
|
||||
'day' => $day_names[$regs[3]],
|
||||
'direction' => !empty($regs[1]) ? $regs[1] : '+',
|
||||
'direction_count' => $regs[2],
|
||||
'month' => NULL,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$week_days[$ordered_keys[$regs[3]]] = $day_names[$regs[3]];
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($week_days);
|
||||
@@ -251,7 +275,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
$current_day = date_repeat_set_month_day($current_day, $day['day'], $day['direction_count'], $day['direction'], $timezone, $modify_time);
|
||||
}
|
||||
else {
|
||||
$current_day = date_repeat_set_year_day($current_day, $day['day'], $day['direction_count'], $day['direction'], $timezone, $modify_time);
|
||||
$current_day = date_repeat_set_year_day($current_day, $day['month'], $day['day'], $day['direction_count'], $day['direction'], $timezone, $modify_time);
|
||||
}
|
||||
date_repeat_add_dates($days, $current_day, $start_date, $end_date, $exceptions, $rrule);
|
||||
}
|
||||
@@ -543,24 +567,42 @@ function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+',
|
||||
* If $day is empty, will set to the number of days from the
|
||||
* beginning or end of the year.
|
||||
*/
|
||||
function date_repeat_set_year_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) {
|
||||
function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) {
|
||||
if (is_object($date_in)) {
|
||||
$current_year = date_format($date_in, 'Y');
|
||||
|
||||
// Reset to the start of the month.
|
||||
// See note above.
|
||||
$datetime = date_format($date_in, DATE_FORMAT_DATETIME);
|
||||
$datetime = substr_replace($datetime, '01-01', 5, 5);
|
||||
$month_key = isset($month) ? $month : '01';
|
||||
$datetime = substr_replace($datetime, $month_key . '-01', 5, 5);
|
||||
$date = new DateObject($datetime, $timezone);
|
||||
if ($direction == '-') {
|
||||
// For negative search, start from the end of the year.
|
||||
date_modify($date, '+1 year' . $modify_time);
|
||||
|
||||
if (isset($month)) {
|
||||
if ($direction == '-') {
|
||||
// For negative search, start from the end of the month.
|
||||
$modifier = '+1 month';
|
||||
}
|
||||
else {
|
||||
// For positive search, back up one day to get outside the
|
||||
// current month, so we can catch the first of the month.
|
||||
$modifier = '-1 day';
|
||||
}
|
||||
}
|
||||
else {
|
||||
// For positive search, back up one day to get outside the
|
||||
// current year, so we can catch the first of the year.
|
||||
date_modify($date, '-1 day' . $modify_time);
|
||||
if ($direction == '-') {
|
||||
// For negative search, start from the end of the year.
|
||||
$modifier = '+1 year';
|
||||
}
|
||||
else {
|
||||
// For positive search, back up one day to get outside the
|
||||
// current year, so we can catch the first of the year.
|
||||
$modifier = '-1 day';
|
||||
}
|
||||
}
|
||||
|
||||
date_modify($date, $modifier . $modify_time);
|
||||
|
||||
if (empty($day)) {
|
||||
date_modify($date, $direction . $count . ' days' . $modify_time);
|
||||
}
|
||||
|
@@ -941,7 +941,6 @@ function theme_date_repeat_current_additions($rows = array()) {
|
||||
*/
|
||||
function theme_date_repeat_rrule($vars) {
|
||||
$element = $vars['element'];
|
||||
$class = $element['#date_repeat_collapsed'] ? array('date-no-float', 'collapsible', 'collapsed') : array('date-no-float', 'collapsible');
|
||||
$id = drupal_html_id('repeat-settings-fieldset');
|
||||
$parents = $element['#parents'];
|
||||
$selector = "{$parents[0]}[{$parents[1]}][{$parents[2]}][show_repeat_settings]";
|
||||
@@ -949,11 +948,10 @@ function theme_date_repeat_rrule($vars) {
|
||||
'#type' => 'item',
|
||||
'#title' => t('Repeat settings'),
|
||||
'#title_display' => 'invisible',
|
||||
'#attributes' => array('class' => $class),
|
||||
'#markup' => $element['#children'],
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
":input[name=\"{$selector}\"]" => array('checked' => TRUE),
|
||||
'invisible' => array(
|
||||
":input[name=\"{$selector}\"]" => array('checked' => FALSE),
|
||||
),
|
||||
),
|
||||
'#id' => $id,
|
||||
|
@@ -377,6 +377,19 @@ class DateRepeatTestCase extends DrupalWebTestCase {
|
||||
$result = implode(', ', $dates);
|
||||
$this->assertEqual($result, $shouldbe, $rule . '; Starting ' . $start . '; results: ' . $result);
|
||||
|
||||
//Every Last Thursday in November, every year, five times:
|
||||
$start = "2014-11-27 00:00:00";
|
||||
$rule = 'FREQ=YEARLY;INTERVAL=1;BYDAY=-1TH;BYMONTH=11;COUNT=5;WKST=SU';
|
||||
// ==> (2014 00:00 AM EDT)November 27
|
||||
// (2015 00:00 AM EDT)November 26
|
||||
// (2016 00:00 AM EDT)November 24
|
||||
// (2017 00:00 AM EDT)November 30
|
||||
// (2018 00:00 AM EDT)November 29
|
||||
$dates = date_repeat_calc($rule, $start, NULL, array());
|
||||
$shouldbe = '2014-11-27 00:00:00, 2015-11-26 00:00:00, 2016-11-24 00:00:00, 2017-11-30 00:00:00, 2018-11-29 00:00:00';
|
||||
$result = implode(', ', $dates);
|
||||
$this->assertEqual($result, $shouldbe, $rule . '; Starting ' . $start . '; results: ' . $result);
|
||||
|
||||
return;
|
||||
|
||||
//Every Thanksgiving, forever:
|
||||
|
@@ -195,20 +195,22 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
$edit = array();
|
||||
$edit['title'] = $this->randomName(8);
|
||||
$edit['body[und][0][value]'] = $this->randomName(16);
|
||||
$current_year = date('Y');
|
||||
|
||||
|
||||
switch ($options) {
|
||||
case 'select':
|
||||
$edit['field_test[und][0][value][year]'] = '2010';
|
||||
$edit['field_test[und][0][value][year]'] = $current_year;
|
||||
$edit['field_test[und][0][value][month]'] = '10';
|
||||
$edit['field_test[und][0][value][day]'] = '7';
|
||||
$edit['field_test[und][0][value][hour]'] = '10';
|
||||
$edit['field_test[und][0][value][minute]'] = '30';
|
||||
break;
|
||||
case 'text':
|
||||
$edit['field_test[und][0][value][date]'] = '2010-10-07 10:30';
|
||||
$edit['field_test[und][0][value][date]'] = format_string('!year-10-07 10:30', array('!year' => $current_year));
|
||||
break;
|
||||
case 'popup':
|
||||
$edit['field_test[und][0][value][date]'] = '2010-10-07';
|
||||
$edit['field_test[und][0][value][date]'] = format_string('!year-10-07', array('!year' => $current_year));
|
||||
$edit['field_test[und][0][value][time]'] = '10:30';
|
||||
break;
|
||||
}
|
||||
@@ -378,7 +380,7 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
else {
|
||||
$edit['field_test[und][0][rrule][range_of_repeat]'] = 'UNTIL';
|
||||
$date = array(
|
||||
'year' => '2011',
|
||||
'year' => $current_year + 1,
|
||||
'month' => '10',
|
||||
'day' => '07'
|
||||
);
|
||||
@@ -392,7 +394,7 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
case 'exclude':
|
||||
$exclude_include_edit['field_test[und][0][rrule][show_exceptions]'] = TRUE;
|
||||
$date = array(
|
||||
'year' => '2010',
|
||||
'year' => $current_year,
|
||||
'month' => '10',
|
||||
'day' => '07'
|
||||
);
|
||||
@@ -401,7 +403,7 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
case 'include':
|
||||
$exclude_include_edit['field_test[und][0][rrule][show_additions]'] = TRUE;
|
||||
$date = array(
|
||||
'year' => '2013',
|
||||
'year' => $current_year + 3,
|
||||
'month' => '10',
|
||||
'day' => '07'
|
||||
);
|
||||
@@ -410,7 +412,7 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
case 'exclude_include':
|
||||
$exclude_include_edit['field_test[und][0][rrule][show_exceptions]'] = TRUE;
|
||||
$date = array(
|
||||
'year' => '2010',
|
||||
'year' => $current_year,
|
||||
'month' => '10',
|
||||
'day' => '07'
|
||||
);
|
||||
@@ -418,7 +420,7 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
|
||||
$exclude_include_edit['field_test[und][0][rrule][show_additions]'] = TRUE;
|
||||
$date = array(
|
||||
'year' => '2013',
|
||||
'year' => $current_year + 3,
|
||||
'month' => '10',
|
||||
'day' => '07'
|
||||
);
|
||||
@@ -510,7 +512,6 @@ class DateRepeatFormTestCase extends DrupalWebTestCase {
|
||||
break;
|
||||
case 'text':
|
||||
case 'popup':
|
||||
//$return["{$field_name}[datetime][date]"] = '2011-10-07';
|
||||
$return["{$form_field_name}[datetime][date]"] = "{$date['year']}-{$date['month']}-{$date['day']}";
|
||||
break;
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ stylesheets[all][] = date_repeat_field.css
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -55,7 +55,7 @@ function theme_date_repeat_display($vars) {
|
||||
$output = '';
|
||||
if (!empty($item['rrule'])) {
|
||||
$output = date_repeat_rrule_description($item['rrule']);
|
||||
$output = '<div>' . $output . '</div>';
|
||||
$output = '<div class="date-repeat-rule">' . $output . '</div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
@@ -115,16 +115,38 @@ function date_repeat_field_permission() {
|
||||
}
|
||||
|
||||
/**
|
||||
* See if the user can access repeat date info for this field.
|
||||
* See if the user can access repeat date info for this entity.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* The entity type.
|
||||
* @param string $entity
|
||||
* The specific entity to check (optional).
|
||||
*
|
||||
* @return bool
|
||||
* Return TRUE if there is at least one date field attached to this entity,
|
||||
* and the current user has the permission 'view date repeats'; FALSE otherwise.
|
||||
*/
|
||||
function date_repeat_field_show($entity_type = 'node', $entity = NULL) {
|
||||
if (!user_access('view date repeats')) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$bundle = date_get_entity_bundle($entity_type, $entity);
|
||||
foreach (field_info_fields() as $field_name => $field) {
|
||||
if (in_array($field['type'], array('date', 'datestamp', 'datetime'))
|
||||
&& array_key_exists($entity_type, $field['bundles'])
|
||||
&& in_array($bundle, $field['bundles'][$entity_type])
|
||||
&& date_is_repeat_field($field)) {
|
||||
return user_access('view date repeats');
|
||||
|
||||
// In Drupal 7.22 the field_info_field_map() function was added, which is more
|
||||
// memory-efficient in certain cases than field_info_fields().
|
||||
// @see https://drupal.org/node/1915646
|
||||
$field_map_available = version_compare(VERSION, '7.22', '>=');
|
||||
$field_list = $field_map_available ? field_info_field_map() : field_info_fields();
|
||||
|
||||
foreach ($field_list as $field_name => $data) {
|
||||
if (in_array($data['type'], array('date', 'datestamp', 'datetime'))
|
||||
&& array_key_exists($entity_type, $data['bundles'])
|
||||
&& in_array($bundle, $data['bundles'][$entity_type])) {
|
||||
$field_info = $field_map_available ? field_info_field($field_name) : $data;
|
||||
if (date_is_repeat_field($field_info)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -346,15 +368,8 @@ function date_repeat_field_widget_validate($element, &$form_state) {
|
||||
// the repeating dates, wipe out the previous values, and populate the
|
||||
// field with the new values.
|
||||
|
||||
// TODO
|
||||
// Is it right to not do anything unless there are changes? Will that
|
||||
// confuse anyone? Commenting that out for now...
|
||||
$rrule = $item['rrule'];
|
||||
if (!empty($rrule)
|
||||
//&& ($rrule != $element['rrule']['#prev_rrule']
|
||||
//|| $item['value'] != $element['rrule']['#prev_value']
|
||||
//|| $item['value2'] != $element['rrule']['#prev_value2'])
|
||||
) {
|
||||
if (!empty($rrule)) {
|
||||
|
||||
// Avoid undefined index problems on dates that don't have all parts.
|
||||
$possible_items = array('value', 'value2', 'timezone', 'offset', 'offset2');
|
||||
@@ -514,9 +529,6 @@ function date_repeat_field_date_combo_process_alter(&$element, &$form_state, $co
|
||||
'#date_increment' => $instance['widget']['settings']['increment'],
|
||||
'#date_year_range' => $instance['widget']['settings']['year_range'],
|
||||
'#date_label_position' => $instance['widget']['settings']['label_position'],
|
||||
'#prev_value' => isset($item['value']) ? $item['value'] : '',
|
||||
'#prev_value2' => isset($item['value2']) ? $item['value2'] : '',
|
||||
'#prev_rrule' => isset($item['rrule']) ? $item['rrule'] : '',
|
||||
'#date_repeat_widget' => str_replace('_repeat', '', $instance['widget']['type']),
|
||||
'#date_repeat_collapsed' => $instance['widget']['settings']['repeat_collapsed'],
|
||||
'#date_flexible' => 0,
|
||||
@@ -626,6 +638,17 @@ function date_repeat_field_form_field_ui_field_edit_form_alter(&$form, &$form_st
|
||||
$form['field']['cardinality']['#disabled'] = TRUE;
|
||||
$form['field']['cardinality']['#value'] = FIELD_CARDINALITY_UNLIMITED;
|
||||
}
|
||||
// Repeating dates need unlimited values, confirm that in element_validate.
|
||||
$form['field']['#element_validate'] = array('date_repeat_field_set_cardinality');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the cardinality gets updated if the option to make a date repeating is checked.
|
||||
*/
|
||||
function date_repeat_field_set_cardinality($element, &$form_state) {
|
||||
if (!empty($form_state['values']['field']['settings']['repeat'])) {
|
||||
form_set_value($element['cardinality'], FIELD_CARDINALITY_UNLIMITED, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -9,13 +9,12 @@ files[] = includes/date_views_argument_handler.inc
|
||||
files[] = includes/date_views_argument_handler_simple.inc
|
||||
files[] = includes/date_views_filter_handler.inc
|
||||
files[] = includes/date_views_filter_handler_simple.inc
|
||||
files[] = includes/date_views.views_default.inc
|
||||
files[] = includes/date_views.views.inc
|
||||
files[] = includes/date_views_plugin_pager.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-13
|
||||
version = "7.x-2.6"
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1344850024"
|
||||
datestamp = "1406653438"
|
||||
|
||||
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the Date Views module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function date_views_install() {
|
||||
variable_set('date_views_month_format_with_year', 'F Y');
|
||||
variable_set('date_views_month_format_without_year', 'F');
|
||||
variable_set('date_views_day_format_with_year', 'l, F j, Y');
|
||||
variable_set('date_views_day_format_without_year', 'l, F j');
|
||||
variable_set('date_views_week_format_with_year', 'F j, Y');
|
||||
variable_set('date_views_week_format_without_year', 'F j');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function date_views_uninstall() {
|
||||
variable_del('date_views_month_format_with_year');
|
||||
variable_del('date_views_month_format_without_year');
|
||||
variable_del('date_views_day_format_with_year');
|
||||
variable_del('date_views_day_format_without_year');
|
||||
variable_del('date_views_week_format_with_year');
|
||||
variable_del('date_views_week_format_without_year');
|
||||
}
|
@@ -1,5 +1,80 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function date_views_menu() {
|
||||
// Used to import files from a local filesystem into Drupal.
|
||||
$items['admin/config/regional/date-time/date-views'] = array(
|
||||
'title' => 'Date views',
|
||||
'description' => 'Configure settings for date views.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('date_views_settings'),
|
||||
'access arguments' => array('administer site configuration '),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form callback for date views settings.
|
||||
*/
|
||||
function date_views_settings($form, &$form_state) {
|
||||
|
||||
$form['date_views_month_format_with_year'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Date views month format with year'),
|
||||
'#size' => 10,
|
||||
'#default_value' => variable_get('date_views_month_format_with_year', 'F Y'),
|
||||
'#description' => t('Date views month format with year, default value : F Y'),
|
||||
);
|
||||
|
||||
$form['date_views_month_format_without_year'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Date views month format without year'),
|
||||
'#size' => 10,
|
||||
'#default_value' => variable_get('date_views_month_format_without_year', 'F'),
|
||||
'#description' => t('Date views month format without year, default value : F'),
|
||||
);
|
||||
|
||||
$form['date_views_day_format_with_year'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Date views day format with year'),
|
||||
'#size' => 10,
|
||||
'#default_value' => variable_get('date_views_day_format_with_year', 'l, F j, Y'),
|
||||
'#description' => t('Date views day format with year, default value : l, F j, Y'),
|
||||
);
|
||||
|
||||
$form['date_views_day_format_without_year'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Date views day format without year'),
|
||||
'#size' => 10,
|
||||
'#default_value' => variable_get('date_views_day_format_without_year', 'l, F j'),
|
||||
'#description' => t('Date views day format without year, default value : l, F j'),
|
||||
);
|
||||
|
||||
$form['date_views_week_format_with_year'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Date views week format with year'),
|
||||
'#size' => 10,
|
||||
'#default_value' => variable_get('date_views_week_format_with_year', 'F j, Y'),
|
||||
'#description' => t('Date views week format with year, default value : F j, Y'),
|
||||
);
|
||||
|
||||
$form['date_views_week_format_without_year'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Date views week format without year'),
|
||||
'#size' => 10,
|
||||
'#default_value' => variable_get('date_views_week_format_without_year', 'F j'),
|
||||
'#description' => t('Date views week format without year, default value : F j'),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*
|
||||
|
@@ -128,7 +128,7 @@ function date_views_views_data_alter(&$data) {
|
||||
// Mark all the core date handlers as date fields.
|
||||
// This will identify all handlers that directly use the _date handlers,
|
||||
// will not pick up any that extend those handlers.
|
||||
foreach ($data as $module => &$table) {
|
||||
foreach ($data as $base_table => &$table) {
|
||||
foreach ($table as $id => &$field) {
|
||||
foreach (array('field', 'sort', 'filter', 'argument') as $type) {
|
||||
if (isset($field[$type]) && isset($field[$type]['handler']) && ($field[$type]['handler'] == 'views_handler_' . $type . '_date')) {
|
||||
|
@@ -64,7 +64,7 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
if ($granularity == 'week') {
|
||||
$now = date_now();
|
||||
$week = date_week(date_format($now, 'Y-m-d'));
|
||||
$value = date_format($now, 'Y') . '-W' . $week;
|
||||
$value = date_format($now, 'o') . '-W' . date_pad($week);
|
||||
}
|
||||
else {
|
||||
$value = date($this->arg_format, REQUEST_TIME);
|
||||
@@ -85,7 +85,7 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
$options = parent::option_definition();
|
||||
$options['year_range'] = array('default' => '-3:+3');
|
||||
$options['granularity'] = array('default' => 'month');
|
||||
$options['default_argument_type'] = array('default' => 'date');
|
||||
$options['default_argument_type']['default'] = 'date';
|
||||
$options['add_delta'] = array('default' => '');
|
||||
$options['use_fromto'] = array('default' => '');
|
||||
$options['title_format'] = array('default' => '');
|
||||
|
@@ -36,6 +36,10 @@ class date_views_filter_handler extends date_views_filter_handler_simple {
|
||||
$this->date_combine_conditions('op_simple');
|
||||
}
|
||||
|
||||
function op_contains($field) {
|
||||
$this->date_combine_conditions('op_contains');
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines multiple date WHERE expressions into a single WHERE expression.
|
||||
*
|
||||
|
@@ -42,6 +42,17 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operators() {
|
||||
$operators = parent::operators();
|
||||
$operators['contains'] = array(
|
||||
'title' => t('Contains'),
|
||||
'method' => 'op_contains',
|
||||
'short' => t('contains'),
|
||||
'values' => 1,
|
||||
);
|
||||
return $operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to find a default value.
|
||||
*/
|
||||
@@ -53,8 +64,8 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
// If this is a remembered value, use the value from the SESSION.
|
||||
if (!empty($this->options['expose']['remember'])) {
|
||||
$display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
|
||||
if (!empty($_SESSION['views'][$this->view->name][$display_id]['date_filter'][$prefix])) {
|
||||
return $_SESSION['views'][$this->view->name][$display_id]['date_filter'][$prefix];
|
||||
if (!empty($_SESSION['views'][$this->view->name][$display_id][$this->options['expose']['identifier']][$prefix])) {
|
||||
return $_SESSION['views'][$this->view->name][$display_id][$this->options['expose']['identifier']][$prefix];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +115,12 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
$element_input['value'] = $this->get_filter_value('value', !empty($element_input['value']) ? $element_input['value'] : '');
|
||||
$element_input['min'] = $this->get_filter_value('min', !empty($element_input['min']) ? $element_input['min'] : '');
|
||||
$element_input['max'] = $this->get_filter_value('max', !empty($element_input['max']) ? $element_input['max'] : '');
|
||||
unset($element_input['default_date']);
|
||||
unset($element_input['default_to_date']);
|
||||
if (is_array($element_input) && isset($element_input['default_date'])) {
|
||||
unset($element_input['default_date']);
|
||||
}
|
||||
if (is_array($element_input) && isset($element_input['default_to_date'])) {
|
||||
unset($element_input['default_to_date']);
|
||||
}
|
||||
|
||||
$input[$this->options['expose']['identifier']] = $element_input;
|
||||
}
|
||||
@@ -163,6 +178,29 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
$this->query->add_where_expression($group, "$field $this->operator $placeholder", array($placeholder => $value));
|
||||
}
|
||||
|
||||
function op_contains($field) {
|
||||
|
||||
// Add the delta field to the view so we can later find the value that matched our query.
|
||||
list($table_name, $field_name) = explode('.', $field);
|
||||
if (!empty($this->options['add_delta']) && (substr($field_name, -6) == '_value' || substr($field_name, -7) == '_value2')) {
|
||||
$this->query->add_field($table_name, 'delta');
|
||||
}
|
||||
|
||||
$value = $this->get_filter_value('value', $this->value['value']);
|
||||
$comp_date = new DateObject($value, date_default_timezone(), $this->format);
|
||||
$fields = date_views_fields($this->base_table);
|
||||
$fields = $fields['name'];
|
||||
$fromto = $fields[$field]['fromto'];
|
||||
$field_min = $this->date_handler->sql_field($fromto[0], NULL, $comp_date);
|
||||
$field_min = $this->date_handler->sql_format($this->format, $field_min);
|
||||
$field_max = $this->date_handler->sql_field($fromto[1], NULL, $comp_date);
|
||||
$field_max = $this->date_handler->sql_format($this->format, $field_max);
|
||||
$placeholder_min = $this->placeholder();
|
||||
$placeholder_max = $this->placeholder();
|
||||
$group = !empty($this->options['date_group']) ? $this->options['date_group'] : $this->options['group'];
|
||||
$this->query->add_where_expression($group, "$field_max >= $placeholder_min AND $field_min <= $placeholder_max", array($placeholder_min => $value, $placeholder_max => $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the granularity of the date parts to use in the filter.
|
||||
*/
|
||||
@@ -316,7 +354,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
$type = 'date_text';
|
||||
}
|
||||
|
||||
$format = $this->date_handler->views_formats($this->options['granularity'], 'sql');
|
||||
$format = $this->date_handler->views_formats($this->options['granularity'], 'display');
|
||||
$granularity = array_keys($this->date_handler->date_parts($this->options['granularity']));
|
||||
$relative_value = ($prefix == 'max' ? $this->options['default_to_date'] : $this->options['default_date']);
|
||||
|
||||
@@ -333,7 +371,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => $this->options['year_range'],
|
||||
'#process' => array($type . '_element_process'),
|
||||
'#prefix' => '<div id="' . $id . '-wrapper"><div id="' . $id . '">',
|
||||
'#prefix' => '<div id="' . $id . '-wrapper"><div id="' . $id . '-inside-wrapper">',
|
||||
'#suffix' => '</div></div>',
|
||||
);
|
||||
if ($which == 'all') {
|
||||
@@ -368,7 +406,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => $this->options['year_range'],
|
||||
'#process' => array($type . '_element_process'),
|
||||
'#prefix' => '<div id="' . $id . '-wrapper"><div id="' . $id . '">',
|
||||
'#prefix' => '<div id="' . $id . '-wrapper"><div id="' . $id . '-inside-wrapper">',
|
||||
'#suffix' => '</div></div>',
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
|
@@ -37,10 +37,10 @@
|
||||
<?php if (!empty($prev_url)) : ?>
|
||||
<li class="date-prev">
|
||||
<?php print l('«' . ($mini ? '' : ' ' . t('Prev', array(), array('context' => 'date_nav'))), $prev_url, $prev_options); ?>
|
||||
</li>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($next_url)) : ?>
|
||||
<li class="date-next">
|
||||
<li class="date-next">
|
||||
<?php print l(($mini ? '' : t('Next', array(), array('context' => 'date_nav')) . ' ') . '»', $next_url, $next_options); ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
@@ -75,8 +75,8 @@ function template_preprocess_date_views_pager(&$vars) {
|
||||
case 'week':
|
||||
$next_week = date_week(date_format($next_date, 'Y-m-d'));
|
||||
$prev_week = date_week(date_format($prev_date, 'Y-m-d'));
|
||||
$next_arg = date_format($next_date, 'Y-\W') . date_pad($next_week);
|
||||
$prev_arg = date_format($prev_date, 'Y-\W') . date_pad($prev_week);
|
||||
$next_arg = date_format($next_date, 'o-\W') . date_pad($next_week);
|
||||
$prev_arg = date_format($prev_date, 'o-\W') . date_pad($prev_week);
|
||||
break;
|
||||
default:
|
||||
$next_arg = date_format($next_date, $format[$granularity]);
|
||||
@@ -165,23 +165,25 @@ function theme_date_nav_title($params) {
|
||||
$date_info = $view->date_info;
|
||||
$link = !empty($params['link']) ? $params['link'] : FALSE;
|
||||
$format = !empty($params['format']) ? $params['format'] : NULL;
|
||||
$format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y');
|
||||
$format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j');
|
||||
switch ($granularity) {
|
||||
case 'year':
|
||||
$title = $date_info->year;
|
||||
$date_arg = $date_info->year;
|
||||
break;
|
||||
case 'month':
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'F Y' : 'F');
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
|
||||
$title = date_format_date($date_info->min_date, 'custom', $format);
|
||||
$date_arg = $date_info->year . '-' . date_pad($date_info->month);
|
||||
break;
|
||||
case 'day':
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'l, F j, Y' : 'l, F j');
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
|
||||
$title = date_format_date($date_info->min_date, 'custom', $format);
|
||||
$date_arg = $date_info->year . '-' . date_pad($date_info->month) . '-' . date_pad($date_info->day);
|
||||
break;
|
||||
case 'week':
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'F j, Y' : 'F j');
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
|
||||
$title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format)));
|
||||
$date_arg = $date_info->year . '-W' . date_pad($date_info->week);
|
||||
break;
|
||||
|
@@ -5,8 +5,7 @@
|
||||
* Test date UI.
|
||||
*/
|
||||
|
||||
class DateUITestCase extends DrupalWebTestCase {
|
||||
protected $privileged_user;
|
||||
class DateUITestCase extends DateFieldBasic {
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
@@ -23,14 +22,7 @@ class DateUITestCase extends DrupalWebTestCase {
|
||||
* @todo.
|
||||
*/
|
||||
public function setUp() {
|
||||
// Load the date_api module.
|
||||
parent::setUp('field', 'field_ui', 'date_api', 'date', 'date_popup', 'date_tools');
|
||||
|
||||
// Create and log in our privileged user.
|
||||
$this->privileged_user = $this->drupalCreateUser(
|
||||
array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools')
|
||||
);
|
||||
$this->drupalLogin($this->privileged_user);
|
||||
parent::setUp();
|
||||
|
||||
variable_set('date_format_long', 'D, m/d/Y - H:i');
|
||||
}
|
||||
@@ -39,82 +31,34 @@ class DateUITestCase extends DrupalWebTestCase {
|
||||
* @todo.
|
||||
*/
|
||||
public function testFieldUI() {
|
||||
$edit = array();
|
||||
$edit['name'] = 'Story';
|
||||
$edit['type'] = 'story';
|
||||
$this->drupalPost('admin/structure/types/add', $edit, t('Save content type'));
|
||||
$this->assertText('The content type Story has been added.', 'Content type added.');
|
||||
$label = 'Test';
|
||||
$current_year = date('Y');
|
||||
|
||||
// Creates select list field stored as a date with default settings.
|
||||
$this->createDateField($type = 'date', $widget = 'date_select');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'select');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a date field using the date_select widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates text field stored as a date with default settings.
|
||||
$this->createDateField($type = 'date', $widget = 'date_text');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'text');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a date field using the date_text widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates popup field stored as a date with default settings.
|
||||
$this->createDateField($type = 'date', $widget = 'date_popup');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'popup');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a date field using the date_popup widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates select list field stored as a datestamp with default settings.
|
||||
$this->createDateField($type = 'datestamp', $widget = 'date_select');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'select');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datestamp field using the date_select widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates text field stored as a datestamp with default settings.
|
||||
$this->createDateField($type = 'datestamp', $widget = 'date_text');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'text');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datestamp field using the date_text widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates popup field stored as a datestamp with default settings.
|
||||
$this->createDateField($type = 'datestamp', $widget = 'date_popup');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'popup');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datestamp field using the date_popup widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates select list field stored as a datetime with default settings.
|
||||
$this->createDateField($type = 'datetime', $widget = 'date_select');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'select');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datetime field using the date_select widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates text field stored as a datetime with default settings.
|
||||
$this->createDateField($type = 'datetime', $widget = 'date_text');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'text');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datetime field using the date_text widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates popup field stored as a datetime with default settings.
|
||||
$this->createDateField($type = 'datetime', $widget = 'date_popup');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'popup');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datetime field using the date_popup widget.');
|
||||
$this->deleteDateField();
|
||||
$field_types = array('date', 'datestamp', 'datetime');
|
||||
$widget_types = array('date_select', 'date_text', 'date_popup');
|
||||
|
||||
// Test widgets with default settings using every widget and field type.
|
||||
foreach ($field_types as $field_type) {
|
||||
foreach ($widget_types as $widget_type) {
|
||||
$this->createDateField(
|
||||
array(
|
||||
'label' => $label,
|
||||
'field_type' => $field_type,
|
||||
'widget_type' => $widget_type,
|
||||
)
|
||||
);
|
||||
$this->dateForm($widget_type);
|
||||
$this->assertText(format_string('10/07/!year - 10:30', array('!year' => $current_year)), 'Found the correct date for a date field using the ' . $widget_type . ' widget.');
|
||||
$this->deleteDateField($label);
|
||||
}
|
||||
}
|
||||
|
||||
// Test timezone handling validation on the field settings form.
|
||||
$this->createDateField($type = 'date', $widget = 'date_select');
|
||||
$this->createDateField(array('label' => $label, 'field_type' => 'date', 'widget_type' => 'date_select', 'granularity' => array('year', 'month', 'day')));
|
||||
$edit = array('field[settings][granularity][hour]' => FALSE);
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->drupalPost('admin/structure/types/manage/story/fields/field_' . strtolower($label), $edit, t('Save settings'));
|
||||
$this->assertText("Dates without hours granularity must not use any timezone handling.", "Dates without hours granularity required to use timezone handling of 'none.'");
|
||||
$this->deleteDateField();
|
||||
$this->deleteDateField($label);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,44 +69,23 @@ class DateUITestCase extends DrupalWebTestCase {
|
||||
$edit = array();
|
||||
$edit['title'] = $this->randomName(8);
|
||||
$edit['body[und][0][value]'] = $this->randomName(16);
|
||||
if ($options == 'select') {
|
||||
$edit['field_test[und][0][value][year]'] = '2010';
|
||||
$current_year = date('Y');
|
||||
|
||||
if ($options == 'date_select') {
|
||||
$edit['field_test[und][0][value][year]'] = $current_year;
|
||||
$edit['field_test[und][0][value][month]'] = '10';
|
||||
$edit['field_test[und][0][value][day]'] = '7';
|
||||
$edit['field_test[und][0][value][hour]'] = '10';
|
||||
$edit['field_test[und][0][value][minute]'] = '30';
|
||||
}
|
||||
elseif ($options == 'text') {
|
||||
$edit['field_test[und][0][value][date]'] = '10/07/2010 - 10:30';
|
||||
elseif ($options == 'date_text') {
|
||||
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year - 10:30', array('!year' => $current_year));
|
||||
}
|
||||
elseif ($options == 'popup') {
|
||||
$edit['field_test[und][0][value][date]'] = '10/07/2010';
|
||||
elseif ($options == 'date_popup') {
|
||||
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year', array('!year' => $current_year));
|
||||
$edit['field_test[und][0][value][time]'] = '10:30';
|
||||
}
|
||||
$this->drupalPost('node/add/story', $edit, t('Save'));
|
||||
$this->assertText($edit['body[und][0][value]'], 'Test node has been created');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
function createDateField($type, $widget) {
|
||||
$edit = array();
|
||||
$edit['fields[_add_new_field][label]'] = 'Test';
|
||||
$edit['fields[_add_new_field][field_name]'] = 'test';
|
||||
$edit['fields[_add_new_field][weight]'] = '-4';
|
||||
$edit['fields[_add_new_field][type]'] = $type;
|
||||
$edit['fields[_add_new_field][widget_type]'] = $widget;
|
||||
$this->drupalPost('admin/structure/types/manage/story/fields', $edit, t('Save'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
function deleteDateField() {
|
||||
$this->drupalGet('admin/structure/types/manage/story/fields');
|
||||
$this->clickLink('delete');
|
||||
$this->drupalPost(NULL, NULL, t('Delete'));
|
||||
$this->assertText('The field Test has been deleted from the Story content type.', 'Removed date field.');
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ class DateMigrateExampleUnitTest extends DrupalWebTestCase {
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Date2 migration',
|
||||
'description' => 'Testing migration of date fields',
|
||||
'group' => 'Migrate',
|
||||
'name' => 'Date Migration',
|
||||
'description' => 'Test migration into date fields',
|
||||
'group' => 'Date',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,17 @@ class DateMigrateExampleUnitTest extends DrupalWebTestCase {
|
||||
* Declars the module dependencies for the test.
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp('migrate', 'features', 'date', 'date_repeat', 'date_repeat_field', 'date_migrate_example');
|
||||
parent::setUp('migrate', 'features', 'date', 'date_repeat',
|
||||
'date_repeat_field', 'date_migrate_example');
|
||||
// Make sure the migration is registered.
|
||||
if (function_exists('migrate_static_registration')) {
|
||||
// Migrate 2.6 and later
|
||||
migrate_static_registration();
|
||||
}
|
||||
else {
|
||||
// Migrate 2.5 and earlier
|
||||
migrate_get_module_apis(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
Reference in New Issue
Block a user