function microdata_autocomplete_itemtype in Microdata 7
Autocomplete callback; Itemtype textfield.
This attempts to autocomplete multiple, comma separated itemtypes. However, the AJAX fails because of issue #93854 (RTBC for Drupal 8).
1 string reference to 'microdata_autocomplete_itemtype'
- microdata_menu in ./
microdata.module - Implements hook_menu().
File
- ./
microdata.pages.inc, line 14 - Page callbacks for microdata module.
Code
function microdata_autocomplete_itemtype($input = '') {
$matches = array();
$input = drupal_explode_tags($input);
$string = drupal_strtolower(array_pop($input));
$types = microdata_get_types();
if (empty($types)) {
drupal_json_output(array(
'' => t('No active vocabularies found. Please enable at least one vocabulary.'),
));
die;
}
if ($string) {
$prefix = count($input) ? drupal_implode_tags($input) . ', ' : '';
foreach ($types as $type) {
if (preg_match("/{$string}/", drupal_strtolower($type['url']))) {
$matches[$prefix . check_plain($type['url'])] = check_plain($type['vocabulary_label']) . ' - ' . check_plain($type['label']);
}
}
}
drupal_json_output($matches);
}