source: extensions/lightbox/lightbox.php @ 5735

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

Compatibility with simple template from boulde.

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