'. t('For more information please read the configuration and customization handbook Location page.', array('%location' => 'http://www.drupal.org/handbook/modules/location/')) .'
';
return $output;
- case 'admin/modules#description':
- return t('Enables the location system and allow users to attach locative information to content.');
}
}
-
+//TODO: check/fix this: admin/content/configure/types above (still use %? still same url?)
function location_search_get_form($edit = array()) {
$location_form = location_form(array('postal_code', 'country'), $edit, array('postal_code', 'country'), variable_get('location_suppress_country', 0) ? array('country' => variable_get('location_default_country', 'us')) : array(), '', 'location', 'nearby_postalcodes_bylocation');
@@ -89,30 +86,30 @@ function location_search_get_form($edit
}
$form['#theme'] = 'location_search';
- return drupal_get_form('location_search', $form);
+ return drupal_get_form($form);
}
function theme_location_search(&$form) {
$row = array();
- $row[] = ''. form_render($form['location']['distance']) . form_render($form['location']['distance_unit']) . '
';
- $row[] = form_render($form['location']['postal_code']) . form_render($form['location']['country']);
- $output = theme('table', NULL, array($row)) . form_render($form['op']);
- $output .= form_render($form);
+ $row[] = ''. drupal_render($form['location']['distance']) . drupal_render($form['location']['distance_unit']) . '
';
+ $row[] = drupal_render($form['location']['postal_code']) . drupal_render($form['location']['country']);
+ $output = theme('table', NULL, array($row)) . drupal_render($form['op']);
+ $output .= drupal_render($form);
return $output;
}
function location_search_view() {
if ($edit = $_POST['edit']) {
$edit = $edit['location'];
- $form = location_search_get_form($edit);
+ $form = drupal_get_form(array('location_search_get_form', $edit));
}
elseif (isset($_GET['postal_code']) && isset($_GET['distance']) && isset($_GET['distance_unit']) && isset($_GET['country'])) {
$edit = array('postal_code' => $_GET['postal_code'], 'distance' => $_GET['distance'], 'distance_unit' => $_GET['distance_unit'], 'country' => $_GET['country']);
- $form = location_search_get_form($edit);
+ $form = drupal_get_form(array('location_search_get_form', $edit));
$search_results = location_search_get_results($edit);
}
else {
- $form = location_search_get_form();
+ $form = drupal_get_form('location_search_get_form');
}
print theme('page', $form . (isset($search_results) ? $search_results : ''));
@@ -153,7 +150,7 @@ function location_search_get_results($ed
$results_offset = isset($_GET['from']) ? $_GET['from'] : 0;
$postal_data = location_get_postalcode_data($location);
$search_results_message = t('Displaying results %a - %b of %count for search on %c', array('%a' => $results_offset + 1, '%b' => $results_offset + $page_count, '%count' => $count->result_count, '%c' => '',
'#type' => 'select',
'#title' => t('Location weight'),
@@ -559,7 +557,7 @@ function location_form_alter($form_id, &
'#description' => t('Weight of the location box in the input form. Lowest values will be displayed higher in the form.')
);
- $form['location']['location_collapsible_'. $type] = array(
+ $form['location']['location_collapsible'] = array(
'#type' => 'checkbox',
'#title' => t('Collapsible'),
'#return_value' => 1,
@@ -567,7 +565,7 @@ function location_form_alter($form_id, &
'#description' => t('Make the location box collapsible.')
);
- $form['location']['location_collapsed_'. $type] = array(
+ $form['location']['location_collapsed'] = array(
'#type' => 'checkbox',
'#title' => t('Collapsed'),
'#return_value' => 1,
@@ -580,42 +578,42 @@ function location_form_alter($form_id, &
'#value' => '
'. t('NOTE:') .' '. t('Locations fields you choose to require will only be required for the first location if you have allowed more than one location to be submitted for this node type.') .'
'
);
- $form['location']['location_name_'. $type] = array(
+ $form['location']['location_name'] = array(
'#type' => 'radios',
'#title' => t('Location names'),
'#default_value' => variable_get('location_name_'. $type, $default),
'#options' => array(t('Do not collect location names (e.g. place of business) for this node type.'), t('Allow location names for content of this type.'), t('Require location names for content of this type.'))
);
- $form['location']['location_street_'. $type] = array(
+ $form['location']['location_street'] = array(
'#type' => 'radios',
'#title' => t('Street locations'),
'#default_value' => variable_get('location_street_'. $type, $default),
'#options' => array(t('Do not collect a street location for content of this type.'), t('Allow street locations to be submitted for content of this type.'), t('Require street locations to be submitted for content of this type.'))
);
- $form['location']['location_city_'. $type] = array(
+ $form['location']['location_city'] = array(
'#type' => 'radios',
'#title' => t('City names'),
'#default_value' => variable_get('location_city_'. $type, 0),
'#options' => array(t('Do not collect city names for content of this type.'), t('Allow city names to be submitted for content of this type.'), t('Require city names to be submitted for content of this type.'))
);
- $form['location']['location_province_'. $type] = array(
+ $form['location']['location_province'] = array(
'#type' => 'radios',
'#title' => 'State/Province names',
'#default_value' => variable_get('location_province_'. $type, 0),
'#options' => array(t('Do not collect state/province names for content of this type.'), t('Allow state/province names to be submitted for content of this type.'), t('Require state/province names to be submitted for content of this type.'))
);
- $form['location']['location_postal_code_'. $type] = array(
+ $form['location']['location_postal_code'] = array(
'#type' => 'radios',
'#title' => 'Postal codes',
'#default_value' => variable_get('location_postal_code_'. $type, 0),
'#options' => array(t('Do not collect postal codes for content of this type.'), t('Allow postal codes to be submitted for content of this type.'), t('Require postal codes to be submitted for content of this type.'))
);
- $form['location']['location_country_'. $type] = array(
+ $form['location']['location_country'] = array(
'#type' => 'radios',
'#title' => 'Country names',
'#default_value' => variable_get('location_country_'. $type, 1),
@@ -629,7 +627,7 @@ function location_form_alter($form_id, &
views_invalidate_cache();
}
}
- elseif (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && variable_get('location_maxnum_'. $form['type']['#value'], 0)) {
+ elseif (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id && variable_get('location_maxnum_'. $form['type']['#value'], 0)) {
$node = $form['#node'];
$location_fields = array();
@@ -769,7 +767,7 @@ function location_nodeapi(&$node, $op, $
if ($index == 0) {
if (variable_get('location_'. $field_name .'_'. $node->type, 0) == 2) {
if (isset($node->locations[$index][$field_name]) && !strlen(trim($node->locations[$index][$field_name]))) {
- form_set_error('locations]['. $index .']['. $field_name, t('The field %field is required.', array('%field' => theme('placeholder', $display_name))));
+ form_set_error('locations]['. $index .']['. $field_name, t('The field %field is required.', array('%field' => $display_name)));
}
}
}
@@ -794,8 +792,8 @@ function location_nodeapi(&$node, $op, $
if (user_access('submit latitude/longitude')) {
if ((!strlen(trim($node->locations[$index]['latitude'])) && strlen(trim($node->locations[$index]['longitude']))) ||
(strlen(trim($node->locations[$index]['latitude'])) && !strlen(trim($node->locations[$index]['longitude'])))) {
- form_set_error('locations]['. $index .'][latitude', t('You must fill out both longitude and latitude or'));
- form_set_error('locations]['. $index .'][longitude', t('you must leave them both blank.'));
+ form_set_error('locations]['. $index .'][latitude', t('You must fill out both longitude and latitude or you must leave them both blank.'));
+ form_set_error('locations]['. $index .'][longitude', NULL);
}
elseif (strlen(trim($node->locations[$index]['latitude'])) && strlen(trim($node->locations[$index]['longitude']))) {
if (!is_numeric($node->locations[$index]['latitude']) || $node->locations[$index]['latitude'] > 90.0 || $node->locations[$index]['latitude'] < -90.0) {
@@ -1019,12 +1017,12 @@ function location_nodeapi(&$node, $op, $
}
if ($output = theme('locations', $posted_locations, variable_get('location_suppress_country', 0) ? array('country') : array())) {
- $node->body .= '
'. t('Location(s)') .'
'. $output;
+ $node->content['locations']['#value'] .= '
'. t('Location(s)') .'
'. $output;
}
}
else {
if ($themed_locations = theme('locations', $node->locations, variable_get('location_suppress_country', 0) ? array('country') : array())) {
- $node->body .= '
'. t('Location(s)') .'
'. $themed_locations;
+ $node->content['locations']['#value'] .= '
'. t('Location(s)') .'
'. $themed_locations;
}
@@ -1035,52 +1033,7 @@ function location_nodeapi(&$node, $op, $
}
if (count($node->locations) < variable_get('location_maxnum_'. $node->type, 0) && !$teaser && node_access('update', $node)) {
- $location_fields = array();
- $required_fields = array();
- foreach (array_keys(location_field_names()) as $field_name) {
- $workflow_setting = variable_get('location_'. $field_name .'_'. $node->type, $field_name == 'country' ? 1 : 0);
- if ($workflow_setting) {
- $location_fields[] = $field_name;
- if ($workflow_setting == 2) {
- $required_fields[] = $field_name;
- }
- }
- }
-
- $suppressed_values = variable_get('location_suppress_country', 0) ? array('country' => variable_get('location_default_country', 'us')) : array();
-
- $form['location'] = array(
- '#type' => 'fieldset',
- '#title' => t('Add another location'),
- '#tree' => TRUE,
- '#attributes' => array('class' => 'location'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE
- );
-
- $form['location'] = array_merge($form['location'], location_form($location_fields, array('country' => variable_get('location_default_country', 'us')), array(), $suppressed_values));
-
- if (user_access('submit latitude/longitude')) {
- $form['location'][] = array(
- '#type' => 'markup',
- '#value' => "
\n"
- );
-
- $form['location'] = array_merge($form['location'], location_latlon_form(t('If you wish to supply your own latitude/longitude, you may do so here. Leaving these fields blank means that the system will determine a latitude/longitude for you, if possible.'), array()));
- }
-
- $form['location']['nid'] = array(
- '#type' => 'hidden',
- '#value' => $node->nid
- );
- //================================================
-
- $form['location']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Add location')
- );
-
- $node->body .= drupal_get_form('location_extra', $form);
+ $node->content['locations']['#value'] .= drupal_get_form('location_extra_form', $node);
}
break;
@@ -1107,7 +1060,56 @@ function location_nodeapi(&$node, $op, $
}
}
-function location_extra_validate($form_id, &$form_values) {
+function location_extra_form(&$node) {
+ $location_fields = array();
+ $required_fields = array();
+ foreach (array_keys(location_field_names()) as $field_name) {
+ $workflow_setting = variable_get('location_'. $field_name .'_'. $node->type, $field_name == 'country' ? 1 : 0);
+ if ($workflow_setting) {
+ $location_fields[] = $field_name;
+ if ($workflow_setting == 2) {
+ $required_fields[] = $field_name;
+ }
+ }
+ }
+
+ $suppressed_values = variable_get('location_suppress_country', 0) ? array('country' => variable_get('location_default_country', 'us')) : array();
+
+ $form['location'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Add another location'),
+ '#tree' => TRUE,
+ '#attributes' => array('class' => 'location'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE
+ );
+
+ $form['location'] = array_merge($form['location'], location_form($location_fields, array('country' => variable_get('location_default_country', 'us')), array(), $suppressed_values));
+
+ if (user_access('submit latitude/longitude')) {
+ $form['location'][] = array(
+ '#type' => 'markup',
+ '#value' => "
\n"
+ );
+
+ $form['location'] = array_merge($form['location'], location_latlon_form(t('If you wish to supply your own latitude/longitude, you may do so here. Leaving these fields blank means that the system will determine a latitude/longitude for you, if possible.'), array()));
+ }
+
+ $form['location']['nid'] = array(
+ '#type' => 'hidden',
+ '#value' => $node->nid
+ );
+ //================================================
+
+ $form['location']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Add location')
+ );
+
+ return $form;
+}
+
+function location_extra_form_validate($form_id, &$form_values) {
foreach ($form_values['location'] as $key => $value) {
$form_values['location'][$key] = trim($value);
}
@@ -1144,7 +1146,7 @@ function location_extra_validate($form_i
}
}
-function location_extra_submit($form_id, &$form_values) {
+function location_extra_form_submit($form_id, &$form_values) {
// handy to have these field names later
$location_fields = array();
$required_fields = array();
@@ -1276,11 +1278,11 @@ function location_get_configured_countri
/**
- * Implementation of hook_settings().
+ * Callback for admin/settings/location
*
*/
-function location_configure() {
- cache_clear_all('location:supported-countries');
+function location_admin_settings() {
+ cache_clear_all('location:supported-countries', 'cache');
$supported_countries = _location_supported_countries();
$default_country = variable_get('location_default_country', 'us');
@@ -1314,7 +1316,7 @@ function location_configure() {
'#title' => t('Hide country selection'),
'#return_value' => 1,
'#default_value' => variable_get('location_suppress_country', 0),
- '#description' => t('If your site is specific to a country and you would like to hide the country field on search forms and content creation forms, check this box. Doing so will automatically assume the country to be the country you have chosen for the \'default country selection\' above.')
+ '#description' => t("If your site is specific to a country and you would like to hide the country field on search forms and content creation forms, check this box. Doing so will automatically assume the country to be the country you have chosen for the 'default country selection' above.")
);
$form['location_search_distance_unit'] = array(
'#type' => 'radios',
@@ -1328,10 +1330,10 @@ function location_configure() {
'#title' => t('Toggle location display'),
'#default_value' => variable_get('location_display_location', 1),
'#options' => array(0 => t('Disable the display of locations.'), 1 => t('Enable the display of locations.')),
- '#description' => t('If you are interested in turning off locations and having a custom theme control their display, you may want to disable the display of locations so your theme can take over them.')
+ '#description' => t('If you are interested in turning off locations and having a custom theme control their display, you may want to disable the display of locations so your theme can take that function.')
);
- if (!module_exist('civicrm')) {
+ if (!module_exists('civicrm')) {
$form['location_user'] = array(
'#type' => 'radios',
'#title' => 'User locations',
@@ -1344,7 +1346,7 @@ function location_configure() {
$form['location_user'] = array(
'#type' => 'item',
'#title' => t('User locations'),
- '#description' => t('You have enabled the CiviCRM module. This means that CiviCRM will collect user locations for you. To make sure you will be able to use location module features with these user addresses, you should make sure the CiviCRM \'address\' profile is marked as active. If you are using CivicSpace, this comes activated on a default install. If you installed CiviCRM on a seperate Drupal installation, please consult the documentation in the README file for the location module.')
+ '#description' => t("You have enabled the CiviCRM module. This means that CiviCRM will collect user locations for you. To make sure you will be able to use location module features with these user addresses, you should make sure the CiviCRM 'address' profile is marked as active. If you installed CiviCRM on a seperate Drupal installation, please consult the documentation in the README.txt file for the Location module.")
);
}
@@ -1352,8 +1354,8 @@ function location_configure() {
'#type' => 'checkbox',
'#title' => t('Use a Google Map to set latitude and longitude '),
'#return_value' => 1,
- '#default_value' => variable_get('location_usegmap',1),
- '#description' => t('If the gmap.module is installed and %enabled, and this is setting is turned on, users that are allowed to manually enter latitude/longitude coordinates will be able to do so with an interactive Google Map. You should also make sure you have entered a %google_maps_api_key into your %gmap_module_settings.', array('%enabled' => l('enabled', 'admin/modules'), '%google_maps_api_key' => '
Google Maps API key', '%gmap_module_settings' => l('gmap module settings', 'admin/settings/gmap')))
+ '#default_value' => variable_get('location_usegmap', 1),
+ '#description' => t('If the gmap.module is installed and
enabled, and this is setting is turned on, users that are allowed to manually enter latitude/longitude coordinates will be able to do so with an interactive Google Map. You should also make sure you have entered a
Google Maps API key into your
gmap module settings.', array('@enabled' => 'admin/build/modules', '@google_maps_api_key' => 'http://www.google.com/apis/maps', '@gmap_module_settings' => 'admin/settings/gmap'))
);
$form['location_configured_countries'] = array(
@@ -1364,12 +1366,12 @@ function location_configure() {
'#description' => t('Currently, your CivicSpace site is capable of supporting extra features (e.g., postal code proximity searches) for locations from this list of countries. Please narrow the list down to countries for which you want to support these extra features. It may be useful for performance to narrow down this list if most the locations in your system are from only a handful of the listed countries.')
);
- return system_settings_form('location_configure_settings', $form);
+ return system_settings_form($form);
}
function _location_effective_user_setting() {
- if (module_exist('civicrm')) {
+ if (module_exists('civicrm')) {
return LOCATION_USER_CIVICRM_ONLY;
}
else {
@@ -1386,7 +1388,7 @@ function location_user($op, &$edit, &$us
if ($op == 'form' && $category == 'account' && $user_setting == LOCATION_USER_COLLECT) {
$form = array(1 => array());
- $form[0]['location'] = location_form(array('street', 'city', 'province', 'postal_code', 'country'), (isset($user->location) && !_location_is_empty($user->location)) ? location_api2form($user->location) : array('country' => variable_get('location_default_country', 'us')));
+ $form[0]['location'] = location_form(array('street', 'city', 'province', 'postal_code', 'country'), (isset($user->location) && !_location_is_empty($user->location)) ? location_api2form($user->location) : array('country' => variable_get('location_default_country', 'us')), array(), variable_get('location_suppress_country', 0) ? array('country' => variable_get('location_default_country', 'us')) : array());
$form[0]['location']['#type'] = 'fieldset';
$form[0]['location']['#title'] = t('Location');
$form[0]['location']['#tree'] = TRUE;
@@ -1468,7 +1470,7 @@ function location_user($op, &$edit, &$us
if (user_access('submit latitude/longitude')) {
if ($user->location['latitude'] != NULL && $user->location['longitude'] != NULL) {
$items[] = array('title' => t('Coordinates'),
- 'value' => t('lat: %latitude
lon: %longitude', array('%latitude' => $user->location['latitude'], '%longitude' => $user->location['longitude'])),
+ 'value' => t('lat: %latitude',array('%latitude' => $user->location['latitude'])) .'
'. t('lon: %longitude', array('%longitude' => $user->location['longitude'])),
'class' => 'location',
);
}