source: extensions/custom_contact_link/main.inc.php @ 32599

Last change on this file since 32599 was 32599, checked in by ddtddt, 4 years ago

[custom_contact_link] change test

File size: 3.5 KB
Line 
1<?php
2/*
3Plugin Name: Custom Contact Link
4Version: auto
5Description: Add a specific contact button on the page of the photo
6Plugin URI: https://piwigo.org/ext/extension_view.php?eid=895
7Author: ddtddt
8Author URI: http://temmii.com/piwigo/
9*/
10// +-----------------------------------------------------------------------+
11// | Custom Contact Link for Piwigo by TEMMII                                  |
12// +-----------------------------------------------------------------------+
13// | Copyright(C) 2018-2021 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// +-----------------------------------------------------------------------+
29if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
30
31define('CCL_DIR' , basename(dirname(__FILE__)));
32define('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
36if($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, &$smarty){
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?>
Note: See TracBrowser for help on using the repository browser.