function _office_hours_set_weight in Office Hours 6.2
Same name and namespace in other branches
- 6 office_hours.module \_office_hours_set_weight()
1 call to _office_hours_set_weight()
- office_hours_field in ./
office_hours.module - Implementation of hook_field().
File
- ./
office_hours.module, line 347 - Creates a field and widget for inserting working or office hours per day
Code
function _office_hours_set_weight($items) {
$sorted = array();
foreach ($items as $key => $item) {
if (!is_null($item['day'])) {
$sortkey = (int) $item['day'];
if (count($items) == 14) {
$sortkey = $sortkey * 2;
}
if (is_array($sorted[$sortkey])) {
$sorted[$sortkey + 1] = $item;
}
else {
$sorted[$sortkey] = $item;
}
}
}
//now fill the empty spaces with null values
foreach (range(0, count($items) - 1) as $value) {
if (!is_array($sorted[$value])) {
$sorted[$value] = array(
'day' => NULL,
'starthours' => NULL,
'endhours' => NULL,
);
}
}
return $sorted;
}