You are here

function taxonomy_manager_form_term_data in Taxonomy Manager 6.2

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

term data editing form

Parameters

$tid:

2 calls to taxonomy_manager_form_term_data()
taxonomy_manager_form in ./taxonomy_manager.admin.inc
defines forms for taxonomy manager interface
taxonomy_manager_update_term_data_form in ./taxonomy_manager.admin.inc
menu callback for displaying term data form

File

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

Code

function taxonomy_manager_form_term_data($tid) {
  $term = taxonomy_get_term($tid);
  $module_path = drupal_get_path('module', 'taxonomy_manager') . '/';
  $vocabulary = taxonomy_vocabulary_load($term->vid);

  //prevent that title of the fieldset is too long
  $title = $term->name;
  if (drupal_strlen($title) >= 33) {
    $title = drupal_substr($title, 0, 33) . "...";
  }
  $title .= " (" . $term->tid . ")";
  $title = check_plain($title);
  $form['term_data'] = array(
    '#type' => 'fieldset',
    '#title' => $title,
    '#attributes' => array(
      'id' => 'taxonomy-term-data-fieldset',
    ),
    '#tree' => TRUE,
  );
  $form['term_data']['close'] = array(
    '#value' => '<div id="term-data-close"><span title="' . t('Close') . '">&nbsp;&nbsp;&nbsp;&nbsp;</span></div>',
    '#weight' => -100,
  );
  $form['term_data']['tid'] = array(
    '#type' => 'hidden',
    '#value' => $tid,
  );
  $form['term_data']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $term->name,
    '#size' => 35,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#weight' => -20,
  );
  $form['term_data']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#default_value' => $term->description,
    '#cols' => 35,
    '#rows' => 3,
  );
  $synonyms = taxonomy_get_synonyms($term->tid);
  asort($synonyms);
  $form['term_data']['synonyms'] = _taxonomy_manager_form_term_data_lists($term, $synonyms, t('Synonyms'), 'synonym', FALSE);
  $form['term_data']['synonyms']['#tree'] = TRUE;
  $form['term_data']['synonyms']['#weight'] = '50';
  $form['term_data']['relations'] = _taxonomy_manager_form_term_data_lists($term, taxonomy_get_related($term->tid), t('Relations'), 'related');
  $form['term_data']['relations']['#tree'] = TRUE;
  $form['term_data']['relations']['#weight'] = '51';
  $parents = taxonomy_get_parents($term->tid);
  $form['term_data']['parents'] = _taxonomy_manager_form_term_data_lists($term, $parents, t('Parents'), 'parent', TRUE);
  $form['term_data']['parents']['#tree'] = TRUE;
  $form['term_data']['parents']['#weight'] = '52';
  if (module_exists('i18ntaxonomy')) {
    if (i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_TRANSLATE) {
      $translations = i18ntaxonomy_term_get_translations(array(
        'tid' => $term->tid,
      ), FALSE);
      $form['term_data']['translations'] = _taxonomy_manager_form_term_data_translations($term, $translations, t('Translations'), 'translation', TRUE);
      $form['term_data']['translations']['#tree'] = TRUE;
      $form['term_data']['translations']['#weight'] = '53';
      $form['term_data']['language'] = array(
        '#type' => 'select',
        '#title' => t('Language'),
        '#default_value' => isset($term) && !empty($term->language) ? $term->language : '',
        '#options' => array(
          '' => '',
        ) + locale_language_list('name'),
        '#description' => t('This term belongs to a multilingual vocabulary. You can set a language for it.'),
        '#weight' => 54,
      );
    }
  }
  $form['term_data']['weight'] = array(
    '#type' => 'weight',
    '#default_value' => $term->weight,
    '#delta' => 50,
    '#prefix' => '<div id="term-data-weight">',
    '#suffix' => '</div>',
    '#title' => t('Weight'),
    '#weight' => 55,
  );
  $link_img = theme("image", $module_path . "images/link-small.png", "link to term page");
  $form['term_data']['link'] = array(
    '#value' => '<br />' . l($link_img . '&nbsp;' . t('Go to the term page'), taxonomy_term_path($term), array(
      'attributes' => array(
        'rel' => 'tag',
        'title' => strip_tags($term->description),
        'target' => '_blank',
      ),
      'html' => TRUE,
    )),
    '#weight' => '56',
  );
  $form['term_data']['vid'] = array(
    '#type' => 'hidden',
    '#value' => $term->vid,
  );
  return $form;
}