source: extensions/custom_download_link/main.inc.php @ 27525

Last change on this file since 27525 was 27503, checked in by plg, 10 years ago

plugin do add a big download button on the page of the photo

File size: 1.3 KB
Line 
1<?php
2/*
3Plugin Name: Custom Download Link
4Version: auto
5Description: Add a specific download button on the page of the photo
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
7Author: plg
8Author URI: http://le-gall.net/pierrick
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13add_event_handler('loc_begin_picture', 'cdl_deactivate_hd');
14function cdl_deactivate_hd()
15{
16  global $user;
17
18  $user['cdl_enabled_high'] = $user['enabled_high'];
19  $user['enabled_high'] = false;
20}
21
22add_event_handler('loc_end_picture', 'cdl_add_link');
23function 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
34function 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?>
Note: See TracBrowser for help on using the repository browser.