You are here

function taxonomy_manager_merge_form in Taxonomy Manager 5

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.admin.inc \taxonomy_manager_merge_form()
  2. 6 taxonomy_manager.admin.inc \taxonomy_manager_merge_form()

form for merging terms

1 call to taxonomy_manager_merge_form()
taxonomy_manager_form in ./taxonomy_manager.module
defines forms for taxonomy manager interface

File

./taxonomy_manager.module, line 449
Taxonomy Manager

Code

function taxonomy_manager_merge_form($voc) {
  drupal_add_js(array(
    'hideForm' => array(
      'show_button' => 'edit-merge-show',
      'hide_button' => 'edit-merge-cancel',
      'div' => 'merge-form',
    ),
  ), 'setting');
  $form = array();
  $description .= t("The selected terms get merged into one term. \n    This resulting merged term can either be an exisiting term or a completely new term. \n    The selected terms will automatically get synomyms of the merged term and will be deleted afterwards.");
  $form['merge'] = array(
    '#type' => 'fieldset',
    '#tree' => TRUE,
    '#title' => t('Merging of terms'),
    '#description' => $description,
    '#prefix' => '<div id="merge-form">',
    '#suffix' => '</div>',
  );
  $form['merge']['main_term'] = array(
    '#type' => 'textfield',
    '#title' => t('Resulting merged term'),
    '#required' => FALSE,
    '#autocomplete_path' => 'taxonomy/autocomplete/' . $voc->vid,
  );
  $options = array();
  switch ($voc->hierarchy) {

    //multiple hierarchy
    case 2:
      $options['collect_parents'] = t('Collect all parents of selected terms an add it to the merged term');

    //single hierarchy
    case 1:
      $options['collect_children'] = t('Collect all children of selected terms an add it to the merged term');
      break;
  }
  if ($voc->relations) {
    $options['collect_relations'] = t('Collect all relations of selected terms an add it to the merged term');
  }
  if (count($options) > 0) {
    $form['merge']['options'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Options'),
      '#options' => $options,
    );
  }
  $form['merge']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Merge'),
    '#attributes' => array(
      'class' => 'taxonomy-manager-buttons merge',
    ),
  );
  $form['merge']['cancel'] = array(
    '#type' => 'button',
    '#value' => t('Cancel'),
    '#attributes' => array(
      'class' => 'taxonomy-manager-buttons cancel',
    ),
    '#theme' => 'no_submit_button',
  );
  return $form;
}