function calendar_ical_setup_form in Calendar 5
Same name and namespace in other branches
- 5.2 calendar_ical.module \calendar_ical_setup_form()
Setup Calendar feeds.
@todo - control of the stripe color is not yet implemented.
1 string reference to 'calendar_ical_setup_form'
- calendar_ical_menu in ./
calendar_ical.module - Implementation of hook_menu().
File
- ./
calendar_ical.module, line 91 - Adds ical functionality to Calendar.
Code
function calendar_ical_setup_form($view_name) {
$form = array();
$view = views_get_view($view_name);
for ($i = 0; $i < 10; $i++) {
$node = new StdClass();
$node->stripe = $i;
$stripes[$i] = $i . '<div class="calendar" style="width:150px;">' . theme('calendar_stripe_stripe', $node) . '</div>';
}
$form['#suffix'] = t('<h3>Stripe options</h3>') . implode($stripes);
$period = drupal_map_assoc(array(
0,
3600,
10800,
21600,
32400,
43200,
86400,
172800,
259200,
604800,
1209600,
2419200,
4838400,
9676800,
), 'format_interval');
$form['calendar_ical_expire_' . $view->name] = array(
'#type' => 'select',
'#title' => t('Expire iCal cache'),
'#default_value' => variable_get('calendar_ical_expire_' . $view->name, 9676800),
'#options' => $period,
'#description' => t('iCal feeds are cached to improve performance. Set an expiration time for cached feeds.'),
);
$empty_feed = array(
0 => array(
'name' => '',
'url' => '',
'type' => 'ical',
'stripe' => 0,
),
);
$form[$view->name] = array(
'#type' => 'fieldset',
'#title' => t('iCal Feeds'),
'#description' => t('Use this section to set up iCal feeds that should be displayed in this calendar. They will be shown along with any internal items that match the calendar criteria.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
// One empty input form will be added after any existing items.
$view_feeds = array_merge((array) variable_get('calendar_feeds_' . $view->name, $empty_feed), $empty_feed);
foreach ($view_feeds as $delta => $feed) {
$form[$view->name][$delta] = array(
'type' => array(
'#title' => t('Feed type'),
'#type' => 'hidden',
'#value' => 'ical',
),
'name' => array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $feed['name'],
'#description' => t('The name of a feed to include in this calendar.'),
),
'url' => array(
'#title' => t('Url'),
'#type' => 'textarea',
'#rows' => 2,
'#default_value' => $feed['url'],
'#description' => t('The external feed url or internal file path and name. Change \'webcal://\' to \'http://\'.'),
),
'stripe' => array(
'#title' => t('Stripe'),
'#type' => 'select',
'#options' => range(0, 10),
'#default_value' => $feed['stripe'],
'#description' => t('The color stripe to use for this feed (not working yet).'),
'#suffix' => '<hr>',
),
);
}
$form['view_name'] = array(
'#type' => 'hidden',
'#value' => $view->name,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}