You are here

function elfinder_parse_path_tokens in elFinder file manager 7

Same name and namespace in other branches
  1. 8.2 elfinder.module \elfinder_parse_path_tokens()
  2. 6.2 elfinder.module \elfinder_parse_path_tokens()
  3. 6 elfinder.module \elfinder_parse_path_tokens()
  4. 7.3 elfinder.module \elfinder_parse_path_tokens()
  5. 7.2 elfinder.module \elfinder_parse_path_tokens()

replace path tokens to its values (%uid, %user, etc)

3 calls to elfinder_parse_path_tokens()
elfinder_admin_form_validate in inc/elfinder.admin.inc
Validate form data
elfinder_file_directory_path in ./elfinder.module
path to files directory
elfinder_file_directory_url in ./elfinder.module
files directory url

File

./elfinder.module, line 636

Code

function elfinder_parse_path_tokens($unparsed_path) {
  global $user, $language;
  $path = $unparsed_path;
  $uname = isset($user->name) ? preg_replace('/[[:^alnum:]]+/', '', $user->name) : '';
  $langCode = isset($language->language) ? $language->language : 'en';
  $path_tokens = array(
    '%uid' => $user->uid,
    '%name' => $uname,
    '%files' => elfinder_default_directory_path(),
    '%lang' => $langCode,
  );
  $path = strtr($path, $path_tokens);
  if (function_exists('token_replace')) {
    $node = node_load($user->uid);
    $path = token_replace($path, array(
      'node' => $node,
      'user' => $user,
    ));
  }
  return $path;
}