You are here

function photos_data_album in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 inc/photos.data.inc \photos_data_album()

Album slideshow data.

1 string reference to 'photos_data_album'
photos_menu in ./photos.module
Implements hook_menu().

File

inc/photos.data.inc, line 121
Handles slideshow integration.

Code

function photos_data_album($node) {
  drupal_add_http_header('Content-Type:', 'text/plain;');
  drupal_add_http_header('Cache-Control:', 'no-cache, must-revalidate');
  drupal_add_http_header('Expires:', 'Sat, 26 Jul 1997 05:00:00 GMT');
  if ($node->type == 'photos') {
    $order = explode('|', $node->album['imageorder'] ? $node->album['imageorder'] : variable_get('photos_display_imageorder', 'timestamp|desc'));
    $order = _photos_order_value_change($order[0], $order[1]);
    $column = isset($_GET['field']) ? $_GET['field'] : '';
    $sort = isset($_GET['sort']) ? $_GET['sort'] : '';
    $limit = 100;
    $term = _photos_order_value($column, $sort, $limit, $order);
    $query = db_select('file_managed', 'f');
    $query
      ->join('photos_image', 'p', 'p.fid = f.fid');
    $query
      ->fields('f', array(
      'fid',
      'uri',
      'filemime',
      'timestamp',
      'filename',
      'filesize',
    ))
      ->condition('p.pid', $node->nid)
      ->orderBy($term['order']['column'], $term['order']['sort'])
      ->range(0, $term['limit']);
    $result = $query
      ->execute();
  }
  else {
    $order = explode('|', variable_get('photos_display_imageorder', 'timestamp|desc'));
    $order = _photos_order_value_change($order[0], $order[1]);
    $column = isset($_GET['field']) ? $_GET['field'] : '';
    $sort = isset($_GET['sort']) ? $_GET['sort'] : '';
    $limit = 100;
    $term = _photos_order_value($column, $sort, $limit, $order);
    $query = db_select('file_managed', 'f');
    $query
      ->join('photos_image', 'p', 'p.fid = f.fid');
    $query
      ->join('photos_node', 'a', 'a.fid = p.fid');
    $query
      ->fields('f', array(
      'fid',
      'uri',
      'filemime',
      'timestamp',
      'filename',
      'filesize',
    ))
      ->condition('a.nid', $node->nid)
      ->orderBy($term['order']['column'], $term['order']['sort'])
      ->range(0, $term['limit']);
    $result = $query
      ->execute();
  }
  $thumb = variable_get('photos_slide_show_thumb', 0);
  $view = variable_get('photos_slide_show_view', 0);
  $true = FALSE;
  foreach ($result as $images) {
    $image = photos_get_info(0, $images);
    $array[] = array(
      'title' => $image->filename,
      'timestamp' => $image->timestamp,
      'thumbnail' => _photos_l($image->thumb[$thumb]),
      'image' => _photos_l($image->thumb[$view]),
    );
    $true = TRUE;
  }
  if ($true) {
    $albums = array(
      array(
        'properties' => array(
          'title' => check_plain($node->title),
          'description' => check_plain($node->teaser),
          // 相册描述
          'icon' => $node->album['cover']['url'],
        ),
        'images' => $array,
      ),
    );
    if (variable_get('photos_slide_music', FALSE)) {
      $setting['config']['theme']['config_theme_music'] = $node->album['slide_music'] ? $node->album['slide_music'] : variable_get('photos_slide_music', FALSE);
    }
    print dfgallery_json($albums, $setting);
  }
}