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