function filefield_source_attach_settings in FileField Sources 7
Same name and namespace in other branches
- 6 sources/attach.inc \filefield_source_attach_settings()
Implements hook_filefield_source_settings().
File
- sources/
attach.inc, line 44 - A FileField extension to allow use of files within a server directory.
Code
function filefield_source_attach_settings($op, $instance) {
$return = array();
if ($op == 'form') {
$settings = $instance['widget']['settings']['filefield_sources'];
$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']['path'] = array(
'#type' => 'textfield',
'#title' => t('File attach path'),
'#default_value' => $settings['source_attach']['path'],
'#size' => 60,
'#maxlength' => 128,
'#description' => t('The directory within the <em>File attach location</em> that will contain attachable files.'),
);
if (module_exists('token')) {
$return['source_attach']['tokens'] = array(
'#theme' => 'token_tree',
'#token_types' => array(
'user',
),
);
}
$return['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' => $settings['source_attach']['absolute'],
'#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' => drupal_realpath(file_default_scheme() . '://'),
'%realpath' => realpath('./'),
)),
);
$return['source_attach']['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($settings['source_attach']['attach_mode']) ? $settings['source_attach']['attach_mode'] : 'move',
);
}
elseif ($op == 'save') {
$return['source_attach']['path'] = 'file_attach';
$return['source_attach']['absolute'] = 0;
$return['source_attach']['attach_mode'] = 'move';
}
return $return;
}