You are here

function photos_data_sub_block in Album Photos 6.2

1 string reference to 'photos_data_sub_block'
photos_menu in ./photos.module

File

inc/photos.data.inc, line 49

Code

function photos_data_sub_block($node, $op) {
  drupal_set_header('Content-Type: text/plain;');
  drupal_set_header('Cache-Control: no-cache, must-revalidate');
  drupal_set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
  switch ($op) {
    case 'block_new':
      $result = db_query_range('SELECT f.fid, f.filepath, f.filemime, f.timestamp, f.filename, f.filesize, n.title, u.uid, u.name, p.pid, p.comcount, p.count FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid INNER JOIN {node} n ON p.pid = n.nid INNER JOIN {users} u ON f.uid = u.uid INNER JOIN {x_node} a ON p.fid = a.fid WHERE a.nid = %d ORDER BY f.fid DESC', $node->nid, 0, 3);
      $i = 0;
      while ($images = db_fetch_array($result)) {
        $image = photos_get_info(0, $images);
        $t = array();
        if (is_array($image['thumb'])) {
          foreach ($image['thumb'] as $key => $thumb) {
            $t['url'] = _photos_l($thumb);
            break;
          }
        }
        $t['filename'] = $image['filename'];
        $t['link'] = _photos_l('photos/image/' . $image['fid']);
        $array[] = $t;
        ++$i;
      }
      $array['count'] = $i;
  }
  if ($_GET['type'] != 'xml' && $array['count']) {
    print _photos_json('en', $array);
  }
}