source: extensions/lightbox/lightbox.php @ 4621

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

[Plugin][Lightbox]
Update Colorbox to 1.3.5
Add grey2 theme.

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