function content_taxonomy_allowed_values in Content Taxonomy 6
Same name and namespace in other branches
- 6.2 content_taxonomy.module \content_taxonomy_allowed_values()
- 7 content_taxonomy.module \content_taxonomy_allowed_values()
Called by content_allowed_values to create the $options array for the content_taxonomy_options
1 call to content_taxonomy_allowed_values()
File
- ./
content_taxonomy.module, line 251 - Defines a field type for referencing a taxonomy term.
Code
function content_taxonomy_allowed_values($field) {
$options = array();
//for opt groups call different function
if (isset($field['widget']['group_parent']) && $field['widget']['group_parent'] > 0) {
$options = content_taxonomy_allowed_values_groups($field);
}
else {
$depth = is_numeric($field['depth']) ? $field['depth'] : NULL;
$tree = taxonomy_get_tree($field['vid'], content_taxonomy_field_get_parent($field), -1, $depth);
if (is_array($tree)) {
foreach ($tree as $term) {
_content_taxonomy_localize_term($term);
if ($field['widget']['show_depth']) {
$value = str_repeat(' - ', $term->depth) . $term->name;
}
else {
$value = $term->name;
}
//do a check_plain except for selects because form api does that
$options[$term->tid] = $field['widget']['type'] == 'content_taxonomy_select' ? $value : check_plain($value);
}
}
}
if ($field['widget']['type'] == 'content_taxonomy_select' && !$field['multiple'] && !$field['required'] || $field['widget']['type'] == 'content_taxonomy_options' && !$field['multiple'] && !$field['required']) {
$options = array(
'' => theme('content_taxonomy_options_widgets_none', $field),
) + $options;
}
return $options;
}