source: extensions/lightbox/lightbox.php @ 12734

Last change on this file since 12734 was 12734, checked in by patdenice, 12 years ago

Bug fixed with HD link in title.

File size: 3.0 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_combine_script(array('id'=>'jquery.colorbox', 'path'=>'plugins/lightbox/js/jquery.colorbox.js'), $smarty);
11$template->func_combine_script(array('id'=>'core.scripts', 'path'=>'themes/default/js/scripts.js'), $smarty);
12$template->func_combine_css(array('path'=>'plugins/lightbox/theme/'.$params['theme'].'/colorbox.css'), $smarty);
13$template->block_html_head('','
14<script type="text/javascript">
15function PWG_Colorbox() {
16  jQuery("'.$selector.'").attr("href", function () {
17    return this.name;   
18  });
19  jQuery("'.$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}
37jQuery(document).ready(PWG_Colorbox);
38jQuery(window).bind("RVTS_loaded", PWG_Colorbox);
39</script>
40', $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.