Changeset 30052 for extensions/Fotorama
- Timestamp:
- Oct 14, 2014, 9:25:41 PM (10 years ago)
- Location:
- extensions/Fotorama
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Fotorama/admin.php
r30048 r30052 4 4 5 5 global $conf, $template, $page; 6 load_language('plugin.lang', FOTORAMA_PATH); 6 7 7 8 if (isset($_POST['submit'])) -
extensions/Fotorama/main.inc.php
r30029 r30052 16 16 define('FOTORAMA_ID', basename(dirname(__FILE__))); 17 17 define('FOTORAMA_PATH' , PHPWG_PLUGINS_PATH . FOTORAMA_ID . '/'); 18 define('FOTORAMA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . FOTORAMA_ID);19 18 20 19 add_event_handler('init', 'Fotorama_init'); … … 23 22 add_event_handler('get_admin_plugin_menu_links', 'Fotorama_admin_menu'); 24 23 } 25 else 26 { 27 if ($conf['light_slideshow']) 28 { 29 add_event_handler('render_element_content', 'Fotorama_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10); 30 add_event_handler('loc_end_picture', 'Fotorama_end_picture'); 31 add_event_handler('loc_end_page_header', 'Fotorama_end_page_header'); 32 } 24 elseif ($conf['light_slideshow']) 25 { 26 add_event_handler('render_element_content', 'Fotorama_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10); 27 add_event_handler('loc_end_picture', 'Fotorama_end_picture'); 33 28 } 34 29 … … 43 38 { 44 39 global $conf, $user; 45 46 load_language('plugin.lang', FOTORAMA_PATH);47 40 48 41 $conf['Fotorama'] = unserialize($conf['Fotorama']); … … 76 69 } 77 70 78 function Fotorama_element_content($content , $picture)71 function Fotorama_element_content($content) 79 72 { 80 73 global $page; … … 84 77 $page['slideshow'] = true; 85 78 } 79 if ($page['slideshow']) 80 add_event_handler('loc_end_page_header', 'Fotorama_end_page_header'); 86 81 87 82 return $content; … … 113 108 $template->assign('replace_picture', true); 114 109 } 115 116 if ($page['slideshow']) 117 { 118 $query = ' 119 SELECT * 120 FROM '.IMAGES_TABLE.' 121 WHERE id IN ('.implode(',', $page['items']).') 122 ORDER BY FIELD(id, '.implode(',', $page['items']).') 123 ;'; 124 125 $result = pwg_query($query); 126 127 $current = $template->get_template_vars('current'); 128 if (isset($current['selected_derivative'])) 129 { 130 $type = $current['selected_derivative']->get_type(); 131 } 132 133 $defined = ImageStdParams::get_defined_type_map(); 134 if (!isset($type) or !isset($defined[$type])) 135 { 136 $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); 137 } 138 139 $skip = -1; 140 $big_type = $type; 141 $next_type = $type; 142 foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) 143 { 144 if ($def_type == $type) 145 $skip = 2; 146 if ($skip >= 0) 147 $big_type = $def_type; 148 if ($skip >= 1 and $conf['Fotorama']['resize']) 149 $next_type = $def_type; 150 if ($skip == 0) 151 break; 152 $skip = $skip - 1; 153 } 154 $type = $next_type; // +1 size for inpage slideshow 155 if ($conf['Fotorama']['only_fullscreen']) 156 { 157 $type = $big_type; 158 } 159 $type_params = ImageStdParams::get_by_type($type); 160 $big_type_params = ImageStdParams::get_by_type($big_type); 161 162 if ($conf['Fotorama']['nav'] == 'thumbs' or $conf['Fotorama']['fullscreen_nav'] == 'thumbs') 163 { 164 $has_thumbs = true; 110 111 if (!$page['slideshow']) 112 return; 113 114 load_language('plugin.lang', FOTORAMA_PATH); 115 116 $split_limit = 400; 117 if ('mobile' == get_device()) 118 $split_limit /= 2; 119 120 $view_offset = null; 121 if (count($page['items']) >= 1.2*$split_limit) 122 { 123 $first = $split_limit * 0.2; 124 $last = $split_limit - $first; 125 126 $first = $page['current_rank'] - $first; 127 if ($first < 0) 128 $first += count($page['items']); 129 130 $last = $page['current_rank'] + $last; 131 if ($last >= count($page['items'])) 132 $last -= count($page['items']); 133 134 if ($first < $last) 135 { 136 $selection = array_slice($page['items'], $first, $last-$first); 137 $view_borders = array( 0, count($selection)-1); 138 $view_offset = array('from'=>0, 'offset'=>$first); 165 139 } 166 140 else 167 141 { 168 $has_thumbs = false; 169 } 170 142 $selection = array_slice($page['items'], 0, $last); 143 $view_borders = array( count($selection), count($selection)-1); 144 $view_offset = array('from'=>count($selection), 'offset'=>$first-count($selection)); 145 146 $selection = array_merge($selection, array_slice($page['items'], $first)); 147 } 148 } 149 else 150 { 151 $selection = $page['items']; 152 $view_borders = null; 153 } 154 155 $query = ' 156 SELECT * 157 FROM '.IMAGES_TABLE.' 158 WHERE id IN ('.implode(',', $selection).') 159 ORDER BY FIELD(id, '.implode(',', $selection).') 160 ;'; 161 162 $result = pwg_query($query); 163 164 $current = $template->get_template_vars('current'); 165 if (isset($current['selected_derivative'])) 166 { 167 $type = $current['selected_derivative']->get_type(); 168 } 169 170 $defined = ImageStdParams::get_defined_type_map(); 171 if (!isset($type) or !isset($defined[$type])) 172 { 173 $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); 174 } 175 176 $skip = -1; 177 $big_type = $type; 178 $next_type = $type; 179 foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) 180 { 181 if ($def_type == $type) 182 $skip = 2; 183 if ($skip >= 0) 184 $big_type = $def_type; 185 if ($skip >= 1 and $conf['Fotorama']['resize']) 186 $next_type = $def_type; 187 if ($skip == 0) 188 break; 189 $skip = $skip - 1; 190 } 191 $type = $next_type; // +1 size for inpage slideshow 192 if ($conf['Fotorama']['only_fullscreen']) 193 { 194 $type = $big_type; 195 } 196 197 $type_params = ImageStdParams::get_by_type($type); 198 $big_type_params = ImageStdParams::get_by_type($big_type); 199 200 if ($conf['Fotorama']['nav'] == 'thumbs' or $conf['Fotorama']['fullscreen_nav'] == 'thumbs') 201 { 202 $has_thumbs = true; 203 } 204 else 205 { 206 $has_thumbs = false; 207 } 208 209 if ($has_thumbs) 210 { 211 if ($conf['Fotorama']['square_thumb']) 212 { 213 $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']); 214 } 215 else 216 { 217 $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']); 218 } 219 } 220 221 222 $picture = array(); 223 while ($row = pwg_db_fetch_assoc($result)) 224 { 225 $row['src_image'] = new SrcImage($row); 226 $row['derivative'] = new DerivativeImage($type_params, $row['src_image']); 227 $row['derivative_big'] = new DerivativeImage($big_type_params, $row['src_image']); 228 171 229 if ($has_thumbs) 172 230 { 173 if ($conf['Fotorama']['square_thumb']) 174 { 175 $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']); 176 } 177 else 178 { 179 $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']); 180 } 181 } 182 183 $picture = array(); 184 while ($row = pwg_db_fetch_assoc($result)) 185 { 186 $row['src_image'] = new SrcImage($row); 187 $row['derivative'] = new DerivativeImage($type_params, $row['src_image']); 188 $row['derivative_big'] = new DerivativeImage($big_type_params, $row['src_image']); 189 190 if ($has_thumbs) 191 { 192 $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']); 193 } 194 195 $row['url'] = duplicate_picture_url( 196 array( 197 'image_id' => $row['id'], 198 'image_file' => $row['file'], 199 ), 200 array( 201 'start', 202 ) 203 ); 204 205 $row['TITLE'] = render_element_name($row); 206 $picture[] = $row; 207 } 208 209 $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); 210 $template->assign('items', $picture); 211 $template->assign('current_rank', $page['current_rank']); 212 $template->assign(array('Fotorama' => $conf['Fotorama'])); 213 $template->assign('Fotorama_has_thumbs', $has_thumbs); 214 if (is_file('./themes/'.$user['theme'].'/template/fotorama.tpl')) 215 { 216 $template->set_filenames( array('slideshow' => realpath('./themes/'.$user['theme'].'/template/fotorama.tpl'))); 217 } 218 else 219 { 220 $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/fotorama.tpl'))); 221 } 222 $template->assign('FOTORAMA_CONTENT_PATH', realpath(FOTORAMA_PATH.'template/fotorama-content.tpl')); 223 } 231 $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']); 232 } 233 234 $row['url'] = duplicate_picture_url( 235 array( 236 'image_id' => $row['id'], 237 'image_file' => $row['file'], 238 ), 239 array( 240 'start', 241 ) 242 ); 243 244 $row['TITLE'] = render_element_name($row); 245 $picture[] = $row; 246 } 247 $picture = trigger_change('fotorama_items', $picture, $selection); 248 $template->assign(array( 249 'TOTAL_ITEMS' => count($page['items']), 250 'view_borders' => $view_borders, 251 'view_offset' => $view_offset, 252 'current_rank' => array_search($page['image_id'],$selection), 253 )); 254 $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); 255 $template->assign('items', $picture); 256 $template->assign(array('Fotorama' => $conf['Fotorama'])); 257 $template->assign('Fotorama_has_thumbs', $has_thumbs); 258 if (is_file('./themes/'.$user['theme'].'/template/fotorama.tpl')) 259 { 260 $template->set_filenames( array('slideshow' => realpath('./themes/'.$user['theme'].'/template/fotorama.tpl'))); 261 } 262 else 263 { 264 $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/fotorama.tpl'))); 265 } 266 $template->assign('FOTORAMA_CONTENT_PATH', realpath(FOTORAMA_PATH.'template/fotorama-content.tpl')); 224 267 } 225 268 226 269 function Fotorama_end_page_header() 227 270 { 228 global $template, $page; 229 230 if (isset($page['slideshow']) and $page['slideshow']) 231 { 232 $template->clear_assign('page_refresh'); 233 $template->clear_assign('first'); 234 $template->clear_assign('previous'); 235 $template->clear_assign('next'); 236 $template->clear_assign('last'); 237 } 271 global $template; 272 273 $template->clear_assign( array('page_refresh', 274 'first', 275 'previous', 276 'next', 277 'last', 278 )); 238 279 } 239 280 … … 242 283 $menu[] = array( 243 284 'NAME' => 'Fotorama', 244 'URL' => FOTORAMA_ADMIN,285 'URL' => get_root_url() . 'admin.php?page=plugin-' . FOTORAMA_ID, 245 286 ); 246 287 -
extensions/Fotorama/template/fotorama-content.tpl
r29984 r30052 34 34 if (history.replaceState) 35 35 history.replaceState(null, null, fotorama.activeFrame['url']+(fotorama.activeFrame['url'].indexOf('?')==-1 ? '?' : '&')+'slideshow='); 36 jQuery('#slideshow .browsePath a ').attr('href', fotorama.activeFrame['url']);36 jQuery('#slideshow .browsePath a,a.fotorama__close-icon').attr('href', fotorama.activeFrame['url']); 37 37 {/if} 38 38 … … 40 40 41 41 jQuery('#slideshow .showtitle').text(fotorama.activeFrame['caption']); 42 jQuery('#slideshow .imageNumber').text((fotorama.activeFrame['i'])+'/{count($items)}'); 42 var idx = fotorama.activeIndex; 43 {if isset($view_offset)} 44 if (idx >= {$view_offset.from}) 45 idx += {$view_offset.offset}; 46 {/if} 47 jQuery('#slideshow .imageNumber').text((idx+1)+'/{$TOTAL_ITEMS}'); 43 48 document.title = fotorama.activeFrame['caption'] + ' | {$GALLERY_TITLE|escape:javascript}'; 44 49 } … … 48 53 jQuery('.fotorama') 49 54 // Listen to the events 50 .on('fotorama:showend 55 .on('fotorama:showend', 51 56 function (e, fotorama, extra) { 52 57 if (!fullscreen) { 53 58 update_picture(fotorama); 54 59 } 60 {if !empty($view_borders)} 61 {if $view_borders[0] < $view_borders[1]} 62 if (fotorama.activeIndex <= {$view_borders[0]}{if $Fotorama_has_thumbs}+5{/if} || 63 fotorama.activeIndex >= {$view_borders[1]}{if $Fotorama_has_thumbs}-5{/if} ) 64 {else} 65 if (fotorama.activeIndex <= {$view_borders[0]}{if $Fotorama_has_thumbs}+5{/if} && 66 fotorama.activeIndex >= {$view_borders[1]}{if $Fotorama_has_thumbs}-5{/if} ) 67 {/if} 68 { 69 fotorama.stopAutoplay(); 70 var url = fotorama.activeFrame.url + (fotorama.activeFrame.url.indexOf('?')==-1 ? '?' : '&')+'slideshow='; 71 {if !$Fotorama.only_fullscreen} 72 if (fullscreen) url += "&fullscreen"; 73 {/if} 74 window.location = url; 75 } 76 {/if} 55 77 } 56 78 ) … … 108 130 {/if} 109 131 url: "{$thumbnail.url}" 132 {if !empty($thumbnail.video)} 133 ,video:"{$thumbnail.video}"{if !empty($thumbnail.video_id)},id:"{$thumbnail.video_id}"{/if} 134 {/if} 110 135 },{/foreach} 111 136 ] … … 121 146 jQuery('html,body').animate({ scrollTop: jQuery('.fotorama').offset().top }, 'slow'); 122 147 {/if} 148 {if isset($smarty.get.fullscreen)} 149 jQuery('.fotorama').data('fotorama').requestFullScreen(); 150 {/if} 123 151 {/if} 124 152
Note: See TracChangeset
for help on using the changeset viewer.