You are here

function finder_admin_custom_matching in Finder 7

Finder admin custom matching configuration page.

1 string reference to 'finder_admin_custom_matching'
finder_menu in ./finder.module
Implements hook_menu().

File

includes/finder.admin.inc, line 1009
The finder admin screens.

Code

function finder_admin_custom_matching($form, &$form_state) {
  $form['#tree'] = TRUE;

  // This page is styled.
  $form['#attributes']['class'][] = 'finder-custom-matching';
  drupal_add_css(drupal_get_path('module', 'finder') . '/finder.css');
  $form['intro']['#markup'] = '<p>' . t('This page allows you to configure custom matching methods for use in finder configuration.  Presented here for reference are the default matching methods built into finder.  At the bottom of the page you will find two blank rows where you can create new matching methods.  To remove a custom row, delete the name and save the form.') . '</p>';

  // Add the default rows.
  $default_matching = finder_condition_args_default();
  foreach ($default_matching as $k => $v) {
    finder_admin_custom_matching_entry($form, $k, $v, TRUE);
  }

  // Add the configured custom rows.
  $custom_matching = variable_get('finder_custom_matching', array());
  foreach ($custom_matching as $k => $v) {
    finder_admin_custom_matching_entry($form, $k, $v, FALSE);
  }

  // Add two more rows.
  $more = array();
  $custom = 0;
  while (count($more) < 2) {
    if (!isset($custom_matching['c' . $custom])) {
      $more['c' . $custom] = array();
    }
    $custom++;
  }
  foreach ($more as $k => $v) {
    finder_admin_custom_matching_entry($form, $k, $v, FALSE);
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save custom matching'),
  );
  return $form;
}