function photos_sub_album_page in Album Photos 7.3
Same name and namespace in other branches
- 6.2 inc/photos.album.inc \photos_sub_album_page()
Sub album view.
See also
1 string reference to 'photos_sub_album_page'
- photos_menu in ./
photos.module - Implements hook_menu().
File
- inc/
photos.album.inc, line 140 - Handles album views and content.
Code
function photos_sub_album_page($node) {
$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'] : '';
$term = _photos_order_value($column, $sort, variable_get('photos_display_viewpager', 10), $order);
// 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_image', 'p', 'p.fid = f.fid');
$query
->join('photos_node', 'a', 'a.fid = f.fid');
$query
->join('node', 'n', 'n.nid = p.pid');
$query
->join('users', 'u', 'u.uid = f.uid');
$query
->addField('n', 'title', 'album_title');
$query
->fields('f', array(
'uri',
'filemime',
'timestamp',
'filename',
'filesize',
))
->fields('p')
->fields('a')
->fields('u', array(
'uid',
'name',
))
->condition('a.nid', $node->nid);
$query
->orderBy($term['order']['column'], $term['order']['sort']);
$query
->range(0, $term['limit']);
$result = $query
->execute();
$com = variable_get('photos_comment', 0);
$edit = node_access('update', $node);
$del = node_access('delete', $node);
$vote = variable_get('photos_vote', 0);
$style_name = variable_get('photos_display_list_imagesize', 'medium');
foreach ($result as $data) {
$image = photos_get_info(0, $data);
$image->view = theme('photos_imagehtml', array(
'style_name' => $style_name,
'image' => $image,
));
$image->url = url('photos/image/' . $image->fid, array(
'query' => array(
'photos_sub' => $image->nid,
),
));
if ($com) {
$image->links['comment'] = theme('photos_comment_count', array(
'comcount' => $image->comcount,
'url' => $image->url,
));
}
if ($image->count) {
$image->links['count'] = format_plural($image->count, '!cou visit', '!cou visits', array(
'!cou' => $image->count,
));
}
$image->links['info'] = t('Uploaded by !name on !time to !title', array(
'!name' => $image->name,
'!time' => format_date($image->timestamp, 'small'),
'!title' => l($image->album_title, 'photos/album/' . $image->pid),
));
$image->class = array(
'title_class' => '',
'des_class' => '',
);
$image->id = array(
'des_edit' => '',
'title_edit' => '',
);
if ($edit) {
$image->ajax['edit_url'] = $image->url . '/update';
// $image->links['cover'] = l(t('Set as Cover'), 'node/' . $image->pid . '/photos/cover/' . $image->fid, array('query' => drupal_get_destination()));
$image->class = array(
'title_class' => ' jQueryeditable_edit_title',
'des_class' => ' jQueryeditable_edit_des',
);
$image->id = array(
'des_edit' => ' id="photos-image-edit-des-' . $image->fid . '"',
'title_edit' => ' id="photos-image-edit-title-' . $image->fid . '"',
);
}
$image->ajax['del_id'] = '';
if ($del) {
$image->ajax['del_id'] = 'id="photos_ajax_del_' . $image->fid . '"';
$image->ajax['del_link'] = l(t('Move out'), 'photos/image/' . $image->fid . '/delete', array(
'query' => array(
'destination' => $_GET['q'],
'type' => 'sub_album',
'nid' => $node->nid,
),
'attributes' => array(
'class' => 'colorbox-load',
),
));
}
if ($vote) {
$image->links['vote'] = theme('photos_vote', array(
'fid' => $image->fid,
));
}
$album['view'][] = theme('photos_imageview', array(
'image' => $image,
'type' => 'list',
));
}
if (isset($album['view'][0])) {
$album['node_url'] = url('node/' . $node->nid);
$album['album_url'] = url('photos/sub_album/' . $node->nid);
$album['links'] = _photos_order_link('photos/album/' . $node->nid, $node->subalbum['count'], 0, 1);
$album['pager'] = theme('pager');
if (isset($node->album['cover']['url'])) {
$album_cover = theme('image_style', array(
'style_name' => 'thumbnail',
'path' => $node->album['cover']['url'],
'alt' => $node->title,
'title' => $node->title,
));
$album['cover'] = $album_cover;
}
$v = theme('photos_albumview', array(
'album' => $album,
'node' => $node,
));
}
else {
$v = t('Sub-Album is empty');
}
$page_title = t('Sub-Album: @title', array(
'@title' => $node->title,
));
_photos_breadcrumb(array(
l($node->title, 'node/' . $node->nid),
));
drupal_set_title($page_title);
return $v;
}