You are here

function _photos_edit_page_node in Album Photos 7.3

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

Sub-album image management page.

1 call to _photos_edit_page_node()
photos_edit_page in inc/photos.edit.inc
Image management.

File

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

Code

function _photos_edit_page_node($node) {
  $output = '';
  $result = array();
  if (isset($node->subalbum['count'])) {
    $column = isset($_GET['field']) ? $_GET['field'] : '';
    $sort = isset($_GET['sort']) ? $_GET['sort'] : '';
    $term = _photos_order_value($column, $sort, 10, array(
      'column' => 'a.wid',
      'sort' => 'asc',
    ));

    // Override weight sort for sub albums.
    if ($term['order']['column'] == 'p.wid') {
      $term['order']['column'] = 'a.wid';
    }
    $query = db_select('file_managed', 'f')
      ->extend('PagerDefault');
    $query
      ->join('photos_node', 'a', 'a.fid = f.fid');
    $query
      ->join('photos_image', 'p', 'p.fid = f.fid');
    $query
      ->join('node', 'n', 'n.nid = p.pid');
    $query
      ->join('users', 'u', 'u.uid = f.uid');
    $query
      ->fields('f', array(
      'uri',
      'filemime',
      'timestamp',
      'filename',
      'filesize',
    ));
    $query
      ->fields('p', array(
      'fid',
      'pid',
      'title',
      'des',
      'count',
      'comcount',
      'exif',
    ));
    $query
      ->fields('a', array(
      'wid',
    ));
    $query
      ->fields('n', array(
      'nid',
    ));
    $query
      ->addField('n', 'title', 'album_title');
    $query
      ->fields('u', array(
      'uid',
      'name',
    ));
    $query
      ->condition('a.nid', $node->nid);
    $query
      ->orderBy($term['order']['column'], $term['order']['sort']);
    $query
      ->limit($term['limit']);
    $result = $query
      ->execute();
    $output .= _photos_order_link('node/' . $node->nid . '/photos', $node->subalbum['count'], l(t('Album view'), 'photos/sub_album/' . $node->nid), 1);
    $output .= '<div class="messages warning">' . t('Move out: Move image out of the sub gallery, but it will not delete it.') . '</div>';
  }
  else {
    return;
  }
  $images = array();
  foreach ($result as $data) {
    $images[] = photos_get_info(0, $data);
  }
  if (isset($images[0]->fid)) {
    $images[0]->info = array(
      'title' => $node->title,
      'nid' => $node->nid,
      'uid' => $node->uid,
    );
  }

  // Uploaded photos.
  $editlist_form = drupal_get_form('photos_editlist_form', $images, 'node');
  $output .= theme('pager');
  $output .= drupal_render($editlist_form);
  $output .= theme('pager');
  return $output;
}