Index: contrib/location_views/location_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/contrib/location_views/location_views.module,v
retrieving revision 1.6
diff -u -r1.6 location_views.module
--- contrib/location_views/location_views.module	24 May 2006 20:42:17 -0000	1.6
+++ contrib/location_views/location_views.module	5 Jun 2006 06:05:49 -0000
@@ -112,7 +112,7 @@
     'join' => array(
       'left' => array(
         'table' => 'node',
-        'field' => 'nid'
+        'field' => 'vid'
       ), 
       'right' => array(
         'field' => 'oid'
@@ -454,3 +454,105 @@
   $query->add_where("$filterinfo[table].$filterinfo[field] $filter[operator] '$filter[value]'");
 }
 
+
+function location_views_arguments() {
+  $arguments = array(
+    'city' => array(
+      'name' => t('Location: City'),
+      'handler' => 'views_handler_arg_location_city',
+      'help' => t('The node type argument allows users to filter a view by specifying the city.'),
+    ),
+    'province' => array(
+      'name' => t('Location: Province'),
+      'handler' => 'views_handler_arg_location_province',
+      'help' => t('The node type argument allows users to filter a view by specifying the province.'),
+    ),
+    'country' => array(
+      'name' => t('Location: Country'),
+      'handler' => 'views_handler_arg_location_country',
+      'help' => t('The node type argument allows users to filter a view by specifying the country.'),
+    ));
+    return $arguments;
+}
+
+function views_handler_arg_location_city($op, &$query, $argtype, $arg = '') {
+  switch($op) {
+    case 'summary':
+      $query->add_table('location', true);
+      $query->add_field('city', 'location');
+
+      $fieldinfo['field'] = "location.city";
+  //    $fieldinfo['fieldname'] = 'city';
+      return $fieldinfo;
+      break;
+    case 'sort':
+      $query->add_orderby('node', 'title', $argtype);
+      break;
+    case 'filter':
+      $query->ensure_table('location');
+      $query->add_field('city', 'location');
+
+      $query->add_where("location.city = '%s'", $arg);
+      break;
+//    case 'link':
+//      return l(strtoupper($query->letter), "$arg/$query->letter");
+    case 'title':
+      return $query;
+  }
+}
+
+function views_handler_arg_location_province($op, &$query, $argtype, $arg = '') {
+  switch($op) {
+    case 'summary':
+      $query->add_table('location', true);
+      $query->add_field('province', 'location');
+
+      $fieldinfo['field'] = "location.province";
+  //    $fieldinfo['fieldname'] = 'Province';
+      return $fieldinfo;
+      break;
+    case 'sort':
+      $query->add_orderby('node', 'title', $argtype);
+      break;
+    case 'filter':
+      $query->ensure_table('location');
+      $query->add_field('province', 'location');
+
+      $query->add_where("location.province = '%s'", $arg);
+      break;
+//    case 'link':
+//      return l(strtoupper($query->letter), "$arg/$query->letter");
+    case 'title':
+      return $query;
+  }
+}
+
+function views_handler_arg_location_country($op, &$query, $argtype, $arg = '') {
+  switch($op) {
+    case 'summary':
+      $query->add_table('location', true);
+      $query->add_field('country', 'location');
+
+      $fieldinfo['field'] = "location.country";
+  //    $fieldinfo['fieldname'] = 'Country';
+      return $fieldinfo;
+      break;
+    case 'sort':
+      $query->add_orderby('node', 'title', $argtype);
+      break;
+    case 'filter':
+      $query->ensure_table('location');
+      $query->add_field('country', 'location');
+
+      $query->add_where("location.country = '%s'", $arg);
+      break;
+//    case 'link':
+//      return l(strtoupper($query->letter), "$arg/$query->letter");
+    case 'title':
+      // is this the most efficient way of doing this??
+      $all_countries=_location_get_iso3166_list();
+      return $all_countries[$query];
+  }
+}
+
+
