function media_file_browser_local_files in D7 Media 6
Builds the local directory file browser form @TODO build admin interface to set the location of the local directory @TODO build the ahah callbacks for browsing the directories @TODO abstract this so that all file browsing functions can use the same kind of form
Parameters
unknown_type $files:
unknown_type $title:
Return value
unknown
1 string reference to 'media_file_browser_local_files'
- media_file_browser_media_register in media_file_browser/
media_file_browser.module - Implementation of hook_media_register
File
- media_file_browser/
media_file_browser.module, line 85
Code
function media_file_browser_local_files($files, $title = NULL) {
$pattern = ".*\$";
// @TODO how do we set the local file directory
$path = file_directory_path();
$dir_files = file_scan_directory($path, $pattern, array(), null, false);
foreach ($dir_files as $a_file) {
if (is_dir($a_file->filename)) {
$display_files[$a_file->filename . '/'] = $a_file->basename . ' (directory)';
}
else {
$display_files[$a_file->filename] = $a_file->basename;
}
}
// build the radio form element that the admin can choose from to process a
// file, option is tied to AHAH.
$form['files']['data'] = array(
'#type' => 'select',
'#default_value' => $output_file_id ? $output_file_id : $form_state['values']['files']['data'],
'#options' => $display_files,
'#suffix' => '<div id="media_files_directory"></div>',
'#ahah' => array(
'event' => 'change',
'path' => 'media_browser/files',
'wrapper' => 'media_files_directory',
'method' => 'replace',
),
);
return array(
t('Local Files') => array(
t('Files') => $form,
),
);
}