? new.patch
Index: hierarchical_select.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/hierarchical_select.module,v
retrieving revision 1.154
diff -u -p -r1.154 hierarchical_select.module
--- hierarchical_select.module	10 Mar 2009 22:21:38 -0000	1.154
+++ hierarchical_select.module	13 Mar 2009 17:54:21 -0000
@@ -278,6 +278,14 @@ function hierarchical_select_json() {
 
   $hs_form_build_id = $_POST['hs_form_build_id'];
 
+  
+  //John: Inserted as workaround for views classes not being defined when we call cache_get,
+  //      see also hierarchical_select_after_build for where we set the session var
+  if (isset($_SESSION['hs_view_'.$hs_form_build_id])) {
+    $tmp_view = views_get_view($_SESSION['hs_view_'.$hs_form_build_id]);
+    $tmp_view->execute_display();
+  }
+
   // Collect all necessary variables.
   $cached = cache_get($hs_form_build_id, 'cache');
   $storage = $cached->data;
@@ -678,6 +686,13 @@ function hierarchical_select_after_build
     // render part of the form).
     $expire = max(ini_get('session.cookie_lifetime'), 86400);
     $hs_form_build_id = 'hs_form_'. md5(mt_rand());
+    
+    // John:  If the form is a views exposed filter, we store the view name in a session variable so that we can load
+    //        it before calling cache_get in hierarchical_select_json
+    if (isset($parameters[1]['view'])) {
+      $_SESSION['hs_view_'.$hs_form_build_id] = $parameters[1]['view']->name;
+    }
+    
     cache_set($hs_form_build_id, $storage, 'cache', $expire);
   }
   elseif (isset($_POST['hs_form_build_id'])) {
Index: modules/hierarchical_select_handler_filter_term_node_tid.inc
===================================================================
RCS file: modules/hierarchical_select_handler_filter_term_node_tid.inc
diff -N modules/hierarchical_select_handler_filter_term_node_tid.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/hierarchical_select_handler_filter_term_node_tid.inc	13 Mar 2009 17:54:21 -0000
@@ -0,0 +1,94 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * This file defines a new filter handler for adding hierarchical select to 
+ * expoed filters in views 2.
+ */
+
+class hierarchical_select_handler_filter_term_node_tid extends views_handler_filter_term_node_tid {
+
+  
+  function value_form(&$form, &$form_state) {
+    parent::value_form($form, $form_state);
+      
+    $vid = $this->options['vid'];
+    $vocabulary = taxonomy_vocabulary_load($this->options['vid']);
+
+    // If chosen, make it use a hierarchical select. 
+    if (!empty($this->options['use_hs']) && !empty($form_state['exposed'])   ) {
+
+      require_once(drupal_get_path('module', 'hierarchical_select') .'/includes/common.inc');
+
+      unset($form["value"]['#options']);
+      unset($form["value"]['#theme']);
+      unset($form["value"]['#size']);
+
+      $form['value']['#type'] = 'hierarchical_select';
+      $defaults_override = array(
+       'module' => 'hs_taxonomy_views',
+       'params' => array(
+         'optional'    => (bool) $this->options['expose']['optional'],
+         'vid'         => $vid,
+         'exclude_tid' => NULL,
+         'root_term'   => NULL,
+       ),
+       // When the All option is selected, nothing else should be.
+       'exclusive_lineages' => array('All'),
+       // This is a GET form, so also render the flat select.
+       'render_flat_select' => 1,
+      );
+      $view_name = $this->view->name;
+      hierarchical_select_common_config_apply($form['value'], "taxonomy-views-$view_name-$vid", $defaults_override);
+
+      // Inherit #required from the exposed filter settings.
+      $form['value']['#required'] = !((bool) $view->exposed_filter[$id]['optional']);
+
+      // Put the altered exposed filters in a separate table row.
+      hierarchical_select_common_views_exposed_filters_reposition();
+    }
+
+    if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
+      $form_state['input'][$identifier] = $default_value;
+    } 
+  }
+
+
+  function expose_form(&$form, &$form_state) {
+    parent::expose_form($form, $form_state);
+
+    if (!empty($this->options['use_hs'])) {
+      $form['configure_hs'] = array(
+         '#prefix' => '<div class="views-left-50 form-item">',
+         '#value' => '<p>'. l(t('Configure Hierarchical Select Settings'), 'admin/build/views/hs_config/'. $this->view->name .'/'. $this->options['vid'] .'/'. $this->view->current_display) .'</p>',
+         '#suffix' => '</div>',
+       );
+    }
+  }
+  
+  function option_definition() {
+     $options = parent::option_definition();
+
+     $options['use_hs'] = array('default' => '0');
+
+     return $options;
+   }
+   
+
+  function extra_options_form(&$form, &$form_state) {
+    parent::extra_options_form($form, $form_state);
+    
+    $form['use_hs'] = array(
+      '#prefix' => '<div class="views-left-40">',
+      '#suffix' => '</div>',
+      '#type' => 'checkbox',
+      '#title' => t('Use Hierarchical Select'),
+      '#process' => array('views_process_dependency'),
+      '#dependency' => array('radio:options[type]' => array('select')),
+      '#description' => t('Use the hierarchical select widget for exposed filters?'),
+      '#default_value' => !empty($this->options['use_hs']),
+    );
+  }
+
+}
Index: modules/hs_taxonomy_views.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/modules/hs_taxonomy_views.info,v
retrieving revision 1.2
diff -u -p -r1.2 hs_taxonomy_views.info
--- modules/hs_taxonomy_views.info	28 Jun 2008 18:25:28 -0000	1.2
+++ modules/hs_taxonomy_views.info	13 Mar 2009 17:54:21 -0000
@@ -1,5 +1,8 @@
 ; $Id: hs_taxonomy_views.info,v 1.2 2008/06/28 18:25:28 wimleers Exp $
 name = Hierarchical Select Taxonomy Views
 description = Use Hierarchical Select for Taxonomy exposed filters in Views.
