You are here

function fillpdf_form_export in FillPDF 6

Same name and namespace in other branches
  1. 7.2 fillpdf.admin.inc \fillpdf_form_export()
  2. 7 fillpdf.admin.inc \fillpdf_form_export()

Export an importable array of PDF field key -> Label, Value mappings. The array key is the PDF field key and the value is another array containing the label and the value (properly keyed).

Parameters

mixed $pdf_form The FillPDF form ID.:

1 string reference to 'fillpdf_form_export'
fillpdf_menu in ./fillpdf.module
Implementation of hook_menu().

File

./fillpdf.admin.inc, line 416
Allows mappings of PDFs to site content

Code

function fillpdf_form_export($pdf_form) {
  if (is_numeric($pdf_form)) {
    $fid = db_fetch_object(db_query("SELECT * FROM {fillpdf_forms} WHERE fid = %d", $pdf_form));
  }
  if (!$fid) {
    drupal_not_found();
    exit;
  }
  $fields = db_query('SELECT * FROM {fillpdf_fields} WHERE fid = %d', $fid->fid);
  $export_array = array();
  while ($field = db_fetch_object($fields)) {
    $export_array[$field->pdf_key] = array(
      'label' => $field->label,
      'value' => $field->value,
      'replacements' => $field->replacements,
    );
  }
  if (function_exists('json_decode')) {
    $fillpdf_code = json_encode($export_array);
  }
  else {
    $fillpdf_code = serialize($export_array);
  }
  return drupal_get_form('fillpdf_export_form', $fillpdf_code);
}