You are here

function fillpdf_generate_mappings in FillPDF 7

Same name and namespace in other branches
  1. 7.2 fillpdf.admin.inc \fillpdf_generate_mappings()
2 calls to fillpdf_generate_mappings()
fillpdf_form_edit_submit in ./fillpdf.admin.inc
Submit Edit or Delete for existing PDF form.
fillpdf_form_export in ./fillpdf.admin.inc
Export an importable array of PDF field key -> Label, Value mappings.

File

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

Code

function fillpdf_generate_mappings($pdf_form, $skip_encoding = FALSE) {
  if (is_numeric($pdf_form)) {
    $fid = fillpdf_load($pdf_form, FALSE, FALSE);
  }
  else {
    $fid = $pdf_form;
  }
  if (!$fid) {
    drupal_not_found();
    drupal_exit();
  }
  $fields = db_query('SELECT * FROM {fillpdf_fields} WHERE fid = :fid', array(
    ':fid' => $fid->fid,
  ));
  $export_array = array();
  foreach ($fields as $field) {
    $export_array[$field->pdf_key] = (array) $field;
  }
  return $skip_encoding === FALSE ? json_encode($export_array) : $export_array;
}