source: extensions/lightbox/lightbox.php @ 4193

Last change on this file since 4193 was 3298, checked in by patdenice, 15 years ago

New extension added:
Lightbox (2.0.c)

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