You are here

class Gallery in Node Gallery 6

Hierarchy

Expanded class hierarchy of Gallery

1 string reference to 'Gallery'
node_gallery_config_form in ./node_gallery.admin.inc

File

./node_gallery.model.inc, line 147
Node gallery module.

View source
class Gallery extends base {
  function delete() {
    return db_query("DELETE FROM {ng_images} WHERE gid = %d", $this->nid);
  }
  function get_config() {
    if (empty($this->config)) {
      $this->config = gallery_config_gateway::get_by($this->type);
    }
    return $this->config;
  }
  function get_images() {
    if (empty($this->images)) {
      $result = db_query("SELECT nid FROM {ng_images} WHERE gid = %d", $this->nid);
      while ($r = db_fetch_array($result)) {
        $nids[] = $r['nid'];
      }
      if (!empty($nids)) {
        $this->images = ImageGateway::find_details($nids);
        $this->image_count = count($this->images);
      }
    }
    return $this->images;
  }
  function get_content($teaser = 0) {
    $node = db_fetch_object(db_query("SELECT teaser, body, format FROM {node_revisions} WHERE nid = %d", $this->nid));
    $node->body = isset($node->body) ? str_replace('<!--break-->', '', $node->body) : '';
    $node = node_prepare($node, $teaser);
    return $node->content['body']['#value'];
  }
  function get_title() {
    if (empty($this->title)) {
      $this->title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $this->nid));
    }
    return $this->title;
  }
  function get_image_navigator($nid) {
    $result = db_query("SELECT nid FROM {ng_images} WHERE gid = %d ORDER BY weight, nid", $this->nid);
    while ($r = db_fetch_array($result)) {
      $items[] = $r['nid'];
    }
    $navigator['total'] = count($items);
    $navigator['parent'] = $this->nid;
    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;
  }

}

Members