You are here

function filefield_widget_file_path in FileField 6.3

Determine the widget's files directory

Parameters

$field: A CCK field array.

$account: The user account object to calculate the file path for.

Return value

The files directory path, with any tokens replaced.

2 calls to filefield_widget_file_path()
filefield_save_upload in ./filefield_widget.inc
Given a FAPI element, save any files that may have been uploaded into it.
_filefield_content_generate in ./filefield.devel.inc
Private function used by filefield_content_generate().

File

./filefield_widget.inc, line 156
This file contains CCK widget related functionality.

Code

function filefield_widget_file_path($field, $account = NULL) {
  $account = isset($account) ? $account : $GLOBALS['user'];
  $dest = $field['widget']['file_path'];

  // Replace user level tokens.
  // Node level tokens require a lot of complexity like temporary storage
  // locations when values don't exist. See the filefield_paths module.
  if (module_exists('token')) {
    $dest = token_replace($dest, 'user', $account);
  }

  // Replace nasty characters in the path if possible.
  if (module_exists('transliteration')) {
    module_load_include('inc', 'transliteration');
    $dest_array = array_filter(explode('/', $dest));
    foreach ($dest_array as $key => $directory) {
      $dest_array[$key] = transliteration_clean_filename($directory);
    }
    $dest = implode('/', $dest_array);
  }
  return file_directory_path() . '/' . $dest;
}