source: extensions/lightbox/lightbox.php @ 17335

Last change on this file since 17335 was 17139, checked in by plg, 12 years ago

add plugin Lightbox

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'));
11$template->func_combine_script(array('id'=>'core.scripts', 'path'=>'themes/default/js/scripts.js'));
12$template->func_combine_css(array('path'=>'plugins/lightbox/theme/'.$params['theme'].'/colorbox.css'));
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<style type="text/css">img.cboxPhoto { max-width: none; }</style>
41');
42
43foreach($tpl_thumbnails_var as $key => $tpl_var)
44{
45  // Image URL for lightbox
46  if ($newurl = get_lightbox_url($pictures[$key]))
47  {
48    $tpl_thumbnails_var[$key]['URL'] .= '" id="img-'.$pictures[$key]['id'].'" name="'.$newurl;
49  }
50  else
51  {
52    continue;
53  }
54
55  // Title display
56  if ($params['display_name'])
57  {
58    $tpl_thumbnails_var[$key]['URL'] .= '" title="'.get_lightbox_title($pictures[$key], $params['name_link']);
59  }
60
61  // Arrows display
62  if ($params['display_arrows'])
63  {
64    $tpl_thumbnails_var[$key]['URL'] .= '" rel="colorbox'.$conf['lightbox_rel'];
65  }
66}
67
68// Add all items from category
69if ($params['display_arrows'] and $params['all_cat'] and !empty($page['navigation_bar']))
70{
71  $rank_of = array_flip($page['items']);
72  if ($page['start'] > 0)
73  {
74    $selection = array_slice($page['items'], 0, $page['start']);
75    $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', get_lightbox_extra_pictures($selection, $rank_of, $params['name_link']));
76  }
77
78  if (count($page['items']) > $page['start'] + $page['nb_image_page'])
79  {
80    $selection = array_slice($page['items'], $page['start'] + $page['nb_image_page']);
81    $template->concat('PLUGIN_INDEX_CONTENT_END', get_lightbox_extra_pictures($selection, $rank_of, $params['name_link']));
82  }
83}
84
85?>
Note: See TracBrowser for help on using the repository browser.