You are here

function _fillpdf_process_destination_path in FillPDF 7

Same name and namespace in other branches
  1. 6 fillpdf.module \_fillpdf_process_destination_path()
  2. 7.2 fillpdf.module \_fillpdf_process_destination_path()
2 calls to _fillpdf_process_destination_path()
fillpdf_action_save_to_file in ./fillpdf.module
Save a PDF to a file.
fillpdf_save_to_file in ./fillpdf.deprecated.inc
Saves a PDF to a file.

File

./fillpdf.module, line 1944

Code

function _fillpdf_process_destination_path($destination_path, $token_objects, $scheme = 'public') {

  // 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';
  }
  foreach ($types as $type) {
    $destination_path = token_replace($destination_path, array(
      $type => $token_objects[$type],
    ), array(
      'clear' => TRUE,
    ));
  }
  if ($scheme === 'public' && drupal_substr($destination_path, 0, 1) === '/') {

    // No further modifications needed.
  }
  else {

    // Slap on the files directory in front and return it.
    $destination_path = file_stream_wrapper_uri_normalize("{$scheme}://{$destination_path}");
  }
  return $destination_path;
}