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('init', 'GThumb_init'); |
---|
29 | add_event_handler('loc_begin_index', 'GThumb_index', 60); |
---|
30 | add_event_handler('loc_end_index', 'GThumb_remove_thumb_size'); |
---|
31 | add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu'); |
---|
32 | |
---|
33 | function GThumb_init() |
---|
34 | { |
---|
35 | global $conf, $user, $page; |
---|
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 | $conf['show_thumbnail_caption'] = $conf['GThumb']['show_thumbnail_caption']; |
---|
47 | } |
---|
48 | |
---|
49 | function GThumb_index() |
---|
50 | { |
---|
51 | global $template; |
---|
52 | |
---|
53 | $template->set_prefilter('index', 'GThumb_prefilter'); |
---|
54 | |
---|
55 | add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2); |
---|
56 | } |
---|
57 | |
---|
58 | function process_GThumb($tpl_vars, $pictures) |
---|
59 | { |
---|
60 | global $template, $conf; |
---|
61 | |
---|
62 | $template->set_filename( 'index_thumbnails', realpath(GTHUMB_PATH.'template/gthumb.tpl')); |
---|
63 | $template->assign('GThumb', $conf['GThumb']); |
---|
64 | |
---|
65 | $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height'])); |
---|
66 | |
---|
67 | if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0])) |
---|
68 | { |
---|
69 | $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']); |
---|
70 | $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image'])); |
---|
71 | } |
---|
72 | |
---|
73 | return $tpl_vars; |
---|
74 | } |
---|
75 | |
---|
76 | function GThumb_prefilter($content, $smarty) |
---|
77 | { |
---|
78 | $pattern = '#\<div.*?id\="thumbnails".*?\>\{\$THUMBNAILS\}\</div\>#'; |
---|
79 | $replacement = '<ul id="thumbnails">{$THUMBNAILS}</ul>'; |
---|
80 | |
---|
81 | return preg_replace($pattern, $replacement, $content); |
---|
82 | } |
---|
83 | |
---|
84 | function GThumb_admin_menu($menu) |
---|
85 | { |
---|
86 | array_push($menu, |
---|
87 | array( |
---|
88 | 'NAME' => 'GThumb+', |
---|
89 | 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)), |
---|
90 | ) |
---|
91 | ); |
---|
92 | return $menu; |
---|
93 | } |
---|
94 | |
---|
95 | function GThumb_remove_thumb_size() |
---|
96 | { |
---|
97 | global $template; |
---|
98 | $template->clear_assign('image_derivatives'); |
---|
99 | } |
---|
100 | |
---|
101 | ?> |
---|