function uniqueness_dynamic_callback in Uniqueness 6
Same name and namespace in other branches
- 7 uniqueness.module \uniqueness_dynamic_callback()
Callback for uniqueness-search returns HTML stubs for related content.
1 string reference to 'uniqueness_dynamic_callback'
- uniqueness_menu in ./
uniqueness.module - Implementation of hook_menu().
File
- ./
uniqueness.module, line 320 - uniqueness.module
Code
function uniqueness_dynamic_callback() {
// Build $values from $string.
$values = array();
// @todo refer to tags as 'terms'
if ($_GET['tags']) {
$values['tags'] = strip_tags($_GET['tags']);
}
if ($_GET['title']) {
$values['title'] = strip_tags($_GET['title']);
}
if ($_GET['nid']) {
$values['nid'] = strip_tags($_GET['nid']);
}
if ($_GET['type']) {
$values['type'] = strip_tags($_GET['type']);
}
if (!empty($values)) {
$related_content = uniqueness_content($values);
}
if (!empty($related_content)) {
$items = array();
$i = 0;
$limit = variable_get('uniqueness_results_max', 10);
foreach ($related_content as $nid => $item) {
// Build items and avoid duplicates.
if (!in_array($nid, array_keys($items))) {
$items[$nid] = $item;
$items[$nid]['href'] = url('node/' . $nid);
}
if (++$i > $limit) {
// At least one more than the results_max limit were found
// -> communicate "and more" to the widget
$items[$nid]['more'] = TRUE;
break;
// LOOP EXIT
}
}
drupal_json($items);
}
else {
drupal_json('false');
}
return;
}