You are here

function _photos_edit_page_sub_album_images in Album Photos 7.3

Get images for sub album re-arrange page.

1 call to _photos_edit_page_sub_album_images()
photos_edit_sort_page in inc/photos.edit.inc
Grid drag and drop image sorting.

File

inc/photos.edit.inc, line 572
Handles uploading and editing images.

Code

function _photos_edit_page_sub_album_images($nid, $limit = 10) {
  $images = array();
  $column = isset($_GET['field']) ? $_GET['field'] : '';
  $sort = isset($_GET['sort']) ? $_GET['sort'] : '';
  $term = _photos_order_value($column, $sort, $limit, array(
    'column' => 's.wid',
    'sort' => 'asc',
  ));
  $query = db_select('file_managed', 'f')
    ->extend('PagerDefault');
  $query
    ->join('photos_image', 'p', 'p.fid = f.fid');
  $query
    ->join('photos_node', 's', 's.fid = f.fid');
  $query
    ->join('users', 'u', 'f.uid = u.uid');
  $query
    ->join('node', 'n', 'n.nid = p.pid');
  $query
    ->fields('f', array(
    'uri',
    'filemime',
    'timestamp',
    'filename',
    'filesize',
  ));
  $query
    ->fields('p');
  $query
    ->fields('u', array(
    'uid',
    'name',
  ));
  $query
    ->condition('s.nid', $nid);
  $query
    ->limit($term['limit']);
  $query
    ->orderBy($term['order']['column'], $term['order']['sort']);
  $query
    ->addTag('node_access');
  $result = $query
    ->execute();
  foreach ($result as $data) {
    $images[] = photos_get_info(0, $data);
  }
  if (isset($images[0]->fid)) {
    $node = node_load($nid);
    $images[0]->info = array(
      'pid' => $node->nid,
      'title' => $node->title,
      'uid' => $node->uid,
    );
  }
  return $images;
}