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

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

overload nb_images_page everywhere (for "top" link in picture.php)

File size: 2.6 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('init', 'GThumb_init');
29add_event_handler('loc_begin_index', 'GThumb_index', 60);
30add_event_handler('loc_end_index', 'GThumb_remove_thumb_size');
31add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu');
32
33function 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
49function 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
58function 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
76function 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
84function 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
95function GThumb_remove_thumb_size()
96{
97  global $template;
98  $template->clear_assign('image_derivatives');
99}
100
101?>
Note: See TracBrowser for help on using the repository browser.