function _filefield_paths_get_values in File (Field) Paths 5
Same name and namespace in other branches
- 6 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 560 - Adds extra functionality to FileFields Path settings.
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, "[]");
}
$full->values = pathauto_clean_token_values($temp);
}
// Temporary fix: Remove double slashes from token values.
// TODO: Remove when #420856 is committed to Pathauto.
foreach ($full->values as &$value) {
$value = str_replace('//', '/', $value);
}
return array(
'tokens' => $full->tokens,
'values' => $full->values,
);
}