function theme_getlocations_show in Get Locations 7
Same name and namespace in other branches
- 6.2 getlocations.theme.inc \theme_getlocations_show()
- 6 getlocations.theme.inc \theme_getlocations_show()
- 7.2 getlocations.module \theme_getlocations_show()
Returns HTML for a map.
All the map displays pass through here.
Parameters
array $variables: An associative array containing:
- width: The width of the map.
- height: The height of the map.
- defaults: The settings to be applied to the map, links, buttons and form elements.
- mapid: The unique identifier for the map.
- type: The entity type, eg node, user, term or comment.
- node: The entity object.
Return value
string $output
7 theme calls to theme_getlocations_show()
- getlocations_fields_getmap in modules/
getlocations_fields/ getlocations_fields.module - input map
- getlocations_fields_getmap_show in modules/
getlocations_fields/ getlocations_fields.module - Used by theme for display output.
- getlocations_map_field_formatter_view in modules/
getlocations_map/ getlocations_map.module - Implements hook_field_formatter_view(). Build a renderable array for a field value.
- getlocations_search_getmap in modules/
getlocations_search/ getlocations_search.module - Set up the map and use getlocations to spit it out
- getlocations_setlocations in ./
getlocations.module - Set up javascript settings and map
File
- ./
getlocations.module, line 6865 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function theme_getlocations_show($variables) {
$width = $variables['width'];
$height = $variables['height'];
$defaults = $variables['defaults'];
$mapid = $variables['mapid'];
$type = $variables['type'];
$node = $variables['node'];
$latlons = $variables['latlons'];
$minmaxes = $variables['minmaxes'];
$datanum = count($latlons);
$output = '';
$returnlink = FALSE;
// return link
if ($type == 'node' && $defaults['returnlink_page_enable']) {
if (is_object($node)) {
$linktext = $defaults['returnlink_page_link'];
if (preg_match("/%t/", $linktext)) {
$linktext = preg_replace("/%t/", $node->title, $linktext);
}
$l = l($linktext, 'node/' . $node->nid);
$returnlink = '<div class="getlocations_returnlink">' . $l . '</div>';
}
}
elseif ($type == 'user' && $defaults['returnlink_user_enable']) {
if (is_object($node)) {
$linktext = $defaults['returnlink_user_link'];
if (preg_match("/%n/", $linktext)) {
$linktext = preg_replace("/%n/", $node->name, $linktext);
}
$l = l($linktext, 'user/' . $node->uid);
$returnlink = '<div class="getlocations_returnlink">' . $l . '</div>';
}
}
elseif ($type == 'term' && $defaults['returnlink_term_enable'] && module_exists('taxonomy')) {
if (is_object($node)) {
$linktext = $defaults['returnlink_term_link'];
if (preg_match("/%n/", $linktext)) {
$linktext = preg_replace("/%n/", $node->name, $linktext);
}
$l = l($linktext, 'taxonomy/term/' . $node->tid);
$returnlink = '<div class="getlocations_returnlink">' . $l . '</div>';
}
}
elseif ($type == 'comment' && $defaults['returnlink_comment_enable'] && module_exists('comment')) {
if (is_object($node)) {
$linktext = $defaults['returnlink_comment_link'];
if (preg_match("/%n/", $linktext)) {
$linktext = preg_replace("/%n/", $node->subject, $linktext);
}
$l = l($linktext, 'comment/' . $node->cid);
$returnlink = '<div class="getlocations_returnlink">' . $l . '</div>';
}
}
if ($returnlink) {
$output .= $returnlink;
}
if ($defaults['map_resize'] && getlocations_is_mobile()) {
$width = '100%';
#$height = '100%';
}
// show maplinks if enabled
if ($defaults['show_maplinks']) {
$output .= '<a id="maptop_' . $mapid . '" name="maptop_' . $mapid . '"></a>';
}
// search_places
$sp = '';
if ($defaults['search_places']) {
$sp .= '<div class="search_places_input_wrapper">';
if ($defaults['search_places_label']) {
$sp .= '<label for="search_places_select_' . $mapid . '">' . $defaults['search_places_label'] . '</label>';
}
if ($defaults['search_places_dd']) {
// alternative dropdown
$sp_opts = array(
'accounting' => t('Accounting'),
'airport' => t('Airport'),
'amusement_park' => t('Amusement park'),
'aquarium' => t('Aquarium'),
'art_gallery' => t('Art gallery'),
'atm' => t('ATM'),
'bakery' => t('Bakery'),
'bank' => t('Bank'),
'bar' => t('Bar'),
'beauty_salon' => t('Beauty salon'),
'bicycle_store' => t('Bicycle store'),
'book_store' => t('Book store'),
'bowling_alley' => t('Bowling alley'),
'bus_station' => t('Bus station'),
'cafe' => t('Cafe'),
'campground' => t('Campground'),
'car_dealer' => t('Car dealer'),
'car_rental' => t('Car rental'),
'car_repair' => t('Car repair'),
'car_wash' => t('Car wash'),
'casino' => t('Casino'),
'cemetery' => t('Cemetery'),
'church' => t('Church'),
'city_hall' => t('City hall'),
'clothing_store' => t('Clothing store'),
'convenience_store' => t('Convenience store'),
'courthouse' => t('Courthouse'),
'dentist' => t('Dentist'),
'department_store' => t('Department store'),
'doctor' => t('Doctor'),
'electrician' => t('Electrician'),
'electronics_store' => t('Electronics store'),
'embassy' => t('Embassy'),
'establishment' => t('Establishment'),
'finance' => t('Finance'),
'fire_station' => t('Fire station'),
'florist' => t('Florist'),
'food' => t('Food'),
'funeral_home' => t('Funeral home'),
'furniture_store' => t('Furniture store'),
'gas_station' => t('Gas station'),
'general_contractor' => t('General contractor'),
'grocery_or_supermarket' => t('Grocery or supermarket'),
'gym' => t('Gym'),
'hair_care' => t('Hair care'),
'hardware_store' => t('Hardware store'),
'health' => t('Health'),
'hindu_temple' => t('Hindu temple'),
'home_goods_store' => t('Home goods store'),
'hospital' => t('Hospital'),
'insurance_agency' => t('Insurance agency'),
'jewelry_store' => t('Jewelry store'),
'laundry' => t('Laundry'),
'lawyer' => t('Lawyer'),
'library' => t('Library'),
'liquor_store' => t('Liquor store'),
'local_government_office' => t('Local government office'),
'locksmith' => t('Locksmith'),
'lodging' => t('Lodging'),
'meal_delivery' => t('Meal delivery'),
'meal_takeaway' => t('Meal takeaway'),
'mosque' => t('Mosque'),
'movie_rental' => t('Movie rental'),
'movie_theater' => t('Movie theater'),
'moving_company' => t('Moving company'),
'museum' => t('Museum'),
'night_club' => t('Night club'),
'painter' => t('Painter'),
'park' => t('Park'),
'parking' => t('Parking'),
'pet_store' => t('Pet store'),
'pharmacy' => t('Pharmacy'),
'physiotherapist' => t('Physiotherapist'),
'place_of_worship' => t('Place of worship'),
'plumber' => t('Plumber'),
'police' => t('Police'),
'post_office' => t('Post office'),
'real_estate_agency' => t('Real estate agency'),
'restaurant' => t('Restaurant'),
'roofing_contractor' => t('Roofing contractor'),
'rv_park' => t('RV park'),
'school' => t('School'),
'shoe_store' => t('Shoe store'),
'shopping_mall' => t('Shopping mall'),
'spa' => t('Spa'),
'stadium' => t('Stadium'),
'storage' => t('Storage'),
'store' => t('Store'),
'subway_station' => t('Subway station'),
'synagogue' => t('Synagogue'),
'taxi_stand' => t('Taxi stand'),
'train_station' => t('Train station'),
'travel_agency' => t('Travel agency'),
'university' => t('University'),
'veterinary_care' => t('Veterinary care'),
'zoo' => t('Zoo'),
);
$sp .= '<select id="search_places_select_' . $mapid . '" class="form-select" >';
foreach ($sp_opts as $k_opt => $opt) {
$sel = '';
if ($k_opt == 'establishment') {
$sel = 'selected';
}
$sp .= '<option value="' . $k_opt . '" ' . $sel . '>' . $opt . '</option>';
}
$sp .= '</select>';
$sp .= ' <input type="button" value="' . t('Go') . '" id="search_places_go_btn_' . $mapid . '" class="form-submit" />';
$sp .= ' <input type="button" value="' . t('Reset') . '" onClick="Drupal.getlocations_search_places_clearmarkers(\'' . $mapid . '\', true)" class="form-submit" />';
$sp .= '</div>';
}
else {
$placeholder = '';
if ($defaults['search_places_placeholder']) {
$placeholder = 'placeholder="' . $defaults['search_places_placeholder'] . '"';
}
$sp .= '<input type="text" id="search_places_input_' . $mapid . '" size="' . $defaults['search_places_size'] . '" class="form-text" ' . $placeholder . ' />';
$sp .= ' <input type="button" value="' . t('Reset') . '" onClick="Drupal.getlocations_search_places_clearmarkers(\'' . $mapid . '\', true)" class="form-submit" />';
$sp .= '</div>';
}
if ($defaults['search_places_list']) {
$sp .= '<div class="sp_listing_wrapper"><h4>' . t('Google Places search results') . '</h4><div class="sp_listing"><ul class="sp_ul" id="search_places_results_' . $mapid . '"></ul></div></div>';
}
}
if ($defaults['search_places'] && $defaults['search_places_position'] == 'outside_above') {
$output .= $sp;
}
// type class
$class = '';
if ($type) {
$class = ' getlocations_' . $type;
}
// wrap the map
$output .= '<div class="getlocations_map_wrapper_inner' . $class . '">';
$output .= '<div id="getlocations_map_wrapper_' . $mapid . '" style="width: ' . $width . '; height: ' . $height . '" >';
$output .= '<div class="getlocations_map_canvas" id="getlocations_map_canvas_' . $mapid . '" style="width: 100%; height: 100%" ></div>';
$output .= '</div>';
$output .= '</div>';
// getlocations_map_wrapper_inner
// give each map its own data
$localdata = json_encode(array(
'datanum' => $datanum,
'latlons' => $latlons,
'minmaxes' => $minmaxes,
));
$output .= "\n" . '<script type="text/javascript">' . "\n" . '<!--//--><![CDATA[//><!--' . "\n";
$output .= 'Drupal.getlocations_data["' . $mapid . '"] = ' . $localdata . ';' . "\n";
$output .= '//--><!]]>' . "\n" . '</script>' . "\n";
// show_search_distance
if (module_exists('getlocations_fields') && isset($defaults['search_dist_info'])) {
$output .= '<div id="getlocations_fields_search_views_search_wrapper_' . $mapid . '" class="js-hide">';
$output .= '<div id="getlocations_fields_search_views_search_units_' . $mapid . '">' . $defaults['search_dist_info']['search_units'] . '</div>';
$output .= '<div id="getlocations_fields_search_views_search_latitude_' . $mapid . '">' . $defaults['search_dist_info']['latitude'] . '</div>';
$output .= '<div id="getlocations_fields_search_views_search_longitude_' . $mapid . '">' . $defaults['search_dist_info']['longitude'] . '</div>';
$output .= '<div id="getlocations_fields_search_views_search_distance_meters_' . $mapid . '">' . getlocations_convert_distance_to_meters($defaults['search_dist_info']['search_distance'], $defaults['search_dist_info']['search_units']) . '</div>';
$output .= '</div>';
}
// show maplinks if enabled
if ($defaults['show_maplinks']) {
$output .= '<div class="getlocations_map_links" id="getlocations_map_links_' . $mapid . '" ><ul></ul></div>';
}
// buttons
$buttons = array();
if ($defaults['trafficinfo']) {
$buttons[] = '<input type="button" value="' . t('Traffic Info !t', array(
'!t' => $defaults['trafficinfo_state'] ? t('Off') : t('On'),
)) . '" title="' . t('Limited Availability') . '" id="getlocations_toggleTraffic_' . $mapid . '" class="form-submit" />';
}
if ($defaults['bicycleinfo']) {
$buttons[] = '<input type="button" value="' . t('Bicycle Info !t', array(
'!t' => $defaults['bicycleinfo_state'] ? t('Off') : t('On'),
)) . '" title="' . t('Limited Availability') . '" id="getlocations_toggleBicycle_' . $mapid . '" class="form-submit" />';
}
if ($defaults['transitinfo']) {
$buttons[] = '<input type="button" value="' . t('Transit Info !t', array(
'!t' => $defaults['transitinfo_state'] ? t('Off') : t('On'),
)) . '" title="' . t('Limited Availability') . '" id="getlocations_toggleTransit_' . $mapid . '" class="form-submit" />';
}
// views_search_marker
if (module_exists('getlocations_fields') && isset($defaults['search_dist_info'])) {
if ($defaults['views_search_marker_enable'] && $defaults['views_search_marker_toggle']) {
$buttons[] = '<input type="button" value="' . t('Search marker !t', array(
'!t' => $defaults['views_search_marker_toggle_active'] ? t('Off') : t('On'),
)) . '" id="getlocations_toggleSearchMarker_' . $mapid . '" class="form-submit" />';
}
if ($defaults['views_search_radshape_enable'] && $defaults['views_search_radshape_toggle']) {
$buttons[] = '<input type="button" value="' . t('Search area !t', array(
'!t' => $defaults['views_search_radshape_toggle_active'] ? t('Off') : t('On'),
)) . '" id="getlocations_toggleSearchArea_' . $mapid . '" class="form-submit" />';
}
}
// categories
if (isset($defaults['category_showhide_buttons']) && $defaults['category_showhide_buttons']) {
if (isset($defaults['categories']) && $defaults['categories']) {
foreach ($defaults['categories'] as $cat => $label) {
$buttons[] = '<input type="button" value="' . t('!cat Off', array(
'!cat' => $label,
)) . '" id="getlocations_toggle_' . $cat . '_' . $mapid . '" class="form-submit" />';
}
}
}
// KML
if ($defaults['kml_group']['kml_url'] && $defaults['kml_group']['kml_url_button']) {
$kmlbuttonlabel = t('Kml Layer');
if ($defaults['kml_group']['kml_url_button_label']) {
$kmlbuttonlabel = $defaults['kml_group']['kml_url_button_label'];
}
$kmlbuttonlabel .= ' ' . ($defaults['kml_group']['kml_url_button_state'] ? t('Off') : t('On'));
$buttons[] = '<input type="button" value="' . $kmlbuttonlabel . '" id="getlocations_toggleKmlLayer_' . $mapid . '" class="form-submit" />';
}
if (module_exists('getlocations_search')) {
// search area shape
if (isset($defaults['search_radshape_toggle']) && $defaults['search_radshape_toggle'] && $defaults['search_radshape_enable']) {
$buttons[] = '<input type="button" value="' . t('Search area !t', array(
'!t' => $defaults['search_radshape_toggle_active'] ? t('Off') : t('On'),
)) . '" id="getlocations_search_toggleShape_' . $mapid . '" class="form-submit" />';
}
// search marker toggle button
if (isset($defaults['do_search_marker']) && $defaults['do_search_marker'] && $defaults['search_marker_toggle']) {
$buttons[] = '<input type="button" value="' . t('Marker !t', array(
'!t' => $defaults['search_marker_toggle_active'] ? t('Off') : t('On'),
)) . '" id="getlocations_search_toggleMarker_' . $mapid . '" class="form-submit" />';
}
}
// getlocations_gps
if (module_exists('getlocations_gps')) {
$buttons[] = theme('getlocations_gps_button', array(
'defaults' => $defaults,
'mapid' => $mapid,
));
}
// getlocations_smartip
if (module_exists('getlocations_smartip')) {
$buttons[] = theme('getlocations_smartip_button', array(
'defaults' => $defaults,
'mapid' => $mapid,
));
}
if (count($buttons)) {
$output .= '<div class="getlocations_map_buttons container-inline">';
$output .= implode(' ', $buttons);
$output .= '</div>';
}
// search_places
if ($defaults['search_places'] && $defaults['search_places_position'] == 'outside_below') {
$output .= $sp;
}
// What3Words
$what3words_lic = variable_get('getlocations_what3words_lic', array(
'key' => '',
'url' => 'http://api.what3words.com',
));
if ($what3words_lic['key'] && $defaults['what3words_enable']) {
$output .= '<div class="getlocations_what3words container-inline">';
if ($defaults['what3words_search']) {
// textbox
$output .= t('What3Words') . ' <input type="text" id="edit-getlocations-what3words-search" name="edit-getlocations-what3words-search" value="" size="' . $defaults['what3words_size'] . '" class="form-text" />';
$output .= ' <input type="button" value="' . t('Search') . '" id="edit-getlocations-what3words-search-submit" class="form-submit" />';
$output .= '<div class="getlocations_w3w_throbber getlocations_w3w_throbber_inactive" id="getlocations_w3w_throbber_' . $mapid . '"> </div>';
$output .= '<br />';
}
if ($defaults['what3words_show']) {
$output .= '<div id="edit-getlocations-what3words-show"></div>';
}
$output .= '</div>';
}
return $output;
}