source: extensions/lightbox/lightbox.php @ 7175

Last change on this file since 7175 was 6373, checked in by patdenice, 14 years ago

Compatible Piwigo 2.1

File size: 3.0 KB
Line 
1<?php
2
3global $page, $conf, $template, $user;
4
5include_once(LIGHTBOX_PATH.'functions.inc.php');
6$params = unserialize($conf['lightbox']);
7$conf['lightbox_rel'] = isset($conf['lightbox_rel']) ? ++$conf['lightbox_rel'] : 0;
8
9switch ($user['theme'])
10{
11  case 'simple':
12    $selector = '#thumbnails a';
13    break;
14
15  default:
16    $selector = '.thumbnails a';
17    break;
18}
19
20$template->func_known_script(array('id'=>'jquery', 'src'=>get_root_url().'themes/default/js/jquery.packed.js'), $smarty);
21$template->func_known_script(array('id'=>'colorbox', 'src'=>get_root_url().'plugins/lightbox/js/jquery.colorbox-min.js'), $smarty);
22$template->block_html_head('', '
23<link rel="stylesheet" href="'.get_root_url().'plugins/lightbox/theme/'.$params['theme'].'/colorbox.css" type="text/css" media="screen">
24<script type="text/javascript">
25$(document).ready(function(){
26$("'.$selector.'").attr("href", function () {
27  return this.name;   
28});
29$("'.$selector.'").colorbox({
30  current: "",
31  transition: "'.$params['transition'].'",
32  speed: "'.$params['transition_speed'].'",
33  initialWidth: "'.(!empty($params['initial_width']) ? $params['initial_width'] : $config_default['initial_width']).'",
34  initialHeight: "'.(!empty($params['initial_height']) ? $params['initial_height'] : $config_default['initial_height']).'",
35  width: '.(!empty($params['fixed_width']) ? '"'.$params['fixed_width'].'"' : 'false').',
36  height: '.(!empty($params['fixed_height']) ? '"'.$params['fixed_height'].'"' : 'false').'
37  },
38  function() {
39    $.post("'.get_root_url().'plugins/lightbox/save_history.php", {
40      imgid:   this.id,
41      catid:   "'.@$page['category']['id'].'",
42      section: "'.@$page['section'].'",
43      tagids:  "'.@implode(',', @$page['tag_ids']).'"
44  });
45});
46});
47</script>', $smarty, $repeat);
48
49foreach($tpl_thumbnails_var as $key => $tpl_var)
50{
51  // Image URL for lightbox
52  if ($newurl = get_lightbox_url($pictures[$key]))
53  {
54    $tpl_thumbnails_var[$key]['URL'] .= '" id="img-'.$pictures[$key]['id'].'" name="'.$newurl;
55  }
56  else
57  {
58    continue;
59  }
60
61  // Title display
62  if ($params['display_name'])
63  {
64    $tpl_thumbnails_var[$key]['URL'] .= '" title="'.get_lightbox_title($pictures[$key], $params['name_link']);
65  }
66
67  // Arrows display
68  if ($params['display_arrows'])
69  {
70    $tpl_thumbnails_var[$key]['URL'] .= '" rel="colorbox'.$conf['lightbox_rel'];
71  }
72}
73
74// Add all items from category
75if ($params['display_arrows'] and $params['all_cat'] and !empty($page['navigation_bar']))
76{
77  $rank_of = array_flip($page['items']);
78  if ($page['start'] > 0)
79  {
80    $selection = array_slice($page['items'], 0, $page['start']);
81    $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', get_lightbox_extra_pictures($selection, $rank_of, $params['name_link']));
82  }
83
84  if (count($page['items']) > $page['start'] + $page['nb_image_page'])
85  {
86    $selection = array_slice($page['items'], $page['start'] + $page['nb_image_page']);
87    $template->concat('PLUGIN_INDEX_CONTENT_END', get_lightbox_extra_pictures($selection, $rank_of, $params['name_link']));
88  }
89}
90
91?>
Note: See TracBrowser for help on using the repository browser.