You are here

function features_settings_form in Features 7.2

Form builder for 'admin/structure/features/settings'.

Parameters

array $form: Form array, as passed in from form API.

array $form_state: Form state.

Return value

array Form array.

1 string reference to 'features_settings_form'
features_menu in ./features.module
Implements hook_menu().

File

./features.admin.inc, line 19
Forms for Features admin screens.

Code

function features_settings_form($form, $form_state) {
  $form = array();
  $components = features_get_components();
  uasort($components, 'features_compare_component_name');
  $form['show_components'] = array(
    '#type' => 'fieldset',
    '#title' => t('Show components on create/edit feature form.'),
    '#description' => t('Components with no options will not be shown no matter the setting below. Disabled components cannot be used with admin form.'),
  );
  $form['lock_components'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lock components'),
    '#description' => t('Locked components will be prevented from ever being reverted. For example, if site builder updates a feature with new settings for a field instance, but field instance is locked, it will not update that field. If the item is purely in code, like a view, the view changed when the code is updated no matter these settings.'),
  );
  $form['features_lock_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Features lock mode'),
    '#options' => array(
      'rebuild' => t('Allow rebuild (prevent revert)'),
      'all' => t('Prevent rebuild and revert'),
    ),
    '#description' => t('Rebuild will allow the feature to be updated till the point features has detected that the item has changed deliberately on the site, e.g. is overriden.'),
    '#default_value' => variable_get('features_lock_mode', 'all'),
  );
  foreach ($components as $component => $info) {
    if (empty($info['feature_source']) && empty($info['features_source'])) {
      continue;
    }
    $form['show_components']['features_admin_show_component_' . $component] = array(
      '#title' => t('@name (@machine)', array(
        '@name' => $info['name'],
        '@machine' => $component,
      )),
      '#type' => 'checkbox',
      '#default_value' => variable_get('features_admin_show_component_' . $component, TRUE),
    );

    /* @see \hook_features_revert() */

    /* @see \hook_features_rebuild() */
    if (features_hook($component, 'features_revert') || features_hook($component, 'features_rebuild')) {
      $form['lock_components']['features_component_locked_' . $component] = array(
        '#title' => t('@name (@machine)', array(
          '@name' => $info['name'],
          '@machine' => $component,
        )),
        '#type' => 'checkbox',
        '#default_value' => variable_get('features_component_locked_' . $component, FALSE),
      );
    }
    if ($component == 'menu_links' && ($menus = menu_get_menus())) {
      $form['show_components']['features_admin_menu_links'] = array(
        '#title' => t('Advanced Menu Link Settings'),
        '#type' => 'fieldset',
        '#collapsed' => TRUE,
        '#collapsible' => TRUE,
        '#states' => array(
          'invisible' => array(
            'input[name="features_admin_show_component_menu_links"]' => array(
              'checked' => FALSE,
            ),
          ),
        ),
      );
      $form['show_components']['features_admin_menu_links']['features_admin_menu_links_menus'] = array(
        '#title' => t('Allowed menus for menu links'),
        '#type' => 'checkboxes',
        '#options' => array_map('check_plain', $menus),
        '#default_value' => variable_get('features_admin_menu_links_menus', array_keys(menu_get_menus())),
      );
    }
  }
  $form['general'] = array(
    '#title' => t('General settings'),
    '#type' => 'fieldset',
  );
  $form['general']['features_default_export_path'] = array(
    '#title' => t('Default export path'),
    '#type' => 'textfield',
    '#default_value' => variable_get('features_default_export_path', FEATURES_DEFAULT_EXPORT_PATH),
    '#description' => t('All feature exports will be automatically saved to this path, unless overridden on the individual feature.'),
  );
  $form['general']['features_rebuild_on_flush'] = array(
    '#type' => 'checkbox',
    '#title' => t('Rebuild features on cache clear'),
    '#default_value' => variable_get('features_rebuild_on_flush', TRUE),
    '#description' => t('If you have a large site with many features, you may experience lag on full cache clear. If disabled, features will rebuild only when viewing the features list or saving the modules list.'),
  );
  $form['general']['features_rebuild_modules_page'] = array(
    '#type' => 'checkbox',
    '#title' => t('Rebuild features on accessing modules list page'),
    '#default_value' => variable_get('features_rebuild_modules_page', FALSE),
    '#description' => t('If you have a large site with many features, you may experience lag on accessing the modules administration page. If disabled, features will not rebuild when viewing the modules list.'),
  );
  return system_settings_form($form);
}