diff --git a/file_entity.admin.inc b/file_entity.admin.inc index 11d3589..d06e7b3 100644 --- a/file_entity.admin.inc +++ b/file_entity.admin.inc @@ -1083,6 +1083,23 @@ function file_entity_settings_form($form, &$form_state) { '#element_validate' => array('_file_generic_settings_max_filesize'), ); + $form['file_entity_default_file_directory'] = array( + '#type' => 'textfield', + '#title' => t('Default file directory'), + '#default_value' => variable_get('file_entity_default_file_directory', ''), + '#maxlength' => NULL, + ); + if (module_exists('token')) { + $form['file_entity_default_file_directory']['#description'] = t('Optional subdirectory within the upload destination where files will be stored if the file is uploaded through the file entity overview page and the directory is not specified otherwise. Do not include preceding or trailing slashes. This field supports tokens. Suggest using: [current-date:custom:Y]/[current-date:custom:m]/[current-date:custom:d]'); + $form['file_entity_default_file_directory']['tokens'] = array( + '#theme' => 'token_tree', + '#dialog' => TRUE, + ); + } + else { + $form['file_entity_default_file_directory']['#description'] = t('Optional subdirectory within the upload destination where files will be stored if the file is uploaded through the file entity overview page and the directory is not specified otherwise. Do not include preceding or trailing slashes.'); + } + $form['file_entity_default_allowed_extensions'] = array( '#type' => 'textfield', '#title' => t('Default allowed file extensions'), diff --git a/file_entity.install b/file_entity.install index 6f07b91..c2cc7dd 100644 --- a/file_entity.install +++ b/file_entity.install @@ -245,6 +245,7 @@ function file_entity_uninstall() { variable_del('file_entity_file_upload_wizard_skip_file_type'); variable_del('file_entity_file_upload_wizard_skip_scheme'); variable_del('file_entity_file_upload_wizard_skip_fields'); + variable_del('file_entity_default_file_directory'); // Remove any items from the file type queue if still there. DrupalQueue::get('file_entity_type_determine')->deleteQueue(); diff --git a/file_entity.pages.inc b/file_entity.pages.inc index c4f9005..6848a70 100644 --- a/file_entity.pages.inc +++ b/file_entity.pages.inc @@ -511,7 +511,7 @@ function file_entity_add_upload_submit($form, &$form_state) { function file_entity_upload_destination_uri(array $params, array $data = array()) { $params += array( 'uri_scheme' => file_default_scheme(), - 'file_directory' => '', + 'file_directory' => variable_get('file_entity_default_file_directory', ''), ); $destination = trim($params['file_directory'], '/');