Révision b720ea3e
Ajouté par Assos Assos il y a plus de 8 ans
drupal7/sites/all/modules/date/date.devel_generate.inc | ||
---|---|---|
15 | 15 |
$entity_field = array(); |
16 | 16 |
if (isset($instance['widget']['settings']['year_range'])) { |
17 | 17 |
$split = explode(':', $instance['widget']['settings']['year_range']); |
18 |
$back = str_replace('-', '', $split[0]); |
|
19 |
$forward = str_replace('+', '', $split[1]); |
|
18 |
// Determine how much to go back and forward depending on whether a relative |
|
19 |
// number of years (with - or + sign) or an absolute year is given. |
|
20 |
$back = strpos($split[0], '-') === 0 |
|
21 |
? str_replace('-', '', $split[0]) |
|
22 |
: date_format(date_now(), 'Y') - $split[0]; |
|
23 |
$forward = strpos($split[1], '+') === 0 |
|
24 |
? str_replace('+', '', $split[1]) |
|
25 |
: $split[1] - date_format(date_now(), 'Y'); |
|
20 | 26 |
} |
21 | 27 |
else { |
22 | 28 |
$back = 2; |
... | ... | |
61 | 67 |
case 'date': |
62 | 68 |
$format = DATE_FORMAT_ISO; |
63 | 69 |
break; |
70 |
|
|
64 | 71 |
case 'datestamp': |
65 | 72 |
$format = DATE_FORMAT_UNIX; |
66 | 73 |
break; |
74 |
|
|
67 | 75 |
case 'datetime': |
68 | 76 |
$format = DATE_FORMAT_DATETIME; |
69 | 77 |
break; |
drupal7/sites/all/modules/date/date.field.inc | ||
---|---|---|
19 | 19 |
'multiple_from' => '', |
20 | 20 |
'multiple_to' => '', |
21 | 21 |
'fromto' => 'both', |
22 |
'show_remaining_days' => FALSE, |
|
22 | 23 |
), |
23 | 24 |
), |
24 | 25 |
'format_interval' => array( |
... | ... | |
48 | 49 |
case 'format_interval': |
49 | 50 |
$form = date_interval_formatter_settings_form($field, $instance, $view_mode, $form, $form_state); |
50 | 51 |
break; |
52 |
|
|
51 | 53 |
default: |
52 | 54 |
$form = date_default_formatter_settings_form($field, $instance, $view_mode, $form, $form_state); |
53 | 55 |
break; |
... | ... | |
72 | 74 |
case 'format_interval': |
73 | 75 |
$summary = date_interval_formatter_settings_summary($field, $instance, $view_mode); |
74 | 76 |
break; |
77 |
|
|
75 | 78 |
default: |
76 | 79 |
$summary = date_default_formatter_settings_summary($field, $instance, $view_mode); |
77 | 80 |
break; |
... | ... | |
169 | 172 |
$element[$delta] = array('#markup' => $item['value']); |
170 | 173 |
} |
171 | 174 |
else { |
172 |
$element[$delta] = array('#markup' => t('!start-date to !end-date', array('!start-date' => $item['value'], '!end-date' => $item['value2']))); |
|
175 |
$element[$delta] = array( |
|
176 |
'#markup' => t('!start-date to !end-date', array( |
|
177 |
'!start-date' => $item['value'], |
|
178 |
'!end-date' => $item['value2'] |
|
179 |
))); |
|
173 | 180 |
} |
174 | 181 |
} |
175 | 182 |
} |
176 | 183 |
break; |
184 |
|
|
177 | 185 |
case 'format_interval': |
178 | 186 |
foreach ($items as $delta => $item) { |
179 | 187 |
if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) { |
... | ... | |
188 | 196 |
} |
189 | 197 |
} |
190 | 198 |
break; |
199 |
|
|
191 | 200 |
default: |
192 | 201 |
foreach ($items as $delta => $item) { |
193 | 202 |
if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) { |
... | ... | |
198 | 207 |
$variables['item'] = $item; |
199 | 208 |
$variables['dates'] = date_formatter_process($formatter, $entity_type, $entity, $field, $instance, $langcode, $item, $display); |
200 | 209 |
$variables['attributes'] = !empty($rdf_mapping) ? rdf_rdfa_attributes($rdf_mapping, $item['value']) : array(); |
210 |
$variables['show_remaining_days'] = $display['settings']['show_remaining_days']; |
|
201 | 211 |
$output = theme('date_display_combination', $variables); |
202 | 212 |
if (!empty($output)) { |
203 | 213 |
$element[$delta] = array('#markup' => $output); |
... | ... | |
231 | 241 |
* Implements hook_field_info(). |
232 | 242 |
*/ |
233 | 243 |
function date_field_info() { |
244 |
$granularity = array('year', 'month', 'day', 'hour', 'minute'); |
|
234 | 245 |
$settings = array( |
235 | 246 |
'settings' => array( |
236 | 247 |
'todate' => '', |
237 |
'granularity' => drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute')),
|
|
248 |
'granularity' => drupal_map_assoc($granularity),
|
|
238 | 249 |
'tz_handling' => 'site', |
239 | 250 |
'timezone_db' => 'UTC', |
240 | 251 |
), |
... | ... | |
250 | 261 |
); |
251 | 262 |
return array( |
252 | 263 |
'datetime' => array( |
253 |
'label' => 'Date',
|
|
264 |
'label' => t('Date'),
|
|
254 | 265 |
'description' => t('Store a date in the database as a datetime field, recommended for complete dates and times that may need timezone conversion.'), |
255 | 266 |
'default_widget' => 'date_select', |
256 | 267 |
'default_formatter' => 'date_default', |
257 | 268 |
'default_token_formatter' => 'date_plain', |
258 |
) + $settings,
|
|
269 |
) + $settings, |
|
259 | 270 |
'date' => array( |
260 |
'label' => 'Date (ISO format)',
|
|
271 |
'label' => t('Date (ISO format)'),
|
|
261 | 272 |
'description' => t('Store a date in the database as an ISO date, recommended for historical or partial dates.'), |
262 | 273 |
'default_widget' => 'date_select', |
263 | 274 |
'default_formatter' => 'date_default', |
264 | 275 |
'default_token_formatter' => 'date_plain', |
265 |
) + $settings,
|
|
276 |
) + $settings, |
|
266 | 277 |
'datestamp' => array( |
267 |
'label' => 'Date (Unix timestamp)',
|
|
278 |
'label' => t('Date (Unix timestamp)'),
|
|
268 | 279 |
'description' => t('Store a date in the database as a timestamp, deprecated format to support legacy data.'), |
269 | 280 |
'default_widget' => 'date_select', |
270 | 281 |
'default_formatter' => 'date_default', |
271 | 282 |
'default_token_formatter' => 'date_plain', |
272 |
) + $settings,
|
|
283 |
) + $settings, |
|
273 | 284 |
); |
274 | 285 |
} |
275 | 286 |
|
... | ... | |
294 | 305 |
|
295 | 306 |
$info = array( |
296 | 307 |
'date_select' => array( |
297 |
'label' => t('Select list'),
|
|
308 |
'label' => t('Select list'), |
|
298 | 309 |
'field types' => array('date', 'datestamp', 'datetime'), |
299 | 310 |
) + $settings, |
300 | 311 |
'date_text' => array( |
301 |
'label' => t('Text field'),
|
|
312 |
'label' => t('Text field'), |
|
302 | 313 |
'field types' => array('date', 'datestamp', 'datetime'), |
303 |
) + $settings,
|
|
314 |
) + $settings, |
|
304 | 315 |
); |
305 | 316 |
|
306 | 317 |
if (module_exists('date_popup')) { |
307 | 318 |
$info['date_popup'] = array( |
308 |
'label' => t('Pop-up calendar'),
|
|
319 |
'label' => t('Pop-up calendar'), |
|
309 | 320 |
'field types' => array('date', 'datestamp', 'datetime'), |
310 | 321 |
) + $settings; |
311 | 322 |
} |
drupal7/sites/all/modules/date/date.info | ||
---|---|---|
11 | 11 |
files[] = tests/date_migrate.test |
12 | 12 |
files[] = tests/date_validation.test |
13 | 13 |
files[] = tests/date_timezone.test |
14 |
files[] = tests/date_views_pager.test |
|
15 |
files[] = tests/date_views_popup.test |
|
14 | 16 |
|
15 |
; Information added by Drupal.org packaging script on 2014-07-29
|
|
16 |
version = "7.x-2.8"
|
|
17 |
; Information added by Drupal.org packaging script on 2015-09-08
|
|
18 |
version = "7.x-2.9"
|
|
17 | 19 |
core = "7.x" |
18 | 20 |
project = "date" |
19 |
datestamp = "1406653438"
|
|
21 |
datestamp = "1441727353"
|
|
20 | 22 |
|
drupal7/sites/all/modules/date/date.install | ||
---|---|---|
19 | 19 |
'views' => TRUE, |
20 | 20 |
); |
21 | 21 |
break; |
22 |
|
|
22 | 23 |
case 'datetime': |
23 | 24 |
$db_columns['value'] = array( |
24 | 25 |
'type' => 'datetime', |
... | ... | |
31 | 32 |
'views' => TRUE, |
32 | 33 |
); |
33 | 34 |
break; |
35 |
|
|
34 | 36 |
default: |
35 | 37 |
$db_columns['value'] = array( |
36 | 38 |
'type' => 'varchar', |
... | ... | |
66 | 68 |
'views' => FALSE, |
67 | 69 |
); |
68 | 70 |
if (!empty($field['settings']['todate'])) { |
69 |
$db_columns['offset2'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE, 'views' => FALSE); |
|
71 |
$db_columns['offset2'] = array( |
|
72 |
'type' => 'int', |
|
73 |
'not null' => FALSE, |
|
74 |
'sortable' => TRUE, |
|
75 |
'views' => FALSE |
|
76 |
); |
|
70 | 77 |
} |
71 | 78 |
} |
72 | 79 |
if (isset($field['settings']['repeat']) && $field['settings']['repeat'] == 1) { |
... | ... | |
88 | 95 |
} |
89 | 96 |
|
90 | 97 |
/** |
91 |
* Get rid of the individual formatters for each format type, |
|
92 |
* these are now settings in the default formatter. |
|
98 |
* Get rid of the individual formatters for each format type. |
|
99 |
* |
|
100 |
* These are now settings in the default formatter. |
|
93 | 101 |
*/ |
94 | 102 |
function date_update_7000() { |
95 | 103 |
$instances = field_info_instances(); |
... | ... | |
115 | 123 |
} |
116 | 124 |
|
117 | 125 |
/** |
118 |
* Get rid of the separate widgets for repeating dates. The code now handles |
|
119 |
* repeating dates correctly using the regular widgets. |
|
126 |
* Get rid of the separate widgets for repeating dates. |
|
127 |
* |
|
128 |
* The code now handles repeating dates correctly using the regular widgets. |
|
120 | 129 |
*/ |
121 | 130 |
function date_update_7001() { |
122 | 131 |
$query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC)); |
... | ... | |
127 | 136 |
|
128 | 137 |
foreach ($results as $record) { |
129 | 138 |
$instance = unserialize($record['data']); |
130 |
if (in_array($instance['widget']['type'], array('date_popup_repeat', 'date_text_repeat', 'date_select_repeat'))) { |
|
139 |
if (in_array($instance['widget']['type'], array( |
|
140 |
'date_popup_repeat', |
|
141 |
'date_text_repeat', |
|
142 |
'date_select_repeat' |
|
143 |
))) { |
|
131 | 144 |
$instance['widget']['type'] = str_replace('_repeat', '', $instance['widget']['type']); |
132 | 145 |
db_update('field_config_instance') |
133 | 146 |
->fields(array( |
... | ... | |
191 | 204 |
field_cache_clear(); |
192 | 205 |
drupal_set_message(t('Date text widgets have been updated to use an increment of 1.')); |
193 | 206 |
} |
194 |
|
drupal7/sites/all/modules/date/date.js | ||
---|---|---|
27 | 27 |
this.$widget = $(widget); |
28 | 28 |
this.$start = this.$widget.find('.form-type-date-select[class$=value]'); |
29 | 29 |
this.$end = this.$widget.find('.form-type-date-select[class$=value2]'); |
30 |
if (this.$end.length == 0) { |
|
30 |
if (this.$end.length === 0) {
|
|
31 | 31 |
return; |
32 | 32 |
} |
33 | 33 |
this.initializeSelects(); |
... | ... | |
68 | 68 |
var id; |
69 | 69 |
for (id in this.selects) { |
70 | 70 |
if (this.selects.hasOwnProperty(id)) { |
71 |
if (this.selects[id].end.val() != '') { |
|
71 |
if (this.selects[id].end.val() !== '') {
|
|
72 | 72 |
return false; |
73 | 73 |
} |
74 | 74 |
} |
drupal7/sites/all/modules/date/date.migrate.inc | ||
---|---|---|
40 | 40 |
* @return array |
41 | 41 |
* An array of the defined variables in this scope. |
42 | 42 |
*/ |
43 |
static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) { |
|
43 |
public static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) {
|
|
44 | 44 |
return get_defined_vars(); |
45 | 45 |
} |
46 | 46 |
|
... | ... | |
129 | 129 |
// timestamp for 'now'. |
130 | 130 |
if (empty($from)) { |
131 | 131 |
$return[$language][$delta]['value'] = NULL; |
132 |
$return[$language][$delta]['timezone'] = NULL; |
|
132 | 133 |
if (!empty($field_info['settings']['todate'])) { |
133 | 134 |
$return[$language][$delta]['value2'] = NULL; |
134 | 135 |
} |
... | ... | |
151 | 152 |
case 'datestamp': |
152 | 153 |
// Already done. |
153 | 154 |
break; |
155 |
|
|
154 | 156 |
case 'datetime': |
155 | 157 |
// YYYY-MM-DD HH:MM:SS. |
156 | 158 |
$from = format_date($from, 'custom', 'Y-m-d H:i:s', $timezone); |
... | ... | |
158 | 160 |
$to = format_date($to, 'custom', 'Y-m-d H:i:s', $timezone); |
159 | 161 |
} |
160 | 162 |
break; |
163 |
|
|
161 | 164 |
case 'date': |
162 | 165 |
// ISO date: YYYY-MM-DDTHH:MM:SS. |
163 | 166 |
$from = format_date($from, 'custom', 'Y-m-d\TH:i:s', $timezone); |
... | ... | |
165 | 168 |
$to = format_date($to, 'custom', 'Y-m-d\TH:i:s', $timezone); |
166 | 169 |
} |
167 | 170 |
break; |
171 |
|
|
168 | 172 |
default: |
169 | 173 |
break; |
170 | 174 |
} |
... | ... | |
173 | 177 |
// created. |
174 | 178 |
if (function_exists('date_repeat_build_dates') && !empty($field_info['settings']['repeat']) && $rrule) { |
175 | 179 |
include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc'; |
176 |
$item = array('value' => $from, 'value2' => $to, 'timezone' => $timezone); |
|
180 |
$item = array( |
|
181 |
'value' => $from, |
|
182 |
'value2' => $to, |
|
183 |
'timezone' => $timezone, |
|
184 |
); |
|
177 | 185 |
// Can be de-uglified when http://drupal.org/node/1159404 is committed. |
178 | 186 |
$return[$language] = date_repeat_build_dates(NULL, date_ical_parse_rrule($field_info, $rrule), $field_info, $item); |
179 | 187 |
} |
180 | 188 |
else { |
181 | 189 |
$return[$language][$delta]['value'] = $from; |
190 |
$return[$language][$delta]['timezone'] = $timezone; |
|
182 | 191 |
if (!empty($to)) { |
183 | 192 |
$return[$language][$delta]['value2'] = $to; |
184 | 193 |
} |
... | ... | |
190 | 199 |
return $return; |
191 | 200 |
} |
192 | 201 |
|
202 |
/** |
|
203 |
* {@inheritdoc} |
|
204 |
*/ |
|
193 | 205 |
public function fields($migration = NULL) { |
194 | 206 |
return array( |
195 | 207 |
'timezone' => t('Timezone'), |
drupal7/sites/all/modules/date/date.module | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* Defines date/time field types. |
5 | 6 |
*/ |
7 |
|
|
6 | 8 |
module_load_include('theme', 'date', 'date'); |
7 | 9 |
module_load_include('inc', 'date', 'date.field'); |
8 | 10 |
module_load_include('inc', 'date', 'date_elements'); |
... | ... | |
15 | 17 |
case 'field_collection_item': |
16 | 18 |
$bundle = $entity->field_name; |
17 | 19 |
break; |
20 |
|
|
18 | 21 |
default: |
19 | 22 |
$bundle = field_extract_bundle($entity_type, $entity); |
20 | 23 |
break; |
... | ... | |
40 | 43 |
* Wrapper function around each of the widget types for creating a date object. |
41 | 44 |
*/ |
42 | 45 |
function date_input_date($field, $instance, $element, $input) { |
46 |
// Trim extra spacing off user input of text fields. |
|
47 |
if (isset($input['date'])) { |
|
48 |
$input['date'] = trim($input['date']); |
|
49 |
} |
|
50 |
|
|
43 | 51 |
switch ($instance['widget']['type']) { |
44 | 52 |
case 'date_text': |
45 | 53 |
$function = 'date_text_input_date'; |
46 | 54 |
break; |
55 |
|
|
47 | 56 |
case 'date_popup': |
48 | 57 |
$function = 'date_popup_input_date'; |
49 | 58 |
break; |
59 |
|
|
50 | 60 |
default: |
51 | 61 |
$function = 'date_select_input_date'; |
52 | 62 |
} |
... | ... | |
66 | 76 |
); |
67 | 77 |
$themes = array( |
68 | 78 |
'date_combo' => $base + array('render element' => 'element'), |
79 |
'date_form_element' => $base + array('render element' => 'element'), |
|
69 | 80 |
'date_text_parts' => $base + array('render element' => 'element'), |
70 | 81 |
'date' => $base + array('render element' => 'element'), |
71 | 82 |
'date_display_single' => $base + array( |
... | ... | |
97 | 108 |
'add_rdf' => NULL, |
98 | 109 |
'microdata' => NULL, |
99 | 110 |
'add_microdata' => NULL, |
100 |
)), |
|
111 |
), |
|
112 |
), |
|
113 |
'date_display_remaining' => $base + array( |
|
114 |
'variables' => array( |
|
115 |
'remaining_days' => NULL, |
|
116 |
), |
|
117 |
), |
|
101 | 118 |
'date_display_combination' => $base + array( |
102 | 119 |
'variables' => array( |
103 | 120 |
'entity_type' => NULL, |
... | ... | |
130 | 147 |
'attributes' => array(), |
131 | 148 |
'rdf_mapping' => NULL, |
132 | 149 |
'add_rdf' => NULL, |
133 |
),
|
|
150 |
), |
|
134 | 151 |
), |
135 | 152 |
); |
136 | 153 |
|
... | ... | |
209 | 226 |
$settings = $display['settings']; |
210 | 227 |
$field_name = $field['field_name']; |
211 | 228 |
$format = date_formatter_format($formatter, $settings, $granularity, $langcode); |
212 |
$timezone = isset($item['timezone']) ? $item['timezone'] : ''; |
|
213 |
$timezone = date_get_timezone($field['settings']['tz_handling'], $timezone); |
|
229 |
if (!isset($field['settings']['tz_handling']) || $field['settings']['tz_handling'] !== 'utc') { |
|
230 |
$timezone = isset($item['timezone']) ? $item['timezone'] : ''; |
|
231 |
$timezone = date_get_timezone($field['settings']['tz_handling'], $timezone); |
|
232 |
} |
|
214 | 233 |
$timezone_db = date_get_timezone_db($field['settings']['tz_handling']); |
215 | 234 |
$db_format = date_type_format($field['type']); |
216 | 235 |
$process = date_process_values($field); |
... | ... | |
246 | 265 |
$dates[$processed]['formatted_iso'] = date_format_date($date, 'custom', 'c'); |
247 | 266 |
if (is_object($date)) { |
248 | 267 |
if ($format == 'format_interval') { |
249 |
$dates[$processed]['interval'] = date_format_interval($date);
|
|
268 |
$dates[$processed]['interval'] = date_format_interval($date); |
|
250 | 269 |
} |
251 | 270 |
elseif ($format == 'format_calendar_day') { |
252 |
$dates[$processed]['calendar_day'] = date_format_calendar_day($date);
|
|
271 |
$dates[$processed]['calendar_day'] = date_format_calendar_day($date); |
|
253 | 272 |
} |
254 | 273 |
elseif ($format == 'U' || $format == 'r' || $format == 'c') { |
255 | 274 |
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format); |
... | ... | |
258 | 277 |
$dates[$processed]['formatted_timezone'] = ''; |
259 | 278 |
} |
260 | 279 |
elseif (!empty($format)) { |
261 |
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format); |
|
262 |
$dates[$processed]['formatted_date'] = date_format_date($date, 'custom', date_limit_format($format, array('year', 'month', 'day'))); |
|
263 |
$dates[$processed]['formatted_time'] = date_format_date($date, 'custom', date_limit_format($format, array('hour', 'minute', 'second'))); |
|
264 |
$dates[$processed]['formatted_timezone'] = date_format_date($date, 'custom', date_limit_format($format, array('timezone'))); |
|
280 |
$formats = _get_custom_date_format($date, $format); |
|
281 |
$dates[$processed]['formatted'] = $formats['formatted']; |
|
282 |
$dates[$processed]['formatted_date'] = $formats['date']; |
|
283 |
$dates[$processed]['formatted_time'] = $formats['time']; |
|
284 |
$dates[$processed]['formatted_timezone'] = $formats['zone']; |
|
265 | 285 |
} |
266 | 286 |
} |
267 | 287 |
} |
... | ... | |
288 | 308 |
return $dates; |
289 | 309 |
} |
290 | 310 |
|
311 |
/** |
|
312 |
* Get a custom date format. |
|
313 |
*/ |
|
314 |
function _get_custom_date_format($date, $format) { |
|
315 |
$custom = array(); |
|
316 |
$custom['granularities'] = array( |
|
317 |
'date' => array('year', 'month', 'day'), |
|
318 |
'time' => array('hour', 'minute', 'second'), |
|
319 |
'zone' => array('timezone'), |
|
320 |
); |
|
321 |
$custom['limits'] = array( |
|
322 |
'date' => date_limit_format($format, $custom['granularities']['date']), |
|
323 |
'time' => date_limit_format($format, $custom['granularities']['time']), |
|
324 |
'zone' => date_limit_format($format, $custom['granularities']['zone']), |
|
325 |
); |
|
326 |
|
|
327 |
return array( |
|
328 |
'formatted' => date_format_date($date, 'custom', $format), |
|
329 |
'date' => date_format_date($date, 'custom', $custom['limits']['date']), |
|
330 |
'time' => date_format_date($date, 'custom', $custom['limits']['time']), |
|
331 |
'zone' => date_format_date($date, 'custom', $custom['limits']['zone']), |
|
332 |
); |
|
333 |
} |
|
334 |
|
|
291 | 335 |
/** |
292 | 336 |
* Retrieves the granularity for a field. |
293 | 337 |
* |
... | ... | |
301 | 345 |
*/ |
302 | 346 |
function date_granularity($field) { |
303 | 347 |
if (!is_array($field) || !is_array($field['settings']['granularity'])) { |
304 |
$field['settings']['granularity'] = drupal_map_assoc(array('year', 'month', 'day')); |
|
348 |
$granularity = drupal_map_assoc(array('year', 'month', 'day')); |
|
349 |
$field['settings']['granularity'] = $granularity; |
|
305 | 350 |
} |
306 | 351 |
return array_values(array_filter($field['settings']['granularity'])); |
307 | 352 |
} |
308 | 353 |
|
309 | 354 |
/** |
310 |
* Helper function to create an array of the date values in a |
|
311 |
* field that need to be processed. |
|
355 |
* Helper function to create an array of the date values in a field that need to be processed. |
|
312 | 356 |
*/ |
313 | 357 |
function date_process_values($field) { |
314 | 358 |
return $field['settings']['todate'] ? array('value', 'value2') : array('value'); |
... | ... | |
394 | 438 |
switch ($formatter) { |
395 | 439 |
case 'format_interval': |
396 | 440 |
return 'format_interval'; |
397 |
break; |
|
441 |
|
|
398 | 442 |
case 'date_plain': |
399 | 443 |
return 'date_plain'; |
400 |
break; |
|
444 |
|
|
401 | 445 |
default: |
402 | 446 |
$format = date_format_type_format($format_type, $langcode); |
403 | 447 |
break; |
... | ... | |
410 | 454 |
|
411 | 455 |
/** |
412 | 456 |
* Helper function to get the right format for a format type. |
457 |
* |
|
413 | 458 |
* Checks for locale-based format first. |
414 | 459 |
*/ |
415 | 460 |
function date_format_type_format($format_type, $langcode = NULL) { |
... | ... | |
432 | 477 |
case 'short': |
433 | 478 |
$default = 'm/d/Y - H:i'; |
434 | 479 |
break; |
480 |
|
|
435 | 481 |
case 'long': |
436 | 482 |
$default = 'l, F j, Y - H:i'; |
437 | 483 |
break; |
484 |
|
|
438 | 485 |
// If it's not one of the core date types and isn't stored in the |
439 | 486 |
// database, we'll fall back on using the same default format as the |
440 | 487 |
// 'medium' type. |
441 | 488 |
case 'medium': |
442 | 489 |
default: |
443 | 490 |
// @todo: If a non-core module provides a date type and does not |
444 |
// variable_set() a default for it, the default assumed here may
|
|
445 |
// not be correct (since the default format used by 'medium' may
|
|
446 |
// not even be one of the allowed formats for the date type in
|
|
447 |
// question). To fix this properly, we should really call
|
|
448 |
// system_get_date_formats($format_type) and take the first
|
|
449 |
// format from that list as the default. However, this function
|
|
450 |
// is called often (on many different page requests), so calling
|
|
451 |
// system_get_date_formats() from here would be a performance hit
|
|
452 |
// since that function writes several records to the database
|
|
453 |
// during each page request that calls it.
|
|
491 |
// variable_set() a default for it, the default assumed here may |
|
492 |
// not be correct (since the default format used by 'medium' may |
|
493 |
// not even be one of the allowed formats for the date type in |
|
494 |
// question). To fix this properly, we should really call |
|
495 |
// system_get_date_formats($format_type) and take the first |
|
496 |
// format from that list as the default. However, this function |
|
497 |
// is called often (on many different page requests), so calling |
|
498 |
// system_get_date_formats() from here would be a performance hit |
|
499 |
// since that function writes several records to the database |
|
500 |
// during each page request that calls it. |
|
454 | 501 |
$default = 'D, m/d/Y - H:i'; |
455 | 502 |
break; |
503 |
|
|
456 | 504 |
} |
457 | 505 |
$format = variable_get('date_format_' . $format_type, $default); |
458 | 506 |
} |
... | ... | |
506 | 554 |
elseif ((!empty($max_count) && is_numeric($max_count) && $count >= $max_count) || |
507 | 555 |
(!empty($value['value']) && $value['value'] < $start) || |
508 | 556 |
(!empty($value['value2']) && $value['value2'] > $end)) { |
509 |
unset($entity->{$field_name}[$langcode][$delta]);
|
|
557 |
unset($entity->{$field_name}[$langcode][$delta]); |
|
510 | 558 |
} |
511 | 559 |
else { |
512 | 560 |
$count++; |
... | ... | |
647 | 695 |
} |
648 | 696 |
|
649 | 697 |
/** |
650 |
* Auto creation callback for fields which contain two date values in one |
|
698 |
* Auto creation callback for fields which contain two date values in one.
|
|
651 | 699 |
*/ |
652 | 700 |
function date_entity_metadata_struct_create($name, $property_info) { |
653 | 701 |
return array( |
... | ... | |
658 | 706 |
|
659 | 707 |
/** |
660 | 708 |
* Callback for setting an individual field value if a to-date may be there too. |
709 |
* |
|
661 | 710 |
* Based on entity_property_verbatim_set(). |
662 | 711 |
* |
663 |
* The passed in unix timestamp (UTC) is converted to the right value and |
|
664 |
* format dependent on the field. |
|
712 |
* The passed in unix timestamp (UTC) is converted to the right value and format dependent on the field. |
|
665 | 713 |
* |
666 | 714 |
* $name is either 'value' or 'value2'. |
667 | 715 |
*/ |
... | ... | |
683 | 731 |
} |
684 | 732 |
|
685 | 733 |
/** |
686 |
* Duplicate functionality of what is now date_all_day_field() in |
|
687 |
* the Date All Day module. Copy left here to avoid breaking other
|
|
688 |
* modules that use this function. |
|
734 |
* Duplicate functionality of what is now date_all_day_field() in the Date All Day module.
|
|
735 |
* |
|
736 |
* Copy left here to avoid breaking other modules that use this function.
|
|
689 | 737 |
* |
690 | 738 |
* DEPRECATED!, will be removed at some time in the future. |
691 | 739 |
*/ |
... | ... | |
759 | 807 |
$entity = $context['entity']; |
760 | 808 |
$info = entity_get_info($entity_type); |
761 | 809 |
$id = $info['entity keys']['id']; |
762 |
$widget['is_new']= FALSE; |
|
810 |
$widget['is_new'] = FALSE;
|
|
763 | 811 |
if (empty($entity->$id)) { |
764 | 812 |
$widget['is_new'] = TRUE; |
765 | 813 |
} |
drupal7/sites/all/modules/date/date.theme | ||
---|---|---|
77 | 77 |
$microdata = $variables['microdata']; |
78 | 78 |
$add_microdata = $variables['add_microdata']; |
79 | 79 |
$precision = date_granularity_precision($field['settings']['granularity']); |
80 |
$show_remaining_days = $variables['show_remaining_days']; |
|
80 | 81 |
|
81 | 82 |
$output = ''; |
82 | 83 |
|
... | ... | |
121 | 122 |
$date1 = $dates['value']['formatted']; |
122 | 123 |
$date2 = $date1; |
123 | 124 |
break; |
125 |
|
|
124 | 126 |
case 'value2': |
125 | 127 |
$date2 = $dates['value2']['formatted']; |
126 | 128 |
$date1 = $date2; |
127 | 129 |
break; |
130 |
|
|
128 | 131 |
default: |
129 | 132 |
$date1 = $dates['value']['formatted']; |
130 | 133 |
$date2 = $dates['value2']['formatted']; |
... | ... | |
151 | 154 |
$has_time_string = FALSE; |
152 | 155 |
} |
153 | 156 |
|
157 |
// Check remaining days. |
|
158 |
$show_remaining_days = ''; |
|
159 |
if (!empty($variables['show_remaining_days'])) { |
|
160 |
$remaining_days = floor((strtotime($variables['dates']['value']['formatted_iso']) |
|
161 |
- strtotime('now')) / (24 * 3600)); |
|
162 |
|
|
163 |
// Show remaining days only for future events. |
|
164 |
if ($remaining_days >= 0) { |
|
165 |
$show_remaining_days = theme('date_display_remaining', array( |
|
166 |
'remaining_days' => $remaining_days, |
|
167 |
)); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
154 | 171 |
// No date values, display nothing. |
155 | 172 |
if (empty($date1) && empty($date2)) { |
156 | 173 |
$output .= ''; |
... | ... | |
167 | 184 |
'microdata' => $microdata, |
168 | 185 |
'add_microdata' => $add_microdata, |
169 | 186 |
'dates' => $dates, |
187 |
'show_remaining_days' => $show_remaining_days, |
|
170 | 188 |
)); |
171 | 189 |
} |
172 | 190 |
// Same day, different times, don't repeat the date but show both Start and |
... | ... | |
186 | 204 |
'microdata' => $microdata, |
187 | 205 |
'add_microdata' => $add_microdata, |
188 | 206 |
'dates' => $dates, |
207 |
'show_remaining_days' => $show_remaining_days, |
|
189 | 208 |
)); |
190 | 209 |
$replaced = str_replace($time1, $time, $date1); |
191 | 210 |
$output .= theme('date_display_single', array( |
... | ... | |
209 | 228 |
'microdata' => $microdata, |
210 | 229 |
'add_microdata' => $add_microdata, |
211 | 230 |
'dates' => $dates, |
231 |
'show_remaining_days' => $show_remaining_days, |
|
212 | 232 |
)); |
213 | 233 |
} |
214 | 234 |
|
... | ... | |
236 | 256 |
// Because the Entity API integration for Date has a variable data |
237 | 257 |
// structure depending on whether there is an end value, the attributes |
238 | 258 |
// could be attached to the field or to the value property. |
239 |
if(!empty($variables['microdata']['#attributes']['itemprop'])) { |
|
259 |
if (!empty($variables['microdata']['#attributes']['itemprop'])) {
|
|
240 | 260 |
$variables['microdata']['value']['#attributes'] = $variables['microdata']['#attributes']; |
241 | 261 |
} |
242 | 262 |
|
243 | 263 |
// Add the machine readable time using the content attribute. |
244 |
if(!empty($variables['microdata']['value']['#attributes'])) { |
|
264 |
if (!empty($variables['microdata']['value']['#attributes'])) {
|
|
245 | 265 |
$variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso']; |
246 | 266 |
} |
247 | 267 |
else { |
... | ... | |
257 | 277 |
$date = $variables['date']; |
258 | 278 |
$timezone = $variables['timezone']; |
259 | 279 |
$attributes = $variables['attributes']; |
280 |
$show_remaining_days = isset($variables['show_remaining_days']) ? $variables['show_remaining_days'] : ''; |
|
260 | 281 |
|
261 | 282 |
// Wrap the result with the attributes. |
262 | 283 |
$output = '<span class="date-display-single"' . drupal_attributes($attributes) . '>' . $date . $timezone . '</span>'; |
... | ... | |
265 | 286 |
$output .= '<meta' . drupal_attributes($variables['microdata']['value']['#attributes']) . '/>'; |
266 | 287 |
} |
267 | 288 |
|
268 |
return $output; |
|
289 |
// Add remaining message and return. |
|
290 |
return $output . $show_remaining_days; |
|
269 | 291 |
} |
270 | 292 |
|
271 | 293 |
/** |
... | ... | |
314 | 336 |
$timezone = $variables['timezone']; |
315 | 337 |
$attributes_start = $variables['attributes_start']; |
316 | 338 |
$attributes_end = $variables['attributes_end']; |
339 |
$show_remaining_days = $variables['show_remaining_days']; |
|
317 | 340 |
|
318 | 341 |
$start_date = '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>'; |
319 | 342 |
$end_date = '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . $timezone . '</span>'; |
... | ... | |
326 | 349 |
} |
327 | 350 |
|
328 | 351 |
// Wrap the result with the attributes. |
329 |
return t('!start-date to !end-date', array(
|
|
352 |
$output = '<div class="date-display-range">' . t('!start-date to !end-date', array(
|
|
330 | 353 |
'!start-date' => $start_date, |
331 | 354 |
'!end-date' => $end_date, |
332 |
)); |
|
355 |
)) . '</div>'; |
|
356 |
|
|
357 |
// Add remaining message and return. |
|
358 |
return $output . $show_remaining_days; |
|
333 | 359 |
} |
334 | 360 |
|
335 | 361 |
/** |
... | ... | |
375 | 401 |
'#title' => field_filter_xss(t($element['#title'])) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''), |
376 | 402 |
'#value' => '', |
377 | 403 |
'#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '', |
378 |
'#attributes' => array(), |
|
404 |
'#attributes' => array('class' => array('date-combo')),
|
|
379 | 405 |
'#children' => $element['#children'], |
380 | 406 |
); |
381 | 407 |
// Add marker to required date fields. |
... | ... | |
396 | 422 |
$rows[] = drupal_render($element[$key]); |
397 | 423 |
} |
398 | 424 |
else { |
399 |
$rows[] = array($part, drupal_render($element[$key][0]), drupal_render($element[$key][1])); |
|
425 |
$rows[] = array( |
|
426 |
$part, |
|
427 |
drupal_render($element[$key][0]), |
|
428 |
drupal_render($element[$key][1]), |
|
429 |
); |
|
400 | 430 |
} |
401 | 431 |
} |
402 | 432 |
if ($element['year']['#type'] == 'hidden') { |
... | ... | |
408 | 438 |
} |
409 | 439 |
} |
410 | 440 |
|
441 |
/** |
|
442 |
* Render a date combo as a form element. |
|
443 |
*/ |
|
444 |
function theme_date_form_element($variables) { |
|
445 |
$element = &$variables['element']; |
|
446 |
|
|
447 |
// Detect whether element is multiline. |
|
448 |
$count = preg_match_all('`<(?:div|span)\b[^>]* class="[^"]*\b(?:date-no-float|date-clear)\b`', $element['#children'], $matches, PREG_OFFSET_CAPTURE); |
|
449 |
$multiline = FALSE; |
|
450 |
if ($count > 1) { |
|
451 |
$multiline = TRUE; |
|
452 |
} |
|
453 |
elseif ($count) { |
|
454 |
$before = substr($element['#children'], 0, $matches[0][0][1]); |
|
455 |
if (preg_match('`<(?:div|span)\b[^>]* class="[^"]*\bdate-float\b`', $before)) { |
|
456 |
$multiline = TRUE; |
|
457 |
} |
|
458 |
} |
|
459 |
|
|
460 |
// Detect if there is more than one subfield. |
|
461 |
$count = count(explode('<label', $element['#children'])) - 1; |
|
462 |
if ($count == 1) { |
|
463 |
$element['#title_display'] = 'none'; |
|
464 |
} |
|
465 |
|
|
466 |
// Wrap children with a div and add an extra class if element is multiline. |
|
467 |
$element['#children'] = '<div class="date-form-element-content'. ($multiline ? ' date-form-element-content-multiline' : '') .'">'. $element['#children'] .'</div>'; |
|
468 |
|
|
469 |
return theme('form_element', $variables); |
|
470 |
} |
|
471 |
|
|
472 |
/** |
|
473 |
* Returns HTML for remaining message. |
|
474 |
*/ |
|
475 |
function theme_date_display_remaining($variables) { |
|
476 |
$remaining_days = $variables['remaining_days']; |
|
477 |
$output = ''; |
|
478 |
$show_remaining_text = t('The upcoming date less then 1 day.'); |
|
479 |
if ($remaining_days) { |
|
480 |
$show_remaining_text = format_plural($remaining_days, 'To event remaining 1 day', 'To event remaining @count days'); |
|
481 |
} |
|
482 |
|
|
483 |
return '<div class="date-display-remaining"><span class="date-display-remaining">' . $show_remaining_text . '</span></div>'; |
|
484 |
} |
|
485 |
|
|
411 | 486 |
/** @} End of addtogroup themeable */ |
drupal7/sites/all/modules/date/date_admin.inc | ||
---|---|---|
74 | 74 |
'#description' => t('Identify specific start and/or end dates in the format YYYY-MM-DDTHH:MM:SS, or leave blank for all available dates.'), |
75 | 75 |
); |
76 | 76 |
|
77 |
$form['show_remaining_days'] = array( |
|
78 |
'#title' => t('Show remaining days'), |
|
79 |
'#type' => 'checkbox', |
|
80 |
'#default_value' => $settings['show_remaining_days'], |
|
81 |
'#weight' => 0, |
|
82 |
); |
|
77 | 83 |
return $form; |
78 | 84 |
} |
79 | 85 |
|
... | ... | |
127 | 133 |
case 'date_plain': |
128 | 134 |
$format = t('Plain'); |
129 | 135 |
break; |
136 |
|
|
130 | 137 |
case 'format_interval': |
131 | 138 |
$format = t('Interval'); |
132 | 139 |
break; |
140 |
|
|
133 | 141 |
default: |
134 | 142 |
if (!empty($format_types[$settings['format_type']])) { |
135 | 143 |
$format = $format_types[$settings['format_type']]; |
... | ... | |
148 | 156 |
'value' => t('Display Start date only'), |
149 | 157 |
'value2' => t('Display End date only'), |
150 | 158 |
); |
151 |
$summary[] = $options[$settings['fromto']]; |
|
159 |
if (isset($options[$settings['fromto']])) { |
|
160 |
$summary[] = $options[$settings['fromto']]; |
|
161 |
} |
|
152 | 162 |
} |
153 | 163 |
|
154 | 164 |
if (array_key_exists('multiple_number', $settings) && !empty($field['cardinality'])) { |
... | ... | |
159 | 169 |
)); |
160 | 170 |
} |
161 | 171 |
|
172 |
if (array_key_exists('show_remaining_days', $settings)) { |
|
173 |
$summary[] = t('Show remaining days: @value', array('@value' => ($settings['show_remaining_days'] ? 'yes' : 'no'))); |
|
174 |
} |
|
175 |
|
|
162 | 176 |
return $summary; |
163 | 177 |
} |
164 | 178 |
|
... | ... | |
191 | 205 |
'#type' => 'select', |
192 | 206 |
'#title' => t('Default date'), |
193 | 207 |
'#default_value' => $settings['default_value'], |
194 |
'#options' => array('blank' => t('No default value'), 'now' => t('Now'), 'strtotime' => t('Relative')), |
|
208 |
'#options' => array( |
|
209 |
'blank' => t('No default value'), |
|
210 |
'now' => t('Now'), |
|
211 |
'strtotime' => t('Relative'), |
|
212 |
), |
|
195 | 213 |
'#weight' => 1, |
196 | 214 |
'#fieldset' => 'default_values', |
197 | 215 |
); |
... | ... | |
204 | 222 |
'#default_value' => $settings['default_value_code'], |
205 | 223 |
'#states' => array( |
206 | 224 |
'visible' => array( |
207 |
':input[name="instance[settings][default_value]"]' => array('value' => 'strtotime')), |
|
225 |
':input[name="instance[settings][default_value]"]' => array( |
|
226 |
'value' => 'strtotime', |
|
227 |
), |
|
208 | 228 |
), |
229 |
), |
|
209 | 230 |
'#weight' => 1.1, |
210 | 231 |
'#fieldset' => 'default_values', |
211 | 232 |
); |
... | ... | |
213 | 234 |
'#type' => !empty($field['settings']['todate']) ? 'select' : 'hidden', |
214 | 235 |
'#title' => t('Default end date'), |
215 | 236 |
'#default_value' => $settings['default_value2'], |
216 |
'#options' => array('same' => t('Same as Default date'), 'blank' => t('No default value'), 'now' => t('Now'), 'strtotime' => t('Relative')), |
|
237 |
'#options' => array( |
|
238 |
'same' => t('Same as Default date'), |
|
239 |
'blank' => t('No default value'), |
|
240 |
'now' => t('Now'), |
|
241 |
'strtotime' => t('Relative'), |
|
242 |
), |
|
217 | 243 |
'#weight' => 2, |
218 | 244 |
'#fieldset' => 'default_values', |
219 | 245 |
); |
... | ... | |
224 | 250 |
'#default_value' => $settings['default_value_code2'], |
225 | 251 |
'#states' => array( |
226 | 252 |
'visible' => array( |
227 |
':input[name="instance[settings][default_value2]"]' => array('value' => 'strtotime')), |
|
253 |
':input[name="instance[settings][default_value2]"]' => array( |
|
254 |
'value' => 'strtotime', |
|
255 |
), |
|
228 | 256 |
), |
257 |
), |
|
229 | 258 |
'#weight' => 2.1, |
230 | 259 |
'#fieldset' => 'default_values', |
231 | 260 |
); |
... | ... | |
284 | 313 |
$formats = drupal_map_assoc($formats); |
285 | 314 |
} |
286 | 315 |
$now = date_example_date(); |
316 |
$options['site-wide'] = t('Short date format: @date', array('@date' => date_format_date($now, 'short'))); |
|
287 | 317 |
foreach ($formats as $f) { |
288 | 318 |
$options[$f] = date_format_date($now, 'custom', $f); |
289 | 319 |
} |
... | ... | |
369 | 399 |
'#weight' => 9, |
370 | 400 |
); |
371 | 401 |
if (in_array($widget['type'], array('date_select'))) { |
372 |
$options = array('above' => t('Above'), 'within' => t('Within'), 'none' => t('None')); |
|
402 |
$options = array( |
|
403 |
'above' => t('Above'), |
|
404 |
'within' => t('Within'), |
|
405 |
'none' => t('None'), |
|
406 |
); |
|
373 | 407 |
$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."); |
374 | 408 |
} |
375 | 409 |
else { |
376 |
$options = array('above' => t('Above'), 'none' => t('None')); |
|
410 |
$options = array( |
|
411 |
'above' => t('Above'), |
|
412 |
'none' => t('None'), |
|
413 |
); |
|
377 | 414 |
$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."); |
378 | 415 |
} |
379 | 416 |
$form['advanced']['label_position'] = array( |
... | ... | |
403 | 440 |
} |
404 | 441 |
} |
405 | 442 |
|
443 |
$form['advanced']['no_fieldset'] = array( |
|
444 |
'#type' => 'checkbox', |
|
445 |
'#title' => t('Render as a regular field'), |
|
446 |
'#default_value' => !empty($settings['no_fieldset']), |
|
447 |
'#description' => t('Whether to render this field as a regular field instead of a fieldset. The date field elements are wrapped in a fieldset by default, and may not display well without it.'), |
|
448 |
); |
|
449 |
|
|
406 | 450 |
$context = array( |
407 | 451 |
'field' => $field, |
408 | 452 |
'instance' => $instance, |
... | ... | |
470 | 514 |
'#title' => t('Date attributes to collect'), |
471 | 515 |
'#default_value' => $granularity, |
472 | 516 |
'#options' => $options, |
473 |
'#attributes' => array('class' => array('container-inline')), |
|
517 |
'#attributes' => array( |
|
518 |
'class' => array('container-inline'), |
|
519 |
), |
|
474 | 520 |
'#description' => $description, |
475 | 521 |
'year' => $checkbox_year, |
476 | 522 |
); |
... | ... | |
528 | 574 |
'#weight' => 11, |
529 | 575 |
'#states' => array( |
530 | 576 |
'visible' => array( |
531 |
'input[name="field[settings][cache_enabled]"]' => array('checked' => TRUE), |
|
577 |
'input[name="field[settings][cache_enabled]"]' => array( |
|
578 |
'checked' => TRUE, |
|
579 |
), |
|
532 | 580 |
), |
533 | 581 |
), |
534 | 582 |
); |
... | ... | |
600 | 648 |
'site' => t("Site's time zone"), |
601 | 649 |
'date' => t("Date's time zone"), |
602 | 650 |
'user' => t("User's time zone"), |
603 |
'utc' => 'UTC', |
|
651 |
'utc' => 'UTC',
|
|
604 | 652 |
'none' => t('No time zone conversion'), |
605 | 653 |
); |
606 | 654 |
} |
drupal7/sites/all/modules/date/date_all_day/date_all_day.info | ||
---|---|---|
5 | 5 |
package = Date/Time |
6 | 6 |
core = 7.x |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2014-07-29
|
|
9 |
version = "7.x-2.8"
|
|
8 |
; Information added by Drupal.org packaging script on 2015-09-08
|
|
9 |
version = "7.x-2.9"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "date" |
12 |
datestamp = "1406653438"
|
|
12 |
datestamp = "1441727353"
|
|
13 | 13 |
|
drupal7/sites/all/modules/date/date_all_day/date_all_day.module | ||
---|---|---|
31 | 31 |
'format' => NULL, |
32 | 32 |
'entity_type' => NULL, |
33 | 33 |
'entity' => NULL, |
34 |
'view' => NULL |
|
35 |
) |
|
34 |
'view' => NULL,
|
|
35 |
),
|
|
36 | 36 |
), |
37 | 37 |
'date_all_day_label' => array( |
38 |
'variables' => array()
|
|
38 |
'variables' => array(),
|
|
39 | 39 |
), |
40 | 40 |
); |
41 | 41 |
|
... | ... | |
91 | 91 |
/** |
92 | 92 |
* Adjust start/end date format to account for 'all day' . |
93 | 93 |
* |
94 |
* @param array $field, the field definition for this date field. |
|
95 |
* @param string $which, which value to return, 'date1' or 'date2' . |
|
96 |
* @param object $date1, a date/time object for the 'start' date. |
|
97 |
* @param object $date2, a date/time object for the 'end' date. |
|
98 |
* @param string $format |
|
99 |
* @param object $entity, the node this date comes from (may be incomplete, always contains nid). |
|
100 |
* @param object $view, the view this node comes from, if applicable. |
|
101 |
* @return formatted date. |
|
94 |
* @params array $field |
|
95 |
* The field definition for this date field. |
|
96 |
* |
|
97 |
* @params string $which |
|
98 |
* Which value to return, 'date1' or 'date2'. |
|
99 |
* |
|
100 |
* @params object $date1 |
|
101 |
* A date/time object for the 'start' date. |
|
102 |
* |
|
103 |
* @params object $date2 |
|
104 |
* A date/time object for the 'end' date. |
|
105 |
* |
|
106 |
* @params string $format |
|
107 |
* A date/time format |
|
108 |
* |
|
109 |
* @params object $entity |
|
110 |
* The node this date comes from (may be incomplete, always contains nid). |
|
111 |
* |
|
112 |
* @params object $view |
|
113 |
* The view this node comes from, if applicable. |
|
114 |
* |
|
115 |
* @return string |
|
116 |
* Formatted date. |
|
102 | 117 |
*/ |
103 | 118 |
function theme_date_all_day($vars) { |
104 | 119 |
$field = $vars['field']; |
... | ... | |
135 | 150 |
} |
136 | 151 |
|
137 | 152 |
return trim(date_format_date($$which, 'custom', $format) . $suffix); |
138 |
|
|
139 | 153 |
} |
140 | 154 |
|
141 | 155 |
/** |
142 | 156 |
* Theme the way an 'all day' label will look. |
143 | 157 |
*/ |
144 | 158 |
function theme_date_all_day_label() { |
145 |
return '(' . t('All day', array(), array('context' => 'datetime')) .')'; |
|
159 |
return '(' . t('All day', array(), array('context' => 'datetime')) . ')';
|
|
146 | 160 |
} |
147 | 161 |
|
148 | 162 |
/** |
149 | 163 |
* Determine if a Start/End date combination qualify as 'All day'. |
150 | 164 |
* |
151 |
* @param array $field, the field definition for this date field. |
|
152 |
* @param object $date1, a date/time object for the 'Start' date. |
|
153 |
* @param object $date2, a date/time object for the 'End' date. |
|
154 |
* @return TRUE or FALSE. |
|
165 |
* @param array $field |
|
166 |
* The field definition for this date field. |
|
167 |
* |
|
168 |
* @param array $instance |
|
169 |
* The field instance for this date field. |
|
170 |
* |
|
171 |
* @param object $date1 |
|
172 |
* A date/time object for the 'Start' date. |
|
173 |
* |
|
174 |
* @param object $date2 |
|
175 |
* A date/time object for the 'End' date. |
|
176 |
* |
|
177 |
* @return bool |
|
178 |
* TRUE or FALSE. |
|
155 | 179 |
*/ |
156 | 180 |
function date_all_day_field($field, $instance, $date1, $date2 = NULL) { |
157 | 181 |
if (empty($date1) || !is_object($date1)) { |
... | ... | |
167 | 191 |
$granularity = date_granularity_precision($field['settings']['granularity']); |
168 | 192 |
$increment = isset($instance['widget']['settings']['increment']) ? $instance['widget']['settings']['increment'] : 1; |
169 | 193 |
return date_is_all_day(date_format($date1, DATE_FORMAT_DATETIME), date_format($date2, DATE_FORMAT_DATETIME), $granularity, $increment); |
170 |
|
|
171 | 194 |
} |
172 | 195 |
|
173 | 196 |
/** |
... | ... | |
222 | 245 |
function date_all_day_date_text_process_alter(&$element, &$form_state, $context) { |
223 | 246 |
$all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : ''; |
224 | 247 |
if ($all_day_id != '') { |
225 |
// All Day handling on text dates works only if the user leaves the time out of the input value. |
|
248 |
// All Day handling on text dates works only |
|
249 |
// if the user leaves the time out of the input value. |
|
226 | 250 |
// There is no element to hide or show. |
227 | 251 |
} |
228 | 252 |
} |
... | ... | |
234 | 258 |
*/ |
235 | 259 |
function date_all_day_date_select_process_alter(&$element, &$form_state, $context) { |
236 | 260 |
|
237 |
// Hide or show this element in reaction to the all_day status for this element. |
|
261 |
// Hide or show this element in reaction |
|
262 |
// to the all_day status for this element. |
|
238 | 263 |
$all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : ''; |
239 | 264 |
if ($all_day_id != '') { |
240 |
foreach(array('hour', 'minute', 'second', 'ampm') as $field) { |
|
265 |
foreach (array('hour', 'minute', 'second', 'ampm') as $field) {
|
|
241 | 266 |
if (array_key_exists($field, $element)) { |
242 | 267 |
$element[$field]['#states'] = array( |
243 | 268 |
'visible' => array( |
... | ... | |
255 | 280 |
*/ |
256 | 281 |
function date_all_day_date_popup_process_alter(&$element, &$form_state, $context) { |
257 | 282 |
|
258 |
// Hide or show this element in reaction to the all_day status for this element. |
|
283 |
// Hide or show this element in reaction to |
|
284 |
// the all_day status for this element. |
|
259 | 285 |
$all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : ''; |
260 | 286 |
if ($all_day_id != '' && array_key_exists('time', $element)) { |
261 | 287 |
$element['time']['#states'] = array( |
... | ... | |
272 | 298 |
* of the date_select validation gets fired. |
273 | 299 |
*/ |
274 | 300 |
function date_all_day_date_text_pre_validate_alter(&$element, &$form_state, &$input) { |
275 |
// Let Date module massage the format for all day values so they will pass validation. |
|
301 |
// Let Date module massage the format for all day |
|
302 |
// values so they will pass validation. |
|
276 | 303 |
// The All day flag, if used, actually exists on the parent element. |
277 | 304 |
date_all_day_value($element, $form_state); |
278 | 305 |
} |
... | ... | |
284 | 311 |
* of the date_select validation gets fired. |
285 | 312 |
*/ |
286 | 313 |
function date_all_day_date_select_pre_validate_alter(&$element, &$form_state, &$input) { |
287 |
// Let Date module massage the format for all day values so they will pass validation. |
|
314 |
// Let Date module massage the format for all |
|
315 |
// day values so they will pass validation. |
|
288 | 316 |
// The All day flag, if used, actually exists on the parent element. |
289 | 317 |
date_all_day_value($element, $form_state); |
290 | 318 |
} |
... | ... | |
296 | 324 |
* of the date_popup validation gets fired. |
297 | 325 |
*/ |
298 | 326 |
function date_all_day_date_popup_pre_validate_alter(&$element, &$form_state, &$input) { |
299 |
// Let Date module massage the format for all day values so they will pass validation. |
|
327 |
// Let Date module massage the format for all |
|
328 |
// day values so they will pass validation. |
|
300 | 329 |
// The All day flag, if used, actually exists on the parent element. |
301 | 330 |
date_all_day_value($element, $form_state); |
302 | 331 |
} |
303 | 332 |
|
304 | 333 |
/** |
305 |
* A helper function to check if the all day flag is set on the parent of an |
|
334 |
* A helper function date_all_day_value(). |
|
335 |
* |
|
336 |
* To check if the all day flag is set on the parent of an |
|
306 | 337 |
* element, and adjust the date_format accordingly so the missing time will |
307 | 338 |
* not cause validation errors. |
308 | 339 |
*/ |
... | ... | |
332 | 363 |
$field = $context['field']; |
333 | 364 |
|
334 | 365 |
// If we have an all day flag on this date and the time is empty, |
335 |
// change the format to match the input value so we don't get validation errors. |
|
366 |
// change the format to match the input value |
|
367 |
// so we don't get validation errors. |
|
336 | 368 |
$element['#date_is_all_day'] = TRUE; |
337 | 369 |
$element['value']['#date_format'] = date_part_format('date', $element['value']['#date_format']); |
338 | 370 |
if (!empty($field['settings']['todate'])) { |
... | ... | |
344 | 376 |
/** |
345 | 377 |
* Implements hook_date_combo_validate_date_start_alter(). |
346 | 378 |
* |
347 |
* This hook lets us alter the local date objects created by the date_combo validation |
|
348 |
* before they are converted back to the database timezone and stored. |
|
379 |
* This hook lets us alter the local date objects |
|
380 |
* created by the date_combo validation before they are |
|
381 |
* converted back to the database timezone and stored. |
|
349 | 382 |
*/ |
350 | 383 |
function date_all_day_date_combo_validate_date_start_alter(&$date, &$form_state, $context) { |
351 |
|
|
352 |
// If this is an 'All day' value, set the time to midnight. |
|
353 |
if (!empty($context['element']['#date_is_all_day'])) { |
|
354 |
$date->setTime(0, 0, 0); |
|
355 |
} |
|
384 |
// If this is an 'All day' value, set the time to midnight. |
|
385 |
if (!empty($context['element']['#date_is_all_day'])) { |
|
386 |
$date->setTime(0, 0, 0); |
|
387 |
} |
|
356 | 388 |
} |
357 | 389 |
|
358 | 390 |
/** |
359 | 391 |
* Implements hook_date_combo_validate_date_end_alter(). |
360 | 392 |
* |
361 |
* This hook lets us alter the local date objects created by the date_combo validation |
|
362 |
* before they are converted back to the database timezone and stored. |
|
393 |
* This hook lets us alter the local date objects |
|
394 |
* created by the date_combo validation before |
|
395 |
* they are converted back to the database timezone and stored. |
|
363 | 396 |
*/ |
364 | 397 |
function date_all_day_date_combo_validate_date_end_alter(&$date, &$form_state, $context) { |
365 |
|
|
366 |
// If this is an 'All day' value, set the time to midnight. |
|
367 |
if (!empty($context['element']['#date_is_all_day'])) { |
|
368 |
$date->setTime(0, 0, 0); |
|
369 |
} |
|
398 |
// If this is an 'All day' value, set the time to midnight. |
|
399 |
if (!empty($context['element']['#date_is_all_day'])) { |
|
400 |
$date->setTime(0, 0, 0); |
|
401 |
} |
|
370 | 402 |
} |
371 | 403 |
|
372 | 404 |
/** |
drupal7/sites/all/modules/date/date_api/date.css | ||
---|---|---|
15 | 15 |
.container-inline-date > .form-item { |
16 | 16 |
display: inline-block; |
17 | 17 |
margin-right: 0.5em; /* LTR */ |
18 |
margin-bottom: 10px; |
|
19 | 18 |
vertical-align: top; |
20 | 19 |
} |
20 |
fieldset.date-combo .container-inline-date > .form-item { |
|
21 |
margin-bottom: 10px; |
|
22 |
} |
|
21 | 23 |
.container-inline-date .form-item .form-item { |
22 | 24 |
float: left; /* LTR */ |
23 | 25 |
} |
... | ... | |
52 | 54 |
|
53 | 55 |
/* The exposed Views form doesn't need some of these styles */ |
54 | 56 |
.container-inline-date .date-padding { |
55 |
padding: 10px; |
|
56 | 57 |
float: left; |
57 | 58 |
} |
59 |
fieldset.date-combo .container-inline-date .date-padding { |
|
60 |
padding: 10px; |
|
61 |
} |
|
58 | 62 |
.views-exposed-form .container-inline-date .date-padding { |
59 | 63 |
padding: 0; |
60 | 64 |
} |
... | ... | |
116 | 120 |
} |
117 | 121 |
|
118 | 122 |
/* Add space between the date and time portions of the date_select widget. */ |
119 |
.form-type-date-select .form-type-select[class$=hour] {
|
|
123 |
.form-type-date-select .form-type-select[class*=hour] {
|
|
120 | 124 |
margin-left: .75em; /* LTR */ |
121 | 125 |
} |
122 | 126 |
|
... | ... | |
173 | 177 |
padding: 2px; |
174 | 178 |
} |
175 | 179 |
|
180 |
.date-form-element-content-multiline { |
|
181 |
padding: 10px; |
|
182 |
border: 1px solid #CCC; |
|
183 |
} |
|
176 | 184 |
/* Admin styling */ |
177 | 185 |
.form-item.form-item-instance-widget-settings-input-format-custom, |
178 | 186 |
.form-item.form-item-field-settings-enddate-required { |
drupal7/sites/all/modules/date/date_api/date_api.admin.inc | ||
---|---|---|
10 | 10 |
*/ |
11 | 11 |
function _date_timezone_replacement($old) { |
12 | 12 |
$replace = array( |
13 |
'Brazil/Acre' => 'America/Rio_Branco', |
|
14 |
'Brazil/DeNoronha' => 'America/Noronha', |
|
15 |
'Brazil/East' => 'America/Recife', |
|
16 |
'Brazil/West' => 'America/Manaus', |
|
17 |
'Canada/Atlantic' => 'America/Halifax', |
|
18 |
'Canada/Central' => 'America/Winnipeg', |
|
19 |
'Canada/East-Saskatchewan' => 'America/Regina', |
|
20 |
'Canada/Eastern' => 'America/Toronto', |
|
21 |
'Canada/Mountain' => 'America/Edmonton', |
|
22 |
'Canada/Newfoundland' => 'America/St_Johns', |
|
23 |
'Canada/Pacific' => 'America/Vancouver', |
|
24 |
'Canada/Saskatchewan' => 'America/Regina', |
|
25 |
'Canada/Yukon' => 'America/Whitehorse', |
|
26 |
'CET' => 'Europe/Berlin', |
|
27 |
'Chile/Continental' => 'America/Santiago', |
|
28 |
'Chile/EasterIsland' => 'Pacific/Easter', |
|
29 |
'CST6CDT' => 'America/Chicago', |
|
30 |
'Cuba' => 'America/Havana', |
|
31 |
'EET' => 'Europe/Bucharest', |
|
32 |
'Egypt' => 'Africa/Cairo', |
|
33 |
'Eire' => 'Europe/Belfast', |
|
34 |
'EST' => 'America/New_York', |
|
35 |
'EST5EDT' => 'America/New_York', |
|
36 |
'GB' => 'Europe/London', |
|
37 |
'GB-Eire' => 'Europe/Belfast', |
|
38 |
'Etc/GMT' => 'UTC', |
|
39 |
'Etc/GMT+0' => 'UTC', |
|
40 |
'Etc/GMT+1' => 'UTC', |
|
41 |
'Etc/GMT+10' => 'UTC', |
|
42 |
'Etc/GMT+11' => 'UTC', |
|
43 |
'Etc/GMT+12' => 'UTC', |
|
44 |
'Etc/GMT+2' => 'UTC', |
|
45 |
'Etc/GMT+3' => 'UTC', |
|
46 |
'Etc/GMT+4' => 'UTC', |
|
47 |
'Etc/GMT+5' => 'UTC', |
|
48 |
'Etc/GMT+6' => 'UTC', |
|
49 |
'Etc/GMT+7' => 'UTC', |
|
50 |
'Etc/GMT+8' => 'UTC', |
|
51 |
'Etc/GMT+9' => 'UTC', |
|
52 |
'Etc/GMT-0' => 'UTC', |
|
53 |
'Etc/GMT-1' => 'UTC', |
|
54 |
'Etc/GMT-10' => 'UTC', |
|
55 |
'Etc/GMT-11' => 'UTC', |
|
56 |
'Etc/GMT-12' => 'UTC', |
|
57 |
'Etc/GMT-13' => 'UTC', |
|
58 |
'Etc/GMT-14' => 'UTC', |
|
59 |
'Etc/GMT-2' => 'UTC', |
|
60 |
'Etc/GMT-3' => 'UTC', |
|
61 |
'Etc/GMT-4' => 'UTC', |
|
62 |
'Etc/GMT-5' => 'UTC', |
|
63 |
'Etc/GMT-6' => 'UTC', |
|
64 |
'Etc/GMT-7' => 'UTC', |
|
65 |
'Etc/GMT-8' => 'UTC', |
|
66 |
'Etc/GMT-9' => 'UTC', |
|
67 |
'Etc/GMT0' => 'UTC', |
|
68 |
'Etc/Greenwich' => 'UTC', |
|
69 |
'Etc/UCT' => 'UTC', |
|
70 |
'Etc/Universal' => 'UTC', |
|
71 |
'Etc/UTC' => 'UTC', |
|
72 |
'Etc/Zulu' => 'UTC', |
|
73 |
'Factory' => 'UTC', |
|
74 |
'GMT' => 'UTC', |
|
75 |
'GMT+0' => 'UTC', |
|
76 |
'GMT-0' => 'UTC', |
|
77 |
'GMT0' => 'UTC', |
|
78 |
'Hongkong' => 'Asia/Hong_Kong', |
|
79 |
'HST' => 'Pacific/Honolulu', |
|
80 |
'Iceland' => 'Atlantic/Reykjavik', |
|
81 |
'Iran' => 'Asia/Tehran', |
|
82 |
'Israel' => 'Asia/Tel_Aviv', |
|
83 |
'Jamaica' => 'America/Jamaica', |
|
84 |
'Japan' => 'Asia/Tokyo', |
|
85 |
'Kwajalein' => 'Pacific/Kwajalein', |
|
86 |
'Libya' => 'Africa/Tunis', |
|
87 |
'MET' => 'Europe/Budapest', |
|
88 |
'Mexico/BajaNorte' => 'America/Tijuana', |
|
89 |
'Mexico/BajaSur' => 'America/Mazatlan', |
|
90 |
'Mexico/General' => 'America/Mexico_City', |
|
91 |
'MST' => 'America/Boise', |
|
92 |
'MST7MDT' => 'America/Boise', |
|
93 |
'Navajo' => 'America/Phoenix', |
|
94 |
'NZ' => 'Pacific/Auckland', |
|
95 |
'NZ-CHAT' => 'Pacific/Chatham', |
|
96 |
'Poland' => 'Europe/Warsaw', |
|
97 |
'Portugal' => 'Europe/Lisbon', |
|
98 |
'PRC' => 'Asia/Chongqing', |
|
99 |
'PST8PDT' => 'America/Los_Angeles', |
|
100 |
'ROC' => 'Asia/Taipei', |
|
101 |
'ROK' => 'Asia/Seoul', |
|
102 |
'Singapore' => 'Asia/Singapore', |
|
103 |
'Turkey' => 'Europe/Istanbul', |
|
104 |
'US/Alaska' => 'America/Anchorage', |
|
105 |
'US/Aleutian' => 'America/Adak', |
|
106 |
'US/Arizona' => 'America/Phoenix', |
|
107 |
'US/Central' => 'America/Chicago', |
|
108 |
'US/East-Indiana' => 'America/Indianapolis', |
|
109 |
'US/Eastern' => 'America/New_York', |
|
110 |
'US/Hawaii' => 'Pacific/Honolulu', |
|
111 |
'US/Indiana-Starke' => 'America/Indiana/Knox', |
|
112 |
'US/Michigan' => 'America/Detroit', |
|
113 |
'US/Mountain' => 'America/Boise', |
|
114 |
'US/Pacific' => 'America/Los_Angeles', |
|
115 |
'US/Pacific-New' => 'America/Los_Angeles', |
|
116 |
'US/Samoa' => 'Pacific/Samoa', |
|
117 |
'W-SU' => 'Europe/Moscow', |
|
118 |
'WET' => 'Europe/Paris', |
|
13 |
'Brazil/Acre' => 'America/Rio_Branco', |
|
14 |
'Brazil/DeNoronha' => 'America/Noronha', |
|
15 |
'Brazil/East' => 'America/Recife', |
|
16 |
'Brazil/West' => 'America/Manaus', |
|
17 |
'Canada/Atlantic' => 'America/Halifax', |
|
18 |
'Canada/Central' => 'America/Winnipeg', |
|
19 |
'Canada/East-Saskatchewan' => 'America/Regina', |
|
20 |
'Canada/Eastern' => 'America/Toronto', |
|
21 |
'Canada/Mountain' => 'America/Edmonton', |
|
22 |
'Canada/Newfoundland' => 'America/St_Johns', |
|
23 |
'Canada/Pacific' => 'America/Vancouver', |
|
24 |
'Canada/Saskatchewan' => 'America/Regina', |
|
25 |
'Canada/Yukon' => 'America/Whitehorse', |
|
26 |
'CET' => 'Europe/Berlin', |
|
27 |
'Chile/Continental' => 'America/Santiago', |
|
28 |
'Chile/EasterIsland' => 'Pacific/Easter', |
|
29 |
'CST6CDT' => 'America/Chicago', |
|
30 |
'Cuba' => 'America/Havana', |
|
31 |
'EET' => 'Europe/Bucharest', |
|
32 |
'Egypt' => 'Africa/Cairo', |
|
33 |
'Eire' => 'Europe/Belfast', |
|
34 |
'EST' => 'America/New_York', |
|
35 |
'EST5EDT' => 'America/New_York', |
|
36 |
'GB' => 'Europe/London', |
|
37 |
'GB-Eire' => 'Europe/Belfast', |
|
38 |
'Etc/GMT' => 'UTC', |
|
39 |
'Etc/GMT+0' => 'UTC', |
|
40 |
'Etc/GMT+1' => 'UTC', |
|
41 |
'Etc/GMT+10' => 'UTC', |
|
42 |
'Etc/GMT+11' => 'UTC', |
|
43 |
'Etc/GMT+12' => 'UTC', |
|
44 |
'Etc/GMT+2' => 'UTC', |
|
45 |
'Etc/GMT+3' => 'UTC', |
|
46 |
'Etc/GMT+4' => 'UTC', |
|
47 |
'Etc/GMT+5' => 'UTC', |
|
48 |
'Etc/GMT+6' => 'UTC', |
|
49 |
'Etc/GMT+7' => 'UTC', |
|
50 |
'Etc/GMT+8' => 'UTC', |
|
51 |
'Etc/GMT+9' => 'UTC', |
|
52 |
'Etc/GMT-0' => 'UTC', |
|
53 |
'Etc/GMT-1' => 'UTC', |
|
54 |
'Etc/GMT-10' => 'UTC', |
|
55 |
'Etc/GMT-11' => 'UTC', |
|
56 |
'Etc/GMT-12' => 'UTC', |
|
57 |
'Etc/GMT-13' => 'UTC', |
|
58 |
'Etc/GMT-14' => 'UTC', |
|
59 |
'Etc/GMT-2' => 'UTC', |
|
60 |
'Etc/GMT-3' => 'UTC', |
|
61 |
'Etc/GMT-4' => 'UTC', |
|
62 |
'Etc/GMT-5' => 'UTC', |
|
63 |
'Etc/GMT-6' => 'UTC', |
|
64 |
'Etc/GMT-7' => 'UTC', |
|
65 |
'Etc/GMT-8' => 'UTC', |
|
66 |
'Etc/GMT-9' => 'UTC', |
|
67 |
'Etc/GMT0' => 'UTC', |
|
68 |
'Etc/Greenwich' => 'UTC', |
|
69 |
'Etc/UCT' => 'UTC', |
|
70 |
'Etc/Universal' => 'UTC', |
|
71 |
'Etc/UTC' => 'UTC', |
|
72 |
'Etc/Zulu' => 'UTC', |
|
73 |
'Factory' => 'UTC', |
|
74 |
'GMT' => 'UTC', |
|
75 |
'GMT+0' => 'UTC', |
|
76 |
'GMT-0' => 'UTC', |
|
77 |
'GMT0' => 'UTC', |
|
78 |
'Hongkong' => 'Asia/Hong_Kong', |
|
79 |
'HST' => 'Pacific/Honolulu', |
|
80 |
'Iceland' => 'Atlantic/Reykjavik', |
Formats disponibles : Unified diff
Weekly update of contrib modules