Issue #1027184 by Aron Novak: Expose file download URL as a token.
[project/filefield.git] / filefield.token.inc
index b2e4b70..e850186 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-// $Id$
 
 /**
  * @file
@@ -18,6 +17,7 @@ function filefield_token_list($type = 'all') {
     $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)');
@@ -41,6 +41,7 @@ function filefield_token_values($type, $object = NULL) {
     $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']);
@@ -58,7 +59,7 @@ function filefield_token_values($type, $object = NULL) {
     }
     if (!isset($tokens['filefield-extension'])) {
       $info = pathinfo($item['filename']);
-      $tokens['filefield-onlyname'] = $info['filename'];
+      $tokens['filefield-onlyname'] = basename($info['basename'], '.'. $info['extension']);
       $tokens['filefield-extension'] = $info['extension'];
     }
   }