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

Last change on this file since 12856 was 12856, checked in by patdenice, 9 years ago

Compatible with question_mark_in_urls = false.

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