Révision 599a39cd
Ajouté par Assos Assos il y a environ 3 ans
drupal7/sites/all/modules/date/date.field.inc | ||
---|---|---|
15 | 15 |
'field types' => array('date', 'datestamp', 'datetime'), |
16 | 16 |
'settings' => array( |
17 | 17 |
'format_type' => 'long', |
18 |
'custom_date_format' => '', |
|
19 |
'fromto' => 'both', |
|
18 | 20 |
'multiple_number' => '', |
19 | 21 |
'multiple_from' => '', |
20 | 22 |
'multiple_to' => '', |
21 |
'fromto' => 'both', |
|
22 | 23 |
'show_remaining_days' => FALSE, |
23 | 24 |
), |
24 | 25 |
), |
... | ... | |
28 | 29 |
'settings' => array( |
29 | 30 |
'interval' => 2, |
30 | 31 |
'interval_display' => 'time ago', |
31 |
'use_end_date' => false,
|
|
32 |
'use_end_date' => FALSE,
|
|
32 | 33 |
), |
33 | 34 |
), |
34 | 35 |
'date_plain' => array( |
... | ... | |
53 | 54 |
|
54 | 55 |
default: |
55 | 56 |
$form = date_default_formatter_settings_form($field, $instance, $view_mode, $form, $form_state); |
56 |
break; |
|
57 | 57 |
} |
58 | 58 |
$context = array( |
59 | 59 |
'field' => $field, |
... | ... | |
78 | 78 |
|
79 | 79 |
default: |
80 | 80 |
$summary = date_default_formatter_settings_summary($field, $instance, $view_mode); |
81 |
break; |
|
82 | 81 |
} |
83 | 82 |
$context = array( |
84 | 83 |
'field' => $field, |
... | ... | |
92 | 91 |
|
93 | 92 |
/** |
94 | 93 |
* Implements hook_field_formatter_view(). |
95 |
* |
|
96 |
* Useful values: |
|
97 |
* |
|
98 |
* $entity->date_id |
|
99 |
* If set, this will show only an individual date on a field with |
|
100 |
* multiple dates. The value should be a string that contains |
|
101 |
* the following values, separated with periods: |
|
102 |
* - module name of the module adding the item |
|
103 |
* - node nid |
|
104 |
* - field name |
|
105 |
* - delta value of the field to be displayed |
|
106 |
* - other information the module's custom theme might need |
|
107 |
* |
|
108 |
* Used by the calendar module and available for other uses. |
|
109 |
* example: 'date:217:field_date:3:test' |
|
110 |
* |
|
111 |
* $entity->date_repeat_show |
|
112 |
* If true, tells the theme to show all the computed values |
|
113 |
* of a repeating date. If not true or not set, only the |
|
114 |
* start date and the repeat rule will be displayed. |
|
115 | 94 |
*/ |
116 | 95 |
function date_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { |
96 |
// Useful values: |
|
97 |
// - $entity->date_id |
|
98 |
// If set, this will show only an individual date on a field with |
|
99 |
// multiple dates. The value should be a string that contains |
|
100 |
// the following values, separated with periods: |
|
101 |
// - module name of the module adding the item |
|
102 |
// - node nid |
|
103 |
// - field name |
|
104 |
// - delta value of the field to be displayed |
|
105 |
// - other information the module's custom theme might need |
|
106 |
// Used by the calendar module and available for other uses. |
|
107 |
// example: 'date:217:field_date:3:test' |
|
108 |
// - $entity->date_repeat_show |
|
109 |
// If TRUE, tells the theme to show all the computed values |
|
110 |
// of a repeating date. If not TRUE or not set, only the |
|
111 |
// start date and the repeat rule will be displayed. |
|
117 | 112 |
$element = array(); |
118 | 113 |
$settings = $display['settings']; |
119 | 114 |
$formatter = $display['type']; |
... | ... | |
176 | 171 |
$element[$delta] = array( |
177 | 172 |
'#markup' => t('!start-date to !end-date', array( |
178 | 173 |
'!start-date' => $item['value'], |
179 |
'!end-date' => $item['value2'] |
|
180 |
))); |
|
174 |
'!end-date' => $item['value2'], |
|
175 |
)), |
|
176 |
); |
|
181 | 177 |
} |
182 | 178 |
} |
183 | 179 |
} |
... | ... | |
215 | 211 |
} |
216 | 212 |
} |
217 | 213 |
} |
218 |
break; |
|
219 | 214 |
} |
215 |
|
|
216 |
// Add the CSS stylesheet only if we have something to display. |
|
217 |
if (!empty($element)) { |
|
218 |
$element['#attached']['css'][] = drupal_get_path('module', 'date_api') . '/date.css'; |
|
219 |
} |
|
220 |
|
|
220 | 221 |
return $element; |
221 | 222 |
} |
222 | 223 |
|
... | ... | |
224 | 225 |
* Implements hook_field_is_empty(). |
225 | 226 |
*/ |
226 | 227 |
function date_field_is_empty($item, $field) { |
227 |
// Sometimes a $item is a date object. |
|
228 |
// Coming from repeating dates. Why?? |
|
228 |
// Sometimes a $item is a date object. Coming from repeating dates. Why?? |
|
229 | 229 |
if (!is_array($item)) { |
230 | 230 |
return FALSE; |
231 | 231 |
} |
... | ... | |
373 | 373 |
foreach ($items as $delta => $item) { |
374 | 374 |
if (is_array($item) && isset($item['value'])) { |
375 | 375 |
$process = date_process_values($field, $instance); |
376 |
$date1 = new DateObject($item['value'], $item['timezone'], date_type_format($field['type'])); |
|
377 |
if (count($process) == 1 || (empty($item['value2']) && $item['value2'] !== 0)) { |
|
378 |
$date2 = clone($date1); |
|
376 |
$timezone = date_get_timezone($field['settings']['tz_handling'], isset($item['timezone']) ? $item['timezone'] : ''); |
|
377 |
$date1 = new DateObject($item['value'], $timezone, date_type_format($field['type'])); |
|
378 |
if (count($process) === 1 || (empty($item['value2']) && $item['value2'] !== 0)) { |
|
379 |
$date2 = clone $date1; |
|
379 | 380 |
} |
380 | 381 |
else { |
381 |
$date2 = new DateObject($item['value2'], $item['timezone'], date_type_format($field['type']));
|
|
382 |
$date2 = new DateObject($item['value2'], $timezone, date_type_format($field['type']));
|
|
382 | 383 |
} |
383 | 384 |
$valid1 = $date1->validGranularity($field['settings']['granularity'], $flexible); |
384 | 385 |
$valid2 = $date2->validGranularity($field['settings']['granularity'], $flexible); |
... | ... | |
411 | 412 |
if (empty($items)) { |
412 | 413 |
return; |
413 | 414 |
} |
415 |
|
|
414 | 416 |
// Add some information needed to interpret token values. |
415 | 417 |
$values = $items; |
416 | 418 |
foreach ($values as $delta => $item) { |
... | ... | |
454 | 456 |
|
455 | 457 |
/** |
456 | 458 |
* Implements hook_field_instance_settings_form(). |
457 |
* |
|
458 |
* Wrapper functions for date administration, included only when processing |
|
459 |
* field settings. |
|
460 | 459 |
*/ |
461 | 460 |
function date_field_instance_settings_form($field, $instance) { |
461 |
// Wrapper functions for date administration, included only when processing |
|
462 |
// field settings. |
|
462 | 463 |
module_load_include('inc', 'date', 'date_admin'); |
463 | 464 |
return _date_field_instance_settings_form($field, $instance); |
464 | 465 |
} |
... | ... | |
505 | 506 |
|
506 | 507 |
/** |
507 | 508 |
* Implements hook_content_migrate_field_alter(). |
508 |
* |
|
509 |
* Use this to tweak the conversion of field settings from the D6 style to the |
|
510 |
* D7 style for specific situations not handled by basic conversion, as when |
|
511 |
* field types or settings are changed. |
|
512 |
* |
|
513 |
* $field_value['widget_type'] is available to see what widget type was |
|
514 |
* originally used. |
|
515 | 509 |
*/ |
516 | 510 |
function date_content_migrate_field_alter(&$field_value, $instance_value) { |
511 |
// Use this to tweak the conversion of field settings from the D6 style to the |
|
512 |
// D7 style for specific situations not handled by basic conversion, as when |
|
513 |
// field types or settings are changed. |
|
514 |
// |
|
515 |
// $field_value['widget_type'] is available to see what widget type was |
|
516 |
// originally used. |
|
517 | 517 |
switch ($field_value['module']) { |
518 | 518 |
case 'date': |
519 | 519 |
// Those settings do not exist anymore, or have been moved to the instance |
... | ... | |
526 | 526 |
|
527 | 527 |
/** |
528 | 528 |
* Implements hook_content_migrate_instance_alter(). |
529 |
* |
|
530 |
* Use this to tweak the conversion of instance or widget settings from the D6 |
|
531 |
* style to the D7 style for specific situations not handled by basic |
|
532 |
* conversion, as when formatter or widget names or settings are changed. |
|
533 | 529 |
*/ |
534 | 530 |
function date_content_migrate_instance_alter(&$instance_value, $field_value) { |
531 |
// Use this to tweak the conversion of instance or widget settings from the D6 |
|
532 |
// style to the D7 style for specific situations not handled by basic |
|
533 |
// conversion, as when formatter or widget names or settings are changed. |
|
535 | 534 |
switch ($instance_value['widget']['module']) { |
536 | 535 |
case 'date': |
537 |
|
|
538 | 536 |
// Some settings have been moved from field to instance. |
539 | 537 |
$instance_value['widget']['settings']['repeat_collapsed'] = $field_value['settings']['repeat_collapsed']; |
540 | 538 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules