function getlocations_get_path_from_lid in Get Locations 7.2
Same name and namespace in other branches
- 7 getlocations.module \getlocations_get_path_from_lid()
Function to return url from a supplied location identifier
Parameters
int $lid location identifier:
Return value
string url
1 call to getlocations_get_path_from_lid()
- theme_getlocations_lidinfo in ./
getlocations.module - Returns HTML of a url, requested by ajax.
File
- ./
getlocations.module, line 1535 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_get_path_from_lid($lid) {
if (is_numeric($lid) && $lid) {
$query = FALSE;
if (module_exists('getlocations_fields')) {
$info = getlocations_get_entity_info_from_glid($lid);
$entity_get_info = entity_get_info($info['entity_type']);
$load_hook = $entity_get_info['load hook'];
$object = $load_hook($info['entity_id']);
$uri_callback = $entity_get_info['uri callback'];
$path = $uri_callback($object);
return url($path['path']);
}
elseif (module_exists('location') && (module_exists('location_cck') || module_exists('location_node') || module_exists('location_user'))) {
$query = db_select('location_instance', 'i')
->fields('i', array(
'nid',
'uid',
))
->condition('i.lid', $lid);
}
if ($query) {
$row = $query
->execute()
->fetchAssoc();
$path = '';
if (isset($row['nid']) && $row['nid'] > 0) {
$path = url('node/' . $row['nid']);
}
elseif (isset($row['uid']) && $row['uid'] > 0) {
$path = url('user/' . $row['uid']);
}
elseif (isset($row['tid']) && $row['tid'] > 0 && module_exists('taxonomy')) {
$path = url('taxonomy/term/' . $row['tid']);
}
elseif (isset($row['cid']) && $row['cid'] > 0 && module_exists('comment')) {
$path = url('comment/' . $row['cid']);
}
return $path;
}
}
return FALSE;
}