/usr/share/drupal6/modules/filefield/filefield.token.inc is in drupal6-mod-filefield 3.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | <?php
/**
* @file
* Token hook implementations. Included if token.module is installed.
*/
/**
* Implementation of hook_token_list().
*
* Provide a user readable list of FileField tokens.
*/
function filefield_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
$tokens = array();
$tokens['file']['filefield-fid'] = t('File ID');
$tokens['file']['filefield-description'] = t('File description');
$tokens['file']['filefield-filename'] = t('File name');
$tokens['file']['filefield-filepath'] = t('File path');
$tokens['file']['filefield-fileurl'] = t('File URL');
$tokens['file']['filefield-filemime'] = t('File MIME type');
$tokens['file']['filefield-filesize'] = t('File size (in bytes)');
$tokens['file']['filefield-filesize_formatted'] = t('File size (pretty printed)');
$tokens['file']['filefield-view'] = t('Fully formatted HTML file tag');
$tokens['file']['filefield-onlyname'] = t('File name without extension');
$tokens['file']['filefield-extension'] = t('File extension');
return $tokens;
}
}
/**
* Implementation of hook_token_values().
*
* Provide the token values for a given file item.
*/
function filefield_token_values($type, $object = NULL) {
$tokens = array();
if ($type == 'field' && isset($object[0]['fid'])) {
$item = $object[0];
$tokens['filefield-fid'] = $item['fid'];
$tokens['filefield-description'] = isset($item['data']['description']) ? check_plain($item['data']['description']) : '';
$tokens['filefield-filename'] = check_plain($item['filename']);
$tokens['filefield-filepath'] = check_plain($item['filepath']);
$tokens['filefield-fileurl'] = file_create_url($item['filepath']);
$tokens['filefield-filemime'] = $item['filemime'];
$tokens['filefield-filesize'] = $item['filesize'];
$tokens['filefield-filesize_formatted'] = format_size($item['filesize']);
$tokens['filefield-view'] = $item['view'];
$double_extensions = array('tar.gz', 'tar.bz2');
foreach ($double_extensions as $ext) {
$length = strlen($ext) + 1;
$filename = drupal_strtolower($item['filename']);
$pos = strrpos($filename, '.'. $ext);
if ($pos !== FALSE && strlen($filename) - $pos == $length) {
$tokens['filefield-onlyname'] = substr($item['filename'], 0, $pos);
$tokens['filefield-extension'] = $ext;
break;
}
}
if (!isset($tokens['filefield-extension'])) {
$info = pathinfo($item['filename']);
$tokens['filefield-onlyname'] = basename($info['basename'], '.'. $info['extension']);
$tokens['filefield-extension'] = $info['extension'];
}
}
return $tokens;
}
|