function tripal_bulk_loader_import_export_template_form

1.x tripal_bulk_loader.admin.templates.inc tripal_bulk_loader_import_export_template_form($form_state = NULL, $mode)

Import/Export Template Form

On export, simply selects the serialized array from the db for a given template and presents it to the user. On import, a serialized template array and a name is supplied and a template record is created.

@todo Make array presented to the user more readable. (ie: unserialize and print to the screen)

Parameters

$form_state: The values and storage for the form

$mode: Either 'import' or 'export' to indicate which function is being performed

Return value

A form array to be rendered by drupal_get_form

Related topics

1 string reference to 'tripal_bulk_loader_import_export_template_form'
tripal_bulk_loader_menu in tripal_bulk_loader/tripal_bulk_loader.module
Implements hook_menu

File

tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc, line 573
All functions in this file pertain to administrative management of bulk loader templates

Code

function tripal_bulk_loader_import_export_template_form($form_state = NULL, $mode) {
  $form = array();

  $form['mode'] = array(
    '#type' => 'hidden',
    '#value' => $mode,
  );

  if (preg_match('/import/', $mode)) {
    $form['new_template_name'] = array(
      '#type' => 'textfield',
      '#title' => 'Template Name',
      '#weight' => 1,
    );
  }
  elseif (preg_match('/export/', $mode)) {
    $sql = "SELECT * FROM {tripal_bulk_loader_template}";
    $resource = db_query($sql);
    $templates = array();
    $templates[''] = 'Select a Template';
    while ($r = db_fetch_object($resource)) {
      $templates[$r->template_id] = $r->name;
    }

    $form['template_id'] = array(
      '#title' => t('Template'),
      '#description' => t('Please select the template you would like to edit.'),
      '#type' => 'select',
      '#options' => $templates,
      '#default_value' => $form_state['storage']['template_id'],
      '#weight' => 0,
      '#required' => TRUE,
    );
  }

  $form['template_array'] = array(
    '#type' => 'textarea',
    '#title' => 'Template Array',
    '#default_value' => $form_state['storage']['template_array'],
    '#description' => t('Use this serialized array for import.'),
    '#rows' => 15,
    '#weight' => 5,

  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
    '#weight' => 10,
  );

  return $form;
}