You are here

function content_taxonomy_allowed_values_groups in Content Taxonomy 6

Same name and namespace in other branches
  1. 6.2 content_taxonomy.module \content_taxonomy_allowed_values_groups()

Creating Opt Groups for content_taxonomy_options

1 call to content_taxonomy_allowed_values_groups()
content_taxonomy_allowed_values in ./content_taxonomy.module
Called by content_allowed_values to create the $options array for the content_taxonomy_options

File

./content_taxonomy.module, line 287
Defines a field type for referencing a taxonomy term.

Code

function content_taxonomy_allowed_values_groups($field) {
  $options = array();
  $parent = content_taxonomy_field_get_parent($field);
  $group_parent = $field['widget']['group_parent'];

  //if children in no group
  $default_terms = taxonomy_get_children($parent, $field['vid']);
  foreach ($default_terms as $default_term) {
    _content_taxonomy_localize_term($default_term);
    $options[$default_term->tid] = check_plain($default_term->name);
  }
  foreach (taxonomy_get_children($group_parent) as $group) {
    foreach (taxonomy_get_children($group->tid) as $term) {
      _content_taxonomy_localize_term($term);
      $options[$group->name][$term->tid] = check_plain($term->name);
      unset($options[$term->tid]);
    }
    unset($options[$group->tid]);
  }
  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;
}