source: extensions/lightbox/lightbox.php @ 4826

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

Load jquery earlier...
Compatibility with AMM.

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