the translated name of the provider
* 'url' => the url to the main page for the provider
* 'settings_description' => a description of the provider that will be posted in the admin settings form
* 'supported_features' => an array of rows describing the state of certain supported features by the provider.
* These will be rendered in a table, with the columns being 'Feature', 'Supported', 'Notes'.
*/
function emvideo_flickr_sets_info() {
$features = array(
array(t('Autoplay'), t('Yes'), ''),
array(t('RSS Attachment'), t('No'), ''),
array(t('Thumbnails'), t('Yes'), t('')),
array(t('Full screen mode'), t('Yes'), t('Full screen mode is enabled for this player, but may not be disabled.')),
);
return array(
'provider' => 'flickr_sets',
'name' => t('Flickr Photosets'),
'url' => EMVIDEO_FLICKR_SETS_MAIN_URL,
'settings_description' => t('These settings specifically affect slideshows displayed from !flickr_sets.', array('!flickr_sets' => l(t('Flickr.com'), EMVIDEO_FLICKR_SETS_MAIN_URL))),
'supported_features' => $features,
);
}
/**
* hook emvideo_PROVIDER_settings
* this should return a subform to be added to the emvideo_settings() admin settings page.
* note that a form field will already be provided, at $form['PROVIDER'] (such as $form['flickr_sets'])
* so if you want specific provider settings within that field, you can add the elements to that form field.
*/
function emvideo_flickr_sets_settings() {
if (function_exists('emimage_flickr_settings')) {
$form['flickr']['api'] = array(
'#type' => 'fieldset',
'#title' => t('Flickr API'),
'#description' => t('You will first need to apply for an API Developer Key from the Flickr Developer Profile page.', array('@flickr' => EMIMAGE_FLICKR_API_APPLICATION_URL)),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('emimage_flickr_api_key', '') != ''),
);
$form['flickr']['api']['notice'] = array(
'#type' => 'item',
'#value' => t('Please enter your Flickr Developer Key in the fieldset for Flickr, in the Embedded Image Field field set above.'),
);
}
else {
$form['flickr']['api'] = array(
'#type' => 'fieldset',
'#title' => t('Flickr API'),
'#description' => t('You will first need to apply for an API Developer Key from the Flickr Developer Profile page.', array('@flickr' => EMIMAGE_FLICKR_API_APPLICATION_URL)),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('emimage_flickr_api_key', '') != ''),
);
$form['flickr']['api']['emimage_flickr_api_key'] = array(
'#type' => 'textfield',
'#title' => t('Flickr API Key'),
'#default_value' => variable_get('emimage_flickr_api_key', ''),
'#description' => t('Please enter your Flickr Developer Key here.'),
);
$form['flickr']['api']['emimage_flickr_api_secret'] = array(
'#type' => 'textfield',
'#title' => t('Flickr API Secret'),
'#default_value' => variable_get('emimage_flickr_api_secret', ''),
'#description' => t('If you have a secret for the Flickr API, enter it here.'),
);
}
return $form;
}
/**
* hook emfield_PROVIDER_data
*
* provides an array to be serialised and made available with $item elsewhere
*/
function emvideo_flickr_sets_data($field, $item) {
$data = array();
$xml = _emvideo_flickr_sets_request('flickr.photosets.getPhotos', array('photoset_id' => $item['value'], 'per_page' => 1));
$data['owner'] = $xml['photoset']['owner'];
$data['first_photo'] = $xml['photoset']['photo'][0]['id'];
return $data;
}
/**
* this is a wrapper for emimage_request_xml that includes flickr's api key
*/
function _emvideo_flickr_sets_request($method, $args = array(), $cached = TRUE) {
// display an error if we don't have an api key yet
_emvideo_flickr_set_error_check();
$args['api_key'] = trim(variable_get('emimage_flickr_api_key', ''));
if ($secret = trim(variable_get('emimage_flickr_api_secret', ''))) {
$args['secret'] = md5($secret . $arghash);
}
$args['method'] = $method;
$args['format'] = 'php_serial';
$xml = module_invoke('emfield', 'request_xml', 'flickr', EMVIDEO_FLICKR_SETS_RESTPOINT, $args, $cached, FALSE, FALSE, TRUE);
return $xml;
}
/**
*
*/
function emvideo_flickr_sets_rss($item, $teaser = NULL) {
}
/**
* hook emvideo_PROVIDER_extract
* this is called to extract the video code from a pasted URL or embed code.
* @param $embed
* an optional string with the pasted URL or embed code
* @return
* either an array of regex expressions to be tested, or a string with the video code to be used
* if the hook tests the code itself, it should return either the string of the video code (if matched), or an empty array.
* otherwise, the calling function will handle testing the embed code against each regex string in the returned array.
*/
function emvideo_flickr_sets_extract($embed = '') {
// http://www.flickr_sets.com/watch/1404/saturday-night-live-snl-digital-short-natalie-raps
return array(
'@\.flickr\.com/.+?/.+?/sets/([^/\?]+)@i',
'@sets%2F(.+?)%2Fshow.+?flickr\.com/apps/slideshow/show\.swf@i',
);
}
/**
* hook emvideo_PROVIDER_embedded_link($video_code)
* returns a link to view the video at the provider's site
* @param $video_code
* the string containing the video to watch
* @return
* a string containing the URL to view the video at the original provider's site
*/
function emvideo_flickr_sets_embedded_link($video_code, $data = array()) {
return 'http://www.flickr.com/photos/'. $data['owner'] .'/sets/'. $video_code;
}
/**
* The embedded flash displaying the flickr_sets video.
*/
function theme_emvideo_flickr_sets_flash($item, $width, $height, $autoplay) {
$output = '';
if ($item['value']) {
$embed = drupal_urlencode('photos/'. $item['data']['owner'] .'/sets/'. $item['value']);
$output = <<