You are here

function theme_flickrgallery_set in FlickrGallery 7

Same name and namespace in other branches
  1. 6.2 flickrgallery.module \theme_flickrgallery_set()
  2. 7.2 flickrgallery.module \theme_flickrgallery_set()
1 theme call to theme_flickrgallery_set()
flickrgallery_set in ./flickrgallery.module

File

./flickrgallery.module, line 171
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();

  // 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, NULL, variable_get('flickrgallery_privacy_filter', 1));

  // 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) {
    $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);
    $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, $f
      ->buildPhotoURL($photo, variable_get('flickrgallery_large', 'large')), 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,
  ));
}