? countryInfo.csv
? csv_to_associativearray.php
? location.inc_7.patch
? location_activeselect.patch
? location_addanother.patch
? location_foreach_problem.alternate.patch
? location_foreach_problem.patch
? location_iso3166update.patch
? location_plurals.patch
? location_searchpermission.patch
? missingfiles.php
? supported/location.zz.inc
Index: location.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/location.inc,v
retrieving revision 1.34.2.10
diff -u -p -r1.34.2.10 location.inc
--- location.inc 5 Jan 2007 02:34:23 -0000 1.34.2.10
+++ location.inc 2 Feb 2007 13:40:52 -0000
@@ -220,7 +220,7 @@ function location_distance_between($latl
/**
- * Generates a Drupal HTML form for collecting locationes.
+ * Generates a Drupal HTML form for collecting locations.
*
* @param $fields
* An array of values where each value is one of 'street', 'city', 'province', 'postal_code', or 'country'.
@@ -383,6 +383,7 @@ function location_form($fields = array()
);
}
else {
+ $province_form = TRUE;
$form['province'] = _location_province_select_options(isset($prefilled_values['province']) ? $prefilled_values['province'] : '', in_array('province', $required_fields), in_array('country', array_keys($suppressed_values)) ? $suppressed_values['country'] : NULL);
$form['province']['#prefix'] = '
';
$form['province']['#suffix'] = "
\n";
@@ -411,12 +412,61 @@ function location_form($fields = array()
$form['country'] = _location_country_select_options(isset($prefilled_values['country']) ? $prefilled_values['country'] : '', in_array('country', $required_fields), $function);
$form['country']['#prefix'] = '';
$form['country']['#suffix'] = "
\n";
+
+ // Auto-update list of provinces with only those relevant to selected country
+ // (requires Active Select module)
+ $activeselect = module_exist('activeselect');
+ if ($activeselect && $province_form) {
+ $form['country']['#type'] = 'activeselect';
+ $form['country']['#activeselect_path'] = 'location/activeselect';
+ // TODO: need to pass in index of form (only works for first location form at present)
+ $index = 0;
+ $form['country']['#activeselect_targets'] = 'locations-'. $index .'-province';
+ $form['country']['#activeselect_extra'] = 'province';
+ }
}
}
return $form;
}
+/**
+ * Function to automagically select the correct provinces to list in the dropdown
+ * (requires Active Select module)
+ */
+function location_activeselect($source, $targets, $string, $extra = NULL) {
+ if (empty($source) || empty($targets) || empty($string)) {
+ exit();
+ }
+
+ $targets = explode(',', $targets);
+ $output = array();
+
+ $array = activeselect_explode_values($string);
+
+ $first_element = TRUE;
+ foreach ($targets as $target) {
+ $options = array();
+ if ($extra == 'province') {
+ $country = check_plain(key($array));
+ $options_form = location_province_select_options('', FALSE, $country);
+ foreach ($options_form['#options'] as $key => $value) {
+ $options[$key] = array('value' => $value, 'selected' => $first_element);
+ $first_element = FALSE;
+ }
+ }
+
+ $multiple = FALSE; // multiple select
+
+ $output[$target] = array('options' => $options, 'multiple' => $multiple);
+ }
+
+ activeselect_set_header_nocache();
+
+ print drupal_to_js($output);
+ exit();
+}
+
function location_latlon_form($description = '', $prefilled_values = array()) {
$form = array();
Index: location.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/location.module,v
retrieving revision 1.62.2.16
diff -u -p -r1.62.2.16 location.module
--- location.module 30 Jan 2007 02:46:26 -0000 1.62.2.16
+++ location.module 2 Feb 2007 13:40:53 -0000
@@ -22,6 +22,12 @@ function location_menu($may_cache = FALS
$items = array();
if ($may_cache) {
//$items[] = array('path' => 'search/location', 'title' => t('by location'), 'callback' => 'location_search_form_page', 'access' => user_access('search content'), 'type' => MENU_LOCAL_TASK, 'weight' => 9);
+ $items[] = array('path' => 'location/activeselect',
+ 'title' => t('activeselect location'),
+ 'callback' => 'location_activeselect',
+ 'access' => user_access('access content'),
+ 'type' => MENU_CALLBACK,
+ );
$items[] = array('path' => 'search/location', 'title' => t('by location'), 'callback' => 'location_search_view', 'access' => user_access('search content'), 'type' => MENU_LOCAL_TASK, 'weight' => 9);
$items[] = array('path' => 'admin/settings/location', 'title' => t('location'), 'callback' => 'location_configure');
$items[] = array('path' => 'admin/settings/location/main', 'title' => t('main settings'), 'type' => MENU_DEFAULT_LOCAL_TASK);