You are here

function photos_edit_upload in Album Photos 7.3

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

Photos upload and edit page.

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

File

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

Code

function photos_edit_upload() {
  global $user;
  $v = '';
  $header = array(
    array(
      'data' => t('Album title'),
      'field' => 'n.title',
    ),
    array(
      'data' => t('Image count'),
      'field' => 'p.count',
    ),
    array(
      'data' => t('Link'),
    ),
    array(
      'data' => t('Create time'),
      'field' => 'n.nid',
      'sort' => 'desc',
    ),
  );
  $query = db_select('node', 'n')
    ->extend('TableSort')
    ->extend('PagerDefault');
  $query
    ->join('photos_album', 'p', 'p.pid = n.nid');
  $query
    ->fields('n')
    ->fields('p', array(
    'count',
  ));
  $query
    ->condition('n.uid', $user->uid);
  $query
    ->orderByHeader($header);
  $query
    ->limit(20);
  $result = $query
    ->execute();
  foreach ($result as $node) {
    $slideshow = '';
    if (module_exists('dfgallery')) {

      // @todo add check and support for other slideshow options.
      $slideshow = l(t('Slideshow'), 'photos/Slide/' . $node->nid);
    }
    $table[] = array(
      l($node->title, 'node/' . $node->nid),
      $node->count,
      array(
        'data' => l(t('Upload'), 'node/' . $node->nid . '/photos') . l(t('View'), 'photos/album/' . $node->nid) . $slideshow,
        'class' => 'photos_album_edit_table_link',
      ),
      format_date($node->created, 'small'),
    );
  }
  $edit = array(
    'submit' => TRUE,
  );
  $upload_form = drupal_get_form('photos_upload_form', 0, $edit);
  $v = drupal_render($upload_form);
  if (empty($table)) {
    $table[] = array(
      array(
        'data' => l(t('Please create an album.'), 'node/add/photos'),
        'colspan' => 4,
      ),
    );
  }
  else {
    $v .= t('Or select an album') . ': ';
  }
  $v .= theme('table', array(
    'header' => $header,
    'rows' => $table,
  ));
  $v .= theme('pager');
  return $v;
}