function filefield_source_attach_settings in FileField Sources 6
Same name and namespace in other branches
- 7 sources/attach.inc \filefield_source_attach_settings()
Implements hook_filefield_source_settings().
File
- sources/
attach.inc, line 43 - A FileField extension to allow use of files within a server directory.
Code
function filefield_source_attach_settings($op, $field) {
$return = array();
if ($op == 'form') {
$return['source_attach'] = array(
'#title' => t('File attach settings'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('File attach allows for selecting a file from a directory on the server, commonly used in combination with FTP.') . ' <strong>' . t('This file source will ignore file size checking when used.') . '</strong>',
'#element_validate' => array(
'_filefield_source_attach_file_path_validate',
),
'#weight' => 3,
);
$return['source_attach']['filefield_source_attach_path'] = array(
'#type' => 'textfield',
'#title' => t('File attach path'),
'#default_value' => isset($field['filefield_source_attach_path']) ? $field['filefield_source_attach_path'] : 'file_attach',
'#size' => 60,
'#maxlength' => 128,
'#description' => t('The directory within the <em>File attach location</em> that will contain attachable files.'),
);
$return['source_attach']['filefield_source_attach_absolute'] = array(
'#type' => 'radios',
'#title' => t('File attach location'),
'#options' => array(
0 => t('Within the files directory'),
1 => t('Absolute server path'),
),
'#default_value' => isset($field['filefield_source_attach_absolute']) ? $field['filefield_source_attach_absolute'] : 0,
'#description' => t('The <em>File attach path</em> may be with the files directory (%file_directory) or from the root of your server. If an absolute path is used and it does not start with a "/" your path will be relative to your site directory: %realpath.', array(
'%file_directory' => file_directory_path(),
'%realpath' => realpath('./'),
)),
);
$return['source_attach']['filefield_source_attach_mode'] = array(
'#type' => 'radios',
'#title' => t('Attach method'),
'#options' => array(
'move' => t('Move the file directly to the final location'),
'copy' => t('Leave a copy of the file in the attach directory'),
),
'#default_value' => isset($field['filefield_source_attach_mode']) ? $field['filefield_source_attach_mode'] : 'move',
);
$return['source_attach']['tokens'] = array(
'#type' => 'markup',
'#value' => theme('token_help', 'user'),
);
}
elseif ($op == 'save') {
$return[] = 'filefield_source_attach_path';
$return[] = 'filefield_source_attach_absolute';
$return[] = 'filefield_source_attach_mode';
}
return $return;
}