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

Revision 13652, 2.0 KB checked in by patdenice, 8 years ago (diff)

Compatible with Piwigo 2.4

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
15define('GTHUMB_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
16
17$conf['GThumb'] = unserialize($conf['GThumb']);
18
19// RV Thumbnails Scroller
20if (isset($_GET['rvts']))
21{
22  $conf['GThumb']['big_thumb'] = false;
23  add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2);
24}
25
26add_event_handler('loc_begin_index', 'GThumb_init', 60);
27add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu');
28
29function GThumb_init()
30{
31  global $conf, $user, $page, $template;
32
33  $template->set_prefilter('index', 'GThumb_prefilter');
34
35  add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2);
36
37  $user['nb_image_page'] = $conf['GThumb']['nb_image_page'];
38  $page['nb_image_page'] = $conf['GThumb']['nb_image_page'];
39}
40
41function process_GThumb($tpl_vars, $pictures)
42{
43  global $template, $conf;
44
45  $template->set_filename( 'index_thumbnails', realpath(GTHUMB_PATH.'template/gthumb.tpl'));
46  $template->assign('GThumb', $conf['GThumb']);
47
48  $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height']));
49
50  if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0]))
51  {
52    $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']);
53    $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image']));
54  }
55
56  return $tpl_vars;
57}
58
59function GThumb_prefilter($content, $smarty)
60{
61  $pattern = '#\<div.*?id\="thumbnails".*?\>\{\$THUMBNAILS\}\</div\>#';
62  $replacement = '<ul id="thumbnails">{$THUMBNAILS}</ul>';
63
64  return preg_replace($pattern, $replacement, $content);
65}
66
67function GThumb_admin_menu($menu)
68{
69  array_push($menu,
70    array(
71      'NAME' => 'GThumb+',
72      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)),
73    )
74  );
75  return $menu;
76}
77
78?>
Note: See TracBrowser for help on using the repository browser.