You are here

function _filefield_paths_get_values in File (Field) Paths 6

Same name and namespace in other branches
  1. 5 filefield_paths.module \_filefield_paths_get_values()
1 call to _filefield_paths_get_values()
filefield_paths_process_string in ./filefield_paths.module
Process and cleanup strings.

File

./filefield_paths.module, line 677
Contains core functions for the FileField Paths module.

Code

function _filefield_paths_get_values($type, $object, $pathauto = FALSE) {
  switch ($type) {
    case 'node':
      $full = token_get_values($type, $object, TRUE);
      break;
    case 'field':
      $all = filefield_paths_token_values($type, $object);
      if (function_exists('filefield_token_values')) {
        $all = array_merge(filefield_token_values($type, $object), $all);
      }
      $full = new stdClass();
      $full->tokens = array_keys($all);
      $full->values = array_values($all);
      break;
  }
  $full->tokens = token_prepare_tokens($full->tokens);
  if ($pathauto) {
    $temp = clone $full;

    // Strip square brackets from tokens for Pathauto.
    foreach ($temp->tokens as &$token) {
      $token = trim($token, "[]");
    }
    if (!function_exists('pathauto_clean_token_values')) {
      module_load_include('inc', 'pathauto');
    }
    $full->values = pathauto_clean_token_values($temp);
  }
  return array(
    'tokens' => $full->tokens,
    'values' => $full->values,
  );
}