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

Last change on this file since 12153 was 11948, checked in by flop25, 13 years ago

new parameters in database and managed by the admin page
fr lang updated
need translations

File size: 1.8 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] );
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 
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?>
Note: See TracBrowser for help on using the repository browser.