You are here

function taxonomy_manager_double_tree_form in Taxonomy Manager 6.2

Same name and namespace in other branches
  1. 7 taxonomy_manager.admin.inc \taxonomy_manager_double_tree_form()
1 string reference to 'taxonomy_manager_double_tree_form'
taxonomy_manager_menu in ./taxonomy_manager.module
Implementation of hook_menu

File

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

Code

function taxonomy_manager_double_tree_form(&$form_state, $vid1, $vid2, $tid = 0, $filter = NULL) {

  // Check for confirmation forms.
  if (isset($form_state['confirm_delete'])) {
    return taxonomy_manager_term_confirm_delete($form_state, $vid1, $vid2);
  }
  $module_path = drupal_get_path('module', 'taxonomy_manager') . '/';
  $form = taxonomy_manager_form($form_state, $vid1, $tid, $filter);
  drupal_add_js(array(
    'DoubleTree' => array(
      'enabled' => TRUE,
      'url' => url('admin/content/taxonomy_manager/double-tree/edit'),
    ),
  ), 'setting');
  drupal_add_js($module_path . 'js/doubleTree.js');
  $form['disable'] = array(
    '#value' => l(t('Disable Double Tree'), 'admin/content/taxonomy_manager/voc/' . $vid1),
    '#weight' => -100,
  );
  $voc2 = taxonomy_vocabulary_load($vid2);
  $form['vid2'] = array(
    '#type' => 'value',
    "#value" => $vid2,
  );
  $form['taxonomy2'] = array(
    '#tree' => TRUE,
  );
  $form['taxonomy2']['manager'] = array(
    '#type' => 'fieldset',
    '#title' => check_plain($voc2->name),
    '#weight' => 10,
    '#tree' => TRUE,
  );
  $form['taxonomy2']['manager']['top'] = array(
    '#value' => '',
    '#prefix' => '<div class="taxonomy-manager-tree-top">',
    '#suffix' => '</div>',
  );
  if (module_exists('i18ntaxonomy')) {
    if (i18ntaxonomy_vocabulary($vid2) == I18N_TAXONOMY_TRANSLATE) {
      if ($tid) {
        $language = _taxonomy_manager_term_get_lang($tid);
      }
      else {
        $lang = language_default();
        $language = $lang->language;
      }
      $form['taxonomy2']['manager']['top']['language'] = array(
        '#type' => 'select',
        '#title' => t('Language'),
        '#default_value' => $language,
        '#options' => array(
          '' => t('All'),
          'no language' => t('no language'),
        ) + locale_language_list('name'),
        '#attributes' => array(
          'class' => 'language-selector',
        ),
      );
    }
  }
  $form['taxonomy2']['manager']['top']['size'] = array(
    '#value' => '<div class="taxonomy-manager-tree-size">' . theme("image", $module_path . "images/grippie.png", t("Resize tree"), t("Resize tree"), array(
      'class' => "div-grippie",
    )) . '</div>',
  );
  $form['taxonomy2']['manager']['tree'] = array(
    '#type' => 'taxonomy_manager_tree',
    '#vid' => $vid2,
    '#pager' => TRUE,
    '#search_string' => $tid ? NULL : $filter,
    '#language' => isset($language) ? $language : '',
    '#term_to_expand' => $tid,
  );
  $form['double-tree']['operations'] = array(
    '#tree' => TRUE,
  );
  $form['double-tree']['operations']['move_right'] = array(
    '#type' => 'image_button',
    '#value' => 'Move right',
    '#attributes' => array(
      'title' => t('Move right'),
    ),
    '#src' => $module_path . "images/go-next.png",
    //'#executes_submit_callback' => FALSE,
    '#prefix' => '<div class="taxonomy-manager-double-tree-operations-buttons">',
    '#suffix' => '</div>',
  );
  $form['double-tree']['operations']['move_left'] = array(
    '#type' => 'image_button',
    '#value' => 'Move left',
    '#attributes' => array(
      'title' => t('Move left'),
    ),
    '#src' => $module_path . "images/go-previous.png",
    //'#executes_submit_callback' => FALSE,
    '#prefix' => '<div class="taxonomy-manager-double-tree-operations-buttons">',
    '#suffix' => '</div>',
  );

  //switch operations
  if ($vid1 != $vid2) {
    $form['double-tree']['operations']['move_right']['#value'] = 'Switch right';
    $form['double-tree']['operations']['move_right']['#attributes']['title'] = t('Switch selected terms and its children to the right voc');
    $form['double-tree']['operations']['move_left']['#value'] = 'Switch left';
    $form['double-tree']['operations']['move_left']['#attributes']['title'] = t('Switch selected terms and its children to the left voc');
  }
  else {
    if (isset($language)) {
      $form['double-tree']['operations']['add_translation'] = array(
        '#type' => 'image_button',
        '#value' => 'translation',
        '#attributes' => array(
          'title' => t('Add Translation'),
        ),
        '#src' => $module_path . "images/connect.png",
        //'#executes_submit_callback' => FALSE,
        '#prefix' => '<div class="taxonomy-manager-double-tree-operations-buttons">',
        '#suffix' => '</div>',
      );
    }
  }
  return $form;
}