function theme_flickrgallery_set in FlickrGallery 7.2
Same name and namespace in other branches
- 6.2 flickrgallery.module \theme_flickrgallery_set()
- 7 flickrgallery.module \theme_flickrgallery_set()
1 theme call to theme_flickrgallery_set()
File
- ./
flickrgallery.module, line 198 - This module shows the sets and photo's from a Flickr account
Code
function theme_flickrgallery_set($set_id = NULL) {
// Require FlickrAPI.
module_load_include('module', 'flickrapi');
// Add CSS file.
drupal_add_css(drupal_get_path('module', 'flickrgallery') . '/flickrgallery.css');
// Create Flickr object.
//$f = flickrapi_phpFlickr(); @todo fix when flickrapi supports private pictures -> token is missing
$f = new phpFlickr(variable_get('flickrapi_api_key', NULL), variable_get('flickrapi_api_secret', NULL));
// Because we're not using flickrapi to create the flickr object, we need to handle cache ourselves
$cache = variable_get('flickrapi_cache', '');
$cache_dir = variable_get('flickrapi_cache_path', '');
if ($cache == TRUE) {
$f
->enableCache('fs', $cache_dir);
}
// Check for private pictures
$token = variable_get('flickrgallery_token', NULL);
$private = variable_get('flickrgallery_private_pictures', NULL);
if (!empty($token) && $private == 1) {
$f
->setToken($token);
}
// Get Flickr set title.
$set = $set_id['set_id'];
$set_info = $f
->photosets_getInfo($set);
// Set Flickr set title as page title.
drupal_set_title($set_info['title'], 'Flickr Set');
// Get Flickr photos for this set.
$photos = $f
->photosets_getPhotos($set);
// Get META data for this set.
$meta = $f
->photosets_getInfo($set);
// If there aren't any photo's, display message.
if (empty($set) || empty($photos)) {
drupal_set_message(t('This set doesn\'t exists or there aren\'t any pictures available for this set.'), 'error');
drupal_not_found();
exit;
}
// Get the type for Lightbox.
$type = variable_get('flickrgallery_lightbox_type', 'lighbox2');
// Declare variables.
$photoset = array();
$image_meta = array();
foreach ($photos['photoset']['photo'] as $photo) {
if (variable_get('flickrgallery_display_type') == 1 && module_exists('image') && module_exists('imagecache_external')) {
$original = $f
->buildPhotoURL($photo, 'large');
$img = theme('imagecache_external', array(
'path' => $original,
'style_name' => variable_get('flickrgallery_thumb_imagestyle', 'large'),
));
$url_external = imagecache_external_generate_path($original, variable_get('flickrgallery_large_imagestyle', 'large'));
$url = image_style_url(variable_get('flickrgallery_large_imagestyle', 'large'), $url_external);
}
else {
$variables = array(
'path' => $f
->buildPhotoURL($photo, variable_get('flickrgallery_thumb', 'square')),
'alt' => $photo['title'],
'title' => $photo['title'],
'attributes' => array(
'class' => 'flickrgallery-set-image',
),
);
$img = theme('image', $variables);
$url = $f
->buildPhotoURL($photo, variable_get('flickrgallery_large', 'large'));
}
$image = array();
// Get META data for this image, only if flickrgallery_override is set to TRUE in the admin screen
// This will lead to slower performance
if (variable_get('flickrgallery_override') == TRUE) {
$image_meta = $f
->photos_getInfo($photo['id']);
}
$image['info'] = $photo;
$image['image'] = l($img, $url, array(
'attributes' => array(
'class' => 'flickrgallery-image ' . $type,
'rel' => $type . "[flickrgallery]",
'title' => $photo['title'],
),
'html' => 'true',
));
$photoset[] = theme('flickrgallery_photo', array(
'image' => $image,
'image_meta' => $image_meta,
));
}
// Return the output.
return theme('flickrgallery_photoset', array(
'photoset' => $photoset,
'meta' => $meta,
));
}