diff --git a/hierarchical_select.module b/hierarchical_select.module index 5dfedcb..b9ace69 100644 --- a/hierarchical_select.module +++ b/hierarchical_select.module @@ -333,7 +333,7 @@ function hierarchical_select_ajax($form, $form_state) { 'output' => $output, // 'cache' => $cache, ); - $new_settings = _hs_new_setting_ajax(); + $new_settings = _hs_new_setting_ajax(FALSE); foreach ($new_settings as $new_setting) { $commands[] = array( 'command' => 'hierarchicalSelectSettingsUpdate', @@ -430,7 +430,7 @@ function _hs_process_attach_css_js($element, $hsid, &$form_state, $complete_form return $element; } -function _hs_new_setting_ajax($hsid = FALSE, $settings) { +function _hs_new_setting_ajax($hsid = FALSE, $settings = NULL) { static $hs_settings = array(); if ($hsid !== FALSE) { diff --git a/modules/hs_taxonomy_views.info b/modules/hs_taxonomy_views.info index a17c657..22846b7 100644 --- a/modules/hs_taxonomy_views.info +++ b/modules/hs_taxonomy_views.info @@ -4,6 +4,6 @@ dependencies[] = hierarchical_select dependencies[] = hs_taxonomy dependencies[] = views package = Form Elements -core = 6.x +core = 7.x files[] = hs_taxonomy_views_handler_filter_term_node_tid.inc diff --git a/modules/hs_taxonomy_views.module b/modules/hs_taxonomy_views.module index 6e06490..b852ce5 100644 --- a/modules/hs_taxonomy_views.module +++ b/modules/hs_taxonomy_views.module @@ -84,6 +84,26 @@ function hs_taxonomy_views_form_alter(&$form, $form_state, $form_id) { } } + +function hs_taxonomy_views_form_views_exposed_form_alter(&$form, &$form_state) { + /* AJAX fix */ + $js_code="jQuery(function(){ + for(ajax_object in Drupal.ajax) + if(Drupal.ajax[ajax_object].options) + jQuery.extend(Drupal.ajax[ajax_object].options.data,Drupal.settings.exposed_form_info); + });"; + + $form_info_array = array( + 'form_id' => $form['#form_id'], + 'form_build_id' => $form['#build_id'], + 'form_token' => $form['#token'], + ); + + drupal_add_js(array('exposed_form_info' => $form_info_array), 'setting'); + drupal_add_js($js_code,array('type' => 'inline', 'weight' => 100)); +} + + //---------------------------------------------------------------------------- // Menu system callbacks. @@ -150,7 +170,7 @@ function hs_taxonomy_views_json($view_name, $display_id) { views_set_current_view($view); } - return hierarchical_select_json(); + return hierarchical_select_ajax(); } @@ -162,104 +182,27 @@ function hs_taxonomy_views_json($view_name, $display_id) { */ function hs_taxonomy_views_api() { return array( - 'api' => 2, + 'api' => 3, 'path' => drupal_get_path('module', 'hierarchical_select') . '/modules', ); } /** - * Implementation of hook_views_handlers(). + * Implementation of hook_field_views_data_alter(). */ -function hs_taxonomy_views_handlers() { - return array( - 'handlers' => array( - // Provide a subclass of the term filter handler, to make it possible to - // use Hierarchical Select in Views. - 'hs_taxonomy_views_handler_filter_term_node_tid' => array( - 'parent' => 'views_handler_filter_term_node_tid', - ), - 'hs_taxonomy_views_handler_filter_term_node_tid_depth' => array( - 'parent' => 'hs_taxonomy_views_handler_filter_term_node_tid', - ), - ) - ); -} - -/** - * Implementation of hook_views_data_alter(). - */ -function hs_taxonomy_views_views_data_alter(&$data) { - // Term view type, tid field. - $data['taxonomy_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'), - ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - 'argument' => array( - 'handler' => 'views_handler_argument_numeric', - 'skip base' => array('node', 'node_revision'), - ), - // Override the views_handler_filter_term_node_tid filter handler: use our - // hs_taxonomy_views_handler_filter_term_node_tid subclass instead. - 'filter' => array( - 'handler' => 'hs_taxonomy_views_handler_filter_term_node_tid', - 'hierarchy table' => 'taxonomy_term_hierarchy', - 'numeric' => TRUE, - 'skip base' => array('node', 'node_revision'), - ), - ); - - // Node view type, tid field. - $data['taxonomy_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' => 'taxonomy_term_data', - ), - 'argument' => array( - 'handler' => 'views_handler_argument_term_node_tid', - 'name table' => 'taxonomy_term_data', - 'name field' => 'name', - 'empty name field' => t('Uncategorized'), - 'numeric' => TRUE, - 'skip base' => 'taxonomy_term_data', - ), - // Override the views_handler_filter_term_node_tid filter handler: use our - // hs_taxonomy_views_handler_filter_term_node_tid subclass instead. - 'filter' => array( - 'title' => t('Term'), - 'handler' => 'hs_taxonomy_views_handler_filter_term_node_tid', - 'hierarchy table' => 'taxonomy_term_hierarchy', - 'numeric' => TRUE, - 'skip base' => 'taxonomy_term_data', - ), - ); - - // Node view type, tid with depth field. - $data['node']['term_node_tid_depth'] = array( - 'group' => t('Taxonomy'), - 'title' => t('Term ID (with depth)'), - 'help' => t('The depth filter is more complex, so provides fewer options.'), - 'real field' => 'vid', - 'argument' => array( - 'handler' => 'views_handler_argument_term_node_tid_depth', - 'accept depth modifier' => TRUE, - ), - 'filter' => array( - 'handler' => 'hs_taxonomy_views_handler_filter_term_node_tid_depth', - ), - ); +function hs_taxonomy_views_field_views_data_alter(&$result, $field, $module) { + if ($module == 'taxonomy') { + foreach ($result as $table => $data) { + $field_name = $field['field_name']; + foreach ($data as $column => $value) { + if (array_key_exists('filter', $value)) { + $result[$table][$column]['filter']['handler'] = 'hs_taxonomy_views_handler_filter_term_node_tid'; + } + } + } + } } - //---------------------------------------------------------------------------- // Forms API callbacks. diff --git a/modules/hs_taxonomy_views_handler_filter_term_node_tid.inc b/modules/hs_taxonomy_views_handler_filter_term_node_tid.inc index 1f1a4c6..3e638be 100644 --- a/modules/hs_taxonomy_views_handler_filter_term_node_tid.inc +++ b/modules/hs_taxonomy_views_handler_filter_term_node_tid.inc @@ -22,12 +22,8 @@ class hs_taxonomy_views_handler_filter_term_node_tid extends views_handler_filte // If you can live with a reload of the View edit form, you can wrap the // code below in such a check. - // Add JS and CSS required for Hierarchical Select to work. - _hierarchical_select_setup_js(); - // Ensure that Drupal.HierarchicalSelect.prepareGETSubmit() gets called. require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'hierarchical_select') . '/includes/common.inc'; - hierarchical_select_common_add_views_js(); } function value_form(&$form, &$form_state) { @@ -49,7 +45,9 @@ class hs_taxonomy_views_handler_filter_term_node_tid extends views_handler_filte $view_name = $this->view->name; $filter_id = $this->options['id']; $display_id = _hs_taxonomy_views_get_display_id_for_filter($this->view, $filter_id); - $optional = $this->options['expose']['optional']; + // @TODO: optional fixen!! + //$optional = $this->options['expose']['optional']; + $optional = FALSE; $config_id = "taxonomy-views-$view_name-$display_id-$filter_id"; @@ -168,7 +166,7 @@ class hs_taxonomy_views_handler_filter_term_node_tid extends views_handler_filte '#markup' => l(t('Configure Hierarchical Select'), _hs_taxonomy_views_config_path($this->view->name, $display_id, $filter_id)), '#suffix' => '', // Doesn't work because #process is not called for #type = markup form items. - '#process' => array('views_process_dependency'), + '#process' => array('ctools_dependent_process'), '#dependency' => array('radio:options[type]' => array('hierarchical_select')), // Set #input = TRUE so that #process will be called. '#input' => TRUE,