source: extensions/imgpreview/main.inc.php @ 27153

Last change on this file since 27153 was 23617, checked in by flop25, 11 years ago

2.6 update

File size: 2.3 KB
Line 
1<?php
2/*
3Plugin Name: Image Preview
4Version: auto
5Description: give an image preview when the mouve is over a thumbnail
6Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=551
7Author: Flop25
8Author URI: http://www.planete-flop.fr/
9*/
10if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
11define('IMGP_DIR' , basename(dirname(__FILE__)));
12define('IMGP_PATH' , PHPWG_PLUGINS_PATH . IMGP_DIR . '/');
13add_event_handler('get_admin_plugin_menu_links', 'imgpreview_lien_menu');
14function 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 **/
26add_event_handler('loc_end_index_thumbnails', 'imgpreview_thumbnails');
27function 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], 'title' => $conf_imgp[2], 'opacity' => $conf_imgp[3] , 'preloadImages' => $conf_imgp[4] );
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
48function imgpreview_prefilter_thumbnails($content, &$smarty)
49{
50        global $template;
51  $search = 'href="{$thumbnail.URL}"';
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) )
53  {
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}"';
55  }
56  else {
57    $replacement = 'href="{$thumbnail.URL}" imgsrc="{$thumbnail.FILE_PATH}" data-tittle="{$thumbnail.NAME}"';
58  }
59  $content= str_replace($search, $replacement, $content);
60
61        $content='{$IMGPREVIEW}'.$content;
62        return $content;
63}
64?>
Note: See TracBrowser for help on using the repository browser.