You are here

function module_builder_page in Module Builder 5

Same name and namespace in other branches
  1. 6.2 includes/module_builder.pages.inc \module_builder_page()
  2. 7.2 includes/module_builder.pages.inc \module_builder_page()
  3. 7 includes/module_builder.pages.inc \module_builder_page()

Displays module builder interface via a multi-step form. The steps are:

  • input => shows a form where the user can enter module options.
  • module => shows the generated module and info files.
  • download => pushes a file for download.
  • write => writes files.

Parameters

$form_values will be NULL when the page is first displayed,: when the form is submitted, this will be an array of the submitted values.

Return value

One of three results depending on the state of this multi-step form. Form for entering module options Form showing built module and info file Nothing, but file is pushed to client for download

Related topics

1 string reference to 'module_builder_page'
module_builder_menu in ./module_builder.module
Implementation of hook_menu().

File

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

Code

function module_builder_page($form_values = NULL) {
  if (!isset($form_values)) {
    $count = 1;
  }
  else {
    $count = $form_values['count'] + 1;
  }
  $form['count'] = array(
    '#type' => 'hidden',
    '#value' => $count,
  );
  $step = 'input';

  #print_r('<pre>');
  if (isset($form_values) && isset($form_values['op'])) {

    //print_r("VALUES:\n");

    //print_r($form_values);

    //print_r("\n");
    if ($form_values['op'] == t('Generate')) {
      $step = 'module';
    }
    elseif (stripos($form_values['op'], t('Download')) !== false) {
      $step = 'download';
    }
    elseif (stripos($form_values['op'], t('Write')) !== false) {

      #$step = 'write';
      $step = 'module';
    }
  }

  #print_r("$count - $step - $form_values[op]");
  switch ($step) {
    case 'input':
      $form = module_builder_page_input($form, $form_values);
      break;
    case 'module':
      $form = module_builder_page_module($form, $form_values);
      break;
    case 'download':
      $form = module_builder_page_download($form, $form_values);
      break;
    case 'write':

      #$form = module_builder_page_write($form, $form_values);
      break;
  }
  $form = _module_builder_save_old_form_values($form, $form_values);

  //print_r("FORM:\n");

  //print_r($form);

  //print_r("\n");
  $form['#multistep'] = TRUE;
  $form['#redirect'] = FALSE;
  print_r("</pre>\n");
  return $form;
}