1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Custom Contact Link |
---|
4 | Version: auto |
---|
5 | Description: Add a specific contact button on the page of the photo |
---|
6 | Plugin URI: https://piwigo.org/ext/extension_view.php?eid=895 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://temmii.com/piwigo/ |
---|
9 | */ |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | // | Custom Contact Link for Piwigo by TEMMII | |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | Copyright(C) 2018-2022 ddtddt http://temmii.com/piwigo/ | |
---|
14 | // +-----------------------------------------------------------------------+ |
---|
15 | // | This program is free software; you can redistribute it and/or modify | |
---|
16 | // | it under the terms of the GNU General Public License as published by | |
---|
17 | // | the Free Software Foundation | |
---|
18 | // | | |
---|
19 | // | This program is distributed in the hope that it will be useful, but | |
---|
20 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
21 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
22 | // | General Public License for more details. | |
---|
23 | // | | |
---|
24 | // | You should have received a copy of the GNU General Public License | |
---|
25 | // | along with this program; if not, write to the Free Software | |
---|
26 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
27 | // | USA. | |
---|
28 | // +-----------------------------------------------------------------------+ |
---|
29 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
30 | |
---|
31 | define('CCL_DIR' , basename(dirname(__FILE__))); |
---|
32 | define('CCL_PATH' , PHPWG_PLUGINS_PATH . CCL_DIR . '/'); |
---|
33 | |
---|
34 | $desco = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
35 | |
---|
36 | if($desco['state'] == 'active'){ |
---|
37 | |
---|
38 | add_event_handler('loc_end_picture', 'ccl_add_link'); |
---|
39 | function ccl_add_link(){ |
---|
40 | global $template; |
---|
41 | load_language('plugin.lang', CCL_PATH); |
---|
42 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); |
---|
43 | $template->set_prefilter('picture', 'ccl_add_link_prefilter'); |
---|
44 | } |
---|
45 | |
---|
46 | function ccl_add_link_prefilter($content){ |
---|
47 | $custom_cont_tpl = '<div id="customContactLink"><a href="'.PHPWG_ROOT_PATH.'index.php?/contact/" rel="nofollow"><img src="plugins/custom_contact_link/contact_white_32.png"> {\'Contact us\'|@translate}<span class="clichere"> {\'Clic here\'|@translate}</span></a></div>{combine_css path="plugins/custom_contact_link/style.css"}'; |
---|
48 | if(isset($conf['custom_contact_link_position'])){ |
---|
49 | if ('properties-after' == $conf['custom_contact_link_position']){ |
---|
50 | $search = '#</dl>#'; |
---|
51 | $replace = '</dl>'.$custom_cont_tpl; |
---|
52 | return preg_replace($search, $replace, $content, 1); |
---|
53 | } |
---|
54 | |
---|
55 | if('properties-before' == $conf['custom_contact_link_position']){ |
---|
56 | $search = '<dl id="standard"'; |
---|
57 | $replace = $custom_cont_tpl.$search; |
---|
58 | return str_replace($search, $replace, $content); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | $search = '{$ELEMENT_CONTENT}'; |
---|
63 | $replace = '{$ELEMENT_CONTENT}'.$custom_cont_tpl; |
---|
64 | return str_replace($search, $replace, $content); |
---|
65 | } |
---|
66 | }else{ |
---|
67 | if (script_basename() == 'admin'){ |
---|
68 | global $page,$conf; |
---|
69 | load_language('plugin.lang', CCL_PATH); |
---|
70 | $page['errors'][] = l10n('For use "Custom Contact Link" on photo page the plugin ContactForm must be installed and activated'); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | ?> |
---|