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