source: extensions/GThumb/main.inc.php @ 30608

Last change on this file since 30608 was 27592, checked in by plg, 11 years ago

with Piwigo 2.6, Stripped does not take GThumb nb_image_page into account, let's force it

File size: 2.7 KB
RevLine 
[12678]1<?php
2/*
3Plugin Name: GThumb+
4Version: auto
5Description: Display thumbnails as patchwork
6Plugin URI: auto
7Author: P@t
8Author URI: http://www.gauchon.com
9*/
10
11global $conf;
12
13if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
14
[16318]15if (mobile_theme()) return;
16
[12678]17define('GTHUMB_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
18
19$conf['GThumb'] = unserialize($conf['GThumb']);
20
[12712]21// RV Thumbnails Scroller
22if (isset($_GET['rvts']))
23{
24  $conf['GThumb']['big_thumb'] = false;
25  add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2);
26}
27
[21551]28add_event_handler('init', 'GThumb_init');
29add_event_handler('loc_begin_index', 'GThumb_index', 60);
[16318]30add_event_handler('loc_end_index', 'GThumb_remove_thumb_size');
[12678]31add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu');
32
33function GThumb_init()
34{
[27592]35  global $conf, $user, $page, $stripped;
[18124]36 
37  // new param in 2.4.c
38  if (!isset($conf['GThumb']['show_thumbnail_caption']))
39  {
40    $conf['GThumb']['show_thumbnail_caption'] = true;
41    conf_update_param('GThumb', serialize($conf['GThumb']));
42  }
[12678]43
44  $user['nb_image_page'] = $conf['GThumb']['nb_image_page'];
45  $page['nb_image_page'] = $conf['GThumb']['nb_image_page'];
[27592]46  $stripped['maxThumb'] = $conf['GThumb']['nb_image_page'];
[18124]47  $conf['show_thumbnail_caption'] = $conf['GThumb']['show_thumbnail_caption'];
[12678]48}
49
[21551]50function GThumb_index()
51{
52  global $template;
53 
54  $template->set_prefilter('index', 'GThumb_prefilter');
55
56  add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2);
57}
58
[12678]59function process_GThumb($tpl_vars, $pictures)
60{
61  global $template, $conf;
62
63  $template->set_filename( 'index_thumbnails', realpath(GTHUMB_PATH.'template/gthumb.tpl'));
64  $template->assign('GThumb', $conf['GThumb']);
65
[13652]66  $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height']));
[12678]67
[13652]68  if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0]))
[12678]69  {
[13652]70    $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']);
71    $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image']));
[12678]72  }
73
74  return $tpl_vars;
75}
76
77function GThumb_prefilter($content, $smarty)
78{
79  $pattern = '#\<div.*?id\="thumbnails".*?\>\{\$THUMBNAILS\}\</div\>#';
80  $replacement = '<ul id="thumbnails">{$THUMBNAILS}</ul>';
81
82  return preg_replace($pattern, $replacement, $content);
83}
84
85function GThumb_admin_menu($menu)
86{
87  array_push($menu,
88    array(
89      'NAME' => 'GThumb+',
90      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)),
91    )
92  );
93  return $menu;
94}
95
[16318]96function GThumb_remove_thumb_size()
97{
98  global $template;
99  $template->clear_assign('image_derivatives');
100}
101
[12678]102?>
Note: See TracBrowser for help on using the repository browser.