Index: filebrowser.module
===================================================================
--- filebrowser.module	(revision 2594)
+++ filebrowser.module	(working copy)
@@ -4,8 +4,8 @@
  *    Author : Yoran Brault
  *    eMail  : yoran.brault@bad_arnumeral.fr (remove bad_ before sending an email)
  *    Site   : http://www.arnumeral.fr/node/5
- * 
- * Original credit for susurrus (http://drupal.org/user/118433). 
+ *
+ * Original credit for susurrus (http://drupal.org/user/118433).
  *
  * "filebrowser" is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -22,7 +22,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
- 
+
 define(FILEBROWSER_CREATE_DIRECTORY_LISTING, 'create directory listings');
 define(FILEBROWSER_DELETE_OWN_DIRECTORY_LISTINGS, 'delete own directory listings');
 define(FILEBROWSER_DELETE_ANY_DIRECTORY_LISTINGS, 'delete any directory listings');
@@ -67,14 +67,14 @@
 }
 
 /**
- * return true if the string end with a specific string. 
+ * return true if the string end with a specific string.
  */
 function _filebrowser_ends_with($str, $sub) {
   return (substr($str, strlen($str) - strlen($sub)) == $sub);
 }
 
 function _filebrowser_current_full_path($node) {
-	return $node->file_path . $node->relative_path;
+	return _filebrowser_get_node_file_path($node) . $node->relative_path;
 }
 
 /**
@@ -145,6 +145,15 @@
   return trim($node->hidden_files) != '' && filebrowser_match_path($file, $node->hidden_files);
 }
 
+function _filebrowser_get_node_file_path(&$node)
+{
+	$result=$node->file_path;
+	if (module_exists("token")) {
+		$result=token_replace($result, $type = 'global', $object = NULL, $leading = '[', $trailing = ']');
+	}
+	return $result;
+}
+
 /**
  * Load data from current path.
  */
@@ -188,7 +197,7 @@
   }
 
   // retreive paths
-  $full_path= $node->file_path.$relative_path;
+  $full_path= _filebrowser_get_node_file_path($node).$relative_path;
   $is_subdir= $relative_path != '/';
   logger_error("file_browser", "browsing $relative_path");
   // If we shouldn't be in a subdirectory, redirect to root_dir.
@@ -260,7 +269,7 @@
       // File record building
       $files[$file_name]= array (
         'name' => $file_name,
-        'display-name' => $file_name,
+		'display-name' => mb_convert_encoding($file_name, "UTF-8","ISO-8859-1"),
         'path' => $full_file_path,
         'relative_path' => $relative_path.$file_name,
         'status' => MARK_READ,
@@ -307,8 +316,8 @@
       }
 
       if (is_file($full_file_path)) {
-        $files[$file_name]['url']= $node->private_downloads ? 
-        	url('filebrowser_download/'.$node->nid, array('query'=>"path=".$relative_path.$file_name)) : 
+        $files[$file_name]['url']= $node->private_downloads ?
+        	url('filebrowser_download/'.$node->nid, array('query'=>"path=".$relative_path.$file_name)) :
         	$base_url."/".$full_path.$file_name;
         $files_count++;
       } else {
@@ -344,7 +353,7 @@
 }
 
 /**
- * Node form settings. 
+ * Node form settings.
  */
 function filebrowser_form(& $node, & $param) {
   $type= node_get_types('type', $node);
@@ -356,21 +365,21 @@
     '#collapsed' => FALSE,
     '#weight' => -10
   );
-  
+
   $form['folder_description']['title']= array (
     '#type' => 'textfield',
     '#title' => check_plain($type->title_label),
     '#default_value' => !empty ($node->title) ? $node->title : '',
     '#required' => TRUE,
   );
-  
+
   $form['folder_description']['body_filter']['body']= array (
     '#type' => 'textarea',
     '#title' => t('Description'),
     '#description' => t("This will overide metainformations from .bbs or .ion files."),
     '#default_value' => $node->body,
     '#rows' => 5,
-    '#weight' => -9
+    '#weight' => -10
   );
   $form['folder_description']['body_filter']['format']= filter_form($node->format);
 
@@ -381,8 +390,23 @@
     '#description' => t('This can be an absolute path or should be relative to the Drupal root directory.'),
     '#default_value' => isset ($node->file_path) ? check_plain($node->file_path) : '',
     '#required' => TRUE,
-    '#weight' => -8
+    '#weight' => -9
   );
+
+  if (module_exists('token')) {
+    $form['folder_description']['token_help'] = array(
+      '#title' => t('Replacement patterns'),
+      '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#weight' => -8,
+//      '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
+      );
+
+    $form['folder_description']['token_help']['help'] = array(
+      '#value' => theme('token_help', 'node'),
+      );
+  }
     $form['folder_description']['private_downloads']= array (
     '#type' => 'checkbox',
     '#title' => t("Use private downloads"),
@@ -390,7 +414,7 @@
     '#default_value' => isset ($node->private_downloads) ? $node->private_downloads : '',
     '#weight' => -7
   );
-  
+
 
   $form['folder_rights'] = array (
     '#type' => 'fieldset',
@@ -399,7 +423,7 @@
     '#collapsed' => TRUE,
     '#weight' => -7
   );
-  
+
 
   $form['folder_rights']['explore_subdirs']= array (
     '#type' => 'checkbox',
@@ -422,7 +446,7 @@
     '#default_value' => isset ($node->filtered_files) ? $node->filtered_files : '',
     '#weight' => -3
   );
-  
+
   $form['folder_uploads'] = array (
     '#type' => 'fieldset',
     '#title' => t('Files Upload'),
@@ -437,7 +461,7 @@
     '#default_value' => isset ($node->allow_files_upload) ? $node->allow_files_upload : false,
     '#weight' => -2
   );
-    
+
   $form['folder_uploads']['allowed_uploaded_files']= array (
     '#type' => 'textarea',
     '#title' => t('Allows files for uploading'),
@@ -541,14 +565,17 @@
   }
 
   // Verify the file system location & check that it's a directory.
-  if (!is_dir($node->file_path)) {
-    form_set_error('file_path', t('You must specify a valid directory.'));
+  $path=_filebrowser_get_node_file_path($node);
+  if (!is_dir($path)) {
+    form_set_error('file_path', t('The directory %dir is not a valid directory.', array (
+      '%dir' => $path
+    )));
   }
 
   // Check that it's readable.
-  if (!is_readable($node->file_path)) {
+  if (!is_readable($path)) {
     form_set_error('file_path', t('The directory %dir is not readable.', array (
-      '%dir' => $node->file_path
+      '%dir' => $path
     )));
   }
 }
@@ -751,7 +778,7 @@
 }
 
 /**
- * Upload form. 
+ * Upload form.
  */
 function filebrowser_upload_form($form_state, $node) {
   $form= array ();
@@ -804,7 +831,7 @@
 function filebrowser_upload_form_validate($form, $form_state) {
   //	print "<pre style='background-color:white'>";
   //	print_r($form_state);
-  //	print "</pre>";	
+  //	print "</pre>";
   $file_name= $_FILES['files']['name']['filebrowser_upload'];
   if (!empty ($form_state['values']['filebrowser_file_name'])) {
     $file_name= $form_state['values']['filebrowser_file_name'];
