function theme_flickrgallery_wrapper_albums in FlickrGallery 7.2
Same name and namespace in other branches
- 7 flickrgallery.module \theme_flickrgallery_wrapper_albums()
1 call to theme_flickrgallery_wrapper_albums()
1 theme call to theme_flickrgallery_wrapper_albums()
File
- ./
flickrgallery.module, line 111 - This module shows the sets and photo's from a Flickr account
Code
function theme_flickrgallery_wrapper_albums() {
// Require FlickrAPI.
module_load_include('module', 'flickrapi');
// Add CSS file.
drupal_add_css(drupal_get_path('module', 'flickrgallery') . '/flickrgallery.css');
// Set custom title, only when viewing the page -> not when using the block because it will override every page title
if (arg(0) == variable_get('flickrgallery_path', 'flickr')) {
drupal_set_title(t(variable_get('flickrgallery_title', 'Flickr Gallery')));
}
// Create Flickr object.
//$f = flickrapi_phpFlickr(); -> flickrapi does not support set token for private pictures
// @todo, use flickrapi when it supports token for private pictures
$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 User info and User ID.
$flickr_user = $f
->people_getInfo(variable_get('flickrgallery_userID', NULL));
$flickr_uid = $flickr_user['id'];
// Get Flickr sets.
if (variable_get('flickrgallery_displaysets_bool') == 1) {
// If true, then select the flickrgallery_displaysets_values
$array_set = explode("\n", trim(variable_get('flickrgallery_displaysets_values')));
for ($j = 0; $j < count($array_set); $j++) {
$sets['photoset'][$j] = $f
->photosets_getInfo($array_set[$j]);
}
}
else {
$sets = $f
->photosets_getList($flickr_uid);
}
$description = t(variable_get('flickrgallery_description', NULL));
$albums = array();
$flickr_path = variable_get('flickrgallery_path', 'flickr');
if (!empty($sets)) {
foreach ($sets['photoset'] as $set) {
if (variable_get('flickrgallery_display_type') == 1 && module_exists('image') && module_exists('imagecache_external')) {
$original = "https://farm" . $set['farm'] . ".static.flickr.com/" . $set['server'] . "/" . $set['primary'] . "_" . $set['secret'] . "_b.jpg";
$img = theme('imagecache_external', array(
'path' => $original,
'style_name' => variable_get('flickrgallery_albums_imagestyle', 'thumbnail'),
));
}
else {
$thumb_url = "https://farm" . $set['farm'] . ".staticflickr.com/" . $set['server'] . "/" . $set['primary'] . "_" . $set['secret'] . "_" . variable_get('flickrgallery_albums', 's') . ".jpg";
$variables = array(
'path' => $thumb_url,
'alt' => $set['title'],
'title' => $set['title'],
'attributes' => array(
'class' => 'flickrgallery-set-image',
),
);
$img = theme('image', $variables);
}
$image = array();
$image['info'] = $set;
$image['total'] = $set['photos'];
$image['image_link'] = l($img, $flickr_path . "/set/" . $set['id'], array(
'attributes' => array(
'class' => array(
'flickrgallery',
),
'title' => $set['title'],
),
'html' => 'true',
));
$image['title_link'] = l($set['title'], $flickr_path . "/set/" . $set['id'], array(
'attributes' => array(
'class' => array(
'flickrgallery-title',
),
'title' => $set['title'],
),
'html' => 'true',
));
$albums[] = $image;
}
return theme('flickrgallery_albums', array(
'description' => $description,
'albums' => $albums,
));
}
else {
// If no sets, display msg.
return "<h2>" . t("No pictures available") . "</h2>";
}
}