function theme_getdirections_direction_form in Get Directions 7.3
Same name and namespace in other branches
- 6.2 getdirections.theme.inc \theme_getdirections_direction_form()
- 6 getdirections.theme.inc \theme_getdirections_direction_form()
- 7.2 getdirections.module \theme_getdirections_direction_form()
Themes the getdirections form.
File
- ./
getdirections.module, line 3310 - Fetches google map directions.
Code
function theme_getdirections_direction_form($variables) {
$form = $variables['form'];
$mapid = $form['mapid']['#value'];
unset($form['mapid']);
$getdirections_defaults = getdirections_defaults();
$getdirections_misc = getdirections_misc_defaults();
if (isset($form['settings']['#value'])) {
$settings = $form['settings']['#value'];
$getdirections_defaults = $settings['default'];
$getdirections_misc = $settings['misc'];
unset($form['settings']);
}
$output = '';
// if you want to do fancy things with the form, do it here ;-)
if (isset($form['mto'])) {
$form['mto']['#prefix'] = '<div class="container-inline getdirections_display">';
$form['mto']['#suffix'] = '</div>';
}
if (isset($form['mfrom'])) {
$form['mfrom']['#prefix'] = '<div class="container-inline getdirections_display">';
$form['mfrom']['#suffix'] = '</div>';
}
if (isset($form['travelmode_' . $mapid])) {
$form['travelmode_' . $mapid]['#prefix'] = '<div class="container-inline getdirections_display">';
$form['travelmode_' . $mapid]['#suffix'] = '</div>';
}
if (isset($form['travelextras_' . $mapid])) {
$form['travelextras_' . $mapid]['#prefix'] = '<div class="container-inline getdirections_display">';
$form['travelextras_' . $mapid]['#suffix'] = '</div>';
}
if (!$getdirections_defaults['advanced_autocomplete']) {
if ($getdirections_misc['geolocation_enable'] && getdirections_is_mobile()) {
if ($getdirections_misc['geolocation_option'] == 1) {
// html5 geolocation
$geolocation_button = '<input type="button" value="' . t('Find Location') . '" title="' . t('Get the latitude and longitude for your current position from the browser') . '" id="getdirections_geolocation_button_from_' . $mapid . '" class="form-submit" />';
$geolocation_button .= '<span id="getdirections_geolocation_status_from_' . $mapid . '" ></span>';
$form['from_' . $mapid]['#field_suffix'] = ' ' . $geolocation_button;
}
elseif ($getdirections_misc['geolocation_option'] == 2 && module_exists('smart_ip')) {
// smart ip
$geolocation_button = '<input type="button" value="' . t('Locate by Smart IP') . '" title="' . t('Get the latitude and longitude for your current position from Smart IP') . '" id="getdirections_geolocation_button_from_' . $mapid . '" class="form-submit" />';
$geolocation_button .= '<span id="getdirections_geolocation_status_from_' . $mapid . '" ></span>';
$form['from_' . $mapid]['#field_suffix'] = ' ' . $geolocation_button;
}
elseif ($getdirections_misc['geolocation_option'] == 3 && module_exists('ip_geoloc')) {
// ip_geoloc
$geolocation_button = '<input type="button" value="' . t('Locate by IP Geolocation') . '" title="' . t('Get the latitude and longitude for your current position from IP Geolocation') . '" id="getdirections_geolocation_button_from_' . $mapid . '" class="form-submit" />';
$geolocation_button .= '<span id="getdirections_geolocation_status_from_' . $mapid . '" ></span>';
$form['from_' . $mapid]['#field_suffix'] = ' ' . $geolocation_button;
}
}
}
if ($getdirections_defaults['use_advanced']) {
$desc = t('Fill in the form below.');
$desc .= '<br />';
$desc .= t('You can also click on the map and move the marker.');
if (isset($form['country_from_' . $mapid])) {
$desc = t('Select a country first, then type in a town.');
$desc .= '<br />';
$desc .= t('You can also click on the map and move the marker.');
$form['country_from_' . $mapid]['#prefix'] = '<div id="getdirections_start_' . $mapid . '"><div class="container-inline getdirections_display">';
$form['country_from_' . $mapid]['#suffix'] = '</div>';
}
if (isset($form['from_' . $mapid]) && $form['from_' . $mapid]['#type'] == 'textfield' && (module_exists('location') || module_exists('getlocations_fields')) && !$getdirections_defaults['advanced_autocomplete'] && isset($form['country_from_' . $mapid])) {
$form['from_' . $mapid]['#suffix'] = '</div><div class="getdirections_start_info" id="getdirections_start_info_' . $mapid . '"></div>';
}
if (isset($form['country_to_' . $mapid])) {
$form['country_to_' . $mapid]['#prefix'] = '<div id="getdirections_end_' . $mapid . '"><div class="container-inline getdirections_display">';
$form['country_to_' . $mapid]['#suffix'] = '</div>';
}
if (isset($form['to_' . $mapid]) && $form['to_' . $mapid]['#type'] == 'textfield' && (module_exists('location') || module_exists('getlocations_fields')) && !$getdirections_defaults['advanced_autocomplete'] && isset($form['country_to_' . $mapid])) {
$form['to_' . $mapid]['#suffix'] = '</div><div class="getdirections_end_info" id="getdirections_end_info_' . $mapid . '"></div>';
}
if ($getdirections_defaults['advanced_autocomplete'] && $getdirections_defaults['waypoints'] > 0 && $getdirections_defaults['advanced_autocomplete_via'] && !$getdirections_defaults['advanced_alternate']) {
for ($ct = 1; $ct <= $getdirections_defaults['waypoints']; $ct++) {
if ($ct == 1) {
$form['via_autocomplete_' . $mapid . '_' . $ct]['#prefix'] = '<div id="autocomplete_via_wrapper_' . $mapid . '"><div class="container-inline getdirections_display">';
$form['via_autocomplete_' . $mapid . '_' . $ct]['#suffix'] = '</div>';
}
elseif ($ct == $getdirections_defaults['waypoints']) {
$form['via_autocomplete_' . $mapid . '_' . $ct]['#prefix'] = '<div class="container-inline getdirections_display">';
$form['via_autocomplete_' . $mapid . '_' . $ct]['#suffix'] = '</div></div>';
}
else {
$form['via_autocomplete_' . $mapid . '_' . $ct]['#prefix'] = '<div class="container-inline getdirections_display">';
$form['via_autocomplete_' . $mapid . '_' . $ct]['#suffix'] = '</div>';
}
}
}
}
else {
if (isset($form['country_from_' . $mapid])) {
$form['country_from_' . $mapid]['#prefix'] = '<div class="container-inline getdirections_display">';
$form['country_from_' . $mapid]['#suffix'] = '</div>';
}
if (isset($form['country_to_' . $mapid])) {
$form['country_to_' . $mapid]['#prefix'] = '<div class="container-inline getdirections_display">';
$form['country_to_' . $mapid]['#suffix'] = '</div>';
}
$desc = t('Fill in the form below.');
}
if (isset($form['switchfromto_' . $mapid])) {
$form['switchfromto_' . $mapid]['#prefix'] = '<div id="getdirections_switchfromto_' . $mapid . '">';
$form['switchfromto_' . $mapid]['#suffix'] = '</div>';
}
if (isset($form['next_' . $mapid])) {
$form['next_' . $mapid]['#prefix'] = '<div id="getdirections_nextbtn_' . $mapid . '">';
$form['next_' . $mapid]['#suffix'] = '</div>';
}
if (isset($form['submit_' . $mapid])) {
$form['submit_' . $mapid]['#prefix'] = '<div id="getdirections_btn_' . $mapid . '">';
$form['submit_' . $mapid]['#suffix'] = '</div>';
}
$output .= '<p class="description">' . $desc . '</p>';
$output .= drupal_render_children($form);
// buttons
$buttons = array();
$output_buttons = '';
if ($getdirections_misc['trafficinfo']) {
$buttons[] = '<input type="button" value="' . t('Traffic Info !t', array(
'!t' => $getdirections_misc['trafficinfo_state'] ? t('Off') : t('On'),
)) . '" title="' . t('Limited Availability') . '" id="getdirections_toggleTraffic_' . $mapid . '" class="form-submit" />';
}
if ($getdirections_misc['bicycleinfo']) {
$buttons[] = '<input type="button" value="' . t('Bicycle Info !t', array(
'!t' => $getdirections_misc['bicycleinfo_state'] ? t('Off') : t('On'),
)) . '" title="' . t('Limited Availability') . '" id="getdirections_toggleBicycle_' . $mapid . '" class="form-submit" />';
}
if ($getdirections_misc['transitinfo']) {
$buttons[] = '<input type="button" value="' . t('Transit Info !t', array(
'!t' => $getdirections_misc['transitinfo_state'] ? t('Off') : t('On'),
)) . '" title="' . t('Limited Availability') . '" id="getdirections_toggleTransit_' . $mapid . '" class="form-submit" />';
}
if ($getdirections_misc['panoramio_use'] && $getdirections_misc['panoramio_show']) {
$buttons[] = '<input type="button" value="' . t('Panoramio !t', array(
'!t' => $getdirections_misc['panoramio_state'] ? t('Off') : t('On'),
)) . '" id="getdirections_togglePanoramio_' . $mapid . '" class="form-submit" />';
}
if ($getdirections_misc['weather_use']) {
if ($getdirections_misc['weather_use'] && $getdirections_misc['weather_show']) {
$buttons[] = '<input type="button" value="' . t('Weather !t', array(
'!t' => $getdirections_misc['weather_state'] ? t('Off') : t('On'),
)) . '" id="getdirections_toggleWeather_' . $mapid . '" class="form-submit" />';
}
if ($getdirections_misc['weather_cloud']) {
$buttons[] = '<input type="button" value="' . t('Clouds !t', array(
'!t' => $getdirections_misc['weather_cloud_state'] ? t('Off') : t('On'),
)) . '" id="getdirections_toggleCloud_' . $mapid . '" class="form-submit" />';
}
}
if (count($buttons)) {
$output_buttons .= '<div class="getdirections_map_buttons container-inline">';
$output_buttons .= implode(' ', $buttons);
$output_buttons .= '</div>';
}
$output .= $output_buttons;
return $output;
}