function Xmodule_builder_page_write in Module Builder 7
Same name and namespace in other branches
- 5 module_builder.module \Xmodule_builder_page_write()
- 6.2 module_builder.module \Xmodule_builder_page_write()
Module form: 'write' step
File
- ./
module_builder.module, line 501 - Builds scaffolding for custom modules.
Code
function Xmodule_builder_page_write($form, $form_values) {
####### bug!!!!!!!!!
dpr('writing page: ' . $form_values['op']);
if ($form_values['op'] == t('Write module file')) {
_module_builder_write_file($form_values['module_root_name'], '.module', $form_values['module_code']);
}
elseif ($form_values['op'] == t('Write info file')) {
_module_builder_write_file($form_values['module_root_name'], '.info', $form_values['module_info']);
}
else {
form_set_error('Problem creating file for writing.');
drupal_goto('module_builder');
}
if (strlen($file_content) > 0) {
$directory = file_create_path(variable_get('module_builder_module_write_directory', 'modules') . '/' . $form_values['module_root_name']);
file_check_directory($directory, FILE_CREATE_DIRECTORY);
$file_name = $form_values['module_root_name'] . $file_ext;
$created_file = file_save_data($file_content, "{$directory}/{$file_name}", FILE_EXISTS_REPLACE);
if ($created_file) {
drupal_set_message(t("File @file has been written.", array(
'@file' => $created_file,
)));
}
else {
drupal_set_message(t("There was a problem writing the file @file.", array(
'@file' => "{$directory}/{$file_name}",
)), 'error');
}
}
// return to the module step to write or download some more.
//return module_builder_page_module($form, $form_values);
return $form;
}