function theme_office_hours_formatter_default in Office Hours 6
Same name and namespace in other branches
- 6.2 office_hours.theme.inc \theme_office_hours_formatter_default()
Theme function for 'default' text field formatter.
File
- ./
office_hours.theme.inc, line 6
Code
function theme_office_hours_formatter_default($element) {
$output = '';
$items = array();
$first = variable_get('date_first_day', 0);
$field = content_fields($element['#field_name'], $element['#type_name']);
$weekdays = date_week_days(TRUE);
foreach (element_children($element) as $key => $arraykey) {
$item = $element[$arraykey]['#item'];
$day = $item['day'];
if (isset($day)) {
$strhrs = _office_hours_mil_to_tf(check_plain($item['starthours']));
$endhrs = _office_hours_mil_to_tf(check_plain($item['endhours']));
if ($field['hoursformat']) {
$strhrs = _office_hours_convert_to_ampm($strhrs);
$endhrs = _office_hours_convert_to_ampm($endhrs);
}
$items[$day][] = array(
'strhrs' => $strhrs,
'endhrs' => $endhrs,
);
//we're aggregating hours for days together.
}
}
// add the closed days again, to 1) sort by first_day_of_week and 2) toggle show on/off
foreach ($weekdays as $key => $day) {
if (!array_key_exists($key, $items)) {
$items[$key][] = array(
'closed' => 'closed',
);
//silly, but we need this as an array because we can't use a string offset later
}
}
ksort($items);
$items = date_week_days_ordered($items);
$weekdays = date_week_days_ordered($weekdays);
foreach ($items as $day => $hours) {
$dayname = $weekdays[$day];
if (!(!empty($hours[0]['closed']) && empty($field['showclosed']))) {
// don't output unnecessary fields
$output .= theme('office_hours_display', $dayname, $hours);
}
}
return $output;
}