1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Image Preview |
---|
4 | Version: auto |
---|
5 | Description: give an image preview when the mouve is over a thumbnail |
---|
6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=551 |
---|
7 | Author: Flop25 |
---|
8 | Author URI: http://www.planete-flop.fr/ |
---|
9 | */ |
---|
10 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
11 | define('IMGP_DIR' , basename(dirname(__FILE__))); |
---|
12 | define('IMGP_PATH' , PHPWG_PLUGINS_PATH . IMGP_DIR . '/'); |
---|
13 | add_event_handler('get_admin_plugin_menu_links', 'imgpreview_lien_menu'); |
---|
14 | function imgpreview_lien_menu($menu) |
---|
15 | { |
---|
16 | |
---|
17 | array_push( |
---|
18 | $menu, |
---|
19 | array('NAME' => 'Image Preview', |
---|
20 | 'URL' => get_admin_plugin_menu_link(get_root_url().'plugins/'.IMGP_DIR.'/admin/admin.php') |
---|
21 | ) |
---|
22 | ); |
---|
23 | return $menu; |
---|
24 | } |
---|
25 | /** thumbnails.tpl **/ |
---|
26 | add_event_handler('loc_end_index_thumbnails', 'imgpreview_thumbnails'); |
---|
27 | function imgpreview_thumbnails($tpl_thumbnails_var) |
---|
28 | { |
---|
29 | global $template, $conf ; |
---|
30 | |
---|
31 | $conf_imgp = explode("#" , $conf['imgpreview']); |
---|
32 | $imgpreview=array( 'width' => $conf_imgp[0], 'height' => $conf_imgp[1] ); |
---|
33 | $template->assign(array( |
---|
34 | 'imgpreview' => $imgpreview |
---|
35 | )); |
---|
36 | |
---|
37 | $template->set_prefilter('index_thumbnails', 'imgpreview_prefilter_thumbnails'); |
---|
38 | $template->set_prefilter('stuffs', 'imgpreview_prefilter_thumbnails'); |
---|
39 | $dir=dirname(__FILE__).'/css_js.tpl'; |
---|
40 | $template->set_filenames(array( |
---|
41 | 'imgpreview_css_js' => realpath($dir), |
---|
42 | ) ); |
---|
43 | $template->assign_var_from_handle('IMGPREVIEW', 'imgpreview_css_js'); |
---|
44 | |
---|
45 | return $tpl_thumbnails_var; |
---|
46 | } |
---|
47 | |
---|
48 | function imgpreview_prefilter_thumbnails($content, &$smarty) |
---|
49 | { |
---|
50 | global $template; |
---|
51 | $search = 'href="{$thumbnail.URL}"'; |
---|
52 | |
---|
53 | $replacement = 'href="{$thumbnail.URL}" imgsrc="{$thumbnail.FILE_PATH}"'; |
---|
54 | |
---|
55 | $content= str_replace($search, $replacement, $content); |
---|
56 | |
---|
57 | $content='{$IMGPREVIEW}'.$content; |
---|
58 | return $content; |
---|
59 | } |
---|
60 | ?> |
---|