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

Last change on this file since 30249 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
Line 
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
15if (mobile_theme()) return;
16
17define('GTHUMB_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
18
19$conf['GThumb'] = unserialize($conf['GThumb']);
20
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
28add_event_handler('init', 'GThumb_init');
29add_event_handler('loc_begin_index', 'GThumb_index', 60);
30add_event_handler('loc_end_index', 'GThumb_remove_thumb_size');
31add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu');
32
33function GThumb_init()
34{
35  global $conf, $user, $page, $stripped;
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  }
43
44  $user['nb_image_page'] = $conf['GThumb']['nb_image_page'];
45  $page['nb_image_page'] = $conf['GThumb']['nb_image_page'];
46  $stripped['maxThumb'] = $conf['GThumb']['nb_image_page'];
47  $conf['show_thumbnail_caption'] = $conf['GThumb']['show_thumbnail_caption'];
48}
49
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
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
66  $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height']));
67
68  if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0]))
69  {
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']));
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
96function GThumb_remove_thumb_size()
97{
98  global $template;
99  $template->clear_assign('image_derivatives');
100}
101
102?>
Note: See TracBrowser for help on using the repository browser.