Révision 599a39cd
Ajouté par Assos Assos il y a environ 3 ans
drupal7/sites/all/modules/date/date.theme | ||
---|---|---|
15 | 15 |
/** |
16 | 16 |
* Returns HTML for a date element formatted as a Start/End combination. |
17 | 17 |
* |
18 |
* $entity->date_id
|
|
19 |
* If set, this will show only an individual date on a field with
|
|
20 |
* multiple dates. The value should be a string that contains
|
|
21 |
* the following values, separated with periods:
|
|
22 |
* - module name of the module adding the item
|
|
23 |
* - node nid
|
|
24 |
* - field name
|
|
25 |
* - delta value of the field to be displayed
|
|
26 |
* - other information the module's custom theme might need
|
|
18 |
* $entity->date_id |
|
19 |
* If set, this will show only an individual date on a field with |
|
20 |
* multiple dates. The value should be a string that contains |
|
21 |
* the following values, separated with periods: |
|
22 |
* - module name of the module adding the item |
|
23 |
* - node nid |
|
24 |
* - field name |
|
25 |
* - delta value of the field to be displayed |
|
26 |
* - other information the module's custom theme might need.
|
|
27 | 27 |
* |
28 |
* Used by the calendar module and available for other uses.
|
|
29 |
* example: 'date.217.field_date.3.test'
|
|
28 |
* Used by the calendar module and available for other uses. |
|
29 |
* example: 'date.217.field_date.3.test' |
|
30 | 30 |
* |
31 |
* $entity->date_repeat_show
|
|
32 |
* If true, tells the theme to show all the computed values of a repeating
|
|
33 |
* date. If not true or not set, only the start date and the repeat rule
|
|
34 |
* will be displayed.
|
|
31 |
* $entity->date_repeat_show |
|
32 |
* If TRUE, tells the theme to show all the computed values of a repeating
|
|
33 |
* date. If not TRUE or not set, only the start date and the repeat rule
|
|
34 |
* will be displayed. |
|
35 | 35 |
* |
36 |
* $dates['format']
|
|
37 |
* The format string used on these dates
|
|
38 |
* $dates['value']['local']['object']
|
|
39 |
* The local date object for the Start date
|
|
40 |
* $dates['value2']['local']['object']
|
|
41 |
* The local date object for the End date
|
|
42 |
* $dates['value']['local']['datetime']
|
|
43 |
* The datetime value of the Start date database (GMT) value
|
|
44 |
* $dates['value2']['local']['datetime']
|
|
45 |
* The datetime value of the End date database (GMT) value
|
|
46 |
* $dates['value']['formatted']
|
|
47 |
* Formatted Start date, i.e. 'February 15, 2007 2:00 pm';
|
|
48 |
* $dates['value']['formatted_date']
|
|
49 |
* Only the date part of the formatted Start date
|
|
50 |
* $dates['value']['formatted_time']
|
|
51 |
* Only the time part of the formatted Start date
|
|
52 |
* $dates['value2']['formatted']
|
|
53 |
* Formatted End date, i.e. 'February 15, 2007 6:00 pm';
|
|
54 |
* $dates['value2']['formatted_date']
|
|
55 |
* Only the date part of the formatted End date
|
|
56 |
* $dates['value2']['formatted_time']
|
|
57 |
* Only the time part of the formatted End date
|
|
36 |
* $dates['format'] |
|
37 |
* The format string used on these dates |
|
38 |
* $dates['value']['local']['object'] |
|
39 |
* The local date object for the Start date |
|
40 |
* $dates['value2']['local']['object'] |
|
41 |
* The local date object for the End date |
|
42 |
* $dates['value']['local']['datetime'] |
|
43 |
* The datetime value of the Start date database (GMT) value |
|
44 |
* $dates['value2']['local']['datetime'] |
|
45 |
* The datetime value of the End date database (GMT) value |
|
46 |
* $dates['value']['formatted'] |
|
47 |
* Formatted Start date, i.e. 'February 15, 2007 2:00 pm'; |
|
48 |
* $dates['value']['formatted_date'] |
|
49 |
* Only the date part of the formatted Start date |
|
50 |
* $dates['value']['formatted_time'] |
|
51 |
* Only the time part of the formatted Start date |
|
52 |
* $dates['value2']['formatted'] |
|
53 |
* Formatted End date, i.e. 'February 15, 2007 6:00 pm'; |
|
54 |
* $dates['value2']['formatted_date'] |
|
55 |
* Only the date part of the formatted End date |
|
56 |
* $dates['value2']['formatted_time'] |
|
57 |
* Only the time part of the formatted End date |
|
58 | 58 |
*/ |
59 | 59 |
function theme_date_display_combination($variables) { |
60 | 60 |
static $repeating_ids = array(); |
... | ... | |
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']; |
|
81 | 80 |
|
82 | 81 |
$output = ''; |
83 | 82 |
|
... | ... | |
117 | 116 |
$element['#entity'] = $entity; |
118 | 117 |
} |
119 | 118 |
|
119 |
// Verify these variables exist. |
|
120 |
if (!isset($dates['value']['formatted'])) { |
|
121 |
$dates['value']['formatted'] = ''; |
|
122 |
} |
|
123 |
if (!isset($dates['value2']['formatted'])) { |
|
124 |
$dates['value2']['formatted'] = ''; |
|
125 |
} |
|
126 |
if (!isset($dates['value']['formatted_time'])) { |
|
127 |
$dates['value']['formatted_time'] = ''; |
|
128 |
} |
|
129 |
if (!isset($dates['value2']['formatted_time'])) { |
|
130 |
$dates['value2']['formatted_time'] = ''; |
|
131 |
} |
|
132 |
if (!isset($dates['value1']['formatted_timezone'])) { |
|
133 |
$dates['value1']['formatted_timezone'] = ''; |
|
134 |
} |
|
135 |
if (!isset($dates['value2']['formatted_timezone'])) { |
|
136 |
$dates['value2']['formatted_timezone'] = ''; |
|
137 |
} |
|
138 |
|
|
120 | 139 |
switch ($options['fromto']) { |
121 | 140 |
case 'value': |
122 | 141 |
$date1 = $dates['value']['formatted']; |
... | ... | |
156 | 175 |
|
157 | 176 |
// Check remaining days. |
158 | 177 |
$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)); |
|
178 |
if (!empty($variables['show_remaining_days']) && isset($variables['dates']['value']['formatted_iso'])) {
|
|
179 |
$remaining_days = $variables['dates']['value']['formatted_iso'];
|
|
180 |
$remaining_days = floor((strtotime($remaining_days) - strtotime('now')) / (24 * 3600));
|
|
162 | 181 |
|
163 | 182 |
// Show remaining days only for future events. |
164 | 183 |
if ($remaining_days >= 0) { |
... | ... | |
172 | 191 |
if (empty($date1) && empty($date2)) { |
173 | 192 |
$output .= ''; |
174 | 193 |
} |
194 |
|
|
175 | 195 |
// Start and End dates match or there is no End date, display a complete |
176 | 196 |
// single date. |
177 | 197 |
elseif ($date1 == $date2 || empty($date2)) { |
178 | 198 |
$output .= theme('date_display_single', array( |
179 | 199 |
'date' => $date1, |
180 |
'timezone' => $timezone,
|
|
200 |
'timezone' => $has_time_string ? $timezone : '',
|
|
181 | 201 |
'attributes' => $attributes, |
182 | 202 |
'rdf_mapping' => $rdf_mapping, |
183 | 203 |
'add_rdf' => $add_rdf, |
... | ... | |
187 | 207 |
'show_remaining_days' => $show_remaining_days, |
188 | 208 |
)); |
189 | 209 |
} |
210 |
|
|
190 | 211 |
// Same day, different times, don't repeat the date but show both Start and |
191 | 212 |
// End times. We can NOT do this if the replacement value is an integer |
192 | 213 |
// instead of a time string. |
... | ... | |
216 | 237 |
'dates' => $dates, |
217 | 238 |
)); |
218 | 239 |
} |
240 |
|
|
219 | 241 |
// Different days, display both in their entirety. |
220 | 242 |
else { |
221 | 243 |
$output .= theme('date_display_range', array( |
222 | 244 |
'date1' => $date1, |
223 | 245 |
'date2' => $date2, |
224 |
'timezone' => $timezone,
|
|
246 |
'timezone' => $has_time_string ? $timezone : '',
|
|
225 | 247 |
'attributes' => $attributes, |
226 | 248 |
'rdf_mapping' => $rdf_mapping, |
227 | 249 |
'add_rdf' => $add_rdf, |
... | ... | |
251 | 273 |
$variables['attributes'] = $variables['attributes'] + $base_attributes; |
252 | 274 |
} |
253 | 275 |
|
254 |
// Pass along microdata attributes, or set display to false if none are set.
|
|
276 |
// Pass along microdata attributes, or set display to FALSE if none are set.
|
|
255 | 277 |
if (!empty($variables['add_microdata'])) { |
256 | 278 |
// Because the Entity API integration for Date has a variable data |
257 | 279 |
// structure depending on whether there is an end value, the attributes |
... | ... | |
299 | 321 |
$variables['attributes_end'] += $variables['attributes']; |
300 | 322 |
|
301 | 323 |
if ($variables['add_rdf']) { |
302 |
// Pass along the rdf mapping for this field, if any. Add some default rdf
|
|
324 |
// Pass along the rdf mapping for this field, if any. Add some default RDF
|
|
303 | 325 |
// attributes that will be used if not overridden by attributes passed in. |
304 | 326 |
$dates = $variables['dates']; |
305 | 327 |
$base_attributes = array( |
... | ... | |
315 | 337 |
} |
316 | 338 |
} |
317 | 339 |
|
318 |
// Pass along microdata attributes, or set display to false if none are set.
|
|
340 |
// Pass along microdata attributes, or set display to FALSE if none are set.
|
|
319 | 341 |
if ($variables['add_microdata']) { |
320 | 342 |
if (!empty($variables['microdata']['value']['#attributes'])) { |
321 | 343 |
$variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso']; |
... | ... | |
336 | 358 |
$timezone = $variables['timezone']; |
337 | 359 |
$attributes_start = $variables['attributes_start']; |
338 | 360 |
$attributes_end = $variables['attributes_end']; |
339 |
$show_remaining_days = $variables['show_remaining_days'];
|
|
361 |
$show_remaining_days = isset($variables['show_remaining_days']) ? $variables['show_remaining_days'] : '';
|
|
340 | 362 |
|
341 | 363 |
$start_date = '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>'; |
342 | 364 |
$end_date = '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . $timezone . '</span>'; |
... | ... | |
379 | 401 |
'interval' => $options['interval'], |
380 | 402 |
'interval_display' => $options['interval_display'], |
381 | 403 |
'use_end_date' => !empty($options['use_end_date']) ? |
382 |
$options['use_end_date'] : FALSE,
|
|
404 |
$options['use_end_date'] : FALSE, |
|
383 | 405 |
); |
384 | 406 |
|
385 | 407 |
if ($return = theme('date_time_ago', $time_ago_vars)) { |
... | ... | |
462 | 484 |
// Detect if there is more than one subfield. |
463 | 485 |
$count = count(explode('<label', $element['#children'])) - 1; |
464 | 486 |
if ($count == 1) { |
465 |
$element['#title_display'] = 'none'; |
|
487 |
// If there is only one subfield, hide the label of the main field only if |
|
488 |
// the label of the subfield is visible. |
|
489 |
if (empty($variables['element']['value']['#instance']) |
|
490 |
|| empty($variables['element']['value']['#instance']['widget']) |
|
491 |
|| empty($variables['element']['value']['#instance']['widget']['settings']) |
|
492 |
|| empty($variables['element']['value']['#instance']['widget']['settings']['label_position']) |
|
493 |
|| $variables['element']['value']['#instance']['widget']['settings']['label_position'] != 'none') { |
|
494 |
$element['#title_display'] = 'none'; |
|
495 |
} |
|
466 | 496 |
} |
467 | 497 |
|
468 | 498 |
// Wrap children with a div and add an extra class if element is multiline. |
469 |
$element['#children'] = '<div class="date-form-element-content'. ($multiline ? ' date-form-element-content-multiline' : '') .'">'. $element['#children'] .'</div>';
|
|
499 |
$element['#children'] = '<div class="date-form-element-content' . ($multiline ? ' date-form-element-content-multiline' : '') . '">' . $element['#children'] . '</div>';
|
|
470 | 500 |
|
471 | 501 |
return theme('form_element', $variables); |
472 | 502 |
} |
... | ... | |
477 | 507 |
function theme_date_display_remaining($variables) { |
478 | 508 |
$remaining_days = $variables['remaining_days']; |
479 | 509 |
$output = ''; |
480 |
$show_remaining_text = t('The upcoming date less then 1 day.');
|
|
510 |
$show_remaining_text = t('Less than 1 day remaining');
|
|
481 | 511 |
if ($remaining_days) { |
482 |
$show_remaining_text = format_plural($remaining_days, 'To event remaining 1 day', 'To event remaining @count days');
|
|
512 |
$show_remaining_text = format_plural($remaining_days, '1 day remaining', '@count days remaining');
|
|
483 | 513 |
} |
484 | 514 |
|
485 | 515 |
return '<div class="date-display-remaining"><span class="date-display-remaining">' . $show_remaining_text . '</span></div>'; |
486 | 516 |
} |
487 | 517 |
|
488 |
/** @} End of addtogroup themeable */ |
|
518 |
/** |
|
519 |
* @} End of addtogroup themeable */ |
Formats disponibles : Unified diff
Weekly update of contrib modules