finder_autocomplete_finderapi
- finder
| Versions | |
|---|---|
| 7.x-1.x | finder_autocomplete_finderapi(&$object, $op, $a3 = NULL, $a4 = NULL) |
Implements hook_finder_api().
Code
modules/
<?php
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],
);
}
}
}
}
?>
