function brightcove_field_autocomplete in Brightcove Video Connect 7.2
Same name and namespace in other branches
- 7.7 brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.3 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.4 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.5 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.6 brightcove_field.browse.inc \brightcove_field_autocomplete()
Menu callback for brightcove_field/autocomplete.
Parameters
$field_name: Field name - field name that is requesting autocomplete. Unused, will be utilized to limit access to certain videos for certain fields.
$string: String to search for - will match videos by this text.
Return value
JSON object with matched videos.
1 string reference to 'brightcove_field_autocomplete'
- brightcove_field_menu in brightcove_field/
brightcove_field.module - Implementation of hook_menu().
File
- brightcove_field/
brightcove_field.browse.inc, line 127 - Holds a method to list all BC videos that are attachable to a field.
Code
function brightcove_field_autocomplete($field_name, $string = '') {
$bc = brightcove_initialize();
$matches = array();
$result = array();
try {
$result = $bc
->find('find_videos_by_text', array(
'text' => $string,
));
} catch (Exception $error) {
watchdog('brightcove', 'Finding videos in autocomplete failed.', array(), WATCHDOG_ERROR);
}
foreach ((array) $result as $video) {
// Note: Video ID is autogenerated by Brightcove and thus doesn't require XSS protection.
$matches[check_plain($video->name) . ' [id:' . $video->id . ']'] = check_plain($video->name) . ' [id: ' . $video->id . ']';
}
drupal_json_output($matches);
}