function openlayers_cck_widget_settings in Openlayers 6
Same name and namespace in other branches
- 6.2 modules/openlayers_cck/openlayers_cck.module \openlayers_cck_widget_settings()
Implementation of hook_widget_settings().
File
- modules/
openlayers_cck/ openlayers_cck.module, line 246 - This file holds the main Drupal hook functions and private functions for the openlayers_cck module.
Code
function openlayers_cck_widget_settings($op, $widget) {
switch ($op) {
case 'form':
// Get Presets
$presets = openlayers_get_presets();
$default_preset = variable_get('openlayers_default_preset', 'default');
// Define form elements
$form['openlayers_cck_preset_map'] = array(
'#type' => 'select',
'#title' => t('Input Map Preset'),
'#description' => t('Choose the OpenLayers Preset Map that will be used to input the data.'),
'#options' => $presets,
'#default_value' => isset($widget['openlayers_cck_preset_map']) ? $widget['openlayers_cck_preset_map'] : $default_preset,
);
// Zoom to layer behavior
$form['openlayers_cck_zoom_to_layer'] = array(
'#type' => 'checkbox',
'#title' => t('Zoom to Layer'),
'#description' => t('This option will affect how the map will display on the node view. The zoom to layer behavior means that the map will automatically be centered and zoomed onto the features that are created.'),
'#default_value' => isset($widget['openlayers_cck_zoom_to_layer']) ? $widget['openlayers_cck_zoom_to_layer'] : FALSE,
);
// Zoom levels
$zoom_levels = array();
for ($i = 0; $i <= 20; $i++) {
$zoom_levels[$i] = $i;
}
$form['openlayers_cck_zoom_to_layer_level'] = array(
'#type' => 'select',
'#title' => t('Zoom Level'),
'#description' => t('Choose the zoom level that the Zoom to Layer behavior will have. This will only apply for single feature maps, meaning if you have one point on the map, this level will be given. These levels are arbitrary and the levels will depend on your map and layers. The lower the number the more zoomed in the map will be.'),
'#options' => $zoom_levels,
'#default_value' => isset($widget['openlayers_cck_zoom_to_layer_level']) ? $widget['openlayers_cck_zoom_to_layer_level'] : 10,
);
// Since there are not options for formatters, we are putting
// this here. This defines whethere or not to show an empty
// map for the map formatters.
$form['openlayers_cck_show_empty_map'] = array(
'#type' => 'checkbox',
'#title' => t('Show Empty Map'),
'#description' => t('If the formatter for this field is a map, by default a map will not display if there are no features/data. Check this if you want to ensure that the map does show if there is no data in the field. Please note that this setting actually affects the formatter and will be true in any of the displays that map formatters are used.'),
'#default_value' => isset($widget['openlayers_cck_show_empty_map']) ? $widget['openlayers_cck_show_empty_map'] : FALSE,
);
// Return form
return $form;
case 'save':
return array(
'openlayers_cck_preset_map',
'openlayers_cck_show_empty_map',
'openlayers_cck_zoom_to_layer',
'openlayers_cck_zoom_to_layer_level',
);
}
}