You are here

function _i18ntaxonomy_term_select in Internationalization 6

Same name and namespace in other branches
  1. 5.3 contrib/i18ntaxonomy.module \_i18ntaxonomy_term_select()
  2. 5 contrib/i18ntaxonomy.module \_i18ntaxonomy_term_select()
  3. 5.2 contrib/i18ntaxonomy.module \_i18ntaxonomy_term_select()

Produces tree for taxonomy vocabularies.

The difference with _taxonomy_term_select() is that this function is passed the term tree that may be already localized or filtered by language

2 calls to _i18ntaxonomy_term_select()
i18ntaxonomy_translation_term_form in i18ntaxonomy/i18ntaxonomy.admin.inc
Produces a vocabulary translation form.
i18ntaxonomy_vocabulary_form in i18ntaxonomy/i18ntaxonomy.module
Generate a form element for selecting terms from a vocabulary. Translates all translatable strings.

File

i18ntaxonomy/i18ntaxonomy.module, line 602
i18n taxonomy module

Code

function _i18ntaxonomy_term_select($title, $value, $tree, $description = '', $multiple = FALSE, $blank = '--', $exclude = array()) {
  $options = array();
  if ($blank) {
    $options[''] = $blank;
  }
  if ($tree) {
    foreach ($tree as $term) {
      if (!in_array($term->tid, $exclude)) {
        $choice = new stdClass();
        $choice->option = array(
          $term->tid => str_repeat('--', $term->depth) . $term->name,
        );
        $options[] = $choice;
      }
    }
  }
  return array(
    '#type' => 'select',
    '#title' => $title,
    '#default_value' => $value,
    '#options' => $options,
    '#description' => $description,
    '#multiple' => $multiple,
    '#size' => $multiple ? min(9, count($options)) : 0,
    '#weight' => -15,
    '#theme' => 'taxonomy_term_select',
  );
}