function brightcove_field_autocomplete in Brightcove Video Connect 7.5
Same name and namespace in other branches
- 7.7 brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.2 brightcove_field/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.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 50 - Holds a method to list all BC videos that are attachable to a field.
Code
function brightcove_field_autocomplete($type, $field_name, $string = '') {
$bc = brightcove_initialize();
$matches = array();
$result = array();
switch ($type) {
case 'video':
try {
$result = $bc
->find('find_videos_by_text', array(
'text' => $string,
));
} catch (Exception $error) {
watchdog('brightcove', 'Finding videos in autocomplete failed.', array(), WATCHDOG_ERROR);
}
break;
case 'playlist':
// No API method to find playlists by name.
module_load_include('inc', 'brightcove_field', 'brightcove_field.playlist');
$result = brightcove_field_get_matched_playlists($string);
break;
}
foreach ((array) $result as $bc_item) {
// Note: Brightcove ID is autogenerated by Brightcove and thus doesn't require XSS protection.
$matches[check_plain($bc_item->name) . ' [id:' . $bc_item->id . ']'] = check_plain($bc_item->name) . ' [id: ' . $bc_item->id . ']';
}
drupal_json_output($matches);
}