1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Fotorama |
---|
4 | Version: 2.6.a |
---|
5 | Description: Fotorama based full-screen slideshow |
---|
6 | Author: JanisV |
---|
7 | */ |
---|
8 | |
---|
9 | global $conf; |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | if (mobile_theme()) return; |
---|
14 | |
---|
15 | define('FOTORAMA_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
16 | |
---|
17 | add_event_handler('init', 'Fotorama_init'); |
---|
18 | |
---|
19 | function Fotorama_init() |
---|
20 | { |
---|
21 | global $conf, $user, $page; |
---|
22 | |
---|
23 | add_event_handler('loc_end_picture', 'Fotorama_end_picture'); |
---|
24 | add_event_handler('loc_end_page_header', 'Fotorama_end_page_header'); |
---|
25 | } |
---|
26 | function Fotorama_end_picture() |
---|
27 | { |
---|
28 | global $template, $conf, $user, $page, $refresh; |
---|
29 | |
---|
30 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
31 | { |
---|
32 | $query = ' |
---|
33 | SELECT * |
---|
34 | FROM '.IMAGES_TABLE.' |
---|
35 | WHERE id IN ('.implode(',', $page['items']).') |
---|
36 | ORDER BY FIELD(id, '.implode(',', $page['items']).') |
---|
37 | ;'; |
---|
38 | |
---|
39 | $result = pwg_query($query); |
---|
40 | |
---|
41 | $current = $template->get_template_vars('current'); |
---|
42 | $type = $current['selected_derivative']->get_type(); |
---|
43 | $defined = ImageStdParams::get_defined_type_map(); |
---|
44 | if (!isset($defined[$type])) |
---|
45 | { |
---|
46 | $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); |
---|
47 | } |
---|
48 | |
---|
49 | $skip = -1; |
---|
50 | $big_type = $type; |
---|
51 | foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) |
---|
52 | { |
---|
53 | if ($def_type == $type) |
---|
54 | $skip = 2; |
---|
55 | if ($skip >= 0) |
---|
56 | $big_type = $def_type; |
---|
57 | if ($skip == 0) |
---|
58 | break; |
---|
59 | $skip = $skip - 1; |
---|
60 | } |
---|
61 | |
---|
62 | $picture = array(); |
---|
63 | while ($row = pwg_db_fetch_assoc($result)) |
---|
64 | { |
---|
65 | $row['src_image'] = new SrcImage($row); |
---|
66 | // $row['derivatives'] = DerivativeImage::get_all($row['src_image']); |
---|
67 | $row['derivative'] = DerivativeImage::get_one($type, $row['src_image']); |
---|
68 | if ($row['derivative'] == null) |
---|
69 | { |
---|
70 | $row['derivative'] = $row['src_image']; |
---|
71 | } |
---|
72 | $row['derivative_big'] = DerivativeImage::get_one($big_type, $row['src_image']); |
---|
73 | if ($row['derivative_big'] == null) |
---|
74 | { |
---|
75 | $row['derivative'] = $row['src_image']; |
---|
76 | } |
---|
77 | /* |
---|
78 | $row['url'] = duplicate_picture_url( |
---|
79 | array( |
---|
80 | 'image_id' => $row['id'], |
---|
81 | 'image_file' => $row['file'], |
---|
82 | ), |
---|
83 | array( |
---|
84 | 'start', |
---|
85 | ) |
---|
86 | ); |
---|
87 | */ |
---|
88 | $row['TITLE'] = render_element_name($row); |
---|
89 | $row['TITLE_ESC'] = str_replace('"', '"', $row['TITLE']); |
---|
90 | $picture[] = $row; |
---|
91 | } |
---|
92 | |
---|
93 | $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); |
---|
94 | $template->assign('items', $picture); |
---|
95 | $template->assign('current_rank', $page['current_rank']); |
---|
96 | $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/slideshow.tpl'))); |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|
100 | function Fotorama_end_page_header() |
---|
101 | { |
---|
102 | global $template; |
---|
103 | |
---|
104 | $template->clear_assign('page_refresh'); |
---|
105 | $template->clear_assign('first'); |
---|
106 | $template->clear_assign('previous'); |
---|
107 | $template->clear_assign('next'); |
---|
108 | $template->clear_assign('last'); |
---|
109 | } |
---|
110 | |
---|
111 | ?> |
---|