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('No'), ''),
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' => MEDIA_FLICKR_MAIN_URL,
'settings_description' => t('These settings specifically affect slideshows displayed from !flickr_sets.', array('!flickr_sets' => l(t('Flickr.com'), MEDIA_FLICKR_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('emfield_imagerotator_url')) {
drupal_set_message(t('You should upgrade to a newer version of !emfield if you wish support for the !player or !imagerotator.', array('!emfield' => l(t('Embedded Media Field'), 'http://drupal.org/project/emfield'), '!player' => l(t('JW Flash Media Player'), 'http://www.longtailvideo.com/players/jw-flv-player/'), '!imagerotator' => l(t('JW Image Rotator'), 'http://www.longtailvideo.com/players/jw-image-rotator/'))), 'error');
}
$form['flickr_sets']['media_flickr_store_local'] = array(
'#type' => 'checkbox',
'#title' => t('Store images locally'),
'#description' => t('If checked, then images from Flickr will be stored locally.'),
'#default_value' => variable_get('media_flickr_store_local', FALSE),
);
$form['flickr_sets']['media_flickr_max_saves'] = array(
'#type' => 'textfield',
'#title' => t('Maximum local saves per page load'),
'#description' => t('This will limit the number of remote files that will be stored locally from Flickr per page load when storing a photoset locally, causing the rest in that specific view to be displayed from the remote location. If you set this to 0, then all such files will be stored on the initial slideshow view. Note that setting this to 0 or to an arbitrarily large number can cause the initial view to take a very long time, or even cause the browser to time out. Also note that this setting has no effect if the images are not to be stored locally.'),
'#default_value' => variable_get('media_flickr_max_saves', 10),
);
if (function_exists('emimage_flickr_settings')) {
$form['flickr_sets']['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' => MEDIA_FLICKR_API_APPLICATION_URL)),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('emimage_flickr_api_key', '') != ''),
);
$form['flickr_sets']['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_sets']['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' => MEDIA_FLICKR_API_APPLICATION_URL)),
'#collapsible' => TRUE,
'#collapsed' => (variable_get('emimage_flickr_api_key', '') != ''),
);
$form['flickr_sets']['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_sets']['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;
}
/**
* Implement hook emvideo_PROVIDER_data_version().
*/
function emvideo_flickr_sets_data_version() {
return EMVIDEO_FLICKR_SETS_DATA_VERSION;
}
/**
* 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 = media_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'];
$data['emvideo_data_version'] = EMVIDEO_FLICKR_SETS_DATA_VERSION;
return $data;
}
/**
*
*/
function emvideo_flickr_sets_rss($item, $teaser = NULL) {
}
function emvideo_flickr_sets_validate($value, $error_field) {
if ($value == 'FLICKR_SETS_ERROR_SEARCH') {
form_set_error($error_field, t("Flickr search-based slide shows are not currently supported; only slide shows of a specific photo set will be accepted."));
}
else if ($value == 'FLICKR_SETS_ERROR_USER') {
form_set_error($error_field, t("Flickr user slide shows are not currently supported; only slide shows of a specific photo set will be accepted."));
}
else if ($value == 'FLICKR_SETS_ERROR_GROUPS') {
form_set_error($error_field, t("Flickr groups slide shows are not currently supported; only slide shows of a specific photo set will be accepted."));
}
}
/**
* 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
// http://www.flickr.com/search/?q=Paris+City&l=comm&ss=0&ct=0&mt=photos&w=all&adv=1
// http://www.flickr.com/search/show/?q=Paris+City&l=comm&ss=0&ct=0&mt=photos&adv=1
// http://www.flickr.com/photos/petemorris/show/
// http://www.flickr.com/groups/streamsimages/pool/show/
if (preg_match('@\.flickr\.com/search.+?\?q=([^\&]+)@i', $embed, $matches)) {
return 'FLICKR_SETS_ERROR_SEARCH';
}
else if (!($set = preg_match('@\.flickr\.com/.+?/.+?/sets/([^/\?]+)@i', $embed, $matches)) && preg_match('@\.flickr\.com/photos/([^/\?\#]+)@i', $embed, $matches)) {
return 'FLICKR_SETS_ERROR_USER';
}
else if (!$set && preg_match('@\.flickr\.com/groups/([^/\?\#]+)@i', $embed, $matches)) {
return 'FLICKR_SETS_ERROR_GROUPS';
}
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()) {
if (empty($data)) {
$data = emvideo_flickr_sets_data(NULL, array('value' => $video_code));
}
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, $options = array()) {
$output = '';
if ($item['value']) {
$value = check_plain($item['value']);
$embed = drupal_urlencode('photos/'. $item['data']['owner'] .'/sets/'. $value);
$output = <<