function brightcove_cck_autocomplete in Brightcove Video Connect 6.2
Same name and namespace in other branches
- 6 brightcove_cck/brightcove_cck.browse.inc \brightcove_cck_autocomplete()
Menu callback for brightcove_cck/autocomplete.
Parameters
$field_name: Field name - CCK 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_cck_autocomplete'
- brightcove_cck_menu in brightcove_cck/
brightcove_cck.module - Implementation of hook_menu().
File
- brightcove_cck/
brightcove_cck.browse.inc, line 112 - brightcove_cck.browse.inc Holds a method to list all BC videos that are attachable to a field.
Code
function brightcove_cck_autocomplete($field_name, $string = '') {
$bc = _brightcove_initialize();
$matches = 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 . ']';
}
return drupal_json($matches);
}