source: extensions/lightbox/lightbox.php @ 8804

Last change on this file since 8804 was 7949, checked in by patdenice, 13 years ago

Update Colorbox plugin to 1.3.15.
Avoid jQuery conflicts.

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