-dependencies = hierarchical_select hs_taxonomy views
+dependencies[] = hierarchical_select
+dependencies[] = hs_taxonomy 
+dependencies[] = views
 package = Form Elements
+core = 6.x
\ No newline at end of file
Index: modules/hs_taxonomy_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/modules/hs_taxonomy_views.module,v
retrieving revision 1.16
diff -u -p -r1.16 hs_taxonomy_views.module
--- modules/hs_taxonomy_views.module	20 Nov 2008 01:04:51 -0000	1.16
+++ modules/hs_taxonomy_views.module	13 Mar 2009 17:54:21 -0000
@@ -7,26 +7,41 @@
  * Views exposed filters.
  */
 
+/**
+  TODO:
+        - check enforce deepest works
+        - check with multiple selects
+        - force single should set hs multiple setting 
+        - fix limit options func
+        - can we cope with the rememeber option in tid filter 
+        - test multiple HS filters per view
+        - handle multiple displays per view - insert display into hs config id
+        - does cache get cleared?
+        - only override what is necessary in hs_taxonomy_views_data_alter()
+        - looks like hs_taxonomy_views_hierarchical_select_entity_count should only count nodes in vid when All selected - not bug in d5, maybe with views2
+
+        
+QUESTIONS FOR WIM:
+      
+        - Remove <none> and empty option in level 1 when All option is present
+        - views filtering not working - prepareGETSubmit not working? param with name "tid" does not exist when submitting
+
 
-//----------------------------------------------------------------------------
-// Core hooks.
+*/
 
 /**
  * Implementation of hook_menu().
  */
