[4207] | 1 | <?php /* |
---|
| 2 | Plugin Name: RV Thumbs |
---|
[6718] | 3 | Version: 2.1.a |
---|
[4207] | 4 | Description: Let users see a variable number of thumbnails on index page |
---|
| 5 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=261 |
---|
| 6 | Author: rvelices |
---|
| 7 | Author URI: http://www.modusoptimus.com/ |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | define('RV_THUMBS_MAX', 384); |
---|
| 11 | |
---|
| 12 | add_event_handler('loc_begin_index', 'rv_thumbs_begin_index' ); |
---|
| 13 | |
---|
| 14 | function rv_thumbs_begin_index() |
---|
| 15 | { |
---|
| 16 | global $page; |
---|
| 17 | $multiplier = pwg_get_session_var('idx_thumbs_muliplier', 1); |
---|
| 18 | if (isset($_GET['thumbs'])) |
---|
| 19 | { |
---|
| 20 | $page['meta_robots']['noindex']=1; |
---|
| 21 | switch ($_GET['thumbs']) |
---|
| 22 | { |
---|
| 23 | case 'more': |
---|
[6718] | 24 | if (count($page['items']) > $page['nb_image_page'] * $multiplier) |
---|
| 25 | { |
---|
| 26 | $multiplier = ($multiplier==1) ? 4 : $multiplier*2; |
---|
| 27 | $multiplier = min($multiplier, ceil(RV_THUMBS_MAX/$page['nb_image_page'])); |
---|
| 28 | } |
---|
[4207] | 29 | break; |
---|
| 30 | case 'less': |
---|
| 31 | $multiplier = ($multiplier==4) ? 1 : (int)$multiplier/2; |
---|
| 32 | $multiplier = max(1, $multiplier); |
---|
| 33 | break; |
---|
| 34 | } |
---|
| 35 | if ($multiplier>1) |
---|
| 36 | pwg_set_session_var('idx_thumbs_muliplier', $multiplier); |
---|
| 37 | else |
---|
| 38 | pwg_unset_session_var('idx_thumbs_muliplier'); |
---|
| 39 | } |
---|
| 40 | $page['nb_image_page'] *= $multiplier; |
---|
| 41 | if ( count($page['items']) ) |
---|
| 42 | add_event_handler('loc_end_index', 'rv_thumbs_end_index' ); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | function rv_thumbs_end_index() |
---|
| 46 | { |
---|
| 47 | global $user, $template, $page; |
---|
| 48 | $multiplier = pwg_get_session_var('idx_thumbs_muliplier', 1); |
---|
[6718] | 49 | $title = & $template->get_template_vars('TITLE'); |
---|
[4207] | 50 | $ini_per_page = $user['nb_image_page']; |
---|
| 51 | $has_less = $multiplier>1 && count($page['items'])>$ini_per_page; |
---|
[6718] | 52 | $has_more = !empty($page['navigation_bar']) && $multiplier < ceil(RV_THUMBS_MAX/$ini_per_page ); |
---|
[4207] | 53 | if ($has_less || $has_more) |
---|
| 54 | { |
---|
| 55 | global $lang_info, $conf; if ($lang_info['code']!='en' or $conf['debug_l10n']) load_language( 'lang', dirname(__FILE__).'/' ); |
---|
[6718] | 56 | $css = 'background:url('.get_root_url().'plugins/rv_thumbs/sprite.gif) no-repeat top left; height:15px; width:17px; padding:0 5px 1px 0; display:inline-block; background-position:center '; |
---|
| 57 | $fmt_link = '<a href="%s" rel="nofollow" style="border:none; margin:0;"><div style="'.$css.'%spx;" title="%s"> </div></a>'; |
---|
[4207] | 58 | $fmt = '<div style="'.$css.'%spx; cursor:default" title="%s"> </div>'; |
---|
[6718] | 59 | $bar = '<span style="margin-left:10px;vertical-align:middle;">'; |
---|
[4207] | 60 | if ($has_less) |
---|
| 61 | $bar .= sprintf( $fmt_link, add_url_params(duplicate_index_url(), array('thumbs'=>'less')), -39, l10n('Show less thumbnails') ); |
---|
| 62 | else |
---|
| 63 | $bar .= sprintf( $fmt, -57, l10n('Show less thumbnails') ); |
---|
| 64 | if ($has_more) |
---|
| 65 | $bar .= sprintf( $fmt_link, add_url_params(duplicate_index_url(array('start'=>0)), array('thumbs'=>'more')), -3, l10n('Show more thumbnails') ); |
---|
| 66 | else |
---|
| 67 | $bar .= sprintf( $fmt, -21, l10n('Show more thumbnails') ); |
---|
| 68 | $bar .= '</span>'; |
---|
[6718] | 69 | $title .= $bar; |
---|
[4207] | 70 | } |
---|
| 71 | } |
---|
| 72 | ?> |
---|