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 use Friendica\Content\Text\BBCode;
11 use Friendica\Core\Addon;
12 use Friendica\Core\Config;
13 use Friendica\Core\L10n;
14 use Friendica\Core\Logger;
15 use Friendica\Util\Proxy as ProxyUtils;
17 function impressum_install() {
18 Addon::registerHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
19 Addon::registerHook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
20 Addon::registerHook('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
21 Logger::log("installed impressum Addon");
24 function impressum_uninstall() {
25 Addon::unregisterHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
26 Addon::unregisterHook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
27 Addon::unregisterHook('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
28 Logger::log("uninstalled impressum Addon");
31 function impressum_module() {
33 function impressum_content() {
35 $a->internalRedirect('friendica/');
38 function obfuscate_email ($s) {
39 $s = str_replace('@','(at)',$s);
40 $s = str_replace('.','(dot)',$s);
43 function impressum_footer($a, &$b) {
44 $text = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum','footer_text')));
47 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->getBaseURL().'/addon/impressum/impressum.css" media="all" />';
48 $b .= '<div class="clear"></div>';
49 $b .= '<div id="impressum_footer">'.$text.'</div>';
53 function impressum_load_config(\Friendica\App $a)
55 $a->loadConfigFile(__DIR__. '/config/impressum.ini.php');
58 function impressum_show($a,&$b) {
59 $b .= '<h3>'.L10n::t('Impressum').'</h3>';
60 $owner = Config::get('impressum', 'owner');
61 $owner_profile = Config::get('impressum','ownerprofile');
62 $postal = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum', 'postal')));
63 $notes = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum', 'notes')));
64 $email = obfuscate_email( Config::get('impressum','email') );
66 if (strlen($owner_profile)) {
67 $tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
72 $b .= '<p><strong>'.L10n::t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.L10n::t('Email Address').'</strong>: '.$email.'</p>';
74 $b .= '<p><strong>'.L10n::t('Site Owner').'</strong>: '. $tmp .'</p>';
76 if (strlen($postal)) {
77 $b .= '<p><strong>'.L10n::t('Postal Address').'</strong><br />'. $postal .'</p>';
80 $b .= '<p>'.$notes.'</p>';
83 $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>';
87 function impressum_addon_admin_post (&$a) {
88 $owner = ((x($_POST, 'owner')) ? notags(trim($_POST['owner'])) : '');
89 $ownerprofile = ((x($_POST, 'ownerprofile')) ? notags(trim($_POST['ownerprofile'])) : '');
90 $postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : '');
91 $notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : '');
92 $email = ((x($_POST, 'email')) ? notags(trim($_POST['email'])) : '');
93 $footer_text = ((x($_POST, 'footer_text')) ? (trim($_POST['footer_text'])) : '');
94 Config::set('impressum','owner',strip_tags($owner));
95 Config::set('impressum','ownerprofile',strip_tags($ownerprofile));
96 Config::set('impressum','postal',strip_tags($postal));
97 Config::set('impressum','email',strip_tags($email));
98 Config::set('impressum','notes',strip_tags($notes));
99 Config::set('impressum','footer_text',strip_tags($footer_text));
100 info(L10n::t('Settings updated.'). EOL );
102 function impressum_addon_admin (&$a, &$o) {
103 $t = get_markup_template( "admin.tpl", "addon/impressum/" );
104 $o = replace_macros($t, [
105 '$submit' => L10n::t('Save Settings'),
106 '$owner' => ['owner', L10n::t('Site Owner'), Config::get('impressum','owner'), L10n::t('The page operators name.')],
107 '$ownerprofile' => ['ownerprofile', L10n::t('Site Owners Profile'), Config::get('impressum','ownerprofile'), L10n::t('Profile address of the operator.')],
108 '$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.')],
109 '$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.')],
110 '$email' => ['email', L10n::t('Email Address'), Config::get('impressum','email'), L10n::t('How to contact the operator via email. (will be displayed obfuscated)')],
111 '$footer_text' => ['footer_text', L10n::t('Footer note'), Config::get('impressum','footer_text'), L10n::t('Text for the footer. You can use BBCode here.')],