function getlocations_leaflet_settings_form in Get Locations 7.2
Same name and namespace in other branches
- 7 modules/getlocations_leaflet/getlocations_leaflet.module \getlocations_leaflet_settings_form()
1 string reference to 'getlocations_leaflet_settings_form'
- getlocations_leaflet_menu in modules/
getlocations_leaflet/ getlocations_leaflet.module - Implements hook_menu().
File
- modules/
getlocations_leaflet/ getlocations_leaflet.module, line 3344 - getlocations_leaflet.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_leaflet_settings_form() {
$form = array();
$pagetitle = '<div><h4>' . t('Getlocations Leaflet') . '</h4><p>' . t('The settings selected here will be used as the starting point for all other Leaflet maps.') . '</p></div>';
$form['pagetitle'] = array(
'#markup' => $pagetitle,
);
$form['rebuild'] = array(
'#type' => 'fieldset',
'#title' => t('Regenerate Getlocations leaflet marker cache'),
'#description' => t('If you are having problems with markers, or have changed anything in the markers library, click on the Regenerate button.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$c = count(getlocations_get_marker_titles());
if ($c) {
$rebuildmsg = '<p>' . format_plural($c, 'You have 1 marker installed.', 'You have @count markers installed.') . '</p>';
}
else {
$rebuildmsg = '<p class="error">' . t('WARNING! NO markers found.') . '</p>';
}
$form['rebuild']['msg'] = array(
'#markup' => $rebuildmsg,
);
$form['rebuild']['rebuild_marker_js'] = array(
'#type' => 'submit',
'#value' => t('Regenerate'),
'#submit' => array(
'_getlocations_leaflet_rebuild_marker_js_submit',
),
);
$form['rebuild']['getlocations_leaflet_flush'] = getlocations_element_map_checkbox(t('Flush marker cache'), variable_get('getlocations_leaflet_flush', 1), t('Include the marker cache when the Drupal cache is flushed.'));
// getlocations_leaflet_cdn
$getlocations_leaflet_cdn = variable_get('getlocations_leaflet_cdn', array(
'enable' => 0,
'js' => '',
'css' => '',
));
$leaflet_libraries_installed = libraries_get_path('leaflet') ? TRUE : FALSE;
$leaflet_version = '';
if ($leaflet_libraries_installed) {
$desc = t('The Leaflet Library is installed at !p.', array(
'!p' => libraries_get_path('leaflet'),
));
$leaflet_version = getlocations_leaflet_library_version();
if ($leaflet_version) {
$desc .= ' ' . t('Using version !v', array(
'!v' => $leaflet_version,
));
}
}
elseif ($getlocations_leaflet_cdn['enable']) {
$desc = t('The Leaflet library is being hosted on CDN.');
}
else {
$desc = '<span class="error">' . t('The Leaflet library is NOT installed.') . '</span>';
}
$desc .= '<br />' . t('For details on the Leaflet library please see !u', array(
'!u' => l(t('leafletjs.com'), 'http://leafletjs.com/', array(
'attributes' => array(
'target' => '_blank',
),
)),
));
$desc .= '<br />' . t('Please read the README.txt included with getlocations_leaflet.');
$form['getlocations_leaflet_cdn'] = array(
'#type' => 'fieldset',
'#title' => t('Leaflet Library'),
'#description' => $desc,
'#collapsible' => TRUE,
'#collapsed' => $leaflet_libraries_installed || $getlocations_leaflet_cdn['enable'] && $getlocations_leaflet_cdn['js'] && $getlocations_leaflet_cdn['css'] ? TRUE : FALSE,
// This will store all the defaults in one variable.
'#tree' => TRUE,
);
$form['getlocations_leaflet_cdn']['enable'] = getlocations_element_map_checkbox(t('Enable CDN'), $getlocations_leaflet_cdn['enable'], t('Supply the URLs for CDN below.'));
$form['getlocations_leaflet_cdn']['js'] = getlocations_element_map_tf(t('Leaflet library javascript URL'), $getlocations_leaflet_cdn['js'], t('The full URL to the Leaflet javascript library.'), 80, 128);
$form['getlocations_leaflet_cdn']['css'] = getlocations_element_map_tf(t('Leaflet library CSS URL'), $getlocations_leaflet_cdn['css'], t('The full URL to the Leaflet css library.'), 80, 128);
if ($leaflet_libraries_installed || $getlocations_leaflet_cdn['enable'] && $getlocations_leaflet_cdn['js'] && $getlocations_leaflet_cdn['css']) {
// preview
$form['getlocations_leaflet_preview'] = array(
'#type' => 'fieldset',
'#title' => t('Getlocations Leaflet Preview'),
'#description' => t('A preview of the current map settings.') . '<br />' . t('You can adjust the default Map center and Zoom by changing the map.') . '<br />' . t('For all other changes use the form. Remember to Save configuration when you are done.'),
// This will store all the defaults in one variable.
'#tree' => FALSE,
);
$form['getlocations_leaflet_preview']['preview_map'] = array(
'#markup' => '',
);
}
// plugins
$getlocations_leaflet_plugins = getlocations_leaflet_plugins();
$form['getlocations_leaflet_plugins'] = array(
'#type' => 'fieldset',
'#title' => t('Leaflet plugins'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['getlocations_leaflet_plugins']['markercluster_enable'] = getlocations_element_map_checkbox(t('Enable Markercluster plugin'), $getlocations_leaflet_plugins['markercluster_enable']);
$form['getlocations_leaflet_plugins']['fullscreen_enable'] = getlocations_element_map_checkbox(t('Enable Fullscreen plugin'), $getlocations_leaflet_plugins['fullscreen_enable']);
$form['getlocations_leaflet_plugins']['graticule_enable'] = getlocations_element_map_checkbox(t('Enable Graticule plugin'), $getlocations_leaflet_plugins['graticule_enable']);
$form['getlocations_leaflet_plugins']['pancontrol_enable'] = getlocations_element_map_checkbox(t('Enable Pancontrol plugin'), $getlocations_leaflet_plugins['pancontrol_enable']);
$form['getlocations_leaflet_plugins']['zoomslider_enable'] = getlocations_element_map_checkbox(t('Enable Zoomslider plugin'), $getlocations_leaflet_plugins['zoomslider_enable']);
$form['getlocations_leaflet_plugins']['awesome_enable'] = getlocations_element_map_checkbox(t('Enable Awesome markers plugin'), $getlocations_leaflet_plugins['awesome_enable']);
$form['getlocations_leaflet_plugins']['mouseposition_enable'] = getlocations_element_map_checkbox(t('Enable Mouseposition plugin'), $getlocations_leaflet_plugins['mouseposition_enable']);
$form['getlocations_leaflet_plugins']['minimap_enable'] = getlocations_element_map_checkbox(t('Enable Minimap plugin'), $getlocations_leaflet_plugins['minimap_enable']);
$form['getlocations_leaflet_plugins']['geocoder_enable'] = getlocations_element_map_checkbox(t('Enable Geocoder plugin'), $getlocations_leaflet_plugins['geocoder_enable']);
$form['getlocations_leaflet_plugins']['usermarker_enable'] = getlocations_element_map_checkbox(t('Enable Usermarker plugin'), $getlocations_leaflet_plugins['usermarker_enable']);
$form['getlocations_leaflet_plugins']['bouncemarker_enable'] = getlocations_element_map_checkbox(t('Enable Bouncemarker plugin'), $getlocations_leaflet_plugins['bouncemarker_enable']);
$form['getlocations_leaflet_plugins']['magnifyingglass_enable'] = getlocations_element_map_checkbox(t('Enable Magnifying Glass plugin'), $getlocations_leaflet_plugins['magnifyingglass_enable']);
$form['getlocations_leaflet_plugins']['terminator_enable'] = getlocations_element_map_checkbox(t('Enable Day/Night plugin'), $getlocations_leaflet_plugins['terminator_enable']);
// leaflet-hash
$leaflet_hash_file = getlocations_leaflet_hash_library_check();
if ($leaflet_hash_file) {
$form['getlocations_leaflet_plugins']['hash_enable'] = getlocations_element_map_checkbox(t('Enable Leaflet hash plugin'), $getlocations_leaflet_plugins['hash_enable']);
}
else {
$form['getlocations_leaflet_plugins']['hash_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
}
// mapquest
$mapquest_lic = variable_get('getlocations_mapquest_lic', array(
'key' => '',
'type' => 'l',
));
if ($mapquest_lic['key']) {
if ($mapquest_lic['type'] == 'l') {
$form['getlocations_leaflet_plugins']['mapquest_traffic_enable'] = getlocations_element_map_checkbox(t('Enable Mapquest Traffic plugin'), $getlocations_leaflet_plugins['mapquest_traffic_enable']);
}
else {
$form['getlocations_leaflet_plugins']['mapquest_traffic_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
}
#$form['getlocations_leaflet_plugins']['mapquest_routing_enable'] = getlocations_element_map_checkbox(
# t('Enable Mapquest Routing plugin'),
# $getlocations_leaflet_plugins['mapquest_routing_enable']
#);
$form['getlocations_leaflet_plugins']['mapquest_routing_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
#$form['getlocations_leaflet_plugins']['mapquest_geocoder_enable'] = getlocations_element_map_checkbox(
# t('Enable Mapquest Geocoding plugin'),
# $getlocations_leaflet_plugins['mapquest_geocoder_enable']
#);
$form['getlocations_leaflet_plugins']['mapquest_geocoder_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_leaflet_plugins']['mapquest_maps_enable'] = getlocations_element_map_checkbox(t('Enable Mapquest Maps plugin'), $getlocations_leaflet_plugins['mapquest_maps_enable']);
#$form['getlocations_leaflet_plugins']['mapquest_maps_enable'] = array('#type' => 'value', '#value' => 0);
}
else {
$form['getlocations_leaflet_plugins']['mapquest_traffic_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_leaflet_plugins']['mapquest_routing_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_leaflet_plugins']['mapquest_geocoder_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_leaflet_plugins']['mapquest_maps_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
}
// mapbox
if (module_exists('getlocations_mapbox')) {
$form += getlocations_mapbox_settings_form();
}
// cloudmade
if (module_exists('getlocations_cloudmade')) {
$form += getlocations_cloudmade_settings_form();
}
$settings = getlocations_leaflet_defaults();
$form['getlocations_leaflet_defaults'] = array(
'#type' => 'fieldset',
'#title' => t('Default Page settings'),
// This will store all the defaults in one variable.
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$labels = array(
'width' => t('Width'),
'height' => t('Height'),
);
$form['getlocations_leaflet_defaults'] += getlocations_map_display_basics_form($settings, $labels);
unset($form['getlocations_leaflet_defaults']['map_resize']);
unset($form['getlocations_leaflet_defaults']['fullscreen_disable']);
unset($form['getlocations_leaflet_defaults']['styles']);
unset($form['getlocations_leaflet_defaults']['zoom']['#options']['21']);
unset($form['getlocations_leaflet_defaults']['zoom']['#options']['20']);
unset($form['getlocations_leaflet_defaults']['zoom']['#options']['19']);
unset($form['getlocations_leaflet_defaults']['minzoom_map']['#options']['21']);
unset($form['getlocations_leaflet_defaults']['minzoom_map']['#options']['20']);
unset($form['getlocations_leaflet_defaults']['minzoom_map']['#options']['19']);
unset($form['getlocations_leaflet_defaults']['maxzoom_map']['#options']['21']);
unset($form['getlocations_leaflet_defaults']['maxzoom_map']['#options']['20']);
unset($form['getlocations_leaflet_defaults']['maxzoom_map']['#options']['19']);
$form['getlocations_leaflet_defaults'] += getlocations_leaflet_display_options_form($settings, TRUE);
unset($form['getlocations_leaflet_defaults']['nodezoom']['#options']['21']);
unset($form['getlocations_leaflet_defaults']['nodezoom']['#options']['20']);
unset($form['getlocations_leaflet_defaults']['nodezoom']['#options']['19']);
$fieldables = getlocations_get_fieldable_entity_types();
// awesome
if ($settings['awesome'] && $settings['marker_type'] == 'fa') {
$getlocations_markers = variable_get('getlocations_markers', array());
$type_markers = getlocations_get_type_markers();
// default
$form['getlocations_leaflet_defaults'] += getlocations_leaflet_awesome_markers_elements_get($settings);
// entity types
foreach ($fieldables as $entity_type) {
if (getlocations_check_entity_type($entity_type)) {
$entity_get_info = entity_get_info($entity_type);
$label = $entity_get_info['label'];
$labels = array(
'awesome_icon' => t($label . ' Awesome icon'),
'awesome_icon_color' => t($label . ' Awesome icon color'),
'awesome_marker_color' => t($label . ' Awesome marker color'),
'awesome_title' => t($label . ' Awesome Fonts icon settings'),
'awesome_icon_spin' => t($label . ' Awesome icon spin'),
'awesome_icon_size' => t($label . ' Awesome icon size'),
'awesome_icon_type' => t($label . ' Awesome icon type'),
'awesome_icon_flip' => t($label . ' Awesome icon flip and rotate'),
'awesome_icon_html' => t($label . ' Awesome icon HTML'),
'awesome_icon_class' => t($label . ' Awesome icon class'),
);
$form['getlocations_leaflet_defaults'] += getlocations_leaflet_awesome_markers_elements_get($settings, $labels, $entity_type);
// per field name
foreach ($type_markers as $et => $bundles) {
if ($et == $entity_type) {
if (isset($getlocations_markers[$entity_type]['enable']) && $getlocations_markers[$entity_type]['enable']) {
foreach ($bundles as $bundle => $field_names) {
foreach ($field_names as $field_name => $marker_data) {
$bundle_label = $marker_data['bundle_label'];
$label2 = t('Type %etl, Bundle %name, Field %field Map marker', array(
'%etl' => $label,
'%name' => $bundle_label,
'%field' => $field_name,
));
$mkey = $entity_type . '__' . $bundle . '__' . $field_name;
$labels = array(
'awesome_icon' => t($label2 . ' Awesome icon'),
'awesome_icon_color' => t($label2 . ' Awesome icon color'),
'awesome_marker_color' => t($label2 . ' Awesome marker color'),
'awesome_title' => t($label2 . ' Awesome Fonts icon settings'),
'awesome_icon_spin' => t($label2 . ' Awesome icon spin'),
'awesome_icon_size' => t($label2 . ' Awesome icon size'),
'awesome_icon_type' => t($label2 . ' Awesome icon type'),
'awesome_icon_flip' => t($label2 . ' Awesome icon flip and rotate'),
'awesome_icon_html' => t($label2 . ' Awesome icon HTML'),
'awesome_icon_class' => t($label2 . ' Awesome icon class'),
);
$form['getlocations_leaflet_defaults'] += getlocations_leaflet_awesome_markers_elements_get($settings, $labels, $mkey);
}
}
}
}
}
}
}
}
// return links
foreach ($fieldables as $entity_type) {
$entity_get_info = entity_get_info($entity_type);
$label = $entity_get_info['label'];
if (getlocations_check_entity_type($entity_type)) {
$form['getlocations_leaflet_defaults']['returnlink_' . $entity_type . '_enable'] = getlocations_element_map_checkbox(t('Show link back to !label', array(
'!label' => $label,
)), $settings['returnlink_' . $entity_type . '_enable']);
$form['getlocations_leaflet_defaults']['returnlink_' . $entity_type . '_link'] = getlocations_element_map_tf(t('Text of !label return link', array(
'!label' => $label,
)), $settings['returnlink_' . $entity_type . '_link'], t('Use %t to insert the !label title', array(
'!label' => $label,
)), 30, 64);
}
}
// search markers
if (module_exists('getlocations_fields') && module_exists('views')) {
$form['getlocations_leaflet_defaults'] += getlocations_fields_views_search_form($settings, TRUE);
}
// javascript paths
$getlocations_leaflet_paths = getlocations_leaflet_paths_get();
$form['getlocations_leaflet_paths'] = array(
'#type' => 'fieldset',
'#title' => t('Javascript paths'),
'#description' => t('For advanced users who want to supply their own javascript.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
// This will store all the defaults in one variable.
'#tree' => TRUE,
);
$form['getlocations_leaflet_paths']['getlocations_leaflet_path'] = getlocations_element_path(t('Path to Getlocations leaflet javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_path'], 80, 128, t('Where the Getlocations leaflet javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_circles_path'] = getlocations_element_path(t('Path to Getlocations leaflet circles javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_circles_path'], 80, 128, t('Where the Getlocations leaflet circles javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_formatter_path'] = getlocations_element_path(t('Path to Getlocations leaflet formatter javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_formatter_path'], 80, 128, t('Where the Getlocations leaflet formatter javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_polygons_path'] = getlocations_element_path(t('Path to Getlocations leaflet polygons javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_polygons_path'], 80, 128, t('Where the Getlocations leaflet polygons javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_polylines_path'] = getlocations_element_path(t('Path to Getlocations leaflet polylines javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_polylines_path'], 80, 128, t('Where the Getlocations leaflet polylines javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_rectangles_path'] = getlocations_element_path(t('Path to Getlocations leaflet rectangles javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_rectangles_path'], 80, 128, t('Where the Getlocations leaflet rectangles javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_geojson_path'] = getlocations_element_path(t('Path to Getlocations leaflet geojson javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_geojson_path'], 80, 128, t('Where the Getlocations leaflet geojson javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_providers_path'] = getlocations_element_path(t('Path to Getlocations leaflet providers javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_providers_path'], 80, 128, t('Where the Getlocations leaflet providers javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_preview_path'] = getlocations_element_path(t('Path to Getlocations leaflet preview javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_preview_path'], 80, 128, t('Where the Getlocations leaflet preview javascript file is located.'));
$form['getlocations_leaflet_paths']['getlocations_leaflet_what3words_path'] = getlocations_element_path(t('Path to Getlocations leaflet what3words javascript file'), $getlocations_leaflet_paths['getlocations_leaflet_what3words_path'], 80, 128, t('Where the Getlocations leaflet what3words javascript file is located.'));
$form['getlocations_leaflet_paths']['reset'] = getlocations_element_dd(t('Reset'), 0, array(
0 => t('No'),
1 => t('Reset'),
2 => t('Reset to minified'),
), t('Reset the paths to the defaults.'));
unset($form['#theme']);
$form['#theme'] = 'getlocations_leaflet_settings_form';
$form['#validate'][] = 'getlocations_leaflet_settings_validate';
$form['#attached']['js'] = array(
$getlocations_leaflet_paths['getlocations_leaflet_formatter_path'],
$getlocations_leaflet_paths['getlocations_leaflet_preview_path'],
);
return system_settings_form($form);
}