You are here

function module_builder_page_download in Module Builder 5

Module form: 'download' step. Download the files.

1 call to module_builder_page_download()
module_builder_page in ./module_builder.module
Displays module builder interface via a multi-step form. The steps are:

File

./module_builder.module, line 618
Builds scaffolding for custom modules.

Code

function module_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';
  }
  else {
    if ($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;
  }
}