source: extensions/lightbox/functions.inc.php @ 29215

Last change on this file since 29215 was 21240, checked in by plg, 12 years ago

compatibility with Piwigo 2.5: replace functions mysql_* with pwg_db_* equivalent

bug fixed with option to link photo title on HD

File size: 2.3 KB
Line 
1<?php
2
3// Return picture lightbox picture URL for known extension
4function 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
22function 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')
47  {
48    $src_image = new SrcImage($picture);
49
50    if ($src_image->is_original() and 'true' == $user['enabled_high'])
51    {
52      $name.= ' ('.l10n('Display').' '.l10n('Original').')';
53      return htmlspecialchars('<a href="javascript:phpWGOpenWindow(\''.$src_image->get_url().'\',\'\',\'scrollbars=yes,toolbar=no,status=no,resizable=yes\')" rel="nofollow">'.$name.'</a>');
54    }
55  }
56  return $name;
57}
58
59// Return extra picture for multipage category
60function get_lightbox_extra_pictures($selection, $rank_of, $name_link)
61{
62  global $conf;
63
64  $query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $selection).');';
65  $result = pwg_query($query);
66  $pictures = array();
67  while ($row = pwg_db_fetch_assoc($result))
68  {
69    $row['rank'] = $rank_of[ $row['id'] ];
70    array_push($pictures, $row);
71  }
72  usort($pictures, 'rank_compare');
73 
74  $content = '<div class="thumbnails" style="display: none;">'."\n";
75  foreach ($pictures as $picture)
76  {
77    $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";
78  }
79  $content .= '</div>'."\n";
80 
81  return $content;
82}
83
84?>
Note: See TracBrowser for help on using the repository browser.