-function hs_taxonomy_views_menu($may_cache) {
+function hs_taxonomy_views_menu() {
   $items = array();
 
-  if (!$may_cache && arg(0) == 'admin' && arg(1) == 'build' && arg(2) == 'views' && is_string(arg(3)) && arg(4) == 'hs_config' && is_numeric(arg(5))) {
-    $view_name = arg(3);
-    $vid = arg(5); // Vocabulary ID, not View ID!
-
-    $items[] = array(
-      'path' => "admin/build/views/$view_name/hs_config/$vid",
-      'title' => t('Hierarchical Select configuration for !view', array('!view' => $view_name)),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('hs_taxonomy_views_config_form', $view_name, $vid),
-      'access' => user_access('administer views'),
+  if (!$may_cache) {
+
+    $items["admin/build/views/hs_config/%/%taxonomy_vocabulary/%"] = array(
+      'title' => 'Hierarchical Select configuration',  // we set the title in callback
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('hs_taxonomy_views_config_form', 4, 5, 6),
+      'access arguments' => array('administer views'),
       'type' => MENU_NORMAL_ITEM,
     );
   }
@@ -34,151 +49,99 @@ function hs_taxonomy_views_menu($may_cac
 }
 
 /**
- * Implementation of hook_form_alter().
+ * Implementation of hook_views_api().
  */
-function hs_taxonomy_views_form_alter($form_id, &$form) {
-  // Change the exposed filters of Views. Only affects hierarchical vocabulary
-  // filters.
-  if (in_array($form_id, array('views_filters', 'views_filterblock'))) {
-    $hs_exposed_filters_found = 0;
-
-    // Find the ids and vocabulary ids of the exposed filters.
-    foreach ($form['view']['#value']->exposed_filter as $id => $filter) {
-      if (preg_match("/term_node_(\d+)\.tid/", $filter['field'], $matches)) {
-        $vid = $matches[1];
-
-        // Only apply Hierarchical Select if it's enabled for this vocabulary.
-        if (variable_get("taxonomy_hierarchical_select_$vid", 0)) {
-          $hs_exposed_filters_found++;
-          $vocabulary = taxonomy_get_vocabulary($vid);
-          $view = $form['view']['#value'];
-
-          // Make it use a hierarchical select.
-          require_once(drupal_get_path('module', 'hierarchical_select') .'/includes/common.inc');
+function hierarchical_select_views_api() {
+  return array(
+    'api' => 2,
+    'path' => drupal_get_path('module', 'hierarchical_select') .'/modules',
+  );
+}
 
-          unset($form["filter$id"]['#options']);
-          unset($form["filter$id"]['#theme']);
-          unset($form["filter$id"]['#size']);
-
-          $form["filter$id"]['#type'] = 'hierarchical_select';
-          $defaults_override = array(
-            'module' => 'hs_taxonomy_views',
-            'params' => array(
-              'optional'    => (bool) $view->exposed_filter[$id]['optional'],
-              'vid'         => $vid,
-              'exclude_tid' => NULL,
-              'root_term'   => NULL,
-            ),
-            // When the **ALL** option is selected, nothing else should be.
-            'exclusive_lineages' => array('**ALL**'),
-            // This is a GET form, so also render the flat select.
-            'render_flat_select' => 1,
-          );
-          hierarchical_select_common_config_apply($form["filter$id"], "taxonomy-views-$view->name-$vid", $defaults_override);
+/**
+ * Implementation of hook_views_handlers().
+ */
+function hierarchical_select_views_handlers() {
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'hierarchical_select') .'/modules',
+    ),
+    'handlers' => array(
+      // filter handlers
+      'hierarchical_select_handler_filter_term_node_tid' => array(
+        'parent' => 'views_handler_filter_term_node_tid',
+      ),
+    )
+  );
+}
 
-          // Inherit #required from the exposed filter settings.
-          $form["filter$id"]['#required'] = !((bool) $view->exposed_filter[$id]['optional']);
 
-          // Put the altered exposed filters in a separate table row.
-          hierarchical_select_common_views_exposed_filters_reposition();
-        }
-      }
-    }
+/**
+ * Implementation of hook_views_data_alter().
+ */
+function hierarchical_select_views_data_alter(&$data) {
 
-    if ($hs_exposed_filters_found > 0) {
-      // Views will remove the form_id in views_filters_process(), but we need
-      // it for Hierarchical Select to work, so put it back.
-      $form['copy_of_form_id'] = $form['form_id'] + array('#parents' => array('form_id'));
-    }
-  }
+  // tid field
+  $data['term_data']['tid'] = array(
+   'title' => t('Term ID'),
+   'help' => t('The taxonomy term ID'),
+   'field' => array(
+     'handler' => 'views_handler_field_numeric',
+     'skip base' => array('node', 'node_revision'),
+   ),
+   'argument' => array(
+     'handler' => 'views_handler_argument_numeric',
+     'skip base' => array('node', 'node_revision'),
+   ),
+   'filter' => array(
+     'handler' => 'hierarchical_select_handler_filter_term_node_tid',
+     'hierarchy table' => 'term_hierarchy',
+     'numeric' => TRUE,
+     'skip base' => array('node', 'node_revision'),
+   ),
+  );
 
-  // Alter the edit view form: add a link to the Hierarchical Select
-  // configuration when appropriate and to mark which settings are now managed
-  // by the Hierarchical Select configuration.
-  if ($form_id == 'views_edit_view') {
-    foreach ($form['exposed_filter'] as $filter_id => $filter) {
-      if (is_numeric($filter_id)) {
-        $id = $form['exposed_filter'][$filter_id]['id']['#default_value'];
-        if (preg_match("/term_node_(\d+)\.tid/", $id, $matches)) {
-          $vid  = $matches[1];
-          if (variable_get("taxonomy_hierarchical_select_$vid", 0)) {
-            $view = $form['#parameters'][1];
-
-            $link = l(t('Configure Hierarchical Select'), "admin/build/views/$view->name/hs_config/$vid");
-            $form['exposed_filter'][$filter_id]['name']['#value'] .= '<br />'. $link;
-
-            // Alter the form to support the current Hierarchical Select
-            // config.
-            require_once(drupal_get_path('module', 'hierarchical_select') .'/includes/common.inc');
-            $config_id = "taxonomy-views-$view->name-$vid";
-            $config = hierarchical_select_common_config_get($config_id);
-
-            $text = t('This setting is now managed by the<br />Hierarchical Select configuration!');
-            
-            // Exposed filter's "Force single" setting.
-            $form['exposed_filter'][$filter_id]['single']['#description'] = $text;
-
-            // Additional settings when save_lineage is enabled.
-            if ($config['save_lineage']) {
-              // Filter's "Operator" setting.
-              $form['filter'][$filter_id]['operator']['#description'] = $text;
-
-              // Exposed filter's "Lock Operator" setting.
-              $form['exposed_filter'][$filter_id]['operator']['#description'] = $text;
-            }
-          }
-        }
-      }
-    }
-  }
+  // tid field
+  $data['term_node']['tid'] = array(
+    'title' => t('Term ID'),
+    'help' => t('The taxonomy term ID'),
+    'field' => array(
+      'title' => t('All terms'),
+      'help' => t('Display all taxonomy terms associated with a node from specified vocabularies.'),
+      'handler' => 'views_handler_field_term_node_tid',
+      'skip base' => 'term_data',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_term_node_tid',
+      'name table' => 'term_data',
+      'name field' => 'name',
+      'empty name field' => t('Uncategorized'),
+      'numeric' => TRUE,
+      'skip base' => 'term_data',
+    ),
+    'filter' => array(
+      'title' => t('Term'),
+      'handler' => 'hierarchical_select_handler_filter_term_node_tid',
+      'hierarchy table' => 'term_hierarchy',
+      'numeric' => TRUE,
+      'skip base' => 'term_data',
+    ),
+  );
 }
 
 /**
- * Implementation of hook_requirements().
+ * Implementation of hook_form_alter().
  */
-function hs_taxonomy_views_requirements($phase) {
-  $requirements = array();
-
-  if ($phase == 'runtime') {
-    $pattern = <<<EOT
-function _views_build_filters_form(\$view) {
-  // When the form is retrieved through an AJAX callback, the cache hasn't
-  // been loaded yet. The cache is necesssary for _views_get_filters().
-  views_load_cache();
-EOT;
-    $views_with_patch_257004 = preg_match('#'. preg_quote($pattern) .'#m', file_get_contents(drupal_get_path('module', 'views') .'/views.module'));
-
-    if ($views_with_patch_257004) {
-      $value = t('The Views module is new enough.');
-      $description = '';
-      $severity = REQUIREMENT_OK;
-    }
-    else {
-      $value = t('The Views module is outdated.');
-      $description = t("The version of Views that you have installed is either
-        older than May 11, 2008, or doesn't have the obligatory patch applied.
-        Please apply the <a href=\"!patch_url\">patch</a> or update to a newer
-        version of the Views module!",
-        array('!patch_url' => 'http://drupal.org/files/issues/hs_compatibility.patch')
-      );
-      $severity = REQUIREMENT_ERROR;
-    }
-
-    $requirements['hs_taxonomy_views'] = array(
-      'title'       => t('Hierarchical Select Views Taxonomy'),
-      'value'       => $value,
-      'description' => $description,
-      'severity'    => $severity,
-    );
+function hs_taxonomy_views_form_alter(&$form, $form_state, $form_id) {
+  
+  // Views will remove the form_id in views_filters_process(), but we need
+  // it for Hierarchical Select to work, so put it back.
+  if ($form_id == 'views_exposed_form') {
+    $form['copy_of_form_id'] = $form['form_id'] + array('#parents' => array('form_id'));
   }
-
-  return $requirements;
 }
 
 
-//----------------------------------------------------------------------------
-// Forms API callbacks.
-
 /**
  * Form definition; configuration form for Hierarchical Select as the widget
  * for a Taxonomy exposed filter.
@@ -188,42 +151,49 @@ EOT;
  * @param $vid
  *   A vocabulary id. Provides necessary context.
  */
-function hs_taxonomy_views_config_form($view_name, $vid) {
-  require_once(drupal_get_path('module', 'hierarchical_select') .'/includes/common.inc');
-
-  // Find the exposed filter, we need this to set the default value of
-  // $config['dropbox']['status'].
+function hs_taxonomy_views_config_form($form_state, $view_name, $vocabulary, $display) {
+  
+  // TODO need to check view arg here as there is not a loader we can use in hook_menu
+  
   $view = views_get_view($view_name);
-  foreach ($view->exposed_filter as $filter) {
-    if ($filter['id'] == "term_node_$vid.tid") {
+  $vid = $vocabulary->vid;
+  
+  drupal_set_title(t('Hierarchical Select configuration for !view', array('!view' => $view_name)));
+  
+  require_once(drupal_get_path('module', 'hierarchical_select') .'/includes/common.inc');
+ 
+     // TODO need more rigorous checking in here
+          
+  foreach ($view->display[$display]->display_options['filters'] as $filter) {
+    if (($filter['vid'] == $vid)) {
       $exposed_filter = $filter;
       break;
     }
   }
-
+  
   // Add the Hierarchical Select config form.
   $module = 'hs_taxonomy_views';
   $params = array(
-    'optional'    => (bool) $view->exposed_filter[$id]['optional'],
+    'optional'    => (bool) $exposed_filter['expose']['optional'],
     'vid'         => $vid,
     'exclude_tid' => NULL,
     'root_term'   => NULL,
   );
-    
   
   $config_id = "taxonomy-views-$view_name-$vid";
-  $vocabulary = taxonomy_get_vocabulary($vid);
+
   $defaults = array(
     // Enable the save_lineage setting by default if the multiple parents
     // vocabulary option is enabled.
     'save_lineage' => (int) ($vocabulary->hierarchy == 2),
     'dropbox' => array(
-      'status' => !$exposed_filter['single'],
+      'status' => !$exposed_filter['expose']['single'],
     ),
     'editability' => array(
       'max_levels' => _hs_taxonomy_hierarchical_select_get_depth($vid),
     ),
   );
+  
   $strings = array(
     'hierarchy'   => t('vocabulary'),
     'hierarchies' => t('vocabularies'),
@@ -234,7 +204,7 @@ function hs_taxonomy_views_config_form($
     'entities'    => t('nodes'),
   );
   $max_hierarchy_depth = _hs_taxonomy_hierarchical_select_get_depth($vid);
-  $preview_is_required = !(bool)$exposed_filter['optional'];
+  $preview_is_required = !(bool)$exposed_filter['expose']['optional'];
   $form['hierarchical_select_config'] = hierarchical_select_common_config_form($module, $params, $config_id, $defaults, $strings, $max_hierarchy_depth, $preview_is_required);
   $form['hierarchical_select_config']['save_lineage']['#description'] .= '<br />'. t(
     'When you enable the %save_lineage setting, you will have to resave the
@@ -243,7 +213,7 @@ function hs_taxonomy_views_config_form($
   );
 
   $form['link'] = array(
-    '#value' => l('Back to the view configuration', "admin/build/views/$view_name/edit"),
+    '#value' => l('Back to the view configuration', "admin/build/views/edit/$view_name"),
     '#prefix' => '<div class="hierarchical-select-config-back-link">',
     '#suffix' => '</div>',
     '#weight' => -5,
@@ -255,10 +225,14 @@ function hs_taxonomy_views_config_form($
   );
 
   // Add the the submit handler for the Hierarchical Select config form.
-  $parents = array('hierarchical_select_config');
-  $form['#submit']['hierarchical_select_common_config_form_submit'] = array($parents);
 
-  $form['#submit']['hs_taxonomy_views_common_config_form_submit'] = array($view_name, $vid);
+  $parents = array('hierarchical_select_config');
+  
+  $form['#submit'][] = 'hierarchical_select_common_config_form_submit';
+  $form['#hs_common_config_form_parents'] = $parents;
+  
+// TODO needs to be D6alised  
+//  $form['#submit']['hs_taxonomy_views_common_config_form_submit'] = array($view_name, $vid);
 
   return $form;
 }
@@ -273,6 +247,7 @@ function hs_taxonomy_views_config_form($
  * @param $vid
  *   A vocabulary id. Provides necessary context.
  */
+ /*
 function hs_taxonomy_views_common_config_form_submit($form_id, $form_values, $view_name, $vid) {
   $view_id = db_result(db_query("SELECT vid FROM {view_view} WHERE name = '%s'", $view_name));
   $field = 'term_node_'. $vid .'.tid';
@@ -312,55 +287,68 @@ function hs_taxonomy_views_common_config
     drupal_set_message(t("Updated the View's exposed filter according to the settings you made."));
   }
 }
+*/
 
 
-//----------------------------------------------------------------------------
-// Hierarchical Select hooks.
-
 /**
  * Implementation of hook_hierarchical_select_params().
  */
 function hs_taxonomy_views_hierarchical_select_params() {
-  return array('optional') + hs_taxonomy_hierarchical_select_params();
+  $params = array(
+    'vid',
+    'optional',  // Do we display an "All" option?
+//    'exclude_tid', // Allows a term to be excluded (necessary for the taxonomy_form_term form).
+//    'root_term',   // Displays a fake "<root>" term in the root level (necessary for the taxonomy_form-term form).
+  );
+  return $params;
 }
 
+
+
 /**
  * Implementation of hook_hierarchical_select_root_level().
  */
 function hs_taxonomy_views_hierarchical_select_root_level($params) {
-  $root_level =  ($params['optional']) ? array('**ALL**' => '<'. t('all') .'>') : array();
+  
+  $root_level =  ($params['optional']) ? array('All' => '<'. t('Any') .'>') : array();
   $root_level += hs_taxonomy_hierarchical_select_root_level($params);
   return $root_level;
+  
 }
 
+
 /**
  * Implementation of hook_hierarchical_select_children().
  */
 function hs_taxonomy_views_hierarchical_select_children($parent, $params) {
-  return ($parent == '**ALL**') ? array() : hs_taxonomy_hierarchical_select_children($parent, $params);
+  return ($parent == 'All') ? array() : hs_taxonomy_hierarchical_select_children($parent, $params);
 }
 
+
 /**
  * Implementation of hook_hierarchical_select_lineage().
  */
 function hs_taxonomy_views_hierarchical_select_lineage($item, $params) {
-  return ($item == '**ALL**') ? array($item) : hs_taxonomy_hierarchical_select_lineage($item, $params);
+  return ($item == 'All') ? array($item) : hs_taxonomy_hierarchical_select_lineage($item, $params);
 }
 
+
 /**
  * Implementation of hook_hierarchical_select_valid_item().
  */
 function hs_taxonomy_views_hierarchical_select_valid_item($item, $params) {
-  return ($item == '**ALL**' || hs_taxonomy_hierarchical_select_valid_item($item, $params));
+  return ($item == 'All' || hs_taxonomy_hierarchical_select_valid_item($item, $params));
 }
 
+
 /**
  * Implementation of hook_hierarchical_select_item_get_label().
  */
 function hs_taxonomy_views_hierarchical_select_item_get_label($item, $params) {
-  return ($item == '**ALL**') ? '<'. t('all') .'>' : hs_taxonomy_hierarchical_select_item_get_label($item, $params);
+  return ($item == 'All') ? '<'. t('Any') .'>' : hs_taxonomy_hierarchical_select_item_get_label($item, $params);
 }
 
+
 /**
  * Implementation of hook_hierarchical_select_create_item().
  */
@@ -368,11 +356,12 @@ function hs_taxonomy_views_hierarchical_
 // able to create new items in the hierarchy, how could you then possibly find
 // anything for that item?
 
+
 /**
  * Implementation of hook_hierarchical_select_entity_count().
  */
 function hs_taxonomy_views_hierarchical_select_entity_count($item, $params) {
-  if ($item == '**ALL**') {
+  if ($item == 'All') {
     return db_result(db_query('SELECT COUNT(DISTINCT(t.nid)) FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1'));
   }
   else {
@@ -393,6 +382,7 @@ function hs_taxonomy_views_hierarchical_
 /**
  * Implementation of hook_hierarchical_select_config_info().
  */
+ /*  John: copied from D5 implementation - not sure if we need to port this
 function hs_taxonomy_views_hierarchical_select_config_info() {
   static $config_info;
 
@@ -427,18 +417,29 @@ function hs_taxonomy_views_hierarchical_
 
   return  $config_info;
 }
+*/
+
 
 /**
- * Given an id of the form "term_node_1.tid", with 1 the vid, get the vid.
- *
- * @return
- *   When no valid id was given, FALSE, otherwise the vid.
+ * Helper function to apply the HS config to a form item.
  */
-function _hs_taxonomy_views_parse_vocabulary_id_from_id($id) {
-  $vid = FALSE;
-
-  if (preg_match("/term_node_(\d+)\.tid/", $id, $matches)) {
-    $vid = $matches[1];
-  }
-  return $vid;
+function _hs_taxonomy_views_apply_config(&$form, $exclude) {
+  $form['#config'] = array(
+    'module' => 'hs_menu',
+    'params' => array(
+      'exclude' => $exclude,
+    ),
+    'save_lineage'    => 0,
+    'enforce_deepest' => 0,
+    'resizable'       => variable_get('hs_menu_resizable', 1),
+    'level_labels' => array(
+      'status' => 0,
+    ),
+    'dropbox' => array(
+      'status' => 0,
+    ),
+    'editability' => array(
+      'status' => 0,
+    ),
+  );
 }
