You are here

function Xmodule_builder_page_module in Module Builder 6.2

Same name and namespace in other branches
  1. 7 module_builder.module \Xmodule_builder_page_module()

Module form: 'module' step. Generate the module code.

File

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

Code

function Xmodule_builder_page_module($form, $form_values) {

  // Include link in breadcrumb to go back to main module builder form

  /*
  $breadcrumb = drupal_get_breadcrumb();
  $breadcrumb[] = l(t('Module builder'), 'module_builder');
  drupal_set_breadcrumb($breadcrumb);
  */
  $code = $form_values['module_code'] ? $form_values['module_code'] : module_builder_generate_module($form_values);
  $info = $form_values['module_info'] ? $form_values['module_info'] : module_builder_generate_info($form_values);

  // damn I miss perl at times like this. fugly syntax.
  $form['back'] = array(
    '#type' => 'submit',
    '#name' => 'op',
    '#value' => t('Back'),
  );
  $form['code_instructions'] = array(
    '#value' => t('Please copy and paste the following text into a file called !module.', array(
      '!module' => $form_values['module_root_name'] . '.module',
    )),
    '#prefix' => '<div id="module-message">',
    '#suffix' => '</div>',
  );
  $form['module_code'] = array(
    '#type' => 'textarea',
    '#title' => t('Module code'),
    '#rows' => 20,
    '#default_value' => $code,
    '#prefix' => '<div id="module-code">',
    '#suffix' => '</div>',
  );
  $form['download_module'] = array(
    '#type' => 'submit',
    '#name' => 'op',
    '#value' => t('Download module'),
  );
  $form['write_module'] = array(
    '#type' => 'button',
    '#value' => t('Write module file'),
  );
  $form['info_instructions'] = array(
    '#value' => t('Please copy and paste the following text into a file called !module.', array(
      '!module' => $form_values['module_root_name'] . '.info',
    )),
    '#prefix' => '<div id="module-message">',
    '#suffix' => '</div>',
  );
  $form['module_info'] = array(
    '#type' => 'textarea',
    '#title' => t('Module info'),
    '#rows' => 20,
    '#default_value' => $info,
    '#prefix' => '<div id="module-info">',
    '#suffix' => '</div>',
  );
  $form['download_info'] = array(
    '#type' => 'submit',
    '#name' => 'op',
    '#value' => t('Download info file'),
  );
  $form['write_info'] = array(
    '#type' => 'button',
    '#value' => t('Write info file'),
  );
  $form['#multistep_excludes'] = array(
    'module_code',
    'module_info',
  );

  // handle the write buttons
  $form['#after_build'] = array(
    'module_builder_write_buttons',
  );
  return $form;
}