brightcove_field.browse.inc in Brightcove Video Connect 7.4
Same filename and directory in other branches
Holds a method to list all BC videos that are attachable to a field.
File
brightcove_field/brightcove_field.browse.incView source
<?php
/**
* @file
* Holds a method to list all BC videos that are attachable to a field.
*/
/**
* This function is a callback for modalframe window, providing an access to browse videos.
*
* @see brightcove_field_menu()
*
* @param none
*
* @return A list of available videos that can be attached to a field.
*
* TODO: Allow limiting videos by user (own videos only).
* TODO: Interesting feature would be to detect multiple values allowed in the
* parent field and allow attaching all videos at once.
*/
function brightcove_field_browse($type) {
$content = array();
drupal_add_css(drupal_get_path('module', 'brightcove_field') . '/styles/browse.css');
drupal_add_js(drupal_get_path('module', 'brightcove_field') . '/js/brightcove.js');
switch ($type) {
case 'video':
module_load_include('inc', 'brightcove_field', 'brightcove_field.video');
$content = _brightcove_field_video_browse();
break;
case 'playlist':
module_load_include('inc', 'brightcove_field', 'brightcove_field.playlist');
$content = _brightcove_field_playlist_browse();
break;
}
return '<div class="brightcove-browse-table">' . drupal_render($content['filter_form']) . $content['pager'] . theme('brightcove_field_browse_items', array(
'items' => $content['items'],
)) . $content['pager'] . '</div>';
}
/**
* Menu callback for brightcove_field/autocomplete.
*
* @param $field_name
* Field name - field name that is requesting autocomplete. Unused, will be utilized to limit access to certain videos for certain fields.
* @param $string
* String to search for - will match videos by this text.
* @return
* JSON object with matched videos.
*/
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);
}
function brightcove_field_upload() {
drupal_add_css(drupal_get_path('module', 'brightcove_field') . '/brightcove_field.upload.css');
$form = drupal_get_form('brightcove_field_upload_form');
return drupal_render($form);
}
function brightcove_field_create() {
drupal_add_css(drupal_get_path('module', 'brightcove_field') . '/brightcove_field.upload.css');
$form = drupal_get_form('brightcove_field_create_form');
return drupal_render($form);
}
Functions
Name | Description |
---|---|
brightcove_field_autocomplete | Menu callback for brightcove_field/autocomplete. |
brightcove_field_browse | This function is a callback for modalframe window, providing an access to browse videos. |
brightcove_field_create | |
brightcove_field_upload |