function rules_admin_categories_autocomplete in Rules 6
Menu callback for the autocompletion of categories.
1 string reference to 'rules_admin_categories_autocomplete'
- rules_admin_menu in rules_admin/
rules_admin.module - Implementation of hook_menu().
File
- rules_admin/
rules_admin.rule_forms.inc, line 947
Code
function rules_admin_categories_autocomplete($string) {
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
$array = array_filter(drupal_explode_tags($string));
// Fetch last tag
$last_string = drupal_strtolower(trim(array_pop($array)));
$prefix = count($array) ? implode(', ', $array) . ', ' : '';
$tags = rules_admin_get_categories('rules') + rules_admin_get_categories('rule_sets');
$matches = array();
foreach ($tags as $tag) {
if ($last_string && strpos(drupal_strtolower($tag), $last_string) !== FALSE) {
$matches[$prefix . $tag] = check_plain($tag);
}
}
drupal_json($matches);
}