You are here

function photos_down_page in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 inc/photos.down.inc \photos_down_page()

Photos download (share) page.

1 string reference to 'photos_down_page'
photos_menu in ./photos.module
Implements hook_menu().

File

inc/photos.down.inc, line 10
Handles share image page(s) and content.

Code

function photos_down_page($fid) {
  $op = array();
  $content = array();
  $query = db_select('file_managed', 'f');
  $query
    ->join('photos_image', 'p', 'p.fid = f.fid');
  $query
    ->join('users', 'u', 'u.uid = f.uid');
  $query
    ->fields('f', array(
    'uri',
    'filemime',
    'timestamp',
    'filename',
  ))
    ->fields('u', array(
    'uid',
    'name',
  ))
    ->fields('p')
    ->condition('p.fid', $fid);
  $image = $query
    ->execute()
    ->fetchObject();
  $page_title = t('Sharing code and download image: @title', array(
    '@title' => $image->filename,
  ));
  drupal_set_title($page_title);
  if (!module_exists('colorbox')) {
    $content['back'] = l(t('Back to the image page'), 'photos/image/' . $fid);
  }
  $content['info'] = t('Uploaded on !time by !name', array(
    '!name' => $image->name,
    '!time' => format_date($image->timestamp, 'small'),
  ));
  if (arg(3) != 'exif' && arg(3) != 'vote') {
    $image = photos_get_info(0, $image);
    $size_info = photos_upload_info();
    $content['sizes'] = $size_info['size'];
    $content['link']['original'] = user_access('view original') ? l(t('Original'), 'photos/zoom/' . $fid . '/original') : NULL;
    $op['class'] = array(
      'active',
    );
  }
  if (isset($image->exif) && variable_get('photos_exif', 0) && ($exif = _photos_down_exif($image->uri, $fid))) {
    $content['link']['exif'] = l(t('Exif'), 'photos/zoom/' . $fid . '/exif');
  }
  if (variable_get('photos_vote', 0) && user_access('view vote list')) {
    $content['link']['vote'] = l(t('Vote list'), 'photos/zoom/' . $fid . '/vote');
  }
  $sizes = isset($content['sizes']) ? $content['sizes'] : array();
  foreach ($sizes as $size) {
    $content['link'][$size['style']] = l(t($size['name']), 'photos/zoom/' . $fid . '/' . $size['style']);
  }
  switch (arg(3)) {
    case 'thumb':
      if ($style_name = _photos_down_label(arg(4))) {
        $content['view'] = theme('photos_imagehtml', array(
          'style_name' => $style_name,
          'image' => $image,
        ));
        $content['sharing_url'] = _photos_l($image->uri, $image->thumb[$label]);
        $content['sharing_link'] = url('photos/image/' . $fid, array(
          'absolute' => TRUE,
        ));
        $content['sharing_title'] = $image['filename'];
      }
      else {
        $content['view'] = t('Without this size image');
      }
      break;
    case 'original':
      $content['view'] = theme('photos_imagehtml', array(
        'style_name' => 'original',
        'image' => $image,
      ));
      break;
    case 'exif':
      $content['view'] = $exif ? $exif : t('There is no Exif information for this image.');
      break;
    case 'vote':
      if (!user_access('view vote list')) {
        drupal_access_denied();
        return;
      }
      $content['view'] = _photos_down_vote($fid);
      break;
    default:
      if ($content['sizes'][0]['style']) {
        $style_name = arg(3);
        if (empty($style_name)) {
          $style_name = variable_get('photos_display_view_imagesize', 'large');
        }
        $content['view'] = theme('photos_imagehtml', array(
          'style_name' => $style_name,
          'image' => $image,
        ));
        if ($style_name == 'original') {
          $content['sharing_url'] = _photos_l($image->uri, $style_name);
        }
        else {
          $content['sharing_url'] = _photos_l($image->uri, $style_name);
        }
      }
      $content['sharing_link'] = url('photos/image/' . $fid, array(
        'absolute' => TRUE,
      ));
      $content['sharing_title'] = $image->filename;
  }
  $content['link']['sizes'] = l(t('All sizes'), 'photos/zoom/' . $fid);
  if (variable_get('photos_print_sizes', 1)) {
    print theme('photos_down', array(
      'content' => $content,
      'type' => 'print',
    ));
  }
  else {
    return theme('photos_down', array(
      'content' => $content,
      'type' => 'return',
    ));
  }
}