4 * Description: Plugin to add contact information to the about page (/friendica)
6 * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
7 * License: 3-clause BSD license
10 require_once('include/bbcode.php');
11 require_once('mod/proxy.php');
13 use Friendica\Core\Config;
15 function impressum_install() {
16 register_hook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
17 register_hook('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
18 logger("installed impressum plugin");
21 function impressum_uninstall() {
22 unregister_hook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
23 unregister_hook('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
24 logger("uninstalled impressum plugin");
27 function impressum_module() {
29 function impressum_content() {
31 goaway($a->get_baseurl().'/friendica/');
34 function obfuscate_email ($s) {
35 $s = str_replace('@','(at)',$s);
36 $s = str_replace('.','(dot)',$s);
39 function impressum_footer($a, &$b) {
40 $text = proxy_parse_html(bbcode(Config::get('impressum','footer_text'), true));
42 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/addon/impressum/impressum.css" media="all" />';
43 $b .= '<div class="clear"></div>';
44 $b .= '<div id="impressum_footer">'.$text.'</div>';
47 function impressum_show($a,&$b) {
48 $b .= '<h3>'.t('Impressum').'</h3>';
49 $owner = Config::get('impressum', 'owner');
50 $owner_profile = Config::get('impressum','ownerprofile');
51 $postal = proxy_parse_html(bbcode(Config::get('impressum', 'postal'), true));
52 $notes = proxy_parse_html(bbcode(Config::get('impressum', 'notes'), true));
53 $email = obfuscate_email( Config::get('impressum','email') );
55 if (strlen($owner_profile)) {
56 $tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
61 $b .= '<p><strong>'.t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.t('Email Address').'</strong>: '.$email.'</p>';
63 $b .= '<p><strong>'.t('Site Owner').'</strong>: '. $tmp .'</p>';
65 if (strlen($postal)) {
66 $b .= '<p><strong>'.t('Postal Address').'</strong><br />'. $postal .'</p>';
69 $b .= '<p>'.$notes.'</p>';
72 $b .= '<p>'.t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.').'</p>';
76 function impressum_plugin_admin_post (&$a) {
77 $owner = ((x($_POST, 'owner')) ? notags(trim($_POST['owner'])) : '');
78 $ownerprofile = ((x($_POST, 'ownerprofile')) ? notags(trim($_POST['ownerprofile'])) : '');
79 $postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : '');
80 $notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : '');
81 $email = ((x($_POST, 'email')) ? notags(trim($_POST['email'])) : '');
82 $footer_text = ((x($_POST, 'footer_text')) ? (trim($_POST['footer_text'])) : '');
83 Config::set('impressum','owner',strip_tags($owner));
84 Config::set('impressum','ownerprofile',strip_tags($ownerprofile));
85 Config::set('impressum','postal',strip_tags($postal));
86 Config::set('impressum','email',strip_tags($email));
87 Config::set('impressum','notes',strip_tags($notes));
88 Config::set('impressum','footer_text',strip_tags($footer_text));
89 info( t('Settings updated.'). EOL );
91 function impressum_plugin_admin (&$a, &$o) {
92 $t = get_markup_template( "admin.tpl", "addon/impressum/" );
93 $o = replace_macros($t, array(
94 '$submit' => t('Save Settings'),
95 '$owner' => array('owner', t('Site Owner'), Config::get('impressum','owner'), t('The page operators name.')),
96 '$ownerprofile' => array('ownerprofile', t('Site Owners Profile'), Config::get('impressum','ownerprofile'), t('Profile address of the operator.')),
97 '$postal' => array('postal', t('Postal Address'), Config::get('impressum','postal'), t('How to contact the operator via snail mail. You can use BBCode here.')),
98 '$notes' => array('notes', t('Notes'), Config::get('impressum','notes'), t('Additional notes that are displayed beneath the contact information. You can use BBCode here.')),
99 '$email' => array('email', t('Email Address'), Config::get('impressum','email'), t('How to contact the operator via email. (will be displayed obfuscated)')),
100 '$footer_text' => array('footer_text', t('Footer note'), Config::get('impressum','footer_text'), t('Text for the footer. You can use BBCode here.')),