You are here

function finder_admin_import_custom_matching in Finder 7

Handle custom matching in imports.

1 call to finder_admin_import_custom_matching()
finder_admin_import in includes/finder.admin.inc
Admin finder import page.

File

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

Code

function finder_admin_import_custom_matching(&$finder) {

  // Handle custom matching.
  $custom_matching = variable_get('finder_custom_matching', array());
  foreach ($finder->elements as $feid => &$element) {
    $match =& $element->settings['advanced']['match'];
    if (is_array($match)) {
      $match_data = reset($match);
      $found_key = FALSE;
      foreach ($custom_matching as $custom_key => $custom_match) {
        if ($custom_match['operator'] == $match_data['operator'] && $custom_match['value_prefix'] == $match_data['value_prefix'] && $custom_match['value_suffix'] == $match_data['value_suffix']) {
          $found_key = $custom_key;
        }
      }
      if ($found_key) {
        $match = $found_key;
      }
      else {
        $new = NULL;
        $custom = 0;
        while (is_null($new)) {
          if (!isset($custom_matching['c' . $custom])) {
            $new = array(
              'c' . $custom,
            );
            break;
          }
          $custom++;
        }
        $custom_matching[$new] = $custom_match;
        $match = $new;
      }
    }
  }
  variable_set('finder_custom_matching', $custom_matching);
}