function finder_autocomplete_finderapi in Finder 7
Implements hook_finder_api().
File
- modules/
finder_autocomplete/ finder_autocomplete.module, line 340 - The finder autocomplete module.
Code
function finder_autocomplete_finderapi(&$object, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'finder_import') {
$finder =& $object;
// 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);
}
elseif ($op == 'finder_export') {
$finder =& $object;
// Change how match method is stored to support custom matching.
$custom_matching = variable_get('finder_custom_matching', array());
foreach ($finder->elements as $feid => &$element) {
$match = $element->settings['advanced']['match'];
if (isset($custom_matching[$match])) {
$element->settings['advanced']['match'] = array(
$match => $custom_matching[$match],
);
}
}
}
}