function features_export_build_form_populate in Features 6
Same name and namespace in other branches
- 7 features.admin.inc \features_export_build_form_populate()
AHAH handler for features_export_form_build().
1 string reference to 'features_export_build_form_populate'
- features_menu in ./
features.module - Implementation of hook_menu().
File
- ./
features.admin.inc, line 265
Code
function features_export_build_form_populate() {
module_load_include('inc', 'features', 'features.export');
features_include();
$form_state = array();
$submitted = $_POST;
if ($form = form_get_cache($submitted['form_build_id'], $form_state)) {
$stub = array();
// Assemble the combined component list
$components = array_keys(features_get_components());
foreach ($components as $component) {
// User-selected components take precedence.
if (!empty($submitted['sources'][$component])) {
// Validate and set the default value for each selected option. This
foreach ($submitted['sources'][$component] as $key => $value) {
if (isset($form['export']['sources'][$component]['#options'][$key])) {
$form['export']['sources'][$component]['#default_value'][$key] = $value;
}
}
$stub[$component] = features_dom_decode_options(array_filter($submitted['sources'][$component]));
}
else {
if (!isset($form['export']['sources'][$component]) && !empty($form['#feature']->info['features'][$component])) {
$stub[$component] = $form['#feature']->info['features'][$component];
}
}
}
// Assemble dependencies
$dependencies = isset($submitted['sources']['dependencies']) ? $submitted['sources']['dependencies'] : array();
// Generate populated feature
$module_name = isset($form['#feature'], $form['#feature']->name) ? $form['#feature']->name : '';
$export = features_populate($stub, $dependencies, $module_name);
// Render component display
$components_rendered = theme('features_components', $export, $stub);
$form['export']['features']['#value'] = $components_rendered;
// Re-cache form. This ensures that if the form fails to validate, selected
// values are preserved for the user.
form_set_cache($submitted['form_build_id'], $form, $form_state);
drupal_json(array(
'status' => TRUE,
'data' => $components_rendered . theme('status_messages'),
));
exit;
}
drupal_json(array(
'status' => FALSE,
'data' => '',
));
exit;
}