function hs_content_taxonomy_views_config_form in Hierarchical Select 5.3
Form definition; configuration form for Hierarchical Select as the widget for a Taxonomy exposed filter.
Parameters
$view_name: Name of a view. Provides necessary context.
$field_name: Name of a field. Provides necessary context.
1 string reference to 'hs_content_taxonomy_views_config_form'
- hs_content_taxonomy_views_menu in modules/
hs_content_taxonomy_views.module - Implementation of hook_menu().
File
- modules/
hs_content_taxonomy_views.module, line 199 - Implementation of the Hierarchical Select API for the Content Taxonomy Views module.
Code
function hs_content_taxonomy_views_config_form($view_name, $field_name) {
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'].
$view = views_get_view($view_name);
foreach ($view->exposed_filter as $filter) {
if ($filter['id'] == "content_taxonomy_{$field_name}.tid") {
$exposed_filter = $filter;
break;
}
}
$field = content_fields($field_name);
// Extract the necessary context from the $field array.
$vid = $field['vid'];
$tid = $field['tid'];
$depth = empty($field['depth']) ? 0 : $field['depth'];
// Add the Hierarchical Select config form.
$module = 'hs_content_taxonomy_views';
$params = array(
'vid' => $vid,
'tid' => $tid,
'depth' => $depth,
'optional' => (bool) $exposed_filter['optional'],
);
$config_id = "content-taxonomy-views-{$view_name}-{$field_name}";
$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'],
),
'editability' => array(
'max_levels' => min($depth, _hs_taxonomy_hierarchical_select_get_depth($vid)),
),
);
$strings = array(
'hierarchy' => t('vocabulary'),
'hierarchies' => t('vocabularies'),
'item' => t('term'),
'items' => t('terms'),
'item_type' => t('term type'),
'entity' => t('node'),
'entities' => t('nodes'),
);
$max_hierarchy_depth = min($depth == 0 ? 9 : $depth, _hs_taxonomy_hierarchical_select_get_depth($vid));
$preview_is_required = !(bool) $exposed_filter['optional'];
$form['hierarchical_select_config'] = hierarchical_select_common_config_form($module, $params, $config_id, $defaults, $strings, $max_hierarchy_depth, $preview_is_required);
$form['link'] = array(
'#value' => l('Back to the view configuration', "admin/build/views/{$view_name}/edit"),
'#prefix' => '<div class="hierarchical-select-config-back-link">',
'#suffix' => '</div>',
'#weight' => -5,
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
// 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_content_taxonomy_views_common_config_form_submit'] = array(
$view_name,
$field_name,
);
return $form;
}