You are here

function term_merge_action_form in Term Merge 7

Generate the configuration form for action "Term merge".

File

./term_merge.module, line 260
Provide functionality for merging taxonomy terms one into another.

Code

function term_merge_action_form($context, &$form_state) {
  $term_branch_value = isset($form_state['selection']) && is_array($form_state['selection']) ? $form_state['selection'] : array();
  $vocabulary = FALSE;
  if (!empty($term_branch_value)) {
    $vocabulary = db_select('taxonomy_term_data', 't')
      ->fields('t', array(
      'vid',
    ))
      ->condition('tid', reset($term_branch_value))
      ->execute()
      ->fetchField();
    $vocabulary = taxonomy_vocabulary_load($vocabulary);
  }
  if ($vocabulary) {
    $form = array();
    module_load_include('inc', 'term_merge', 'term_merge.pages');
    term_merge_form_base($form, $form_state, $vocabulary, $term_branch_value);

    // The "step" merge parameter does not make sense here, since the batch will
    // be invoked out of Term Merge scope.
    $form['step']['#access'] = FALSE;
  }
  else {
    $form['vocabulary_missing'] = array(
      '#markup' => '<b>' . t('Oops, something did not seem to go right. Term merge module cannot determine within which vocabulary merge is about to happen. You might want to report it to the <a href="@url">Term Merge issue queue</a>.', array(
        '@url' => 'https://www.drupal.org/project/issues/term_merge',
      )) . '</b>',
    );
  }
  return $form;
}