content_taxonomy.inc in Hierarchical Select 5
File
modules/content_taxonomy.inc
View source
<?php
function content_taxonomy_hierarchical_select_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id) {
$content_type = $form['type']['#value'];
$fields = content_fields(NULL, $content_type);
$hs_fields = array();
foreach ($fields as $field_name => $field_properties) {
if ($field_properties['type_name'] == $content_type) {
$vid = $field_properties['vid'];
$depth = $field_properties['depth'];
if ($depth != 1) {
if (variable_get("hierarchical_select_status_{$vid}", FALSE)) {
$vocabulary = taxonomy_get_vocabulary($vid);
if ($vocabulary->hierarchy > 0) {
$hs_fields[$field_name]['vid'] = $vid;
$hs_fields[$field_name]['depth'] = $depth;
}
}
}
}
}
foreach ($hs_fields as $field_name => $field_properties) {
$vid = $field_properties['vid'];
$depth = $field_properties['depth'];
if (isset($form[$field_name]) && $form[$field_name]['tids']['#type'] == 'select' && !$form[$field_name]['tids']['#multiple']) {
$form[$field_name]['tids']['#type'] = 'hierarchical_select';
$form[$field_name]['tids']['#hierarchical_select_settings'] = array(
'module' => 'content_taxonomy',
'params' => array(
'vid' => $vid,
'depth' => $depth,
),
);
}
elseif (module_exists('fieldgroup')) {
$field_group = fieldgroup_get_group($content_type, $field_name);
if (isset($form[$field_group][$field_name]) && $form[$field_group][$field_name]['tids']['#type'] == 'select' && !$form[$field_group][$field_name]['tids']['#multiple']) {
$form[$field_group][$field_name]['tids']['#type'] = 'hierarchical_select';
$form[$field_group][$field_name]['tids']['#hierarchical_select_settings'] = array(
'module' => 'content_taxonomy',
'params' => array(
'vid' => $vid,
'depth' => $depth,
),
);
}
}
}
}
}
function content_taxonomy_hierarchical_select_render($hsid, $selection, $params) {
return taxonomy_hierarchical_select_render($hsid, $selection, $params);
}