4 * Description: Addon 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 'mod/proxy.php';
12 use Friendica\Content\Text\BBCode;
13 use Friendica\Core\Addon;
14 use Friendica\Core\Config;
15 use Friendica\Core\L10n;
17 function impressum_install() {
18 Addon::registerHook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
19 Addon::registerHook('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
20 logger("installed impressum Addon");
23 function impressum_uninstall() {
24 Addon::unregisterHook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
25 Addon::unregisterHook('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
26 logger("uninstalled impressum Addon");
29 function impressum_module() {
31 function impressum_content() {
36 function obfuscate_email ($s) {
37 $s = str_replace('@','(at)',$s);
38 $s = str_replace('.','(dot)',$s);
41 function impressum_footer($a, &$b) {
42 $text = proxy_parse_html(BBCode::convert(Config::get('impressum','footer_text')));
44 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/addon/impressum/impressum.css" media="all" />';
45 $b .= '<div class="clear"></div>';
46 $b .= '<div id="impressum_footer">'.$text.'</div>';
49 function impressum_show($a,&$b) {
50 $b .= '<h3>'.L10n::t('Impressum').'</h3>';
51 $owner = Config::get('impressum', 'owner');
52 $owner_profile = Config::get('impressum','ownerprofile');
53 $postal = proxy_parse_html(BBCode::convert(Config::get('impressum', 'postal')));
54 $notes = proxy_parse_html(BBCode::convert(Config::get('impressum', 'notes')));
55 $email = obfuscate_email( Config::get('impressum','email') );
57 if (strlen($owner_profile)) {
58 $tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
63 $b .= '<p><strong>'.L10n::t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.L10n::t('Email Address').'</strong>: '.$email.'</p>';
65 $b .= '<p><strong>'.L10n::t('Site Owner').'</strong>: '. $tmp .'</p>';
67 if (strlen($postal)) {
68 $b .= '<p><strong>'.L10n::t('Postal Address').'</strong><br />'. $postal .'</p>';
71 $b .= '<p>'.$notes.'</p>';
74 $b .= '<p>'.L10n::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>';
78 function impressum_addon_admin_post (&$a) {
79 $owner = ((x($_POST, 'owner')) ? notags(trim($_POST['owner'])) : '');
80 $ownerprofile = ((x($_POST, 'ownerprofile')) ? notags(trim($_POST['ownerprofile'])) : '');
81 $postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : '');
82 $notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : '');
83 $email = ((x($_POST, 'email')) ? notags(trim($_POST['email'])) : '');
84 $footer_text = ((x($_POST, 'footer_text')) ? (trim($_POST['footer_text'])) : '');
85 Config::set('impressum','owner',strip_tags($owner));
86 Config::set('impressum','ownerprofile',strip_tags($ownerprofile));
87 Config::set('impressum','postal',strip_tags($postal));
88 Config::set('impressum','email',strip_tags($email));
89 Config::set('impressum','notes',strip_tags($notes));
90 Config::set('impressum','footer_text',strip_tags($footer_text));
91 info(L10n::t('Settings updated.'). EOL );
93 function impressum_addon_admin (&$a, &$o) {
94 $t = get_markup_template( "admin.tpl", "addon/impressum/" );
95 $o = replace_macros($t, [
96 '$submit' => L10n::t('Save Settings'),
97 '$owner' => ['owner', L10n::t('Site Owner'), Config::get('impressum','owner'), L10n::t('The page operators name.')],
98 '$ownerprofile' => ['ownerprofile', L10n::t('Site Owners Profile'), Config::get('impressum','ownerprofile'), L10n::t('Profile address of the operator.')],
99 '$postal' => ['postal', L10n::t('Postal Address'), Config::get('impressum','postal'), L10n::t('How to contact the operator via snail mail. You can use BBCode here.')],
100 '$notes' => ['notes', L10n::t('Notes'), Config::get('impressum','notes'), L10n::t('Additional notes that are displayed beneath the contact information. You can use BBCode here.')],
101 '$email' => ['email', L10n::t('Email Address'), Config::get('impressum','email'), L10n::t('How to contact the operator via email. (will be displayed obfuscated)')],
102 '$footer_text' => ['footer_text', L10n::t('Footer note'), Config::get('impressum','footer_text'), L10n::t('Text for the footer. You can use BBCode here.')],