--- module_builder.module 2006-04-03 13:07:26.000000000 +0000 +++ module_builder.module.new 2006-04-03 15:31:15.000000000 +0000 @@ -286,6 +286,11 @@ ksort($form['hooks'][$hook_group]); } + $form['download'] = array( + '#type' => 'checkbox', + '#title' => 'download file', + ); + $form['op'] = array( '#type' => 'submit', '#value' => t('Submit'), @@ -459,6 +464,17 @@ // Prepare final output $output = $header . check_plain($output) . $footer; + if ($edit['download']){ + $filecontent=$output; + $downloadfile=$edit['module_root_name'].".module"; + header("Content-disposition: attachment; filename=$downloadfile"); + header("Content-Type: application/force-download"); + header("Content-Transfer-Encoding: binary"); + header("Content-Length: ".strlen($filecontent)); + header("Pragma: no-cache"); + header("Expires: 0"); + } + return theme('module_builder_results', $edit['module_root_name'], $output); }