You are here

function patterns_export_page1 in Patterns 7

Same name and namespace in other branches
  1. 7.2 patterns_export/patterns_export.module \patterns_export_page1()
1 call to patterns_export_page1()
patterns_export in patterns_export/patterns_export.module
Forms to export the current web site configuration

File

patterns_export/patterns_export.module, line 56

Code

function patterns_export_page1($form, &$form_state) {

  //Get all the modules implementing patterns and filter those which implement an EXPORT funtion
  $tm_index = patterns_tagmodules_get_index();
  $tm_index = patterns_tagmodules_filter($tm_index, NULL, PATTERNS_EXPORT);
  if (count($tm_index) == 0) {
    drupal_set_message(t('The components currently installed do not allow automatic export of the configuration of the web site'), 'error');
    $form['disabled'] = array(
      '#markup' => l(t('Click here to back'), 'admin/patterns'),
    );
    return $form;
  }
  $text = 'In this area you can export the current configuration of your web site to a new pattern file that can be inserted in the database, or downloaded.';
  $title = 'Export';
  patterns_forms_add_page_header($form, $title, $text);
  $form['all'] = array(
    '#type' => 'fieldset',
    '#title' => 'Components',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['all']['all'] = array(
    '#type' => 'fieldset',
    '#title' => 'I want to select the components individually',
    '#type' => 'checkbox',
  );
  $form['all']['ext'] = array(
    '#type' => 'fieldset',
    '#title' => 'Components with automatic export enabled',
    '#tree' => TRUE,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#states' => array(
      'visible' => array(
        // action to take.
        ':input[name="all"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  foreach ($tm_index as $module => $tags) {
    $form['all']['ext'][$module] = array(
      '#type' => 'fieldset',
      '#title' => $module,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['all']['ext'][$module]['options'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Export options'),
      '#options' => array_combine(array_keys($tags), array_keys($tags)),
    );
    foreach ($tags as $tag => $forms) {
      $input_name = _patterns_export_build_input_name($module, $tag);
      $form['all']['ext'][$module][$tag]['options'] = array(
        '#type' => 'checkboxes',
        '#title' => $tag,
        '#options' => array_combine(array_keys($forms), array_keys($forms)),
        '#states' => array(
          'visible' => array(
            // action to take.
            ':input[name="' . $input_name . '"]' => array(
              'checked' => TRUE,
            ),
          ),
          'checked' => array(
            // action to take.
            ':input[name="' . $input_name . '"]' => array(
              'checked' => TRUE,
            ),
          ),
        ),
      );
    }
  }
  patterns_forms_get_info_section($form, array(), array(
    'collapsed' => TRUE,
  ));
  patterns_forms_get_formats_selector($form, patterns_forms_get_default_format(), t('Export data in this format'), FALSE);
  patterns_forms_get_name_selector($form);
  patterns_forms_get_export_to_selector($form, array(
    'title' => 'Export options',
  ));
  patterns_forms_get_exec_mode_selector($form['export']);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Export'),
  );
  $form['#validate'][] = 'patterns_export_validate';
  return $form;
}