You are here

function fillpdf_generate_mappings in FillPDF 7.2

Same name and namespace in other branches
  1. 7 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. The array key is the PDF field key and the value is another array containing the label and the value (properly keyed).

File

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

Code

function fillpdf_generate_mappings($pdf_form, $skip_encoding = FALSE) {
  if (is_numeric($pdf_form)) {
    $fid = db_query("SELECT * FROM {fillpdf_forms} WHERE fid = :fid", array(
      ':fid' => $pdf_form,
    ))
      ->fetch();
  }
  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;
}