You are here

function taxonomy_manager_export_form in Taxonomy Manager 7

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

form for exporting terms

1 call to taxonomy_manager_export_form()
taxonomy_manager_form in ./taxonomy_manager.admin.inc
defines forms for taxonomy manager interface

File

./taxonomy_manager.admin.inc, line 708

Code

function taxonomy_manager_export_form(&$form, &$form_state, $voc) {
  $form['#attached']['js'][] = array(
    'data' => array(
      'hideForm' => array(
        array(
          'show_button' => 'edit-export-show',
          'hide_button' => 'edit-export-cancel',
          'div' => 'edit-export',
        ),
      ),
    ),
    'type' => 'setting',
  );
  $form['toolbar']['export_show'] = array(
    //'#type' => 'button',
    '#attributes' => array(
      'class' => array(
        'taxonomy-manager-buttons export',
      ),
    ),
    '#value' => t('Export'),
    '#theme' => 'no_submit_button',
  );
  $form['export'] = array(
    '#type' => 'fieldset',
    '#tree' => TRUE,
    '#attributes' => array(
      'style' => 'display:none;',
      'id' => 'edit-export',
    ),
    '#title' => t('Export'),
  );
  $scope_options = array(
    'whole_voc' => t('Whole Vocabulary'),
    'children' => t('Child terms of a selected term'),
    'root_terms' => t('Root level terms only'),
  );
  $form['export']['scope'] = array(
    '#type' => 'radios',
    '#title' => t('Terms to export'),
    '#options' => $scope_options,
    '#default_value' => 'whole_voc',
    '#prefix' => '<div id="taxonomy_manager_export_options">',
    '#suffix' => '</div>',
  );
  $form['export']['depth'] = array(
    '#type' => 'textfield',
    '#title' => t('Depth of tree'),
    '#description' => t('The number of levels of the tree to export. Leave empty to return all levels.'),
    '#size' => 10,
  );
  $format_options = array(
    'term_tree' => t('Term names with hierarchy'),
    'csv' => t('CSV'),
  );
  $help_items[] = t('Term names with hierarchy: Only term names are exported. Child terms are prefixed with dashes. Uses the same format as for mass-import (Add button).');
  $help_items[] = t('CSV: The comma-separated-values export has following columns: voc id | term id | term name | description | parent id 1 | ... | parent id n');
  $form['export']['format'] = array(
    '#type' => 'radios',
    '#title' => t('Format'),
    '#options' => $format_options,
    '#default_value' => 'term_tree',
    '#description' => theme('item_list', array(
      'items' => $help_items,
      'title' => t('Description of formats'),
    )),
  );

  // CSV options
  $form['export']['csv']['delimiter'] = array(
    '#type' => 'textfield',
    '#title' => t('Delimiter for CSV'),
    '#required' => FALSE,
    '#default_value' => ";",
    '#size' => 10,
    '#states' => array(
      'visible' => array(
        ':input[name="export[format]"]' => array(
          'value' => 'csv',
        ),
      ),
    ),
  );
  $wrapper_id = 'taxonomy-manager-export-textarea';
  if (isset($form_state['values']['export']['data'])) {
    $form['export']['data'] = array(
      '#type' => 'textarea',
      '#title' => t('Exported data'),
      '#value' => $form_state['values']['export']['data'],
      '#rows' => 8,
      '#prefix' => '<div id="' . $wrapper_id . '">',
      '#suffix' => '</div>',
    );
  }
  $form['export']['submit'] = array(
    '#prefix' => '<div id="' . $wrapper_id . '"></div>',
    '#type' => 'submit',
    '#attributes' => array(
      'class' => array(
        'taxonomy-manager-buttons',
        'export',
      ),
    ),
    '#value' => t('Export now'),
    '#submit' => array(
      'taxonomy_manager_export_form_submit',
    ),
    '#ajax' => array(
      'callback' => 'taxonomy_manager_export_ajax_callback',
      'method' => 'replaceWith',
      'event' => 'click',
      'wrapper' => $wrapper_id,
      'progress' => array(
        'type' => '',
      ),
    ),
  );
  $form['export']['cancel'] = array(
    //'#type' => 'button',
    '#value' => t('Cancel'),
    '#attributes' => array(
      'class' => array(
        'taxonomy-manager-buttons',
        'cancel',
      ),
    ),
    '#theme' => 'no_submit_button',
  );
}