function spaces_calendar_settings_form in Spaces 5
Same name and namespace in other branches
- 5.2 spaces_calendar/spaces_calendar.module \spaces_calendar_settings_form()
1 string reference to 'spaces_calendar_settings_form'
- spaces_calendar_menu in spaces_calendar/
spaces_calendar.module - Implementation of hook_menu()
File
- spaces_calendar/
spaces_calendar.module, line 116
Code
function spaces_calendar_settings_form() {
if (_spaces_calendar_ical_enabled()) {
$feedtype = variable_get('spaces_calendar_feed_nodetype', '');
if (!variable_get('feedapi_mapper_mapping_' . $feedtype, array())) {
$mapping = array(
serialize(array(
'raw',
'DTSTART',
'datetime',
)) => serialize(array(
'date',
variable_get('spaces_calendar_datefield', ''),
'from',
)),
serialize(array(
'raw',
'DTEND',
'datetime',
)) => serialize(array(
'date',
variable_get('spaces_calendar_datefield', ''),
'to',
)),
);
variable_set('feedapi_mapper_mapping_' . $feedtype, $mapping);
drupal_set_message(t('iCal feed mappings have been set up.'));
}
}
$form = array();
$types = array();
$nodetypes = node_get_types();
foreach ($nodetypes as $ntype => $nname) {
$types[$ntype] = $nname->name;
}
$fields = content_fields();
$fieldtypes = array();
foreach ($fields as $field) {
$fieldtypes[$field['field_name']] = t($field['widget']['label']) . ' (' . $field['field_name'] . ')';
}
$form['spaces_calendar_default_settings'] = array(
'#type' => 'fieldset',
'#title' => 'Spaces calendar default settings',
);
$form['spaces_calendar_default_settings']['spaces_calendar_nodetype'] = array(
'#type' => 'select',
'#title' => t('Event node types'),
'#description' => t('Select the designated node type for events.'),
'#options' => $types,
'#default_value' => variable_get('spaces_calendar_nodetype', ''),
'#multiple' => FALSE,
);
$form['spaces_calendar_default_settings']['spaces_calendar_datefield'] = array(
'#type' => 'select',
'#title' => t('Event date field'),
'#description' => t('Select the designated cck date field to use for events events.'),
'#options' => $fieldtypes,
'#default_value' => variable_get('spaces_calendar_datefield', ''),
'#multiple' => FALSE,
);
if (module_exists('feedapi') && module_exists('feedapi_mapper')) {
$form['spaces_calendar_feedapi_settings'] = array(
'#type' => 'fieldset',
'#title' => 'Spaces calendar feedapi/ical integration settings',
);
$form['spaces_calendar_feedapi_settings']['spaces_calendar_feed_nodetype'] = array(
'#type' => 'select',
'#title' => t('FeedAPI feed node type'),
'#description' => t('Select the type of node that will hold ical feeds.'),
'#options' => $types,
'#default_value' => variable_get('spaces_calendar_feed_nodetype', ''),
'#multiple' => FALSE,
);
$form['spaces_calendar_feedapi_settings']['spaces_calendar_feed_itemtype'] = array(
'#type' => 'select',
'#title' => t('FeedAPI node item type'),
'#description' => t('Select the type of node that events from ical feeds should be created into.'),
'#options' => $types,
'#default_value' => variable_get('spaces_calendar_feed_itemtype', ''),
'#multiple' => FALSE,
);
}
return system_settings_form($form);
}