You are here

function remove_duplicates_build_settings_form in Remove Duplicates 7

Form constructor for the module settings page (Step 1/2).

See also

remove_duplicates_settings_form_submit()

1 call to remove_duplicates_build_settings_form()
remove_duplicates_settings_form in ./remove_duplicates.module
Form constructor for the module.

File

./remove_duplicates.module, line 95
Remove duplicate nodes according to node fields or Custom fields.

Code

function remove_duplicates_build_settings_form($form, &$form_state) {
  $message = t('All actions are logged in <b>Reports</b> >> <b>Recent log messages</b>.');
  $form['message'] = array(
    '#type' => 'item',
    '#markup' => '<div class="description"><p>' . $message . '</p></div>',
  );
  $node_types = node_type_get_names();
  $node_types_fields = _remove_duplicates_get_node_types_fields();
  $form['remove_duplicates_node_types'] = array(
    '#type' => 'select',
    '#title' => t('Select a node type.'),
    '#options' => $node_types,
    '#default_value' => variable_get('remove_duplicates_node_types', array(
      'page',
    )),
    '#description' => t('Select the node type from which duplicates are going to be found.'),
  );
  foreach ($node_types_fields as $machine_name => $node_type_fields) {
    $form[$machine_name . '_node_fields'] = array(
      '#type' => 'select',
      '#title' => t('Select a field from this node type.'),
      '#options' => $node_type_fields,
      '#states' => array(
        'visible' => array(
          ':input[name="remove_duplicates_node_types"]' => array(
            'value' => $machine_name,
          ),
        ),
      ),
      '#description' => t('Select the field which is going to be used to find duplicates for this node type .'),
    );
  }
  $options = array(
    0 => t('Display results as a list (with duplicates to remove autoselection)'),
    1 => t('Display results as a table (with duplicates to remove autoselection)'),
    2 => t('Display results as a tableselect (with duplicates to remove manual selection)'),
  );
  $form['remove_duplicates_select_results_layout'] = array(
    '#type' => 'radios',
    '#title' => t('Results layout'),
    '#default_value' => 2,
    '#options' => $options,
    '#description' => t('You can choose between three layouts to display found duplicates.'),
  );
  $form['remove_duplicates_case_sensitive'] = array(
    '#type' => 'checkbox',
    '#title' => t('The search for duplicate nodes IS <b>case sensitive</b>.'),
    '#default_value' => TRUE,
    '#description' => t('If checked, duplicates search will be case sensitive.'),
  );
  $form['remove_duplicates_prioritize_published'] = array(
    '#type' => 'checkbox',
    '#title' => t('Keep at least one published node.'),
    '#default_value' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[name="remove_duplicates_select_results_layout"]' => array(
          '!value' => 2,
        ),
      ),
      'invisible' => array(
        ':input[name="remove_duplicates_select_results_layout"]' => array(
          'value' => 2,
        ),
      ),
    ),
    '#description' => t('At least one published node among the duplicates found will be kept. If unchecked, there will be no status check among duplicates.'),
  );
  $warning = t('PHP settings limit the maximum post size. If you have 1000+ duplicates found, <b>increase</b> your max post size setting to insure that the <b>whole</b> duplicate selection will be sent to the batch.');
  $form['warning'] = array(
    '#type' => 'item',
    '#markup' => '<div class="description"><p>' . $warning . '</p></div>',
    '#states' => array(
      'visible' => array(
        ':input[name="remove_duplicates_select_results_layout"]' => array(
          'value' => 2,
        ),
      ),
    ),
  );
  $form['message'] = array(
    '#type' => 'item',
    '#markup' => '<div class="description"><p>' . $message . '</p></div>',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Find Duplicates'),
  );
  return $form;
}