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\Config;
12 use Friendica\Core\Hook;
13 use Friendica\Core\L10n;
14 use Friendica\Core\Logger;
15 use Friendica\Core\Renderer;
16 use Friendica\Util\Proxy as ProxyUtils;
17 use Friendica\Util\Strings;
19 function impressum_install() {
20 Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
21 Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
22 Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
23 Logger::log("installed impressum Addon");
26 function impressum_uninstall() {
27 Hook::unregister('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
28 Hook::unregister('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
29 Hook::unregister('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
30 Logger::log("uninstalled impressum Addon");
33 function impressum_module() {
35 function impressum_content() {
37 $a->internalRedirect('friendica/');
40 function obfuscate_email ($s) {
41 $s = str_replace('@','(at)',$s);
42 $s = str_replace('.','(dot)',$s);
45 function impressum_footer($a, &$b) {
46 $text = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum','footer_text')));
49 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->getBaseURL().'/addon/impressum/impressum.css" media="all" />';
50 $b .= '<div class="clear"></div>';
51 $b .= '<div id="impressum_footer">'.$text.'</div>';
55 function impressum_load_config(\Friendica\App $a)
57 $a->loadConfigFile(__DIR__ . '/config/impressum.config.php');
60 function impressum_show($a,&$b) {
61 $b .= '<h3>'.L10n::t('Impressum').'</h3>';
62 $owner = Config::get('impressum', 'owner');
63 $owner_profile = Config::get('impressum','ownerprofile');
64 $postal = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum', 'postal')));
65 $notes = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum', 'notes')));
66 $email = obfuscate_email( Config::get('impressum','email') );
68 if (strlen($owner_profile)) {
69 $tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
74 $b .= '<p><strong>'.L10n::t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.L10n::t('Email Address').'</strong>: '.$email.'</p>';
76 $b .= '<p><strong>'.L10n::t('Site Owner').'</strong>: '. $tmp .'</p>';
78 if (strlen($postal)) {
79 $b .= '<p><strong>'.L10n::t('Postal Address').'</strong><br />'. $postal .'</p>';
82 $b .= '<p>'.$notes.'</p>';
85 $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>';
89 function impressum_addon_admin_post (&$a) {
90 $owner = (!empty($_POST['owner']) ? Strings::escapeTags(trim($_POST['owner'])) : '');
91 $ownerprofile = (!empty($_POST['ownerprofile']) ? Strings::escapeTags(trim($_POST['ownerprofile'])) : '');
92 $postal = (!empty($_POST['postal']) ? (trim($_POST['postal'])) : '');
93 $notes = (!empty($_POST['notes']) ? (trim($_POST['notes'])) : '');
94 $email = (!empty($_POST['email']) ? Strings::escapeTags(trim($_POST['email'])) : '');
95 $footer_text = (!empty($_POST['footer_text']) ? (trim($_POST['footer_text'])) : '');
96 Config::set('impressum','owner',strip_tags($owner));
97 Config::set('impressum','ownerprofile',strip_tags($ownerprofile));
98 Config::set('impressum','postal',strip_tags($postal));
99 Config::set('impressum','email',strip_tags($email));
100 Config::set('impressum','notes',strip_tags($notes));
101 Config::set('impressum','footer_text',strip_tags($footer_text));
102 info(L10n::t('Settings updated.'). EOL );
104 function impressum_addon_admin (&$a, &$o) {
105 $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/impressum/" );
106 $o = Renderer::replaceMacros($t, [
107 '$submit' => L10n::t('Save Settings'),
108 '$owner' => ['owner', L10n::t('Site Owner'), Config::get('impressum','owner'), L10n::t('The page operators name.')],
109 '$ownerprofile' => ['ownerprofile', L10n::t('Site Owners Profile'), Config::get('impressum','ownerprofile'), L10n::t('Profile address of the operator.')],
110 '$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.')],
111 '$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.')],
112 '$email' => ['email', L10n::t('Email Address'), Config::get('impressum','email'), L10n::t('How to contact the operator via email. (will be displayed obfuscated)')],
113 '$footer_text' => ['footer_text', L10n::t('Footer note'), Config::get('impressum','footer_text'), L10n::t('Text for the footer. You can use BBCode here.')],