function _text_noderef_check_result in Text or Nodereference 7
Helper function for text_noderef_json().
Parameters
$string: The string used as needle.
$field: Field definition whose widget is being used.
$result: EFQ result array.
Return value
Array of matches found.
1 call to _text_noderef_check_result()
- text_noderef_json in ./
text_noderef.module - Menu callback; Retrieve a pipe delimited string of autocomplete suggestions.
File
- ./
text_noderef.module, line 48 - Text or nodereference field formatter for a text field and autocomplete widget.
Code
function _text_noderef_check_result($string, $field, $result) {
$matches = array();
if (isset($result['node'])) {
$cnt = 0;
reset($result['node']);
while ($cnt <= 10 && ($node = each($result['node']))) {
$node = node_load($node['value']->nid);
if (!$field['widget']['settings']['case_sensitive']) {
$cnt++;
$matches[$node->title] = $node->title;
}
else {
if ($field['widget']['settings']['autocomplete_match'] == 'contains' && strpos($node->title, $string) !== FALSE) {
$cnt++;
$matches[$node->title] = $node->title;
}
if ($field['widget']['settings']['autocomplete_match'] == 'starts_with' && drupal_substr($node->title, 0, drupal_strlen($string)) == $string) {
$cnt++;
$matches[$node->title] = $node->title;
}
}
}
}
return $matches;
}