function office_hours_field_settings in Office Hours 6.2
Same name and namespace in other branches
- 5 office_hours.module \office_hours_field_settings()
- 6 office_hours.module \office_hours_field_settings()
Implementation of hook_field_settings().
Handle the parameters for a field.
File
- ./
office_hours.module, line 103 - Creates a field and widget for inserting working or office hours per day
Code
function office_hours_field_settings($op, $field) {
switch ($op) {
case 'form':
//$options = _office_hours_create_hours_arr($field, FALSE);
$form = array();
$form['hoursformat'] = array(
'#type' => 'select',
'#title' => t('Hours format'),
'#options' => array(
t('24 hrs.'),
t('12 hrs'),
),
'#default_value' => $field['hoursformat'] ? $field['hoursformat'] : 0,
'#required' => FALSE,
'#description' => t('Format of the clock. IMPORTANT NOTE: if you do not select "Multiple values", you can enter only one day.'),
);
$form['granularity'] = array(
'#type' => 'select',
'#title' => t('granularity of time'),
'#options' => array(
'60' => t('Hours'),
'30' => t('Half hours'),
'15' => t('Quarter hours'),
),
'#default_value' => $field['granularity'] ? $field['granularity'] : 0,
'#required' => FALSE,
'#description' => t('Allow inserting quarter hours, half hours, or only hours of the day'),
);
$form['limitstart'] = array(
'#type' => 'office_hours_select',
'#title' => t('Limit widget start hours'),
'#default_value' => '',
//$field['limitstart']? $field['limitstart'] : '',
'#granularity' => $field['granularity'],
'#hoursformat' => $field['hoursformat'],
'#prefix' => '<div class="office-hours-block" style="display:inline">',
);
$form['limitend'] = array(
'#type' => 'office_hours_select',
'#title' => t('Limit widget end hours'),
'#default_hours' => '',
//$field['limitend']? $field['limitend'] : '',
'#granularity' => $field['granularity'],
'#hoursformat' => $field['hoursformat'],
'#suffix' => '</div>',
);
$form['valhrs'] = array(
'#type' => 'checkbox',
'#title' => t('Validate hours'),
'#required' => FALSE,
'#default_value' => isset($field['valhrs']) ? $field['valhrs'] : 0,
'#description' => t('Please note that this will work as long as the opening hours are not through midnight.'),
);
$form['addhrs'] = array(
'#type' => 'checkbox',
'#title' => t('Display the "Add more hours" link'),
'#required' => FALSE,
'#default_value' => isset($field['addhrs']) ? $field['addhrs'] : 1,
'#description' => t('Make it possible to use 2 hour block for each day instead of one'),
);
return $form;
case 'validate':
/* if ( $field['limitend'] <= $field['limitstart'] && $field['limitend'] != 'none' && $field['limitstart'] !='none') {
form_set_error('limitend','Limit ending hours are earlier than start hours');
}*/
break;
case 'save':
return array(
'hoursformat',
'granularity',
'limitstart',
'limitend',
'valhrs',
'addhrs',
);
case 'database columns':
$columns = array(
'day' => array(
'type' => 'int',
'not null' => FALSE,
'sortable' => TRUE,
),
'starthours' => array(
'type' => 'int',
'not null' => FALSE,
'sortable' => TRUE,
),
'endhours' => array(
'type' => 'int',
'not null' => FALSE,
'sortable' => TRUE,
),
);
return $columns;
break;
case 'views data':
$data = _office_hours_views_field_views_data($field);
$db_info = content_database_info($field);
$table_alias = content_views_tablename($field);
// Swap the filter handler.
$data[$table_alias][$field['field_name'] . '_day']['filter']['handler'] = 'office_hours_handler_filter_day';
$data[$table_alias][$field['field_name'] . '_starthours']['filter']['handler'] = 'office_hours_handler_filter_hours';
$data[$table_alias][$field['field_name'] . '_endhours']['filter']['handler'] = 'content_handler_handler_filter_hours';
return $data;
break;
}
}