You are here

function node_gallery_get_image_navigator in Node Gallery 6.2

Same name and namespace in other branches
  1. 6.3 node_gallery.inc \node_gallery_get_image_navigator()
2 calls to node_gallery_get_image_navigator()
_node_gallery_gallery_view in ./node_gallery.module
_node_gallery_image_view in ./node_gallery.module

File

./node_gallery.inc, line 184
Node gallery models

Code

function node_gallery_get_image_navigator($gid, $nid) {
  $result = db_query("SELECT ng.nid FROM {node_galleries} ng JOIN {node} n ON ng.nid = n.nid WHERE n.status = 1 AND gid = %d ORDER BY weight, nid", $gid);
  while ($r = db_fetch_array($result)) {
    $items[] = $r['nid'];
  }
  $navigator['total'] = count($items);
  $navigator['parent'] = $gid;
  for ($i = 0; $i < $navigator['total']; $i++) {
    if ($items[$i] == $nid) {
      $navigator['current'] = $i + 1;
      $navigator['prev_nid'] = $i == 0 ? $items[$navigator['total'] - 1] : $items[$i - 1];
      $navigator['next_nid'] = $i == $navigator['total'] - 1 ? $items[0] : $items[$i + 1];
    }
  }
  return $navigator;
}