You are here

function _fillpdf_process_destination_path in FillPDF 6

Same name and namespace in other branches
  1. 7.2 fillpdf.module \_fillpdf_process_destination_path()
  2. 7 fillpdf.module \_fillpdf_process_destination_path()
1 call to _fillpdf_process_destination_path()
fillpdf_merge_pdf in ./fillpdf.module
Constructs a page from scratch (pdf content-type) and sends it to the browser or saves it, depending on if a custom path is configured or not.

File

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

Code

function _fillpdf_process_destination_path($destination_path, $token_objects) {

  // Two formats of $destination_path are possible:
  //   1) /absolute/path/to/directory
  //   2) path/below/files/directory
  // So, first: Does it begin with a forward slash?
  $orig_path = $destination_path;
  $destination_path = trim($orig_path);

  // Replace any applicable tokens
  $types = array();
  if (isset($token_objects['node'])) {
    $types[] = 'node';
  }
  elseif (isset($token_objects['webform'])) {
    $types[] = 'webform';
  }
  if (substr($destination_path, 0, 1) == '/') {

    // No further modifications needed
  }
  else {

    // Slap on the files directory in front and return it
    $destination_path = file_directory_path() . "/{$destination_path}";
  }
  foreach ($types as $type) {
    $destination_path = token_replace($destination_path, $type, $token_objects[$type]);
  }
  return $destination_path;
}