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

Last change on this file since 16859 was 16318, checked in by patdenice, 12 years ago

Deactivate GThumb with mobile theme.
Remove thumbnail size icon.

File size: 2.2 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  $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
44function 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
62function 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
70function 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
81function GThumb_remove_thumb_size()
82{
83  global $template;
84  $template->clear_assign('image_derivatives');
85}
86
87?>
Note: See TracBrowser for help on using the repository browser.