You are here

function ftools_form_features_export_form_alter in Features Tools 7.2

Same name and namespace in other branches
  1. 7 ftools.module \ftools_form_features_export_form_alter()

Implements hook_form_FORM_ID_alter().

File

./ftools.module, line 117
ftools module

Code

function ftools_form_features_export_form_alter(&$form, &$form_state) {
  if (isset($form['#feature']) && is_object($form['#feature']) && isset($form['#feature']->name)) {
    $path = drupal_get_path('module', $form['#feature']->name);
  }
  else {
    $path = variable_get('features_default_export_path', 'sites/all/modules');
  }
  $writeable = file_prepare_directory($path);
  if ($writeable === FALSE) {
    drupal_set_message(t('The directory @path does not exists or not writable', array(
      '@path' => $path,
    )), 'error');
  }

  //TODO: add backup options.
  if (variable_get('ftools_disable_features_page_js', 0)) {
    foreach ($form['export']['sources'] as &$value) {
      if (is_array($value) && isset($value['#ajax'])) {
        unset($value['#ajax']);
      }
    }
  }
  $form['buttons']['create'] = array(
    '#type' => 'submit',
    '#value' => t('Auto create feature'),
    '#weight' => 10,
    '#submit' => array(
      'ftools_export_build_form_submit',
    ),
  );
  $form['ftools_dest'] = array(
    '#title' => t('Custom module path.'),
    '#type' => 'textfield',
    '#default_value' => $path,
  );
  if ($form['#feature']) {
    $form['buttons']['safe_recreate'] = array(
      '#type' => 'submit',
      '#value' => t('Safe Auto create feature'),
      '#weight' => 10,
      '#submit' => array(
        'ftools_form_features_export_form_safe_submit',
      ),
    );
  }
}