You are here

function photos_image_page in Album Photos 6.2

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

File

inc/photos.image.inc, line 5

Code

function photos_image_page($fid) {
  global $user;
  $image = db_fetch_array(db_query('SELECT f.filepath, f.filemime, f.timestamp, f.filename, n.title, u.uid, u.name, b.data, p.* FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid INNER JOIN {x_album} b ON p.pid = b.pid INNER JOIN {node} n ON p.pid = n.nid INNER JOIN {users} u ON f.uid = u.uid WHERE p.fid = %d', $fid));
  if (!$image) {
    return drupal_not_found();
  }
  $image = photos_get_info(0, $image);
  $node = db_fetch_object(db_query('SELECT r.format, n.* FROM {node} n INNER JOIN {node_revisions} r ON n.nid = r.nid WHERE n.nid = %d', $image['pid']));
  if (_photos_access('imageEdit', $node)) {
    $image['ajax']['edit_url'] = url('photos/image/' . $image['fid'] . '/update');
    if (_photos_select_sub_album()) {
      $image['links']['to_sub'] = l(t('To sub-album...'), 'photos/image/' . $image['fid'] . '/to_sub', array(
        'query' => 'KeepThis=true&TB_iframe=true&height=450&width=600',
        'attributes' => array(
          'class' => 'thickbox',
        ),
      ));
    }
    $image['links']['cover'] = l(t('Set to Cover'), "node/{$image['pid']}/photos/cover/{$fid}", array(
      'query' => drupal_get_destination(),
    ));
  }
  if (_photos_access('imageDelete', $node)) {
    $image['ajax']['del_link'] = l(t('Delete'), 'photos/image/' . $image['fid'] . '/delete', array(
      'query' => array(
        'destination' => 'node/' . $image['pid'],
      ),
    ));
  }
  if (variable_get('photos_vote', 0)) {
    $image['vote'] = theme('photos_vote', $fid);
  }
  if (variable_get('photos_comment', 0)) {
    $image['links']['comment'] = theme('photos_comment_count', $image['comcount']);
  }
  $data = unserialize($image['data']);
  $label = $data['view_imagesize'] ? $data['view_imagesize'] : variable_get('photos_display_view_imagesize', $view_imagesize);
  $image['links']['more'] = l(t('All sizes'), 'photos/zoom/' . $fid);
  $image['links']['pager'] = photos_image_pager($fid, $image['pid']);
  $image['view'] = theme('photos_imagehtml', $image['thumb'][$label], $image);
  $image['comment']['view'] = _photos_vote_comment($fid, $image['comcount'], $image['pid']);
  if (variable_get('photos_comment', 0) && user_access('post comments')) {
    $image['comment']['box'] = comment_form_box(array(
      'nid' => $image['pid'],
    ), t('Post new comment'));
  }
  if (!variable_get('photos_image_count', 0)) {
    db_query('UPDATE {x_image} SET count = count + 1 WHERE fid = %d', $fid);
  }
  drupal_set_title($image['filename']);
  _photos_breadcrumb(array(
    l(t('Images'), 'photos/image'),
    l(t('@name\'s images', array(
      '@name' => $image['name'],
    )), 'photos/user/' . $image['uid'] . '/image'),
    l($image['title'], "photos/album/{$image['pid']}"),
  ));
  $GLOBALS['photos'][$image['fid'] . '_pid'] = $image['pid'];
  return theme('photos_imageview', $image, 'view');
}