Index: contrib/location_cck/location_cck.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/contrib/location_cck/location_cck.info,v
retrieving revision 1.3.2.1
diff -u -p -r1.3.2.1 location_cck.info
--- contrib/location_cck/location_cck.info	6 Jan 2009 19:33:31 -0000	1.3.2.1
+++ contrib/location_cck/location_cck.info	13 Oct 2010 05:25:28 -0000
@@ -5,3 +5,10 @@ core = 6.x
 package = CCK
 dependencies[] = location
 dependencies[] = content
+
+; Information added by drupal.org packaging script on 2010-07-06
+version = "6.x-3.1"
+core = "6.x"
+project = "location"
+datestamp = "1278427508"
+
Index: contrib/location_cck/location_cck.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/contrib/location_cck/location_cck.module,v
retrieving revision 1.5.2.19
diff -u -p -r1.5.2.19 location_cck.module
--- contrib/location_cck/location_cck.module	25 Mar 2010 07:00:07 -0000	1.5.2.19
+++ contrib/location_cck/location_cck.module	13 Oct 2010 05:25:28 -0000
@@ -483,3 +483,199 @@ function location_cck_locationapi(&$obj,
       }
   }
 }
+
+/**
+ * Implementation of hook_profile_csv_export();
+ */
+function location_cck_profile_csv_export(&$value, $field, $node) {
+  // We only deal with 'location' fields.
+  $subfield_name = str_replace('location_', '', $field['type']);
+  $field_name = str_replace(PROFILE_CSV_PARAM . $node->type .'_', '', $field['name']);
+
+  switch ($field['type']) {
+    case 'location':
+      $field_full = content_fields($field_name, $node->type);
+      $output = array();
+      foreach ($value as $x => $location) {
+        $parts = array();
+        if (!empty($field_full['location_settings']['display']['hide'])) {
+          foreach ($field_full['location_settings']['display']['hide'] as $loc_field => $loc_val) {
+            if ($loc_field == $loc_val && !empty($location[$loc_field])) {
+              switch ($loc_field) {
+                case 'country_name':
+                case 'province_name':
+                  // Skip these ones.
+                  break;
+                case 'country':
+                  $parts[$field_full['location_settings']['form']['fields'][$loc_field]['weight']] = location_country_name($location[$loc_field]);
+                  break;
+                case 'province':
+                  $parts[$field_full['location_settings']['form']['fields'][$loc_field]['weight']] = location_province_name($location['country'], $location[$loc_field]);
+                  break;
+                default:
+                  $parts[$field_full['location_settings']['form']['fields'][$loc_field]['weight']] = $location[$loc_field];
+              }
+            }
+          }
+        }
+        // Join all of the address pieces together.
+        $output[] = implode(', ', $parts);
+      }
+      // Override the output value. 
+      $value = implode("\n", $output);
+
+      // Tell the calling function to use this value.
+      return TRUE;
+      break;
+
+    // The rest of these values are assumed to be singular.
+
+    // These fields are passed over as-is.
+    case 'location_name':
+    case 'location_street':
+    case 'location_additional':
+    case 'location_city':
+    case 'location_postal_code':
+    case 'location_province_name':
+      if (!empty($value[0][$subfield_name])) {
+        $value = $value[0][$subfield_name];
+      }
+      else {
+        $value = '';
+      }
+      return TRUE;
+      break;
+    case 'location_province_code':
+      if (!empty($value[0][$subfield_name])) {
+        $value = strtoupper($value[0][$subfield_name]);
+      }
+      else {
+        $value = '';
+      }
+      return TRUE;
+      break;
+    case 'location_country_code':
+      if (!empty($value[0]['country'])) {
+        $value = strtoupper($value[0]['country']);
+      }
+      else {
+        $value = '';
+      }
+      return TRUE;
+      break;
+    case 'location_country_name':
+      if (!empty($value[0]['country'])) {
+        $value = location_country_name($value[0]['country']);
+      }
+      else {
+        $value = '';
+      }
+      return TRUE;
+      break;
+    case 'location_latitude':
+    case 'location_longitude':
+      if (floatval($value[0][$subfield_name]) > 0) {
+        $value = $value[0][$subfield_name];
+        return TRUE;
+        break;
+      }
+    case 'location_coords':
+      if (floatval($value[0]['longitude']) > 0 && floatval($value[0]['latitude']) > 0) {
+        $value = $value[0]['longitude'] . ':' . $value[0]['latitude'];
+      }
+      else {
+        $value = '';
+      }
+      return TRUE;
+      break;
+  }
+}
+
+/**
+ * Implementation of hook_profile_csv_fields();
+ */
+function location_cck_profile_csv_fields(&$fields) {
+  if (!empty($fields)) {
+    foreach ($fields as $x => $field) {
+      if ($field['type'] == 'location') {
+        $field_settings = content_fields($field['name'], $field['node_type']);
+        foreach (_location_cck_profile_csv_new_fields() as $new_field => $new_label) {
+          $new = $field;
+          $new['base'] = $new['name'];
+          $new['name'] .= '_' . $new_field;
+          $new['type'] .= '_' . $new_field;
+          $new['title'] .= ': ' . $new_label;
+          $fields[] = $new;
+        }
+      }
+    }
+  }
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function location_cck_form_alter(&$form, $form_state, $form_id) {
+  // Add extra fields to the Profile_CSV form.
+  if ($form_id == 'profile_csv_admin_settings') {
+    $new_fields = _location_cck_profile_csv_new_fields();
+    foreach (_profile_csv_get_content_profile_types() as $type_name => $type) {
+      $fieldset = 'profile_csv_param_content_profile_' . $type_name;
+      if (!empty($form['content_profile'][$fieldset])) {
+        foreach ($form['content_profile'][$fieldset] as $field_name => $field) {
+          // Split up location fields.
+          if (!empty($field) && is_array($field) && isset($field['#type'])) {
+            if ($field['#type'] == 'fieldset') {
+              foreach ($field as $inner_name => $inner_field) {
+                if (is_array($inner_field) && strpos($inner_field['#title'], '(location)')) {
+                  foreach ($new_fields as $new_field => $new_label) {
+                    $fld = $inner_name . '_' . $new_field;
+                    $form['content_profile'][$fieldset][$field_name][$fld] = array(
+                      '#type' => 'checkbox',
+                      '#title' => str_replace(' (location)', '', $inner_field['#title']) . ': ' . $new_label,
+                      '#return_value' => 1,
+                      '#default_value' => variable_get($fld, FALSE),
+                    );
+                  }
+                }
+              }
+            }
+            if (strpos($field['#title'], '(location)')) {
+              if (!empty($new_fields)) {
+                foreach ($new_fields as $new_field => $new_label) {
+                  $fld = $field_name . '_' . $new_field;
+                  $form['content_profile'][$fieldset][$fld] = array(
+                    '#type' => 'checkbox',
+                    '#title' => str_replace(' (location)', '', $field['#title']) . ': ' . $new_label,
+                    '#return_value' => 1,
+                    '#default_value' => variable_get($fld, FALSE),
+                  );
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}
+
+/**
+ * List of fields & field names that are available from this module.
+ */
+function _location_cck_profile_csv_new_fields() {
+  return array(
+    'name' => t('Name'),
+    'street' => t('Street'),
+    'additional' => t('Additional'),
+    'city' => t('City'),
+    'province_code' => t('Province Code'),
+    'province_name' => t('Province Name'),
+    'postal_code' => t('Postal Code'),
+    'country_code' => t('Country Code'),
+    'country_name' => t('Country Name'),
+    'coords' => t("Coordinates"),
+    'latitude' => t("Latitude"),
+    'longitude' => t("Longitude"),
+  );
+}
