function calendar_plugin_display_page::options_form in Calendar 6.2
Same name and namespace in other branches
- 7 includes/calendar_plugin_display_page.inc \calendar_plugin_display_page::options_form()
- 7.2 includes/calendar_plugin_display_page.inc \calendar_plugin_display_page::options_form()
File
- includes/
calendar_plugin_display_page.inc, line 139
Class
- calendar_plugin_display_page
- The plugin that handles a full calendar page.
Code
function options_form(&$form, &$form_state) {
// It is very important to call the parent function here:
parent::options_form($form, $form_state);
switch ($form_state['section']) {
case 'calendar_popup':
$form['#title'] .= t('Date changer');
$form['calendar_popup'] = array(
'#type' => 'radios',
'#default_value' => $this
->get_option('calendar_popup'),
'#options' => $this
->popup_options(),
'#description' => t('Display a popup calendar date selector?'),
);
break;
case 'calendar_date_link':
$form['#title'] .= t('Add new date link');
$form['calendar_date_link'] = array(
'#type' => 'radios',
'#default_value' => $this
->get_option('calendar_date_link'),
'#options' => array(
'' => t('No link'),
) + node_get_types('names'),
'#description' => t('Display a link to add a new date of the specified content type. Displayed only to users with appropriate permissions.'),
);
break;
case 'calendar_colors':
$method = 'types';
// TODO Move the embedded styles other than the color into a stylesheet.
$form['#title'] .= t('Content Type Legend Colors');
$form['calendar_colors']['#tree'] = TRUE;
$form['calendar_colors']['#prefix'] .= '<div class="form-item"><label>' . t('Content Type') . '</label><p>' . t('Set a hex color value (like #ffffff) to use in the calendar legend for each content type. Types with empty values will have no stripe in the calendar and will not be added to the legend.') . '</p></div>';
$form['calendar_colors']['colorpicker'] = array(
'#type' => 'calendar_colorpicker',
'#prefix' => '<div class="clear-block"><div style="float:left">',
'#suffix' => '</div>',
);
$colors = $this
->get_option('calendar_colors');
switch ($method) {
case 'types':
$color_types = node_get_types('names');
break;
}
foreach ($color_types as $key => $name) {
$form['calendar_colors']['color'][$key] = array(
'#title' => $name,
'#type' => 'calendar_colorfield',
'#default_value' => isset($colors[$key]) ? $colors[$key] : '#ffffff',
'#calendar_colorpicker' => 'calendar-colors-colorpicker',
'#prefix' => '<div style="float:left;margin-right:10px">',
'#suffix' => '</div>',
);
}
$form['calendar_colors']['color']['#suffix'] = '</div>';
break;
case 'calendar_colors_vocabulary':
$taxonomies = taxonomy_get_vocabularies();
$options = array();
foreach ($taxonomies as $vid => $vocab) {
$options[$vid] = $vocab->name;
}
$colors_vocabulary = $this
->get_option('calendar_colors_vocabulary');
$form['#title'] .= t('Vocabulary Legend Types');
$form['calendar_colors_vocabulary'] = array(
'#type' => 'checkboxes',
'#default_value' => isset($colors_vocabulary) ? $colors_vocabulary : array(),
'#multiple' => TRUE,
'#options' => $options,
);
$form['calendar_colors_vocabulary']['#prefix'] .= '<div class="form-item"><label>' . t('Vocabularies') . '</label>' . t('Select vocabularies to use for setting calendar legend colors by taxonomy term. This works best for vocabularies with only a limited number of possible terms.') . '</div>';
break;
case 'calendar_colors_taxonomy':
$taxonomies = (array) $this
->get_option('calendar_colors_vocabulary');
$colors_taxonomy = $this
->get_option('calendar_colors_taxonomy');
$form['#title'] .= t('Taxonomy Legend Colors');
$form['calendar_colors_taxonomy']['#prefix'] = '';
if (empty($taxonomies)) {
$form['calendar_colors_taxonomy']['#prefix'] .= '<div class="form-item warning">' . t('Please select Legend vocabularies first!') . '</div>';
}
$form['calendar_colors_taxonomy']['#prefix'] .= '<div class="form-item"><label>' . t('Taxonomy Terms') . '</label><p>' . t('Set a hex color value (like #ffffff) to use in the calendar legend for each taxonomy term. Terms with empty values will have no stripe in the calendar and will not be added to the legend.') . '</p></div>';
$form['calendar_colors_taxonomy']['#tree'] = TRUE;
$form['calendar_colors_taxonomy']['colorpicker'] = array(
'#type' => 'calendar_colorpicker',
'#prefix' => '<div class="clear-block"><div style="float:left">',
'#suffix' => '</div>',
);
foreach ($taxonomies as $vid => $taxonomy) {
$vocab = taxonomy_get_tree($vid);
foreach ($vocab as $tid => $term) {
$form['calendar_colors_taxonomy']['color'][$term->tid] = array(
'#title' => t($term->name),
'#type' => 'calendar_colorfield',
'#default_value' => isset($colors_taxonomy[$term->tid]) ? $colors_taxonomy[$term->tid] : '#ffffff',
'#calendar_colorpicker' => 'calendar-colors-taxonomy-colorpicker',
'#prefix' => '<div style="float:left;margin-right:10px">',
'#suffix' => '</div>',
);
}
}
$form['calendar_colors_taxonomy']['color']['#suffix'] = '</div>';
break;
case 'calendar_colors_group':
$colors_group = $this
->get_option('calendar_colors_group');
$form['#title'] .= t('Group Legend Colors');
$form['calendar_colors_group']['#prefix'] = '';
$form['calendar_colors_group']['#prefix'] .= '<div class="form-item"><label>' . t('Group') . '</label><p>' . t('Set a hex color value (like #ffffff) to use in the calendar legend for each group. Groups with empty values will have no stripe in the calendar and will not be added to the legend.') . '</p></div>';
$form['calendar_colors_group']['#tree'] = TRUE;
$form['calendar_colors_group']['colorpicker'] = array(
'#type' => 'calendar_colorpicker',
'#prefix' => '<div class="clear-block"><div style="float:left">',
'#suffix' => '</div>',
);
$groups = og_all_groups_options();
foreach ($groups as $gid => $group_name) {
$form['calendar_colors_group']['color'][$gid] = array(
'#title' => t($group_name),
'#type' => 'calendar_colorfield',
'#default_value' => isset($colors_group[$gid]) ? $colors_group[$gid] : '#ffffff',
'#calendar_colorpicker' => 'calendar-colors-group-colorpicker',
'#prefix' => '<div style="float:left;margin-right:10px">',
'#suffix' => '</div>',
);
}
$form['calendar_colors_group']['color']['#suffix'] = '</div>';
break;
}
}