function tripal_bulk_loader_export_template_form

2.x tripal_bulk_loader.admin.templates.inc tripal_bulk_loader_export_template_form($form, &$form_state)
3.x tripal_bulk_loader.admin.templates.inc tripal_bulk_loader_export_template_form($form, &$form_state)

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

Return value

A form array to be rendered by drupal_get_form

Related topics

1 string reference to 'tripal_bulk_loader_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 801
All functions in this file pertain to administrative management of bulk loader templates

Code

function tripal_bulk_loader_export_template_form($form, &$form_state) {

  // set the breadcrumb
  $breadcrumb = array();
  $breadcrumb[] = l('Home', '<front>');
  $breadcrumb[] = l('Administration', 'admin');
  $breadcrumb[] = l('Tripal', 'admin/tripal');
  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
  drupal_set_breadcrumb($breadcrumb);

  $template_id = $form_state['build_info']['args'][0];
  $form_state['storage']['template_id'] = $template_id;
  if ($template_id > 0) {
    $result = db_select('tripal_bulk_loader_template', 't')
      ->fields('t')
      ->condition('t.template_id', $template_id)
      ->execute();
    $template = $result->fetchObject();
    $form_state['storage']['template_array'] = $template->template_array;
  }

  $form['name'] = array(
    '#type' => 'item',
    '#title' => 'Template Name',
    '#markup' => $template->name,
  );

  $form['template_array'] = array(
    '#type' => 'textarea',
    '#title' => 'Export',
    '#default_value' => json_encode(unserialize($template->template_array)),
    '#description' => t('Use this JSON array for import of this bulk loader template into another Tripal site.'),
    '#rows' => 30,
    '#weight' => 5,

  );

  return $form;
}