function _office_hours_set_group_label in Office Hours 6
Helper function to set combined days label for hour group
File
- ./
office_hours.theme.inc, line 310
Code
function _office_hours_set_group_label(&$group) {
// reference days
$group_days =& $group['days'];
asort($group_days);
// initialize label
list($day_name, $prev_day_num) = each($group_days);
$label_start = $day_name;
$label_end = '';
$label = $label_start;
// build label
while (list($day_name, $day_num) = each($group_days)) {
$diff = $day_num - $prev_day_num;
if ($diff == 1) {
$label_end = $day_name;
}
else {
if ($label_end) {
$label .= ' - ' . $label_end;
}
$label_start = $day_name;
$label_end = '';
$label .= ', ' . $label_start;
}
$prev_day_num = $day_num;
}
// update label if all were consecutive
if ($label_end) {
$label .= ' - ' . $label_end;
}
// update group
$group['label'] = $label;
// clean up and return
unset($group_days);
return $label;
}