function theme_getlocations_adinfo in Get Locations 7.2
Same name and namespace in other branches
- 7 getlocations.module \theme_getlocations_adinfo()
Returns HTML of a location's vcard, requested by ajax.
Parameters
array $variables: An associative array containing:
- location: The information pertaining to the address to be formatted.
Return value
string $output
1 theme call to theme_getlocations_adinfo()
File
- ./
getlocations.module, line 6992 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function theme_getlocations_adinfo($variables) {
$location = $variables['location'];
if (!isset($location['entity_type'])) {
return;
}
$output = '';
$output .= '<div class="location vcard">';
// this logic gives the location name field precedence over the entity title
$entity_link = FALSE;
$entity_title = FALSE;
$l = FALSE;
// build a link
$entity_get_info = entity_get_info($location['entity_type']);
if (!isset($entity_get_info['load hook'])) {
return;
}
$load_hook = $entity_get_info['load hook'];
$object = $load_hook($location['entity_id']);
if (isset($entity_get_info['uri callback'])) {
$uri_callback = $entity_get_info['uri callback'];
$entity_link = $uri_callback($object);
}
if ($location['name']) {
$entity_title = $location['name'];
}
else {
$title = 'name';
if (isset($entity_get_info['entity keys']['label'])) {
$title = $entity_get_info['entity keys']['label'];
}
if (isset($object->{$title})) {
$entity_title = $object->{$title};
}
}
if ($entity_title && $entity_link) {
$l = l($entity_title, $entity_link['path']);
}
if ($l) {
$output .= '<h4>' . $l . '</h4>';
}
$output .= '<div class="adr">';
if (!empty($location['street'])) {
$output .= '<div class="street-address">' . $location['street'];
if (!empty($location['additional'])) {
$output .= " " . '<span class="extended-address">' . $location['additional'] . '</span>';
}
$output .= '</div>';
}
if (!empty($location['city'])) {
$output .= '<span class="locality">' . $location['city'] . '</span>';
if (!empty($location['province_name'])) {
$output .= ", ";
}
elseif (!empty($location['province'])) {
$output .= ", ";
}
else {
$output .= " ";
}
}
if (isset($location['province_name']) && !empty($location['province_name'])) {
$output .= '<span class="region">' . $location['province_name'] . '</span>';
if (!empty($location['postal_code'])) {
$output .= " ";
}
}
elseif (isset($location['province']) && !empty($location['province'])) {
$output .= '<span class="region">' . $location['province'] . '</span>';
if (!empty($location['postal_code'])) {
$output .= " ";
}
}
if (!empty($location['postal_code'])) {
$output .= '<span class="postal-code">' . drupal_strtoupper($location['postal_code']) . '</span>';
}
if (isset($location['country_name']) && !empty($location['country_name'])) {
$output .= '<div class="country-name">' . $location['country_name'] . '</div>';
}
elseif (isset($location['country']) && !empty($location['country'])) {
$output .= '<div class="country-name">' . $location['country'] . '</div>';
}
$output .= '</div>';
if (isset($location['sdist'])) {
if ($location['sdist'] != 1) {
$unit_disp = getlocations_get_unit_names($location['sunit']);
}
else {
$unit_disp = getlocations_get_unit_names($location['sunit'], 'single');
}
$output .= '<div class="search-distance">' . number_format(floatval($location['sdist']), 2) . " " . $unit_disp . '</div>';
}
if (module_exists('getdirections') && isset($location['getdirections_link']) && $location['getdirections_link']) {
$gdlink = '';
if ($location['entity_id'] && $location['entity_type']) {
$gdlink = l(t('Directions'), 'getdirections/' . $location['entity_type'] . '/to/' . $location['entity_id'], array(
'attributes' => array(
'class' => array(
'getlocations_infolink',
),
'target' => '_parent',
),
));
}
# if (isset($location['nid']) && $location['entity_type'] == 'node') {
# $gdlink = l(t('Directions'), 'getdirections/location/to/' . $location['nid'], array('attributes' => array('class' => array('getlocations_infolink'), 'target' => '_parent')));
# }
# elseif (isset($location['uid']) && $location['uid']) {
# $gdlink = l(t('Directions'), 'getdirections/location_user/to/' . $location['uid'], array('attributes' => array('class' => array('getlocations_infolink'), 'target' => '_parent')));
# }
# elseif (isset($location['cid']) && $location['cid'] && getdirections_check_entity_type('comment')) {
# $gdlink = l(t('Directions'), 'getdirections/location_comment/to/' . $location['cid'], array('attributes' => array('class' => array('getlocations_infolink'), 'target' => '_parent')));
# }
# elseif (isset($location['tid']) && $location['tid'] && getdirections_get_vocabularies()) {
# $gdlink = l(t('Directions'), 'getdirections/location_term/to/' . $location['tid'], array('attributes' => array('class' => array('getlocations_infolink'), 'target' => '_parent')));
# }
if ($gdlink) {
$output .= '<div class="getdirections-link">' . $gdlink . '</div>';
}
}
$output .= '</div>';
return $output;
}