You are here

function photos_down_page in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.down.inc \photos_down_page()
1 string reference to 'photos_down_page'
photos_menu in ./photos.module

File

inc/photos.down.inc, line 3

Code

function photos_down_page($fid) {
  $image = db_fetch_array(db_query('SELECT f.filepath, f.filemime, f.timestamp, f.filename, u.uid, u.name, p.* FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid INNER JOIN {users} u ON f.uid = u.uid WHERE p.fid = %d', $fid));
  drupal_set_title(t('Sharing code and download image: @title', array(
    '@title' => $image['filename'],
  )));
  $content['back'] = l(t('Back to the image page'), 'photos/image/' . $fid);
  $content['info'] = t('Uploaded on !time by !name', array(
    '!name' => theme('username', (object) $image),
    '!time' => format_date($image['timestamp'], 'small'),
  ));
  if (arg(3) != 'exif' && arg(3) != 'vote') {
    $image = photos_get_info(0, $image);
    $content['sizes'] = _photos_down_count($image['filepath'], $fid);
    $content['link']['original'] = user_access('view original') ? l(t('Original'), "photos/zoom/{$fid}/original") : NULL;
    $op['class'] = 'active';
  }
  if ($image['exif'] && variable_get('photos_exif', 0) && ($exif = _photos_down_exif($image['filepath'], $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");
  }
  switch (arg(3)) {
    case 'thumb':
      if ($label = _photos_down_label(arg(4))) {
        $content['view'] = theme('photos_imagehtml', $image['thumb'][$label], array(
          'filename' => $image['filename'],
        ));
        $content['sharing_url'] = _photos_l($image['thumb'][$label]);
        $content['sharing_link'] = _photos_l('photos/image/' . $fid);
        $content['sharing_title'] = $image['filename'];
      }
      else {
        $content['view'] = t('Without this size image');
      }
      break;
    case 'original':
      $content['view'] = theme('photos_imagehtml', $image['original'], array(
        'filename' => $image['filename'],
      ));
      break;
    case 'exif':
      $content['view'] = $exif ? $exif : t('This image there is no Exif information.');
      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]['name']) {
        $sizes = end($content['sizes']);
        $content['view'] = theme('photos_imagehtml', $image['thumb'][$sizes['name']], array(
          'filename' => $image['filename'],
        ));
        $content['sharing_url'] = _photos_l($image['thumb'][$sizes['name']]);
      }
      $content['sharing_link'] = _photos_l('photos/image/' . $fid);
      $content['sharing_title'] = $image['filename'];
  }
  $content['link']['sizes'] = l(t('All sizes'), 'photos/zoom/' . $fid, array(
    'attributes' => $op,
  ));
  if (variable_get('photos_print_sizes', 1)) {
    print theme('photos_down', $content, 'print');
  }
  else {
    return theme('photos_down', $content, 'return');
  }
}