You are here

function photos_image_pager in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 photos.module \photos_image_pager()
2 calls to photos_image_pager()
photos_block in ./photos.module
photos_image_page in inc/photos.image.inc

File

./photos.module, line 640

Code

function photos_image_pager($fid, $id, $type = 'pid') {
  switch ($type) {
    case 'pid':
      $sql = 'p.pid';
      break;
    case 'nid':
      $sql = 't.pid';
      break;
    case 'uid':
      $sql = 'p.uid';
  }
  $result = db_query(db_rewrite_sql('SELECT p.pid, f.filepath, f.fid, f.filename FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid WHERE ' . $sql . ' = %d ORDER BY f.fid DESC', 'p', 'pid'), $id);
  $stop = $t['prev'] = $t['next'] = 0;
  while ($image = db_fetch_array($result)) {
    if ($stop == 1) {
      $t['next'] = $image;
      $t['next_view'] = photos_get_info(0, $t['next'], array(
        'label' => variable_get('photos_title_0', false),
      ));
      $t['next_url'] = url('photos/image/' . $image['fid']);
      break;
    }
    if ($image['fid'] == $fid) {
      $t['current'] = $image;
      $t['current_view'] = photos_get_info(0, $t['current'], array(
        'label' => variable_get('photos_title_0', false),
      ));
      $stop = 1;
    }
    else {
      $t['prev'] = $image;
    }
  }
  if ($t['prev']) {
    $t['prev_view'] = photos_get_info(0, $t['prev'], array(
      'label' => variable_get('photos_title_0', false),
    ));
    $t['prev_url'] = url('photos/image/' . $t['prev']['fid']);
  }
  return $t;
}