[11079] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Image Preview |
---|
| 4 | Version: auto |
---|
| 5 | Description: give an image preview when the mouve is over a thumbnail |
---|
[11086] | 6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=551 |
---|
[11079] | 7 | Author: Flop25 |
---|
| 8 | Author URI: http://www.planete-flop.fr/ |
---|
| 9 | */ |
---|
[11086] | 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 | } |
---|
[11079] | 25 | /** thumbnails.tpl **/ |
---|
| 26 | add_event_handler('loc_end_index_thumbnails', 'imgpreview_thumbnails'); |
---|
| 27 | function imgpreview_thumbnails($tpl_thumbnails_var) |
---|
| 28 | { |
---|
[11086] | 29 | global $template, $conf ; |
---|
| 30 | |
---|
| 31 | $conf_imgp = explode("#" , $conf['imgpreview']); |
---|
[13923] | 32 | $imgpreview=array( 'width' => $conf_imgp[0], 'height' => $conf_imgp[1], 'title' => $conf_imgp[2], 'opacity' => $conf_imgp[3] , 'preloadImages' => $conf_imgp[4] ); |
---|
[11086] | 33 | $template->assign(array( |
---|
| 34 | 'imgpreview' => $imgpreview |
---|
| 35 | )); |
---|
| 36 | |
---|
[11079] | 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}"'; |
---|
[23617] | 52 | if ( defined('PHPWG_VERSION') and (strpos(PHPWG_VERSION, "2.4")!==false or strpos(PHPWG_VERSION, "2.5")!==false or strpos(PHPWG_VERSION, "2.6")!==false) ) |
---|
[13912] | 53 | { |
---|
[13921] | 54 | $replacement = 'href="{$thumbnail.URL}" {define_derivative name=\'derivative_imgprev\' width=$imgpreview.width height=$imgpreview.height crop=false}{assign var=d_imgprev value=$pwg->derivative($derivative_imgprev, $thumbnail.src_image)} imgsrc="{$d_imgprev->get_url()}" data-tittle="{$thumbnail.NAME}"'; |
---|
[13912] | 55 | } |
---|
| 56 | else { |
---|
[13921] | 57 | $replacement = 'href="{$thumbnail.URL}" imgsrc="{$thumbnail.FILE_PATH}" data-tittle="{$thumbnail.NAME}"'; |
---|
[13912] | 58 | } |
---|
[11079] | 59 | $content= str_replace($search, $replacement, $content); |
---|
| 60 | |
---|
| 61 | $content='{$IMGPREVIEW}'.$content; |
---|
| 62 | return $content; |
---|
| 63 | } |
---|
| 64 | ?> |
---|