--- module_builder.module.old 2006-04-03 13:07:26.000000000 +0000 +++ module_builder.module 2006-04-04 10:11:10.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'), @@ -457,7 +462,21 @@ $output = preg_replace('#\/\/ \$Id(.*?)\$#', '// $'. 'Id$', $output); // Prepare final output - $output = $header . check_plain($output) . $footer; + $output = $header . $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"); + echo $filecontent; + exit(); + } + return theme('module_builder_results', $edit['module_root_name'], $output); }