You are here

function _taxonomy_manager_form_term_data_lists in Taxonomy Manager 6.2

Same name and namespace in other branches
  1. 5 taxonomy_manager.module \_taxonomy_manager_form_term_data_lists()
  2. 6 taxonomy_manager.admin.inc \_taxonomy_manager_form_term_data_lists()

helper function for generating tables with values and delete op and field for adding

Parameters

$term term object which is going to be displayed:

$values array of values to show, e.g related terms, synonyms, parents, children:

$header_type string to display as header:

$attr attribute type to show, can be 'related', 'synonym', 'parent', 'child':

$autocomplete if true, adds autocomplete, else a textfield:

$add if true, shows add operation:

Return value

an form array

1 call to _taxonomy_manager_form_term_data_lists()
taxonomy_manager_form_term_data in ./taxonomy_manager.admin.inc
term data editing form

File

./taxonomy_manager.admin.inc, line 966
Taxonomy Manager Admin

Code

function _taxonomy_manager_form_term_data_lists($term, $values, $header_type, $attr, $autocomplete = TRUE, $add = TRUE) {
  $module_path = drupal_get_path('module', 'taxonomy_manager') . '/';
  $rows = array();
  $form['#theme'] = 'taxonomy_manager_term_data_extra';
  $form['data'] = array();
  foreach ($values as $tid => $value) {
    if (is_object($value)) {
      $name = $value->name;
      $id = $value->tid;
      $vid = $value->vid;
      $extra_info = taxonomy_manager_tree_term_extra_info($value);
    }
    else {
      $name = $value;
      $id = $value;
    }
    $form['data'][$id][] = array(
      '#value' => isset($vid) && $vid > 0 ? l($name, 'admin/content/taxonomy_manager/termdata/' . $vid . "/" . $id, array(
        'attributes' => array(
          'title' => $extra_info,
          'class' => 'taxonomy-term-data-name-link',
        ),
      )) : check_plain($name),
      '#row-class' => 'taxonomy-term-data-name',
      '#row-id' => 'term-' . $id,
    );
    $form['data'][$id][] = array(
      '#value' => '<span class="' . $attr . '" title="' . t('Remove') . '">&nbsp;</span>',
      '#row-class' => 'taxonomy-term-data-operations',
    );
  }
  $form['headers'][] = array(
    '#value' => $header_type,
  );
  $form['headers'][] = array(
    '#value' => '',
  );
  $form['op'] = array();
  if ($add) {
    $form['op']['add'] = array(
      '#type' => 'textfield',
      '#prefix' => '<div class="term-data-autocomplete">',
      '#suffix' => '</div>',
      '#size' => 35,
    );
    if ($autocomplete) {
      $form['op']['add']['#autocomplete_path'] = 'taxonomy_manager/autocomplete/' . $term->vid;
    }
    $form['op']['add_button'] = array(
      '#value' => '<span class="' . $attr . '" title="' . t('Add') . '">&nbsp;</span>',
      '#prefix' => '<div class="term-data-autocomplete-add">',
      '#suffix' => '</div>',
    );
  }
  return $form;
}