1 | <?php |
---|
2 | |
---|
3 | // Return picture lightbox picture URL for known extension |
---|
4 | function get_lightbox_url($picture) |
---|
5 | { |
---|
6 | global $conf, $pwg_loaded_plugins; |
---|
7 | |
---|
8 | $ext = get_extension($picture['file']); |
---|
9 | if (!empty($pwg_loaded_plugins['gvideo']) and $picture['is_gvideo']) |
---|
10 | { |
---|
11 | return get_root_url().'plugins/lightbox/get_content.php?imgid='.$picture['id']; |
---|
12 | } |
---|
13 | else if (in_array($ext, $conf['picture_ext'])) |
---|
14 | { |
---|
15 | return DerivativeImage::url(IMG_LARGE, new SrcImage($picture)); |
---|
16 | } |
---|
17 | |
---|
18 | return false; |
---|
19 | } |
---|
20 | |
---|
21 | // Return lightbox title |
---|
22 | function get_lightbox_title($picture, $name_link) |
---|
23 | { |
---|
24 | global $conf, $user; |
---|
25 | |
---|
26 | if (isset($picture['name']) and $picture['name'] != '') |
---|
27 | { |
---|
28 | $name = trigger_event('render_element_description', $picture['name']); |
---|
29 | } |
---|
30 | else |
---|
31 | { |
---|
32 | $name = str_replace('_', ' ', get_filename_wo_extension($picture['file'])); |
---|
33 | } |
---|
34 | |
---|
35 | if ($name_link == 'picture') |
---|
36 | { |
---|
37 | $url = duplicate_picture_url( |
---|
38 | array( |
---|
39 | 'image_id' => $picture['id'], |
---|
40 | 'image_file' => $picture['file'] |
---|
41 | ), |
---|
42 | array('start') |
---|
43 | ); |
---|
44 | return htmlspecialchars('<a href="'.$url.'">'.$name.'</a>'); |
---|
45 | } |
---|
46 | elseif ($name_link == 'high' and $picture['has_high'] and $user['enabled_high']=='true') |
---|
47 | { |
---|
48 | include_once(PHPWG_ROOT_PATH . 'include/functions_picture.inc.php'); |
---|
49 | return htmlspecialchars('<a href="javascript:phpWGOpenWindow(\''.get_high_url($picture).'\',\'\',\'scrollbars=yes,toolbar=no,status=no,resizable=yes\')">'.$name.'</a>'); |
---|
50 | } |
---|
51 | return $name; |
---|
52 | } |
---|
53 | |
---|
54 | // Return extra picture for multipage category |
---|
55 | function get_lightbox_extra_pictures($selection, $rank_of, $name_link) |
---|
56 | { |
---|
57 | global $conf; |
---|
58 | |
---|
59 | $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $selection).');'; |
---|
60 | $result = pwg_query($query); |
---|
61 | $pictures = array(); |
---|
62 | while ($row = pwg_db_fetch_assoc($result)) |
---|
63 | { |
---|
64 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
65 | array_push($pictures, $row); |
---|
66 | } |
---|
67 | usort($pictures, 'rank_compare'); |
---|
68 | |
---|
69 | $content = '<div class="thumbnails" style="display: none;">'."\n"; |
---|
70 | foreach ($pictures as $picture) |
---|
71 | { |
---|
72 | $content .= '<a href="#" id="img-'.$picture['id'].'" name="'.get_lightbox_url($picture).'" title="'.get_lightbox_title($picture, $name_link).'" rel="colorbox'.$conf['lightbox_rel'].'"></a>'."\n"; |
---|
73 | } |
---|
74 | $content .= '</div>'."\n"; |
---|
75 | |
---|
76 | return $content; |
---|
77 | } |
---|
78 | |
---|
79 | ?> |
---|