You are here

function fillpdf_pdf_link in FillPDF 6

Same name and namespace in other branches
  1. 7.2 fillpdf.module \fillpdf_pdf_link()
  2. 7 fillpdf.module \fillpdf_pdf_link()

Gets a link to the prinable PDF, merged with the passed-in data

Parameters

array/int $nids or $nid, if you pass in one value it will merge with that node.: If array, it will merge with multiple nodes, with later nids overriding previous ones.

array $webforms Array of webforms, of this strucure: array('nid'=>1, 'sid'=>1):

bool $sample True if you want to populate the form with its own field-names (to get a gist of PDF):

1 call to fillpdf_pdf_link()
fillpdf_form_edit in ./fillpdf.admin.inc
Edit existing PDF form

File

./fillpdf.module, line 132
Allows mappings of PDFs to site content

Code

function fillpdf_pdf_link($fid, $nids = null, $webform_arr = null, $sample = false) {
  if (is_array($nids)) {
    $nids_uri = '&nids[]=' . implode('&nids[]=', $nids);
  }
  elseif (isset($nids)) {
    $nids_uri = "&nids[]={$nids}";
  }
  if (is_array($webform_arr)) {
    if ($webform_arr['nid']) {

      // didn't pass in as array(array('nid','sid'))
      $webform_arr = array(
        $webform_arr,
      );
    }
    foreach ($webform_arr as $key => $webform) {
      $webforms_uri .= "&webforms[{$key}][nid]={$webform['nid']}";
    }
    $webforms_uri .= $webform['sid'] ? "&webforms[{$key}][sid]={$webform['sid']}" : "";
  }
  $sample = $sample ? '&sample=true' : '';
  return url('', array(
    'absolute' => true,
  )) . "fillpdf?fid={$fid}{$nids_uri}{$webforms_uri}{$sample}";
}