function photos_image_page in Album Photos 7.3
Same name and namespace in other branches
- 6.2 inc/photos.image.inc \photos_image_page()
Image page.
1 call to photos_image_page()
- photos_page_image in inc/
photos.page.inc - Latest images page.
1 string reference to 'photos_image_page'
- photos_menu in ./
photos.module - Implements hook_menu().
File
- inc/
photos.image.inc, line 10 - Handles image page view(s) and content.
Code
function photos_image_page($fid, $uid = NULL) {
if (!is_numeric($fid)) {
drupal_not_found();
drupal_exit();
}
global $user;
$query = db_select('file_managed', 'f');
$query
->join('photos_image', 'p', 'p.fid = f.fid');
$query
->join('photos_album', 'a', 'p.pid = a.pid');
$query
->join('node', 'n', 'n.nid = p.pid');
$query
->join('users', 'u', 'u.uid = f.uid');
$query
->fields('f', array(
'uri',
'filemime',
'timestamp',
'filename',
))
->fields('p')
->fields('a', array(
'data',
))
->fields('u', array(
'uid',
'name',
));
$query
->condition('p.fid', $fid);
$query
->addTag('node_access');
$image = $query
->execute()
->fetchObject();
if (!$image) {
return drupal_not_found();
}
$image = photos_get_info(0, $image);
$node = node_load($image->pid);
if (_photos_access('imageEdit', $node)) {
$image->ajax['edit_url'] = url('photos/image/' . $image->fid . '/update');
if (_photos_select_sub_album()) {
$image->links['to_sub'] = l(t('Add to sub-album...'), 'photos/image/' . $image->fid . '/to_sub', array(
'attributes' => array(
'class' => array(
'colorbox',
),
),
));
}
$image->links['cover'] = l(t('Set to Cover'), 'node/' . $image->pid . '/photos/cover/' . $fid, array(
'query' => drupal_get_destination(),
));
}
$image->class = array(
'title_class' => '',
'des_class' => '',
);
$image->id = array(
'des_edit' => '',
'title_edit' => '',
);
if (_photos_access('imageEdit', $node)) {
$image->ajax['edit_link'] = l(t('Edit'), 'photos/image/' . $image->fid . '/edit', array(
'query' => array(
'destination' => 'photos/image/' . $image->fid,
),
'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 . '"',
);
}
if (_photos_access('imageDelete', $node)) {
$image->ajax['del_link'] = l(t('Delete'), 'photos/image/' . $image->fid . '/delete', array(
'query' => array(
'destination' => 'node/' . $image->pid,
),
'attributes' => array(
'class' => array(
'colorbox-load',
'photos-edit-delete',
),
),
));
}
if (variable_get('photos_vote', 0)) {
$image->vote = theme('photos_vote', array(
'fid' => $fid,
));
}
if (variable_get('photos_comment', 0)) {
$image->links['comment'] = theme('photos_comment_count', array(
'comcount' => $image->comcount,
));
}
if ($uid) {
// User images.
$pager_type = 'uid';
$pager_id = $uid;
}
elseif (isset($_GET['photos_sub'])) {
// Sub-album images.
$pager_type = 'sub';
$pager_id = (int) $_GET['photos_sub'];
}
else {
// Album images.
$pager_type = 'pid';
$pager_id = $image->pid;
}
$data = unserialize($image->data);
$style_name = isset($data['view_imagesize']) ? $data['view_imagesize'] : variable_get('photos_display_view_imagesize', 'large');
// 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_view_imagesize', 'large');
}
// Display all sizes link to share code?
$all_sizes_link = variable_get('photos_print_sizes', 0);
if ($all_sizes_link < 2) {
// Display full page or colorbox.
$colorbox = array();
if ($all_sizes_link == 1) {
$colorbox = array(
'query' => array(
'iframe' => 'true',
'height' => 650,
'width' => 850,
),
'attributes' => array(
'class' => array(
'colorbox-load',
),
),
);
}
$image->links['more'] = l(t('All sizes'), 'photos/zoom/' . $fid, $colorbox);
}
$image->links['pager'] = photos_image_pager($fid, $pager_id, $pager_type);
$image->view = theme('photos_imagehtml', array(
'style_name' => $style_name,
'image' => $image,
));
$image->comment['view'] = _photos_comment($fid, $image->comcount, $node);
if (!variable_get('photos_image_count', 0)) {
$count = 1;
db_update('photos_image')
->fields(array(
'count' => $count,
))
->expression('count', 'count + :count', array(
':count' => $count,
))
->condition('fid', $fid)
->execute();
}
drupal_set_title($image->title);
$image->title = check_plain($image->title);
$image->des = check_plain($image->des);
if ($pager_type == 'sub') {
// Home >> Node Title >> Sub Album >> Image
$sub_album = node_load($pager_id);
$sub_title = t('Sub-Album: @title', array(
'@title' => $sub_album->title,
));
_photos_breadcrumb(array(
l($sub_album->title, 'node/' . $sub_album->nid),
l($sub_title, 'photos/sub_album/' . $sub_album->nid),
$image->title,
));
}
else {
_photos_breadcrumb(array(
l(t('Images'), 'photos/image'),
l(t('@name\'s images', array(
'@name' => $image->name,
)), 'photos/user/' . $image->uid . '/image'),
l($node->title, 'photos/album/' . $image->pid),
$image->title,
));
}
$GLOBALS['photos'][$image->fid . '_pid'] = $image->pid;
return theme('photos_imageview', array(
'image' => $image,
'type' => 'view',
));
}