function module_builder_page_generate in Module Builder 6.2
Same name and namespace in other branches
- 7.2 includes/module_builder.pages.inc \module_builder_page_generate()
- 7 includes/module_builder.pages.inc \module_builder_page_generate()
page 2: generate code
1 call to module_builder_page_generate()
- module_builder_page in includes/
module_builder.pages.inc
File
- includes/
module_builder.pages.inc, line 300 - Menu callback for main module builder page.
Code
function module_builder_page_generate($form_state) {
module_builder_include('generate');
// Build module data
$module_data = module_data_from_form($form_state['values']);
$code_array = module_builder_generate_module($module_data);
//dsm($code_array);
/*
// the restitution was all for the DL buttons, no?
// these should be ajaxy!
if ($form_state['values']['module_code']) {
$code = $form_state['values']['module_code'];
}
else {
// Bit messy. This returns an array now.
// TODO: the other files!
$code_array = module_builder_generate_module($module_data);
$code = $code_array[$module_data['module_root_name'] . '.module'];
}
*/
module_builder_include('generate_info');
$info = $form_state['values']['module_info'] ? $form_state['values']['module_info'] : module_builder_generate_info($module_data);
// damn I miss perl at times like this. fugly syntax.
$form['back'] = array(
'#type' => 'submit',
'#value' => t('Back'),
'#name' => 'back',
);
foreach ($code_array as $filename => $code) {
$form['code_instructions_' . $filename] = array(
'#value' => t('Please copy and paste the following text into a file called !module.', array(
'!module' => $filename,
)),
'#prefix' => '<div class="module-message">',
'#suffix' => '</div>',
);
$form['module_code_' . $filename] = array(
'#type' => 'textarea',
'#title' => t($filename . ' code'),
'#rows' => 20,
'#default_value' => $code,
'#prefix' => '<div class="module-code">',
'#suffix' => '</div>',
);
}
/*
$form['code_instructions'] = array(
'#value' => t('Please copy and paste the following text into a file called !module.', array('!module' => $form_state['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',
'#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_state['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'),
);
*/
// handle the write buttons
## $form['#after_build'] = array('module_builder_write_buttons');
return $form;
}