1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Fotorama |
---|
4 | Version: 2.7.j |
---|
5 | Description: Fotorama based full-screen slideshow |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=727 |
---|
7 | Author: JanisV |
---|
8 | */ |
---|
9 | |
---|
10 | global $conf; |
---|
11 | |
---|
12 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
13 | |
---|
14 | if (mobile_theme()) return; |
---|
15 | |
---|
16 | define('FOTORAMA_ID', basename(dirname(__FILE__))); |
---|
17 | define('FOTORAMA_PATH' , PHPWG_PLUGINS_PATH . FOTORAMA_ID . '/'); |
---|
18 | define('FOTORAMA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . FOTORAMA_ID); |
---|
19 | |
---|
20 | add_event_handler('init', 'Fotorama_init'); |
---|
21 | if (defined('IN_ADMIN')) |
---|
22 | { |
---|
23 | add_event_handler('get_admin_plugin_menu_links', 'Fotorama_admin_menu'); |
---|
24 | } |
---|
25 | |
---|
26 | function Fotorama_init() |
---|
27 | { |
---|
28 | global $conf; |
---|
29 | |
---|
30 | load_language('plugin.lang', FOTORAMA_PATH); |
---|
31 | |
---|
32 | $conf['Fotorama'] = unserialize($conf['Fotorama']); |
---|
33 | |
---|
34 | add_event_handler('loc_end_picture', 'Fotorama_end_picture'); |
---|
35 | add_event_handler('loc_end_page_header', 'Fotorama_end_page_header'); |
---|
36 | } |
---|
37 | |
---|
38 | function Fotorama_end_picture() |
---|
39 | { |
---|
40 | global $template, $conf, $user, $page; |
---|
41 | |
---|
42 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
43 | { |
---|
44 | $query = ' |
---|
45 | SELECT * |
---|
46 | FROM '.IMAGES_TABLE.' |
---|
47 | WHERE id IN ('.implode(',', $page['items']).') |
---|
48 | ORDER BY FIELD(id, '.implode(',', $page['items']).') |
---|
49 | ;'; |
---|
50 | |
---|
51 | $result = pwg_query($query); |
---|
52 | |
---|
53 | $current = $template->get_template_vars('current'); |
---|
54 | $type = $current['selected_derivative']->get_type(); |
---|
55 | $defined = ImageStdParams::get_defined_type_map(); |
---|
56 | if (!isset($defined[$type])) |
---|
57 | { |
---|
58 | $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); |
---|
59 | } |
---|
60 | |
---|
61 | $skip = -1; |
---|
62 | $big_type = $type; |
---|
63 | foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) |
---|
64 | { |
---|
65 | if ($def_type == $type) |
---|
66 | $skip = 2; |
---|
67 | if ($skip >= 0) |
---|
68 | $big_type = $def_type; |
---|
69 | if ($skip == 0) |
---|
70 | break; |
---|
71 | $skip = $skip - 1; |
---|
72 | } |
---|
73 | |
---|
74 | $picture = array(); |
---|
75 | while ($row = pwg_db_fetch_assoc($result)) |
---|
76 | { |
---|
77 | $row['src_image'] = new SrcImage($row); |
---|
78 | // $row['derivatives'] = DerivativeImage::get_all($row['src_image']); |
---|
79 | $row['derivative'] = DerivativeImage::get_one($type, $row['src_image']); |
---|
80 | if ($row['derivative'] == null) |
---|
81 | { |
---|
82 | $row['derivative'] = $row['src_image']; |
---|
83 | } |
---|
84 | $row['derivative_big'] = DerivativeImage::get_one($big_type, $row['src_image']); |
---|
85 | if ($row['derivative_big'] == null) |
---|
86 | { |
---|
87 | $row['derivative_big'] = $row['src_image']; |
---|
88 | } |
---|
89 | $row['derivative_thumb'] = DerivativeImage::get_one(IMG_SQUARE, $row['src_image']); |
---|
90 | if ($row['derivative_thumb'] == null) |
---|
91 | { |
---|
92 | $row['derivative_thumb'] = $row['src_image']; |
---|
93 | } |
---|
94 | |
---|
95 | $row['url'] = duplicate_picture_url( |
---|
96 | array( |
---|
97 | 'image_id' => $row['id'], |
---|
98 | 'image_file' => $row['file'], |
---|
99 | ), |
---|
100 | array( |
---|
101 | 'start', |
---|
102 | ) |
---|
103 | ); |
---|
104 | |
---|
105 | $row['TITLE'] = render_element_name($row); |
---|
106 | $row['TITLE_ESC'] = str_replace('"', '"', $row['TITLE']); |
---|
107 | $picture[] = $row; |
---|
108 | } |
---|
109 | |
---|
110 | $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); |
---|
111 | $template->assign('items', $picture); |
---|
112 | $template->assign('current_rank', $page['current_rank']); |
---|
113 | $template->assign(array('Fotorama' => $conf['Fotorama'])); |
---|
114 | if (is_file('./themes/'.$user['theme'].'/template/fotorama.tpl')) |
---|
115 | { |
---|
116 | $template->set_filenames( array('slideshow' => realpath('./themes/'.$user['theme'].'/template/fotorama.tpl'))); |
---|
117 | } |
---|
118 | else |
---|
119 | { |
---|
120 | $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/slideshow.tpl'))); |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | function Fotorama_end_page_header() |
---|
126 | { |
---|
127 | global $template, $conf, $page; |
---|
128 | |
---|
129 | if (isset($page['slideshow']) and $page['slideshow'] and $conf['light_slideshow']) |
---|
130 | { |
---|
131 | $template->clear_assign('page_refresh'); |
---|
132 | $template->clear_assign('first'); |
---|
133 | $template->clear_assign('previous'); |
---|
134 | $template->clear_assign('next'); |
---|
135 | $template->clear_assign('last'); |
---|
136 | } |
---|
137 | } |
---|
138 | |
---|
139 | function Fotorama_admin_menu($menu) |
---|
140 | { |
---|
141 | $menu[] = array( |
---|
142 | 'NAME' => 'Fotorama', |
---|
143 | 'URL' => FOTORAMA_ADMIN, |
---|
144 | ); |
---|
145 | |
---|
146 | return $menu; |
---|
147 | } |
---|
148 | |
---|
149 | ?> |
---|