1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Custom Download Link |
---|
4 | Version: auto |
---|
5 | Description: Add a specific download button on the page of the photo |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid= |
---|
7 | Author: plg |
---|
8 | Author URI: http://le-gall.net/pierrick |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | add_event_handler('loc_begin_picture', 'cdl_deactivate_hd'); |
---|
14 | function cdl_deactivate_hd() |
---|
15 | { |
---|
16 | global $user; |
---|
17 | |
---|
18 | $user['cdl_enabled_high'] = $user['enabled_high']; |
---|
19 | $user['enabled_high'] = false; |
---|
20 | } |
---|
21 | |
---|
22 | add_event_handler('loc_end_picture', 'cdl_add_link'); |
---|
23 | function cdl_add_link() |
---|
24 | { |
---|
25 | global $conf, $template, $user, $picture; |
---|
26 | |
---|
27 | load_language('plugin.lang', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
28 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); |
---|
29 | |
---|
30 | $template->set_prefilter('picture', 'cdl_add_link_prefilter'); |
---|
31 | $template->assign('CDL_LINK', get_action_url($picture['current']['id'], 'e', true)); |
---|
32 | } |
---|
33 | |
---|
34 | function cdl_add_link_prefilter($content, &$smarty) |
---|
35 | { |
---|
36 | $search = '{$ELEMENT_CONTENT}'; |
---|
37 | $replace = '{$ELEMENT_CONTENT}<div id="customDownloadLink"><a href="{$CDL_LINK}" rel="nofollow"><img src="plugins/custom_download_link/download_white_32.png"> {\'Download Photo\'|@translate}</a></div>{combine_css path="plugins/custom_download_link/style.css"}'; |
---|
38 | |
---|
39 | return str_replace($search, $replace, $content); |
---|
40 | } |
---|
41 | ?> |
---|