function module_builder_page_input in Module Builder 7
Same name and namespace in other branches
- 5 module_builder.module \module_builder_page_input()
- 6.2 includes/module_builder.pages.inc \module_builder_page_input()
- 7.2 includes/module_builder.pages.inc \module_builder_page_input()
1 call to module_builder_page_input()
- module_builder_page in includes/module_builder.pages.inc
File
- includes/module_builder.pages.inc, line 60
- Menu callback for main module builder page.
Code
function module_builder_page_input($form_state) {
module_builder_include('process');
$hook_groups = module_builder_get_hook_data();
if (!is_array($hook_groups) || !count($hook_groups)) {
form_set_error('hooks', t('No hooks were found. Please check the documentation path specified in the <a href="!settings">%administer >> %settings >> %modulebuilder</a> page.', array(
'!settings' => url('admin/settings/module_builder'),
'%administer' => 'Administer',
'%settings' => 'Site configuration',
'%modulebuilder' => "Module builder",
)));
return $form;
}
drupal_add_css(drupal_get_path('module', 'module_builder') . '/theme/module_builder.css');
if ($form_state['clicked_button']['#name'] != 'back') {
$form['#attributes'] = array(
'class' => 'fresh',
);
}
$form['module_root_name'] = array(
'#type' => 'textfield',
'#title' => t('Machine-readable name'),
'#description' => t('This string is used to name the module files and to prefix all of your functions. This must only contain letters, numbers, and underscores, and may not start with a number.'),
'#required' => TRUE,
'#default_value' => t('mymodule'),
'#repopulate' => TRUE,
);
$form['module_readable_name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('Name of your module as it will appear on the module admin page.'),
'#required' => TRUE,
'#default_value' => t('My Module'),
'#repopulate' => TRUE,
);
$form['module_short_description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('This text will appear in the module listing at <a href="!listing">%administer >> %build >> %modules</a>.', array(
'!listing' => url('admin/build/modules'),
'%administer' => 'Administer',
'%build' => 'Site building',
'%modules' => 'Modules',
)),
'#required' => TRUE,
'#default_value' => t('Does awesome things. Makes tea. Washes up. Favours of a personal nature.'),
'#repopulate' => TRUE,
);
$form['module_help_text'] = array(
'#type' => 'textarea',
'#title' => t('Help text'),
'#description' => t('Help text (HTML) to appear in <a href="!help">%administer >> %help >> module_name</a> page.', array(
'!help' => url('admin/help'),
'%administer' => 'Administer',
'%help' => 'Help',
)),
'#repopulate' => TRUE,
);
$form['module_dependencies'] = array(
'#type' => 'textfield',
'#title' => t('Dependencies'),
'#description' => t('Space seperated list of other modules that your module requires.'),
'#repopulate' => TRUE,
);
$form['module_package'] = array(
'#type' => 'textfield',
'#title' => t('Package'),
'#description' => t('If your module comes with other modules or is meant to be used exclusively with other modules, enter the package name here. Suggested package names: Audio, Bot, CCK, Chat, E-Commerce, Event, Feed parser, Organic groups, Station, Video, Views and Voting.'),
'#repopulate' => TRUE,
);
$path = drupal_get_path('module', 'module_builder');
if (file_exists($path . MODULE_BUILDER_CUSTOM_HOOK_GROUPS_TEMPLATE_PATH)) {
$template_file = file_get_contents($path . MODULE_BUILDER_CUSTOM_HOOK_GROUPS_TEMPLATE_PATH);
}
else {
$template_file = file_get_contents($path . MODULE_BUILDER_HOOK_GROUPS_TEMPLATE_PATH);
}
$form['hook_groups'] = array(
'#type' => 'fieldset',
'#title' => t('Hook groupings'),
'#description' => t('Selecting one or more of these features will automatically select appropriate hooks for you.'),
);
drupal_add_js($path . '/theme/module_builder.js');
module_builder_include('process');
$hook_presets = module_builder_parse_template($template_file);
foreach ($hook_presets as $hook_preset_name => $hook_preset) {
$hooks = explode("\n", $hook_preset['template']);
$hook_array = array();
foreach ($hooks as $hook) {
$hook = trim($hook);
if (!empty($hook)) {
$hook_array[] = "'{$hook}'";
}
}
$form['hook_groups']['groups-' . $hook_preset_name] = array(
'#type' => 'checkbox',
'#title' => $hook_preset_name,
'#attributes' => array(
'onclick' => 'check_hooks(this, [' . implode(', ', $hook_array) . '])',
),
);
}
$form['hooks'] = array(
'#type' => 'checkboxes',
'#title' => t('Use the following specific hooks'),
);
foreach ($hook_groups as $hook_group => $hooks) {
$form['hooks'][$hook_group] = array(
'#type' => 'fieldset',
'#title' => $hook_group . ' hooks',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#theme' => 'module_builder_hook_list',
);
foreach ($hooks as $hook) {
$name = $hook['name'];
$desc = $hook['description'];
$form['hooks'][$hook_group][$name] = array(
'#type' => 'checkbox',
'#title' => preg_replace('/^hook_/', '', $name),
'#description' => $desc,
'#repopulate' => TRUE,
);
if ($name == 'hook_menu') {
$form['hooks'][$hook_group][$name]['#default_value'] = 1;
}
}
ksort($form['hooks'][$hook_group]);
}
$form['generate_module'] = array(
'#type' => 'submit',
'#name' => 'generate',
'#value' => t('Generate'),
);
$form['#submit'] = array(
'module_builder_page_input_submit',
);
if ($form_state['values']) {
$form = _form_repopulate($form, $form_state);
}
return $form;
}