function heartbeat_autocomplete_tag in Heartbeat 6.4
Page callback for heartbeat tag autocomplete
1 string reference to 'heartbeat_autocomplete_tag'
- heartbeat_menu in ./
heartbeat.module - Implementation of hook_menu().
File
- ./
heartbeat.admin.inc, line 1549 - Admnistration tasks for heartbeat.
Code
function heartbeat_autocomplete_tag($string = '') {
$matches = array();
// Take the last array value
$strings = explode(",", $string);
$string = trim(array_pop($strings));
if (!empty($string)) {
$previous = implode(",", $strings);
// Get tags that are known
$tags = heartbeat_get_available_tags();
foreach ($tags as $tag) {
if (!empty($tag) && strpos($tag, $string) === 0) {
$key = '';
if (!empty($previous)) {
$key .= $previous . ",";
}
$key .= $tag;
$matches[$key] = $tag;
}
}
}
drupal_json($matches);
}