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\Hook;
12 use Friendica\Core\Logger;
13 use Friendica\Core\Renderer;
15 use Friendica\Core\Config\Util\ConfigFileLoader;
16 use Friendica\Util\Proxy as ProxyUtils;
18 function impressum_install() {
19 Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
20 Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
21 Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
22 Logger::notice("installed impressum Addon");
25 function impressum_module() {
27 function impressum_content() {
28 DI::baseUrl()->redirect('friendica/');
31 function obfuscate_email ($s) {
32 $s = str_replace('@','(at)',$s);
33 $s = str_replace('.','(dot)',$s);
36 function impressum_footer($a, &$b) {
37 $text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum','footer_text')));
40 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.DI::baseUrl()->get().'/addon/impressum/impressum.css" media="all" />';
41 $b .= '<div class="clear"></div>';
42 $b .= '<div id="impressum_footer">'.$text.'</div>';
46 function impressum_load_config(\Friendica\App $a, ConfigFileLoader $loader)
48 $a->getConfigCache()->load($loader->loadAddonConfig('impressum'));
51 function impressum_show($a,&$b) {
52 $b .= '<h3>'.DI::l10n()->t('Impressum').'</h3>';
53 $owner = DI::config()->get('impressum', 'owner');
54 $owner_profile = DI::config()->get('impressum','ownerprofile');
55 $postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
56 $notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
57 $email = obfuscate_email( DI::config()->get('impressum','email') );
59 if (strlen($owner_profile)) {
60 $tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
65 $b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.DI::l10n()->t('Email Address').'</strong>: '.$email.'</p>';
67 $b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'</p>';
69 if (strlen($postal)) {
70 $b .= '<p><strong>'.DI::l10n()->t('Postal Address').'</strong><br />'. $postal .'</p>';
73 $b .= '<p>'.$notes.'</p>';
76 $b .= '<p>'.DI::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>';
80 function impressum_addon_admin_post (&$a) {
81 $owner = trim($_POST['owner'] ?? '');
82 $ownerprofile = trim($_POST['ownerprofile'] ?? '');
83 $postal = trim($_POST['postal'] ?? '');
84 $notes = trim($_POST['notes'] ?? '');
85 $email = trim($_POST['email'] ?? '');
86 $footer_text = trim($_POST['footer_text'] ?? '');
87 DI::config()->set('impressum','owner',strip_tags($owner));
88 DI::config()->set('impressum','ownerprofile',strip_tags($ownerprofile));
89 DI::config()->set('impressum','postal',strip_tags($postal));
90 DI::config()->set('impressum','email',strip_tags($email));
91 DI::config()->set('impressum','notes',strip_tags($notes));
92 DI::config()->set('impressum','footer_text',strip_tags($footer_text));
94 function impressum_addon_admin (&$a, &$o) {
95 $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/impressum/" );
96 $o = Renderer::replaceMacros($t, [
97 '$submit' => DI::l10n()->t('Save Settings'),
98 '$owner' => ['owner', DI::l10n()->t('Site Owner'), DI::config()->get('impressum','owner'), DI::l10n()->t('The page operators name.')],
99 '$ownerprofile' => ['ownerprofile', DI::l10n()->t('Site Owners Profile'), DI::config()->get('impressum','ownerprofile'), DI::l10n()->t('Profile address of the operator.')],
100 '$postal' => ['postal', DI::l10n()->t('Postal Address'), DI::config()->get('impressum','postal'), DI::l10n()->t('How to contact the operator via snail mail. You can use BBCode here.')],
101 '$notes' => ['notes', DI::l10n()->t('Notes'), DI::config()->get('impressum','notes'), DI::l10n()->t('Additional notes that are displayed beneath the contact information. You can use BBCode here.')],
102 '$email' => ['email', DI::l10n()->t('Email Address'), DI::config()->get('impressum','email'), DI::l10n()->t('How to contact the operator via email. (will be displayed obfuscated)')],
103 '$footer_text' => ['footer_text', DI::l10n()->t('Footer note'), DI::config()->get('impressum','footer_text'), DI::l10n()->t('Text for the footer. You can use BBCode here.')],