function Xmodule_builder_page_download in Module Builder 7
Same name and namespace in other branches
- 6.2 module_builder.module \Xmodule_builder_page_download()
Module form: 'download' step. Download the files.
File
- ./
module_builder.module, line 417 - Builds scaffolding for custom modules.
Code
function Xmodule_builder_page_download($form, $form_values) {
$file_content = '';
$file_ext = '.txt';
if ($form_values['op'] == t('Download module')) {
$file_content = $form_values['module_code'];
$file_ext = '.module';
}
elseif ($form_values['op'] == t('Download info file')) {
$file_content = $form_values['module_info'];
$file_ext = '.info';
}
else {
form_set_error('Problem creating file for download.');
drupal_goto('module_builder');
}
if (strlen($file_content) > 0) {
$file_name = $form_values['module_root_name'] . $file_ext;
header("Content-disposition: attachment; filename={$file_name}");
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . strlen($file_content));
header('Pragma: no-cache');
header('Expires: 0');
echo $file_content;
exit;
}
}