[27034] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Fotorama |
---|
[29616] | 4 | Version: auto |
---|
[27034] | 5 | Description: Fotorama based full-screen slideshow |
---|
[29616] | 6 | Plugin URI: auto |
---|
[27034] | 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 | |
---|
[27148] | 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); |
---|
[27034] | 19 | |
---|
| 20 | add_event_handler('init', 'Fotorama_init'); |
---|
[27148] | 21 | if (defined('IN_ADMIN')) |
---|
| 22 | { |
---|
| 23 | add_event_handler('get_admin_plugin_menu_links', 'Fotorama_admin_menu'); |
---|
[29917] | 24 | } |
---|
| 25 | else |
---|
| 26 | { |
---|
[29943] | 27 | if ($conf['light_slideshow']) |
---|
| 28 | { |
---|
[29945] | 29 | add_event_handler('render_element_content', 'Fotorama_element_content'); |
---|
[29943] | 30 | add_event_handler('loc_end_picture', 'Fotorama_end_picture'); |
---|
| 31 | add_event_handler('loc_end_page_header', 'Fotorama_end_page_header'); |
---|
| 32 | } |
---|
[29917] | 33 | } |
---|
[27034] | 34 | |
---|
[29946] | 35 | function Fotorama_is_replace_picture() |
---|
| 36 | { |
---|
| 37 | global $conf; |
---|
| 38 | |
---|
| 39 | return ($conf['Fotorama']['replace_picture'] and (!$conf['Fotorama']['replace_picture_only_users'] or !is_admin()) and (!isset($_GET['slidestop']))); |
---|
| 40 | } |
---|
| 41 | |
---|
[27034] | 42 | function Fotorama_init() |
---|
| 43 | { |
---|
[29946] | 44 | global $conf, $user; |
---|
| 45 | |
---|
[27148] | 46 | load_language('plugin.lang', FOTORAMA_PATH); |
---|
| 47 | |
---|
| 48 | $conf['Fotorama'] = unserialize($conf['Fotorama']); |
---|
| 49 | |
---|
[29593] | 50 | // Upgrade params from 2.7.j |
---|
| 51 | if (!isset($conf['Fotorama']['thumbheight'])) { |
---|
| 52 | $conf['Fotorama']['thumbheight'] = 64; |
---|
| 53 | } |
---|
[29615] | 54 | // Upgrade params from 2.7.l |
---|
| 55 | if (!isset($conf['Fotorama']['replace_picture'])) { |
---|
| 56 | $conf['Fotorama']['replace_picture'] = false; |
---|
| 57 | $conf['Fotorama']['replace_picture_only_users'] = false; |
---|
[29622] | 58 | $conf['Fotorama']['clicktransition_crossfade'] = false; |
---|
[29615] | 59 | } |
---|
[29730] | 60 | // Upgrade params from 2.7.m |
---|
| 61 | if (!isset($conf['Fotorama']['close_button'])) { |
---|
| 62 | $conf['Fotorama']['close_button'] = false; |
---|
[29732] | 63 | $conf['Fotorama']['resize'] = false; |
---|
[29730] | 64 | } |
---|
[29915] | 65 | // Upgrade params from 2.7.n |
---|
| 66 | if (!isset($conf['Fotorama']['period'])) { |
---|
| 67 | $conf['Fotorama']['period'] = 4000; |
---|
[29918] | 68 | $conf['Fotorama']['info_button'] = false; |
---|
[29928] | 69 | $conf['Fotorama']['square_thumb'] = true; |
---|
[29915] | 70 | } |
---|
[27148] | 71 | |
---|
[29946] | 72 | if ($user['theme'] == 'modus' and Fotorama_is_replace_picture()) |
---|
| 73 | { |
---|
| 74 | remove_event_handler('loc_begin_picture', 'modus_loc_begin_picture'); |
---|
| 75 | } |
---|
[29945] | 76 | } |
---|
| 77 | |
---|
| 78 | function Fotorama_element_content() |
---|
| 79 | { |
---|
| 80 | global $page; |
---|
| 81 | |
---|
| 82 | if (Fotorama_is_replace_picture()) |
---|
| 83 | { |
---|
| 84 | $page['slideshow'] = true; |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
[27034] | 88 | function Fotorama_end_picture() |
---|
| 89 | { |
---|
[27035] | 90 | global $template, $conf, $user, $page; |
---|
[29918] | 91 | |
---|
[29945] | 92 | if (Fotorama_is_replace_picture()) |
---|
[29615] | 93 | { |
---|
| 94 | $url_up = duplicate_index_url( |
---|
| 95 | array( |
---|
| 96 | 'start' => |
---|
| 97 | floor($page['current_rank'] / $page['nb_image_page']) |
---|
| 98 | * $page['nb_image_page'] |
---|
| 99 | ), |
---|
| 100 | array( |
---|
| 101 | 'start', |
---|
| 102 | ) |
---|
| 103 | ); |
---|
| 104 | //slideshow end |
---|
| 105 | $template->assign( |
---|
| 106 | array( |
---|
| 107 | 'U_SLIDESHOW_STOP' => $url_up, |
---|
| 108 | ) |
---|
| 109 | ); |
---|
| 110 | |
---|
| 111 | $template->assign('replace_picture', true); |
---|
| 112 | } |
---|
[29918] | 113 | |
---|
[29943] | 114 | if ($page['slideshow']) |
---|
[27034] | 115 | { |
---|
| 116 | $query = ' |
---|
| 117 | SELECT * |
---|
| 118 | FROM '.IMAGES_TABLE.' |
---|
| 119 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 120 | ORDER BY FIELD(id, '.implode(',', $page['items']).') |
---|
| 121 | ;'; |
---|
| 122 | |
---|
| 123 | $result = pwg_query($query); |
---|
| 124 | |
---|
| 125 | $current = $template->get_template_vars('current'); |
---|
| 126 | $type = $current['selected_derivative']->get_type(); |
---|
| 127 | $defined = ImageStdParams::get_defined_type_map(); |
---|
| 128 | if (!isset($defined[$type])) |
---|
| 129 | { |
---|
| 130 | $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | $skip = -1; |
---|
| 134 | $big_type = $type; |
---|
[29640] | 135 | $next_type = $type; |
---|
[27034] | 136 | foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) |
---|
| 137 | { |
---|
| 138 | if ($def_type == $type) |
---|
| 139 | $skip = 2; |
---|
| 140 | if ($skip >= 0) |
---|
| 141 | $big_type = $def_type; |
---|
[29732] | 142 | if ($skip >= 1 and $conf['Fotorama']['resize']) |
---|
[29640] | 143 | $next_type = $def_type; |
---|
[27034] | 144 | if ($skip == 0) |
---|
| 145 | break; |
---|
| 146 | $skip = $skip - 1; |
---|
| 147 | } |
---|
[29640] | 148 | $type = $next_type; // +1 size for inpage slideshow |
---|
[29628] | 149 | if ($conf['Fotorama']['only_fullscreen']) |
---|
| 150 | { |
---|
| 151 | $type = $big_type; |
---|
| 152 | } |
---|
[29979] | 153 | $type_params = ImageStdParams::get_by_type($type); |
---|
| 154 | $big_type_params = ImageStdParams::get_by_type($big_type); |
---|
[29976] | 155 | |
---|
| 156 | if ($conf['Fotorama']['nav'] == 'thumbs' or $conf['Fotorama']['fullscreen_nav'] == 'thumbs') |
---|
| 157 | { |
---|
| 158 | $has_thumbs = true; |
---|
| 159 | } |
---|
| 160 | else |
---|
| 161 | { |
---|
| 162 | $has_thumbs = false; |
---|
| 163 | } |
---|
[27034] | 164 | |
---|
[29976] | 165 | if ($has_thumbs) |
---|
| 166 | { |
---|
| 167 | if ($conf['Fotorama']['square_thumb']) |
---|
| 168 | { |
---|
| 169 | $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']); |
---|
| 170 | } |
---|
| 171 | else |
---|
| 172 | { |
---|
| 173 | $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']); |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
[27034] | 177 | $picture = array(); |
---|
| 178 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 179 | { |
---|
| 180 | $row['src_image'] = new SrcImage($row); |
---|
[29979] | 181 | $row['derivative'] = new DerivativeImage($type_params, $row['src_image']); |
---|
| 182 | $row['derivative_big'] = new DerivativeImage($big_type_params, $row['src_image']); |
---|
[29928] | 183 | |
---|
[29976] | 184 | if ($has_thumbs) |
---|
[29928] | 185 | { |
---|
[29979] | 186 | $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']); |
---|
[29928] | 187 | } |
---|
[27039] | 188 | |
---|
[27034] | 189 | $row['url'] = duplicate_picture_url( |
---|
| 190 | array( |
---|
| 191 | 'image_id' => $row['id'], |
---|
| 192 | 'image_file' => $row['file'], |
---|
| 193 | ), |
---|
| 194 | array( |
---|
| 195 | 'start', |
---|
| 196 | ) |
---|
| 197 | ); |
---|
[27039] | 198 | |
---|
[29978] | 199 | $row['TITLE'] = render_element_name($row); |
---|
[27034] | 200 | $picture[] = $row; |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); |
---|
| 204 | $template->assign('items', $picture); |
---|
| 205 | $template->assign('current_rank', $page['current_rank']); |
---|
[27148] | 206 | $template->assign(array('Fotorama' => $conf['Fotorama'])); |
---|
[29976] | 207 | $template->assign('Fotorama_has_thumbs', $has_thumbs); |
---|
[29381] | 208 | if (is_file('./themes/'.$user['theme'].'/template/fotorama.tpl')) |
---|
| 209 | { |
---|
| 210 | $template->set_filenames( array('slideshow' => realpath('./themes/'.$user['theme'].'/template/fotorama.tpl'))); |
---|
| 211 | } |
---|
| 212 | else |
---|
| 213 | { |
---|
[29626] | 214 | $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/fotorama.tpl'))); |
---|
[29381] | 215 | } |
---|
[29626] | 216 | $template->assign('FOTORAMA_CONTENT_PATH', realpath(FOTORAMA_PATH.'template/fotorama-content.tpl')); |
---|
[27034] | 217 | } |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | function Fotorama_end_page_header() |
---|
| 221 | { |
---|
[29945] | 222 | global $template, $page; |
---|
[27034] | 223 | |
---|
[29943] | 224 | if (isset($page['slideshow']) and $page['slideshow']) |
---|
[27035] | 225 | { |
---|
| 226 | $template->clear_assign('page_refresh'); |
---|
| 227 | $template->clear_assign('first'); |
---|
| 228 | $template->clear_assign('previous'); |
---|
| 229 | $template->clear_assign('next'); |
---|
| 230 | $template->clear_assign('last'); |
---|
| 231 | } |
---|
[27034] | 232 | } |
---|
| 233 | |
---|
[27148] | 234 | function Fotorama_admin_menu($menu) |
---|
| 235 | { |
---|
| 236 | $menu[] = array( |
---|
| 237 | 'NAME' => 'Fotorama', |
---|
| 238 | 'URL' => FOTORAMA_ADMIN, |
---|
| 239 | ); |
---|
| 240 | |
---|
| 241 | return $menu; |
---|
| 242 | } |
---|
| 243 | |
---|
[27034] | 244 | ?> |
---|