| 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 | define('GTHUMB_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
|---|
| 16 | |
|---|
| 17 | $conf['GThumb'] = unserialize($conf['GThumb']); |
|---|
| 18 | |
|---|
| 19 | // RV Thumbnails Scroller |
|---|
| 20 | if (isset($_GET['rvts'])) |
|---|
| 21 | { |
|---|
| 22 | $conf['GThumb']['big_thumb'] = false; |
|---|
| 23 | add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | add_event_handler('loc_begin_index', 'GThumb_init', 60); |
|---|
| 27 | add_event_handler('get_admin_plugin_menu_links', 'GThumb_admin_menu'); |
|---|
| 28 | |
|---|
| 29 | function GThumb_init() |
|---|
| 30 | { |
|---|
| 31 | global $conf, $user, $page, $template; |
|---|
| 32 | |
|---|
| 33 | $template->set_prefilter('index', 'GThumb_prefilter'); |
|---|
| 34 | |
|---|
| 35 | add_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50, 2); |
|---|
| 36 | |
|---|
| 37 | $user['nb_image_page'] = $conf['GThumb']['nb_image_page']; |
|---|
| 38 | $page['nb_image_page'] = $conf['GThumb']['nb_image_page']; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | function process_GThumb($tpl_vars, $pictures) |
|---|
| 42 | { |
|---|
| 43 | global $template, $conf; |
|---|
| 44 | |
|---|
| 45 | $template->set_filename( 'index_thumbnails', realpath(GTHUMB_PATH.'template/gthumb.tpl')); |
|---|
| 46 | $template->assign('GThumb', $conf['GThumb']); |
|---|
| 47 | |
|---|
| 48 | $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height'])); |
|---|
| 49 | |
|---|
| 50 | if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0])) |
|---|
| 51 | { |
|---|
| 52 | $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']); |
|---|
| 53 | $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image'])); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | return $tpl_vars; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | function GThumb_prefilter($content, $smarty) |
|---|
| 60 | { |
|---|
| 61 | $pattern = '#\<div.*?id\="thumbnails".*?\>\{\$THUMBNAILS\}\</div\>#'; |
|---|
| 62 | $replacement = '<ul id="thumbnails">{$THUMBNAILS}</ul>'; |
|---|
| 63 | |
|---|
| 64 | return preg_replace($pattern, $replacement, $content); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | function GThumb_admin_menu($menu) |
|---|
| 68 | { |
|---|
| 69 | array_push($menu, |
|---|
| 70 | array( |
|---|
| 71 | 'NAME' => 'GThumb+', |
|---|
| 72 | 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)), |
|---|
| 73 | ) |
|---|
| 74 | ); |
|---|
| 75 | return $menu; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | ?> |
|---|