updated date pathauto addressfield honeypot features modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-10-12 12:03:12 +02:00
parent 0ba0c21bb9
commit eb699f528d
109 changed files with 5363 additions and 2372 deletions

View File

@@ -1,8 +1,10 @@
<?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');
@@ -15,6 +17,7 @@ function date_get_entity_bundle($entity_type, $entity) {
case 'field_collection_item':
$bundle = $entity->field_name;
break;
default:
$bundle = field_extract_bundle($entity_type, $entity);
break;
@@ -40,13 +43,20 @@ function date_default_format($type) {
* Wrapper function around each of the widget types for creating a date object.
*/
function date_input_date($field, $instance, $element, $input) {
// Trim extra spacing off user input of text fields.
if (isset($input['date'])) {
$input['date'] = trim($input['date']);
}
switch ($instance['widget']['type']) {
case 'date_text':
$function = 'date_text_input_date';
break;
case 'date_popup':
$function = 'date_popup_input_date';
break;
default:
$function = 'date_select_input_date';
}
@@ -66,6 +76,7 @@ function date_theme() {
);
$themes = array(
'date_combo' => $base + array('render element' => 'element'),
'date_form_element' => $base + array('render element' => 'element'),
'date_text_parts' => $base + array('render element' => 'element'),
'date' => $base + array('render element' => 'element'),
'date_display_single' => $base + array(
@@ -97,7 +108,13 @@ function date_theme() {
'add_rdf' => NULL,
'microdata' => NULL,
'add_microdata' => NULL,
)),
),
),
'date_display_remaining' => $base + array(
'variables' => array(
'remaining_days' => NULL,
),
),
'date_display_combination' => $base + array(
'variables' => array(
'entity_type' => NULL,
@@ -130,7 +147,7 @@ function date_theme() {
'attributes' => array(),
'rdf_mapping' => NULL,
'add_rdf' => NULL,
),
),
),
);
@@ -209,8 +226,10 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
$settings = $display['settings'];
$field_name = $field['field_name'];
$format = date_formatter_format($formatter, $settings, $granularity, $langcode);
$timezone = isset($item['timezone']) ? $item['timezone'] : '';
$timezone = date_get_timezone($field['settings']['tz_handling'], $timezone);
if (!isset($field['settings']['tz_handling']) || $field['settings']['tz_handling'] !== 'utc') {
$timezone = isset($item['timezone']) ? $item['timezone'] : '';
$timezone = date_get_timezone($field['settings']['tz_handling'], $timezone);
}
$timezone_db = date_get_timezone_db($field['settings']['tz_handling']);
$db_format = date_type_format($field['type']);
$process = date_process_values($field);
@@ -246,10 +265,10 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
$dates[$processed]['formatted_iso'] = date_format_date($date, 'custom', 'c');
if (is_object($date)) {
if ($format == 'format_interval') {
$dates[$processed]['interval'] = date_format_interval($date);
$dates[$processed]['interval'] = date_format_interval($date);
}
elseif ($format == 'format_calendar_day') {
$dates[$processed]['calendar_day'] = date_format_calendar_day($date);
$dates[$processed]['calendar_day'] = date_format_calendar_day($date);
}
elseif ($format == 'U' || $format == 'r' || $format == 'c') {
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format);
@@ -258,10 +277,11 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
$dates[$processed]['formatted_timezone'] = '';
}
elseif (!empty($format)) {
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format);
$dates[$processed]['formatted_date'] = date_format_date($date, 'custom', date_limit_format($format, array('year', 'month', 'day')));
$dates[$processed]['formatted_time'] = date_format_date($date, 'custom', date_limit_format($format, array('hour', 'minute', 'second')));
$dates[$processed]['formatted_timezone'] = date_format_date($date, 'custom', date_limit_format($format, array('timezone')));
$formats = _get_custom_date_format($date, $format);
$dates[$processed]['formatted'] = $formats['formatted'];
$dates[$processed]['formatted_date'] = $formats['date'];
$dates[$processed]['formatted_time'] = $formats['time'];
$dates[$processed]['formatted_timezone'] = $formats['zone'];
}
}
}
@@ -288,6 +308,30 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
return $dates;
}
/**
* Get a custom date format.
*/
function _get_custom_date_format($date, $format) {
$custom = array();
$custom['granularities'] = array(
'date' => array('year', 'month', 'day'),
'time' => array('hour', 'minute', 'second'),
'zone' => array('timezone'),
);
$custom['limits'] = array(
'date' => date_limit_format($format, $custom['granularities']['date']),
'time' => date_limit_format($format, $custom['granularities']['time']),
'zone' => date_limit_format($format, $custom['granularities']['zone']),
);
return array(
'formatted' => date_format_date($date, 'custom', $format),
'date' => date_format_date($date, 'custom', $custom['limits']['date']),
'time' => date_format_date($date, 'custom', $custom['limits']['time']),
'zone' => date_format_date($date, 'custom', $custom['limits']['zone']),
);
}
/**
* Retrieves the granularity for a field.
*
@@ -301,14 +345,14 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
*/
function date_granularity($field) {
if (!is_array($field) || !is_array($field['settings']['granularity'])) {
$field['settings']['granularity'] = drupal_map_assoc(array('year', 'month', 'day'));
$granularity = drupal_map_assoc(array('year', 'month', 'day'));
$field['settings']['granularity'] = $granularity;
}
return array_values(array_filter($field['settings']['granularity']));
}
/**
* Helper function to create an array of the date values in a
* field that need to be processed.
* Helper function to create an array of the date values in a field that need to be processed.
*/
function date_process_values($field) {
return $field['settings']['todate'] ? array('value', 'value2') : array('value');
@@ -394,10 +438,10 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
switch ($formatter) {
case 'format_interval':
return 'format_interval';
break;
case 'date_plain':
return 'date_plain';
break;
default:
$format = date_format_type_format($format_type, $langcode);
break;
@@ -410,6 +454,7 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
/**
* Helper function to get the right format for a format type.
*
* Checks for locale-based format first.
*/
function date_format_type_format($format_type, $langcode = NULL) {
@@ -432,27 +477,30 @@ function date_format_type_format($format_type, $langcode = NULL) {
case 'short':
$default = 'm/d/Y - H:i';
break;
case 'long':
$default = 'l, F j, Y - H:i';
break;
// If it's not one of the core date types and isn't stored in the
// database, we'll fall back on using the same default format as the
// 'medium' type.
case 'medium':
default:
// @todo: If a non-core module provides a date type and does not
// variable_set() a default for it, the default assumed here may
// not be correct (since the default format used by 'medium' may
// not even be one of the allowed formats for the date type in
// question). To fix this properly, we should really call
// system_get_date_formats($format_type) and take the first
// format from that list as the default. However, this function
// is called often (on many different page requests), so calling
// system_get_date_formats() from here would be a performance hit
// since that function writes several records to the database
// during each page request that calls it.
// variable_set() a default for it, the default assumed here may
// not be correct (since the default format used by 'medium' may
// not even be one of the allowed formats for the date type in
// question). To fix this properly, we should really call
// system_get_date_formats($format_type) and take the first
// format from that list as the default. However, this function
// is called often (on many different page requests), so calling
// system_get_date_formats() from here would be a performance hit
// since that function writes several records to the database
// during each page request that calls it.
$default = 'D, m/d/Y - H:i';
break;
}
$format = variable_get('date_format_' . $format_type, $default);
}
@@ -506,7 +554,7 @@ function date_prepare_entity($formatter, $entity_type, $entity, $field, $instanc
elseif ((!empty($max_count) && is_numeric($max_count) && $count >= $max_count) ||
(!empty($value['value']) && $value['value'] < $start) ||
(!empty($value['value2']) && $value['value2'] > $end)) {
unset($entity->{$field_name}[$langcode][$delta]);
unset($entity->{$field_name}[$langcode][$delta]);
}
else {
$count++;
@@ -647,7 +695,7 @@ function date_entity_metadata_field_setter(&$entity, $name, $value, $langcode, $
}
/**
* Auto creation callback for fields which contain two date values in one
* Auto creation callback for fields which contain two date values in one.
*/
function date_entity_metadata_struct_create($name, $property_info) {
return array(
@@ -658,10 +706,10 @@ function date_entity_metadata_struct_create($name, $property_info) {
/**
* Callback for setting an individual field value if a to-date may be there too.
*
* Based on entity_property_verbatim_set().
*
* The passed in unix timestamp (UTC) is converted to the right value and
* format dependent on the field.
* The passed in unix timestamp (UTC) is converted to the right value and format dependent on the field.
*
* $name is either 'value' or 'value2'.
*/
@@ -683,9 +731,9 @@ function date_entity_metadata_struct_setter(&$item, $name, $value, $langcode, $t
}
/**
* Duplicate functionality of what is now date_all_day_field() in
* the Date All Day module. Copy left here to avoid breaking other
* modules that use this function.
* Duplicate functionality of what is now date_all_day_field() in the Date All Day module.
*
* Copy left here to avoid breaking other modules that use this function.
*
* DEPRECATED!, will be removed at some time in the future.
*/
@@ -759,7 +807,7 @@ function date_field_widget_properties_alter(&$widget, $context) {
$entity = $context['entity'];
$info = entity_get_info($entity_type);
$id = $info['entity keys']['id'];
$widget['is_new']= FALSE;
$widget['is_new'] = FALSE;
if (empty($entity->$id)) {
$widget['is_new'] = TRUE;
}