You are here

function photos_album_page in Album Photos 6.2

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

File

inc/photos.album.inc, line 6

Code

function photos_album_page($node) {
  $order = explode('|', $node->album['imageorder'] ? $node->album['imageorder'] : variable_get('photos_display_imageorder', 'timestamp|desc'));
  $order = _photos_order_value_change($order[0], $order[1]);
  $limit = $node->album['viewpager'] ? $node->album['viewpager'] : variable_get('photos_display_viewpager', 10);
  $term = _photos_order_value($_GET['field'], $_GET['sort'], $limit, $order);
  $result = pager_query('SELECT f.filepath, f.filemime, f.timestamp, f.filename, f.filesize, 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.pid = %d' . $term['order'], $term['limit'], 0, NULL, $node->nid);
  $com = variable_get('photos_comment', 0);
  $edit = node_access('update', $node);
  $del = node_access('delete', $node);
  $vote = variable_get('photos_vote', 0);
  $label = $node->album['list_imagesize'] ? $node->album['list_imagesize'] : variable_get('photos_display_list_imagesize', false);
  while ($data = db_fetch_array($result)) {
    $image = photos_get_info(0, $data);
    $image['view'] = theme('photos_imagehtml', $image['thumb'][$label], array(
      'filename' => $image['filename'],
    ));
    $image['url'] = url('photos/image/' . $image['fid']);
    if ($com) {
      $image['links']['comment'] = theme('photos_comment_count', $image['comcount'], $image['url']);
    }
    if ($image['count']) {
      $image['links']['count'] = t('!cou visits', array(
        '!cou' => $image['count'],
      ));
    }
    $image['links']['info'] = t('Uploaded on !time by !name', array(
      '!name' => theme('username', (object) $image),
      '!time' => format_date($image['timestamp'], 'small'),
    ));
    if ($edit) {
      $image['ajax']['edit_url'] = $image['url'] . '/update';
      $image['links']['cover'] = l(t('Set to Cover'), "node/{$image['pid']}/photos/cover/{$image['fid']}", array(
        'query' => drupal_get_destination(),
      ));
    }
    if ($del) {
      $image['ajax']['del_id'] = 'id="photos_ajax_del_' . $image['fid'] . '"';
      $image['ajax']['del_link'] = l(t('Delete'), 'photos/image/' . $image['fid'] . '/delete', array(
        'query' => array(
          'destination' => $_GET['q'],
          'pid' => $node->nid,
          'uid' => $image['uid'],
        ),
        'attributes' => array(
          'class' => 'jQueryeditable_edit_delete',
          'alt' => 'photos_ajax_del_' . $image['fid'],
        ),
      ));
    }
    if ($vote) {
      $image['links']['vote'] = theme('photos_vote', $image['fid']);
    }
    $album['view'][] = theme('photos_imageview', $image, 'list');
  }
  if ($album['view'][0]) {
    $album['access']['edit'] = $edit;
    $album['node_url'] = url("node/{$node->nid}");
    $album['album_url'] = url("photos/album/{$node->nid}");
    $album['links'] = _photos_order_link("photos/album/{$node->nid}", 0, 0, 1);
    $album['pager'] = theme('pager', NULL, $term['limit']);
    $v = theme('photos_albumview', $album, $node);
  }
  else {
    $v = t('Album is empty');
  }
  _photos_breadcrumb(array(
    l(t('@name\'s albums', array(
      '@name' => $node->name,
    )), "photos/user/{$node->uid}/album"),
    l($node->title, "node/{$node->nid}"),
  ));
  drupal_set_title(t('Albums: @title', array(
    '@title' => check_plain($node->title),
  )));
  return $v;
}