function microdata_autocomplete_itemprop in Microdata 7
Autocomplete callback; Itemprop textfield.
1 string reference to 'microdata_autocomplete_itemprop'
- microdata_menu in ./
microdata.module - Implements hook_menu().
File
- ./
microdata.pages.inc, line 39 - Page callbacks for microdata module.
Code
function microdata_autocomplete_itemprop($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) . ', ' : '';
// Decode the itemtype arg, replace the '/'s, and explode it into an array.
$itemtypes = explode(', ', str_replace(';', '/', urldecode($itemtype)));
foreach ($itemtypes as $type) {
if (isset($types[$type]['properties'])) {
foreach ($types[$type]['properties'] as $property) {
if (preg_match("/{$string}/", $property)) {
$matches[$prefix . check_plain($property)] = check_plain($property);
}
}
}
}
}
drupal_json_output($matches);
}