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

Last change on this file since 18124 was 18124, checked in by mistic100, 12 years ago

new option to display thumbnails caption at mouseover

File size: 2.5 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('loc_begin_index', 'GThumb_init', 60);
29add_event_handler('loc_end_index', 'GThumb_remove_thumb_size');
30add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu');
31
32function GThumb_init()
33{
34  global $conf, $user, $page, $template;
35 
36  // new param in 2.4.c
37  if (!isset($conf['GThumb']['show_thumbnail_caption']))
38  {
39    $conf['GThumb']['show_thumbnail_caption'] = true;
40    conf_update_param('GThumb', serialize($conf['GThumb']));
41  }
42 
43
44  $template->set_prefilter('index', 'GThumb_prefilter');
45
46  add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2);
47
48  $user['nb_image_page'] = $conf['GThumb']['nb_image_page'];
49  $page['nb_image_page'] = $conf['GThumb']['nb_image_page'];
50  $conf['show_thumbnail_caption'] = $conf['GThumb']['show_thumbnail_caption'];
51}
52
53function process_GThumb($tpl_vars, $pictures)
54{
55  global $template, $conf;
56
57  $template->set_filename( 'index_thumbnails', realpath(GTHUMB_PATH.'template/gthumb.tpl'));
58  $template->assign('GThumb', $conf['GThumb']);
59
60  $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height']));
61
62  if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0]))
63  {
64    $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']);
65    $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image']));
66  }
67
68  return $tpl_vars;
69}
70
71function GThumb_prefilter($content, $smarty)
72{
73  $pattern = '#\<div.*?id\="thumbnails".*?\>\{\$THUMBNAILS\}\</div\>#';
74  $replacement = '<ul id="thumbnails">{$THUMBNAILS}</ul>';
75
76  return preg_replace($pattern, $replacement, $content);
77}
78
79function GThumb_admin_menu($menu)
80{
81  array_push($menu,
82    array(
83      'NAME' => 'GThumb+',
84      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)),
85    )
86  );
87  return $menu;
88}
89
90function GThumb_remove_thumb_size()
91{
92  global $template;
93  $template->clear_assign('image_derivatives');
94}
95
96?>
Note: See TracBrowser for help on using the repository browser.