function getdirections_direction in Get Directions 7.2
Same name and namespace in other branches
- 6.2 getdirections.module \getdirections_direction()
- 6 getdirections.module \getdirections_direction()
- 7.3 getdirections.module \getdirections_direction()
Function to setup the map and form
Parameters
string $direction: Optional. The direction the supplied input applies to
string $location: Optional. The string to search with
string $country: Optional. The country
string $latlon: Optional. Comma delimited string containing latitude and longitude
Return value
Returns the themed map and form
11 calls to getdirections_direction()
- getdirections_comment_setlocation in ./
getdirections.module - Function to setup the map and form
- getdirections_direction_box in ./
getdirections.module - getdirections_latlon in ./
getdirections.module - Function to setup the map and form
- getdirections_n2u_setlocation in ./
getdirections.module - Function to setup the map
- getdirections_setlocation in ./
getdirections.module - Function to setup the map and form
1 string reference to 'getdirections_direction'
- getdirections_menu in ./
getdirections.module - Implement hook_menu().
File
- ./
getdirections.module, line 284 - Fetches google map directions.
Code
function getdirections_direction($direction = '', $location = '', $country = '', $latlon = '', $id = 0, $type = 'node', $width = '', $height = '') {
if (!getdirections_check()) {
return t('You need to !c first.', array(
'!c' => l('configure Getdirections', 'admin/config/services/getdirections'),
));
}
$getdirections_defaults = getdirections_defaults();
$getdirections_misc = getdirections_misc_defaults();
getdirections_setup_map($getdirections_defaults, $getdirections_misc);
$getdirections_settings = getdirections_get_settings($getdirections_defaults, $getdirections_misc);
$getdirections_settings['switchfromto'] = $getdirections_misc['switchfromto'];
drupal_add_js(array(
'getdirections' => $getdirections_settings,
), 'setting');
if ($getdirections_misc['keep_title'] && $id && $direction) {
if ($direction == 'to') {
$direction_translated = t('to');
}
elseif ($direction == 'from') {
$direction_translated = t('from');
}
if ($type == 'node') {
$node = node_load($id);
drupal_set_title(t('Get directions @d !t', array(
'@d' => $direction_translated,
'!t' => $node->title,
)));
}
elseif ($type == 'user') {
$account = user_load($id);
drupal_set_title(t('Get directions @d !t', array(
'@d' => $direction_translated,
'!t' => $account->name,
)));
}
elseif ($type == 'term') {
$term = taxonomy_term_load($id);
drupal_set_title(t('Get directions @d !t', array(
'@d' => $direction_translated,
'!t' => $term->name,
)));
}
elseif ($type == 'location') {
$t = getdirections_get_lid_title($id);
if ($t) {
drupal_set_title(t('Get directions @d !t', array(
'@d' => $direction_translated,
'!t' => $t,
)));
}
}
}
if (empty($width)) {
$width = $getdirections_defaults['width'];
}
if (empty($height)) {
$height = $getdirections_defaults['height'];
}
// remove brackets if any
$latlon = preg_replace("/^\\(|\\)\$/", '', $latlon);
$raw_form = drupal_get_form('getdirections_direction_form', $direction, $location, $country, $latlon);
$form = render($raw_form);
return theme('getdirections_show', array(
'form' => $form,
'width' => $width,
'height' => $height,
'nid' => $id,
'type' => $type,
));
}