function flashnode_import_form in Flash Node 5.6
Same name and namespace in other branches
- 5.3 flashnode.module \flashnode_import_form()
- 6.3 flashnode.import.inc \flashnode_import_form()
- 6.2 flashnode.import.inc \flashnode_import_form()
Form definition function to show list of files available for import
1 string reference to 'flashnode_import_form'
- flashnode_import in ./
flashnode.module - Generate Flash import form The returned form varies depending on the state. It presents either a list of files available for import, or a confirmation form if some files have been selected for import
File
- ./
flashnode.module, line 1163
Code
function flashnode_import_form() {
$form['help'] = array(
'#value' => t('
<p>This feature can be used to import files directly and create Flash nodes from them. This can be useful for importing batches of files that have been uploaded to the server, or to import files that are too large to be uploaded via the node creation form. Note that files that are imported do not respect file size limitations that would apply to files uploaded via the node form. Nodes that are created by this import function are set to be unpublished.</p>
<p>The import function will scan the %directory directory and sub-directories to locate files for import.</p>', array(
'%directory' => base_path() . file_create_path(variable_get('flashnode_default_path', 'flash')),
)),
);
// Get the list of files that aren't in the database
$filesnotindb = _flashnode_filesnotindb();
// Output count of files not in the database
if ($filesnotindb) {
$form['count'] = array(
'#value' => format_plural(count($filesnotindb), '1 file found.', '@count files found.') . t(' Select the file(s) you want to import, then click \'Import\'.'),
);
}
else {
$form['count'] = array(
'#value' => t('No files were found for import.'),
);
}
// Process each result in turn and build check box list
$files = array();
foreach ($filesnotindb as $file) {
$files[$file] = '';
// Can't use file_create_url as the links fail if the site uses private transfers so force a public url instead
$form['file'][$file] = array(
'#value' => l(str_replace(file_create_path(variable_get('flashnode_default_path', 'flash')) . '/', '', $file), $GLOBALS['base_url'] . '/' . $file),
);
}
// Add list of files to checkboxes
$form['files'] = array(
'#type' => 'checkboxes',
'#options' => $files,
);
// Action button
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Import'),
);
return $form;
}