function photos_album_page in Album Photos 7.3
Same name and namespace in other branches
- 6.2 inc/photos.album.inc \photos_album_page()
Album view.
See also
1 string reference to 'photos_album_page'
- photos_menu in ./
photos.module - Implements hook_menu().
File
- inc/
photos.album.inc, line 12 - Handles album views and content.
Code
function photos_album_page($node) {
$build = array();
$order = explode('|', isset($node->album['imageorder']) ? $node->album['imageorder'] : variable_get('photos_display_imageorder', 'timestamp|desc'));
$order = _photos_order_value_change($order[0], $order[1]);
$limit = isset($node->album['full_viewnum']) ? $node->album['full_viewnum'] : variable_get('photos_display_viewpager', 10);
$column = isset($_GET['field']) ? $_GET['field'] : '';
$sort = isset($_GET['sort']) ? $_GET['sort'] : '';
$term = _photos_order_value($column, $sort, $limit, $order);
$query = db_select('file_managed', 'f')
->extend('PagerDefault');
$query
->join('photos_image', 'p', 'p.fid = f.fid');
$query
->join('users', 'u', 'u.uid = f.uid');
$query
->fields('f', array(
'uri',
'filemime',
'timestamp',
'filename',
'filesize',
))
->fields('p')
->fields('u', array(
'uid',
'name',
))
->condition('p.pid', $node->nid)
->orderBy($term['order']['column'], $term['order']['sort'])
->limit($term['limit']);
$result = $query
->execute();
$com = variable_get('photos_comment', 0);
$vote = variable_get('photos_vote', 0);
$edit = node_access('update', $node);
$del = node_access('delete', $node);
$style_name = isset($node->album['list_imagesize']) ? $node->album['list_imagesize'] : variable_get('photos_display_list_imagesize', 'thumbnail');
// Necessary when upgrading from D6 to D7.
$image_styles = image_style_options(FALSE);
if (!isset($image_styles[$style_name])) {
$style_name = variable_get('photos_display_list_imagesize', 'medium');
}
foreach ($result as $data) {
$image = photos_get_info(0, $data);
$image->title = check_plain($image->title);
$image->des = check_plain($image->des);
$title = $image->title;
$image->view = theme('photos_imagehtml', array(
'style_name' => $style_name,
'image' => $image,
));
$image->url = url('photos/image/' . $image->fid);
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 on !time by !name', array(
'!name' => $image->name,
'!time' => format_date($image->timestamp, 'small'),
));
$image->class = array(
'title_class' => '',
'des_class' => '',
);
$image->id = array(
'des_edit' => '',
'title_edit' => '',
);
if ($edit) {
$destination = drupal_get_destination();
$image->ajax['edit_url'] = $image->url . '/update';
$image->ajax['edit_link'] = l(t('Edit'), 'photos/image/' . $image->fid . '/edit', array(
'query' => array(
'destination' => $destination['destination'],
'pid' => $node->nid,
'uid' => $image->uid,
),
'attributes' => array(
'class' => array(
'colorbox-load',
'photos-edit-edit',
),
),
));
$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->links['cover'] = l(t('Set to Cover'), 'node/' . $image->pid . '/photos/cover/' . $image->fid, array(
'query' => $destination,
));
}
$image->ajax['del_id'] = '';
if ($del) {
$image->ajax['del_id'] = 'id="photos_ajax_del_' . $image->fid . '"';
$destination = drupal_get_destination();
$image->ajax['del_link'] = l(t('Delete'), 'photos/image/' . $image->fid . '/delete', array(
'query' => array(
'destination' => $destination['destination'],
'pid' => $node->nid,
'uid' => $image->uid,
),
'attributes' => array(
'class' => array(
'colorbox-load',
'photos-edit-delete',
),
),
));
}
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['access']['edit'] = $edit;
$album['node_edit_url'] = l(t('Album settings'), 'node/' . $node->nid . '/edit');
$album['image_management_url'] = l(t('Images Management'), 'node/' . $node->nid . '/photos');
$album['album_url'] = url('photos/album/' . $node->nid);
$album['links'] = _photos_order_link('photos/album/' . $node->nid, 0, 0, 1);
$cover_style_name = variable_get('photos_cover_imagesize', 'thumbnail');
if (isset($node->album['cover']['url'])) {
$album_cover = theme('image_style', array(
'style_name' => $cover_style_name,
'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('Album is empty');
}
$node_title = $node->title;
_photos_breadcrumb(array(
l(t('@name\'s albums', array(
'@name' => $node->name,
)), 'photos/user/' . $node->uid . '/album'),
l($node_title, 'node/' . $node->nid),
));
$page_title = t('Albums: @title', array(
'@title' => $node_title,
));
drupal_set_title($page_title, PASS_THROUGH);
return $v;
}