? location.info
? location_5.0.patch
Index: location.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/location/location.module,v
retrieving revision 1.70
diff -u -p -r1.70 location.module
--- location.module	20 Oct 2006 21:44:00 -0000	1.70
+++ location.module	27 Nov 2006 17:57:46 -0000
@@ -15,21 +15,19 @@ define('LOCATION_USER_CIVICRM_ONLY', 2);
 include_once LOCATION_PATH.'/location.inc';
 
 /**
- * Implementation of hook_menu.
- *
+ * Implementation of hook_menu().
  */
 function location_menu($may_cache = FALSE) {
   $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' => '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);
-    $items[] = array('path' => 'admin/settings/location/maplinking', 'title' => t('map links'), 'callback' => 'location_map_link_options_page', 'access' => user_access('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 1);
-    $items[] = array('path' => 'admin/settings/location/geocoding', 'title' => t('geocoding options'), 'callback' => 'location_geocoding_options_page', 'access' => user_access('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 2);
+    $items[] = array('path' => 'search/location', 'title' => t('By location'), 'callback' => 'drupal_get_form', 'callback arguments' => array('location_search_view'), 'access' => user_access('search content'), 'type' => MENU_LOCAL_TASK, 'weight' => 9,);
+    $items[] = array('path' => 'admin/settings/location/main', 'title' => t('Main settings'), 'type' => MENU_DEFAULT_LOCAL_TASK,);
+    $items[] = array('path' => 'admin/settings/location/maplinking', 'title' => t('Map links'), 'callback' => 'drupal_get_form', 'callback arguments' => array('location_map_link_options_page'), 'access' => user_access('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 1,);
+    $items[] = array('path' => 'admin/settings/location/geocoding', 'title' => t('Geocoding options'), 'callback' => 'drupal_get_form', 'callback arguments' => array('location_geocoding_options_page'), 'access' => user_access('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => 2,);
+    $items[] = array('path' => 'admin/settings/location', 'title' => t('Location'), 'description' => t('Settings for Location module'), 'callback' => 'drupal_get_form', 'callback arguments' => array('location_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM, );
   }
   else {
-    theme_add_style(drupal_get_path('module', 'location') .'/location.css');
+    drupal_add_css(drupal_get_path('module', 'location') .'/location.css');
   }
   return $items;
 }
@@ -54,14 +52,12 @@ function location_help($section) {
 <li>administer locative information at <a href="%admin-node-configure-types"> administer &gt;&gt; content types</a> to configure a type and see the locative information.</li>
 <li>administer location at <a href="%admin-settings-location">administer &gt;&gt; settings &gt;&gt; location</a>.</li>
 <li>use a database dump for a U.S. postal codes table that can be found at <a href="%external-http-trac-civicspacelabs-com-cgi-bin-trac-cgi-file-trunk-database-zipcodes-mysql">zipcode database</a>.</li>
-', array('%admin-node-configure-types' => url('admin/node/configure/types'), '%admin-settings-location' => url('admin/settings/location'), '%external-http-trac-civicspacelabs-com-cgi-bin-trac-cgi-file-trunk-database-zipcodes-mysql' => 'http://trac.civicspacelabs.com/cgi-bin/trac.cgi/file/trunk/database/zipcodes.mysql')) .'</ul>';
+', array('%admin-node-configure-types' => url('admin/content/configure/types'), '%admin-settings-location' => url('admin/settings/location'), '%external-http-trac-civicspacelabs-com-cgi-bin-trac-cgi-file-trunk-database-zipcodes-mysql' => 'http://trac.civicspacelabs.com/cgi-bin/trac.cgi/file/trunk/database/zipcodes.mysql')) .'</ul>';
       $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%location">Location page</a>.', array('%location' => 'http://www.drupal.org/handbook/modules/location/')) .'</p>';
       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
 
 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 +85,30 @@ function location_search_get_form($edit 
   }
   
   $form['#theme'] = 'location_search';
-  return drupal_get_form('location_search', $form);  
+  return $form;  
 }
 
 function theme_location_search(&$form) {
   $row = array();
-  $row[] = '<div class="container-inline">'. form_render($form['location']['distance']) . form_render($form['location']['distance_unit']) . '</div>';
-  $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[] = '<div class="container-inline">'. drupal_render($form['location']['distance']) . drupal_render($form['location']['distance_unit']) . '</div>';
+  $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 +149,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' => '<em>'. filter_xss($edit['postal_code']) .'</em> ('. $postal_data['city'] . ', '. $postal_data['province'] .')'));
-        }
+        }  //TODO: filter_xss?
         else {
           if (isset($_POST['edit']) && !isset($_GET['from'])) {
             $search_results .= theme('box', t('Your search yielded no results.'), '');
@@ -176,7 +172,7 @@ function location_search_get_results($ed
                                  );
                                
           $extra = t('Local to ') . $result_location['postal_code'] .', ' . $result_location['city'] . ', '. $result_location['province'] .', '. $country_index[$result_location['country']] .' - '. $result_location['distance'] . ' ' . $edit['distance_unit'] .' away.';
-          
+          //TODO: shouldn't this use printf style replacement like: %postal (array(%postal=>$result_location['postal_code'])) 
           $extra = array();
           $extra['location'] = t('Local to %place', array('%place' => l($result_location['city'] . ', '. $result_location['province'] .', '. $country_index[$result_location['country']], 'search/location', array(), 'postal_code='. urlencode($result_location['postal_code']) . '&country='. urlencode($result_location['country']) .'&distance='. urlencode($edit['distance']) .'&distance_unit='. urlencode($edit['distance_unit']))));
           if ($result_location['postal_code'] == $edit['postal_code'] && $result_location['country'] == $edit['country']) {
@@ -189,8 +185,8 @@ function location_search_get_results($ed
             else {
               $distance_unit = ($edit['distance_unit'] == 'km') ? t('km') : t('mile');
             }
-            $extra['distance'] = t('Approximately %distance from %location', array('%distance' => '<strong>'. round($result_location['distance']) .' '. $distance_unit .'</strong>', '%location' => $edit['postal_code']));
-          }
+            $extra['distance'] = t('Approximately %distance from %location', array('%distance' => round($result_location['distance']) .' '. $distance_unit, '%location' => $edit['postal_code']));
+          } //TODO: removed <strongs> - because I think they are unnecessary, but maybe they are necessary...
           
           
           $item = array('link' => url('node/'. $row->nid), 
@@ -295,7 +291,7 @@ function location_map_link_options_page(
       
   $form['#theme'] = 'location_map_link_options';
   
-  return drupal_get_form('location_map_link_options', $form);
+  return $form;
 }
 
 function theme_location_map_link_options(&$form) {
@@ -306,10 +302,10 @@ function theme_location_map_link_options
       $row = array();
       $second_cell = '';
       foreach (element_children($form[$key]) as $checkbox_key) {
-        $second_cell .= form_render($form[$key][$checkbox_key]);
+        $second_cell .= drupal_render($form[$key][$checkbox_key]);
       }
       $row[1] = $second_cell;
-      $row[0] = form_render($form[$key]);
+      $row[0] = drupal_render($form[$key]);
       ksort($row);
       $rows[] = $row;
     }
@@ -319,11 +315,11 @@ function theme_location_map_link_options
 
   $nontable_elems = '';
   foreach (array('form_id', 'save', 'reset') as $key) {
-    $nontable_elems .= form_render($form[$key]);
+    $nontable_elems .= drupal_render($form[$key]);
   }
   
   $output = theme('table', $header, $rows) . $nontable_elems;
-  $output .= form_render($form);
+  $output .= drupal_render($form);
   return $output;
 }
 
@@ -339,7 +335,7 @@ function location_geocoding_parameters_p
       $providers = $provider_function();
       drupal_set_title(t('Configure parameters for %service', array('%service' => $providers[$service]['name'])));
       $breadcrumbs = drupal_get_breadcrumb();
-      $breadcrumbs[] = l('location', 'admin/settings/locaiton');
+      $breadcrumbs[] = l('location', 'admin/settings/location');
       $breadcrumbs[] = l('geocoding', 'admin/settings/location/geocoding');
       $countries = location_get_iso3166_list();
       $breadcrumbs[] = l($countries[$country_iso], 'admin/settings/location/geocoding', array(), NULL, $country_iso);
@@ -448,7 +444,7 @@ function location_geocoding_options_page
       
   $form['#theme'] = 'location_geocoding_options';
   
-  return drupal_get_form('location_geocoding_options', $form);
+  return $form;
 }
 
 function theme_location_geocoding_options(&$form) {
@@ -460,14 +456,14 @@ function theme_location_geocoding_option
       $second_cell = '';
       foreach (element_children($form[$key]) as $checkbox_key) {
         if ($checkbox_key != 'configure_link') {
-          $second_cell .= form_render($form[$key][$checkbox_key]);
+          $second_cell .= drupal_render($form[$key][$checkbox_key]);
         }
         else {
-          $third_cell = form_render($form[$key][$checkbox_key]);
+          $third_cell = drupal_render($form[$key][$checkbox_key]);
         }
       }
       $row[1] = $second_cell;
-      $row[0] = form_render($form[$key]);
+      $row[0] = drupal_render($form[$key]);
       $row[2] = empty($third_cell) ? t('No service selected for country.') : $third_cell;
       unset($third_cell);
       ksort($row);
@@ -480,17 +476,17 @@ function theme_location_geocoding_option
 
   $nontable_elems = '';
   foreach (array('form_id', 'save', 'reset') as $key) {
-    $nontable_elems .= form_render($form[$key]);
+    $nontable_elems .= drupal_render($form[$key]);
   }
   
   $output = theme('table', $header, $rows) . $nontable_elems .'<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>';
-  $output .= form_render($form);
+  $output .= drupal_render($form);
   return $output;
 }
 
 
 function location_form_alter($form_id, &$form) {
-  if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
+  if ($form_id == 'node_type_form') {
     $type = $form['type']['#value'];
     $form['location'] = array(
       '#type' => 'fieldset',
@@ -566,7 +562,7 @@ function location_form_alter($form_id, &
       '#title' => 'Country names',
       '#default_value' => variable_get('location_country_'. $type, 1),
       '#options' => array(1 => t('Allow country names to be submitted for content of this type.'), 2 => t('Require country names to be submitted for content of this type.')),
-      '#description' => t('The selection of a country can be hidden and/or forced to a default country selection by going to the %location_settings and checking the box marked "Hide country selection" and selecting a country from the drop down select labelled "Default country selection".', array('%location_settings' => l(t('location settings page'), 'admin/settings/location'))),
+      '#description' => t('The selection of a country can be hidden and/or forced to a default country selection by going to the <a href="@location_settings">location settings page</a> and checking the box marked "Hide country selection" and selecting a country from the drop down select labelled "Default country selection".', array('%location_settings' => 'admin/settings/location')),
       '#suffix' => '</div>'
     );
     // clear the views cache in case anything was changed
@@ -649,7 +645,7 @@ function location_nodeapi(&$node, $op, $
         $workflow_setting = variable_get('location_'. $field_name .'_'. $node->type, $field_name == 'country' ? 1 : 0);
         if (variable_get('location_'. $field_name .'_'. $node->type, 0) == 2) {
           if (isset($node->location[$field_name]) && !strlen(trim($node->location[$field_name]))) {
-            form_set_error('location]['. $field_name, t('The field %field is required.', array('%field' => theme('placeholder', $display_name))));
+            form_set_error('location]['. $field_name, t('The field %field is required.', array('%field' => $display_name)));
           }
         }
         $node->location[$field_name] = trim($node->location[$field_name]);
@@ -671,8 +667,8 @@ function location_nodeapi(&$node, $op, $
       if (user_access('submit latitude/longitude')) {
         if ((!strlen(trim($node->location['latitude'])) && strlen(trim($node->location['longitude']))) ||
             (strlen(trim($node->location['latitude'])) && !strlen(trim($node->location['longitude'])))) {
-          form_set_error('location][latitude', t('You must fill out both longitude and latitude or'));
-          form_set_error('location][longitude', t('you must leave them both blank.'));
+          form_set_error('location][latitude', t('You must fill out both longitude and latitude or you must leave them both blank.'));
+          form_set_error('location][longitude', NULL);
         }
         elseif (strlen(trim($node->location['latitude'])) && strlen(trim($node->location['longitude']))) {
           if (!is_numeric($node->location['latitude']) || $node->location['latitude'] > 90.0 || $node->location['latitude'] < -90.0) {
@@ -890,10 +886,10 @@ function location_get_configured_countri
 
 
 /**
- * Implementation of hook_settings().
+ * Callback for admin/settings/location
  *
  */
-function location_configure() {
+function location_admin_settings() {
   $supported_countries = _location_supported_countries();
 
   $default_country = variable_get('location_default_country', 'us');
@@ -927,7 +923,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',
@@ -941,10 +937,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',
@@ -957,7 +953,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.")
         );
   }
   
@@ -965,8 +961,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' => '<a href="http://www.google.com/apis/maps" target="_blank">Google Maps API key</a>', '%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 <a href="@enabled">enabled</a>, 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 <a href="@google_maps_api_key">Google Maps API key</a> into your <a href="@gmap_module_settings">gmap module settings</a>.', 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(
@@ -977,12 +973,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 {
@@ -1073,7 +1069,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<br/>lon: %longitude', array('%latitude' => $user->location['latitude'], '%longitude' => $user->location['longitude'])),
+          'value' => t('lat: %latitude',array('%latitude' => $user->location['latitude'])) .'<br/>'. t('lon: %longitude', array('%longitude' => $user->location['longitude'])),
           'class' => 'location',
         );
       }
Index: contrib/location_views/location_views.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/location/contrib/location_views/location_views.module,v
retrieving revision 1.14
diff -u -p -r1.14 location_views.module
--- contrib/location_views/location_views.module	17 Sep 2006 20:55:22 -0000	1.14
+++ contrib/location_views/location_views.module	27 Nov 2006 17:57:47 -0000
@@ -3,8 +3,10 @@
 /**
  * @file
  * Views-enables the location module.
- *
+ *  
  */
+ 
+//TODO: are the cache_get/cache_clear_all calls still appropriate?  not sure...
 
 /**
  * Implementation of hook_help().
@@ -24,6 +26,7 @@ function location_views_form_alter($form
 
   /**
    * hunmonk's module dependency check: see http://drupal.org/node/54463
+   * TODO: we can probably skip this or use the .info
    */
   if ($form_id == 'system_modules' && !$_POST) {
     location_views_system_module_validate($form);
@@ -775,7 +778,7 @@ function location_views_map_input_form()
   
   $form = array();
   
-  if (!module_exist('gmap')) return $form;
+  if (!module_exists('gmap')) return $form;
 
   $user = $GLOBALS['user'];
   $res=db_query("SELECT * FROM {location} WHERE oid=%d AND type='user'",$user->uid);
