function features_admin_form in Features 6
Same name and namespace in other branches
- 7.2 features.admin.inc \features_admin_form()
- 7 features.admin.inc \features_admin_form()
admin/build/features page callback.
1 string reference to 'features_admin_form'
- features_menu in ./
features.module - Implementation of hook_menu().
File
- ./
features.admin.inc, line 319
Code
function features_admin_form($form_state) {
// Load export functions to use in comparison.
module_load_include('inc', 'features', 'features.export');
// Clear & rebuild key caches
module_rebuild_cache();
features_rebuild();
features_get_info(NULL, NULL, TRUE);
$modules = features_get_modules();
$features = features_get_features();
$conflicts = features_get_conflicts();
foreach ($features as $key => $feature) {
if (!empty($feature->info['hidden'])) {
unset($features[$key]);
}
}
foreach ($modules as $key => $module) {
if ($module->status && !empty($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $dependent) {
if (isset($features[$dependent])) {
$features[$dependent]->dependents[$key] = $module->info['name'];
}
}
}
}
$form = array(
'#features' => $features,
'#theme' => 'features_form',
);
// Generate features form.
foreach ($features as $name => $module) {
$package_title = !empty($module->info['package']) ? $module->info['package'] : t('Other');
$package = strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $package_title));
// Set up package elements
if (!isset($form[$package])) {
$form[$package] = array(
'#tree' => FALSE,
'#title' => t($package_title),
'#theme' => 'features_form_package',
);
$form[$package]['links'] = $form[$package]['version'] = $form[$package]['weight'] = $form[$package]['status'] = $form[$package]['action'] = array(
'#tree' => TRUE,
);
}
$disabled = FALSE;
$description = isset($module->info['description']) ? $module->info['description'] : '';
// Detect unmet dependencies
if (!empty($module->info['dependencies'])) {
$unmet_dependencies = array();
$dependencies = _features_export_maximize_dependencies($module->info['dependencies']);
foreach ($dependencies as $dependency) {
if (empty($modules[$dependency])) {
$unmet_dependencies[] = theme('features_module_status', FEATURES_MODULE_MISSING, $dependency);
}
}
if (!empty($unmet_dependencies)) {
$description .= "<div class='dependencies'>" . t('Unmet dependencies: !dependencies', array(
'!dependencies' => implode(', ', $unmet_dependencies),
)) . "</div>";
$disabled = TRUE;
}
}
if (!empty($module->dependents)) {
$disabled = TRUE;
$description .= "<div class='requirements'>" . t('Required by: !dependents', array(
'!dependents' => implode(', ', $module->dependents),
)) . "</div>";
}
// Detect potential conflicts
if (!empty($conflicts[$name])) {
$module_conflicts = array();
foreach (array_keys($conflicts[$name]) as $conflict) {
$module_conflicts[] = theme('features_module_status', FEATURES_MODULE_MISSING, $conflict);
// Only disable modules with conflicts if they are not already enabled.
// If they are already enabled, somehow the user got themselves into a
// bad situation and they need to be able to disable a conflicted module.
if (module_exists($conflict) && !module_exists($name)) {
$disabled = TRUE;
}
}
$description .= "<div class='conflicts'>" . t('Conflicts with: !conflicts', array(
'!conflicts' => implode(', ', $module_conflicts),
)) . "</div>";
}
$form[$package]['status'][$name] = array(
'#type' => 'checkbox',
'#title' => $module->info['name'],
'#description' => $description,
'#default_value' => $module->status,
'#disabled' => $disabled,
);
if (!empty($module->info['project status url'])) {
$uri = l(truncate_utf8($module->info['project status url'], 35, TRUE, TRUE), $module->info['project status url']);
}
else {
if (isset($module->info['project'], $module->info['version'], $module->info['datestamp'])) {
$uri = l('http://drupal.org', 'http://drupal.org/project/' . $module->info['project']);
}
else {
$uri = t('Unavailable');
}
}
$version = !empty($module->info['version']) ? $module->info['version'] : '';
$version = !empty($version) ? "<div class='description'>{$version}</div>" : '';
$form[$package]['sign'][$name] = array(
'#type' => 'markup',
'#value' => "{$uri} {$version}",
);
if (user_access('administer features')) {
// Add status link
$href = "admin/build/features/{$name}";
if ($module->status) {
$state = '<span class="admin-loading features-storage">' . t('Checking...') . '</span>';
$state .= l(t('Check'), "admin/build/features/{$name}/status", array(
'attributes' => array(
'class' => 'admin-check',
),
));
$state .= theme('features_storage_link', FEATURES_REBUILDING, NULL, $href);
$state .= theme('features_storage_link', FEATURES_NEEDS_REVIEW, NULL, $href);
$state .= theme('features_storage_link', FEATURES_OVERRIDDEN, NULL, $href);
$state .= theme('features_storage_link', FEATURES_DEFAULT, NULL, $href);
}
elseif (!empty($conflicts[$name])) {
$state = theme('features_storage_link', FEATURES_CONFLICT, NULL, $href);
}
else {
$state = theme('features_storage_link', FEATURES_DISABLED, NULL, $href);
}
$form[$package]['state'][$name] = array(
'#type' => 'markup',
'#value' => !empty($state) ? $state : '',
);
// Add in recreate link
$form[$package]['actions'][$name] = array(
'#type' => 'markup',
'#value' => l(t('Recreate'), "admin/build/features/{$name}/recreate", array(
'attributes' => array(
'class' => 'admin-update',
),
)),
);
}
}
$form['buttons'] = array(
'#theme' => 'features_form_buttons',
);
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
'#submit' => array(
'features_form_submit',
),
'#validate' => array(
'features_form_validate',
),
);
return $form;
}